Esempio n. 1
0
  public static void main(String[] args) throws Exception {

    Properties properties = new Properties();

    // properties.setProperty("auth.endpoint", "http://192.168.1.52:5000/v2.0");
    // properties.setProperty("auth.username", "admin");
    // properties.setProperty("auth.password", "secret0");

    // properties.setProperty("identity.default.endpoint.adminURL","http://192.168.1.52:35357/v2.0");
    // The admintoken (setted on keystone config file)
    // properties.setProperty("identity.admin.token", "secret0");

    properties.setProperty(
        "identity.endpoint.publicURL",
        "https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/");
    properties.setProperty("auth.credentials", "apiAccessKeyCredentials");
    properties.setProperty("auth.accessKey", "");
    properties.setProperty("auth.secretKey", "");
    properties.setProperty("auth.tenantId", "");
    properties.setProperty("verbose", "true");

    OpenStackClient openstack = OpenStackClient.authenticate(properties);

    // IdentityAdministrationEndpoint identity = openstack.getIdentityAdministationEndpoint();

    //		TenantList tenants = identity.tenants().get();
    //
    //		KeystoneTenant kst = new KeystoneTenant();
    //		kst.setName("test");
    //		kst.setDescription("desc");
    //		kst.setEnabled(true);
    //		Tenant tenant = identity.tenants().post(kst);
    //
    //		tenant = identity.tenants().tenant(tenant.getId()).get();
    //
    //		identity.tenants().tenant(tenant.getId()).delete();
    //
    //		UserList users = identity.users().get();
    //
    //		KeystoneUser ksu = new KeystoneUser();
    //		ksu.setName("test");
    //		ksu.setPassword("secret0");
    //		ksu.setEmail("*****@*****.**");
    //		ksu.setEnabled(true);
    //		User user = identity.users().post(ksu);
    //
    //		user = identity.users().user(user.getId()).get();
    //
    //		identity.users().user(user.getId()).delete();
    //
    //		RoleList roles = identity.roles().get();
    //
    //		KeystoneRole ksr = new KeystoneRole();
    //		ksr.setName("test");
    //		Role role = identity.roles().post(ksr);
    //
    //		role = identity.roles().role(role.getId()).get();
    //
    //		identity.roles().role(role.getId()).delete();
    //
    //		ServiceList services = identity.services().get();

    //		KeystoneService kss = new KeystoneService();
    //		kss.setName("test");
    //		kss.setType("compute");
    //		kss.setDescription("Nova 3");
    //		Service service = identity.services().post(kss);
    //
    //		Service service = identity.services().service(services.getList().get(0).getId()).get();

    //		identity.endpoints().get();

    //		KeystoneEndpoint kse = new KeystoneEndpoint();
    //
    //
    //		kse.setRegion("RegionOne");
    //		kse.setServiceId(service.getId());
    //		kse.setPublicURL("http://192.168.1.52:8774/v2/$(tenant_id)s");
    //		kse.setInternalURL("http://192.168.1.52:8774/v2/$(tenant_id)s");
    //		kse.setAdminURL("http://192.168.1.52:8774/v2/$(tenant_id)s");
    //
    //		Endpoint endpoint = identity.endpoints().post(kse);

    //		identity.endpoints().endpoint(endpoint.getId()).delete();

    //		identity.services().service(service.getId()).delete();
    //
    //		openstack = openstack.reauthenticateOnTenant("admin");
    //
    //
    //		TenantResource compute = openstack.getComputeEndpoint();
    //
    //		ServerList servers = compute.servers().get();
    //
    //		ImageList images = compute.images().get();
    //		// "cirros-0.3.0-x86_64-blank"
    //
    //		FlavorList flavors = compute.flavors().get();
    //
    //		KeyPairList keypairs = compute.keyPairs().get();
    //
    //		SecurityGroupList securityGroups = compute.securityGroups().get();
    //
    //		VolumeList volumes = compute.volumes().get();
    //
    //		org.openstack.model.images.ImageList gImages = openstack.getImagesEndpoint().get();
    //
    //		List<StorageContainer> sAccount = openstack.getStorageEndpoint().get();
    //
    //		SwiftStorageObjectProperties p = new SwiftStorageObjectProperties();
    //		openstack.getStorageEndpoint().container(sAccount.get(0).getName()).object("test2").put(new
    // File("logging.properties"), p);

  }
 public TenantResource internalEndpoint(String region) {
   return client.target(regions.get(region).getInternalURL(), TenantResource.class);
 }
 public TenantResource administrationEndpoint(String region) {
   return client.target(regions.get(region).getAdminURL(), TenantResource.class);
 }
 public TenantResource publicEndpoint(String region) {
   return client.target(regions.get(region).getPublicURL(), TenantResource.class);
 }