summaryrefslogtreecommitdiffstats
path: root/openstack-examples/src/main/java/com/woorea/openstack/examples/compute
diff options
context:
space:
mode:
Diffstat (limited to 'openstack-examples/src/main/java/com/woorea/openstack/examples/compute')
-rw-r--r--openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaListFlavors.java68
-rw-r--r--openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaListImages.java72
-rw-r--r--openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaListServers.java48
-rw-r--r--openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaStopStartServer.java56
4 files changed, 122 insertions, 122 deletions
diff --git a/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaListFlavors.java b/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaListFlavors.java
index 8b449e9..25b196c 100644
--- a/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaListFlavors.java
+++ b/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaListFlavors.java
@@ -29,39 +29,39 @@ import com.woorea.openstack.nova.model.Flavors;
public class NovaListFlavors {
- /**
- * @param args
- */
- public static void main(String[] args) {
- Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL);
- Access access = keystone.tokens().authenticate(
- new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD))
- .execute();
-
- //use the token in the following requests
- keystone.token(access.getToken().getId());
-
- Tenants tenants = keystone.tenants().list().execute();
-
- //try to exchange token using the first tenant
- if(tenants.getList().size() > 0) {
-
- access = keystone.tokens().authenticate(new TokenAuthentication(access.getToken().getId())).withTenantId(tenants.getList().get(0).getId()).execute();
-
- //NovaClient novaClient = new NovaClient(KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "compute", null, "public"), access.getToken().getId());
- Nova novaClient = new Nova(ExamplesConfiguration.NOVA_ENDPOINT.concat("/").concat(tenants.getList().get(0).getId()));
- novaClient.token(access.getToken().getId());
- //novaClient.enableLogging(Logger.getLogger("nova"), 100 * 1024);
-
- Flavors flavors = novaClient.flavors().list(true).execute();
- for(Flavor flavor : flavors) {
- System.out.println(flavor);
- }
-
- } else {
- System.out.println("No tenants found!");
- }
-
- }
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL);
+ Access access = keystone.tokens().authenticate(
+ new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD))
+ .execute();
+
+ //use the token in the following requests
+ keystone.token(access.getToken().getId());
+
+ Tenants tenants = keystone.tenants().list().execute();
+
+ //try to exchange token using the first tenant
+ if(tenants.getList().size() > 0) {
+
+ access = keystone.tokens().authenticate(new TokenAuthentication(access.getToken().getId())).withTenantId(tenants.getList().get(0).getId()).execute();
+
+ //NovaClient novaClient = new NovaClient(KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "compute", null, "public"), access.getToken().getId());
+ Nova novaClient = new Nova(ExamplesConfiguration.NOVA_ENDPOINT.concat("/").concat(tenants.getList().get(0).getId()));
+ novaClient.token(access.getToken().getId());
+ //novaClient.enableLogging(Logger.getLogger("nova"), 100 * 1024);
+
+ Flavors flavors = novaClient.flavors().list(true).execute();
+ for(Flavor flavor : flavors) {
+ System.out.println(flavor);
+ }
+
+ } else {
+ System.out.println("No tenants found!");
+ }
+
+ }
}
diff --git a/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaListImages.java b/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaListImages.java
index 37cd70f..1f7a431 100644
--- a/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaListImages.java
+++ b/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaListImages.java
@@ -28,41 +28,41 @@ import com.woorea.openstack.nova.model.Image;
import com.woorea.openstack.nova.model.Images;
public class NovaListImages {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
-
- Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL);
- Access access = keystone.tokens().authenticate(new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD)).execute();
-
- //use the token in the following requests
- keystone.token(access.getToken().getId());
-
- Tenants tenants = keystone.tenants().list().execute();
-
- //try to exchange token using the first tenant
- if(tenants.getList().size() > 0) {
-
- access = keystone.tokens().authenticate(new TokenAuthentication(access.getToken().getId()))
- .withTenantId(tenants.getList().get(0).getId())
- .execute();
-
- //NovaClient novaClient = new NovaClient(KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "compute", null, "public"), access.getToken().getId());
- Nova novaClient = new Nova(ExamplesConfiguration.NOVA_ENDPOINT.concat("/").concat(tenants.getList().get(0).getId()));
- novaClient.token(access.getToken().getId());
- //novaClient.enableLogging(Logger.getLogger("nova"), 100 * 1024);
-
- Images images = novaClient.images().list(true).execute();
- for(Image image : images) {
- System.out.println(image);
- }
-
- } else {
- System.out.println("No tenants found!");
- }
-
- }
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+
+ Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL);
+ Access access = keystone.tokens().authenticate(new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD)).execute();
+
+ //use the token in the following requests
+ keystone.token(access.getToken().getId());
+
+ Tenants tenants = keystone.tenants().list().execute();
+
+ //try to exchange token using the first tenant
+ if(tenants.getList().size() > 0) {
+
+ access = keystone.tokens().authenticate(new TokenAuthentication(access.getToken().getId()))
+ .withTenantId(tenants.getList().get(0).getId())
+ .execute();
+
+ //NovaClient novaClient = new NovaClient(KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "compute", null, "public"), access.getToken().getId());
+ Nova novaClient = new Nova(ExamplesConfiguration.NOVA_ENDPOINT.concat("/").concat(tenants.getList().get(0).getId()));
+ novaClient.token(access.getToken().getId());
+ //novaClient.enableLogging(Logger.getLogger("nova"), 100 * 1024);
+
+ Images images = novaClient.images().list(true).execute();
+ for(Image image : images) {
+ System.out.println(image);
+ }
+
+ } else {
+ System.out.println("No tenants found!");
+ }
+
+ }
}
diff --git a/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaListServers.java b/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaListServers.java
index 58faf69..0331a62 100644
--- a/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaListServers.java
+++ b/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaListServers.java
@@ -26,29 +26,29 @@ import com.woorea.openstack.nova.model.Server;
import com.woorea.openstack.nova.model.Servers;
public class NovaListServers {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL);
- Access access = keystone.tokens().authenticate(new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD))
- .withTenantName("demo")
- .execute();
-
- //use the token in the following requests
- keystone.token(access.getToken().getId());
-
- //NovaClient novaClient = new NovaClient(KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "compute", null, "public"), access.getToken().getId());
- Nova novaClient = new Nova(ExamplesConfiguration.NOVA_ENDPOINT.concat("/").concat(access.getToken().getTenant().getId()));
- novaClient.token(access.getToken().getId());
- //novaClient.enableLogging(Logger.getLogger("nova"), 100 * 1024);
-
- Servers servers = novaClient.servers().list(true).execute();
- for(Server server : servers) {
- System.out.println(server);
- }
-
- }
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL);
+ Access access = keystone.tokens().authenticate(new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD))
+ .withTenantName("demo")
+ .execute();
+
+ //use the token in the following requests
+ keystone.token(access.getToken().getId());
+
+ //NovaClient novaClient = new NovaClient(KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "compute", null, "public"), access.getToken().getId());
+ Nova novaClient = new Nova(ExamplesConfiguration.NOVA_ENDPOINT.concat("/").concat(access.getToken().getTenant().getId()));
+ novaClient.token(access.getToken().getId());
+ //novaClient.enableLogging(Logger.getLogger("nova"), 100 * 1024);
+
+ Servers servers = novaClient.servers().list(true).execute();
+ for(Server server : servers) {
+ System.out.println(server);
+ }
+
+ }
}
diff --git a/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaStopStartServer.java b/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaStopStartServer.java
index d113d21..dfc5f06 100644
--- a/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaStopStartServer.java
+++ b/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaStopStartServer.java
@@ -25,32 +25,32 @@ import com.woorea.openstack.nova.api.ServersResource;
import com.woorea.openstack.nova.model.Servers;
public class NovaStopStartServer {
- public static void main(String[] args) throws InterruptedException {
- Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL);
- Access access = keystone.tokens().authenticate(new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD))
- .withTenantName(ExamplesConfiguration.TENANT_NAME)
- .execute();
-
- //use the token in the following requests
- keystone.token(access.getToken().getId());
-
- Nova novaClient = new Nova(ExamplesConfiguration.NOVA_ENDPOINT.concat("/").concat(access.getToken().getTenant().getId()));
- novaClient.token(access.getToken().getId());
-
- Servers servers = novaClient.servers().list(true).execute();
- if(servers.getList().size() > 0) {
-
- // Server has to be in activated state.
- ServersResource.StopServer stopServer = novaClient.servers().stop(servers.getList().get(0).getId());
- stopServer.endpoint(ExamplesConfiguration.NOVA_ENDPOINT);
- stopServer.execute();
-
- // Wait until server shutdown. Or 400 error occurs.
- Thread.sleep(5000);
-
- ServersResource.StartServer startServer = novaClient.servers().start(servers.getList().get(0).getId());
- startServer.endpoint(ExamplesConfiguration.NOVA_ENDPOINT);
- startServer.execute();
- }
- }
+ public static void main(String[] args) throws InterruptedException {
+ Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL);
+ Access access = keystone.tokens().authenticate(new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD))
+ .withTenantName(ExamplesConfiguration.TENANT_NAME)
+ .execute();
+
+ //use the token in the following requests
+ keystone.token(access.getToken().getId());
+
+ Nova novaClient = new Nova(ExamplesConfiguration.NOVA_ENDPOINT.concat("/").concat(access.getToken().getTenant().getId()));
+ novaClient.token(access.getToken().getId());
+
+ Servers servers = novaClient.servers().list(true).execute();
+ if(servers.getList().size() > 0) {
+
+ // Server has to be in activated state.
+ ServersResource.StopServer stopServer = novaClient.servers().stop(servers.getList().get(0).getId());
+ stopServer.endpoint(ExamplesConfiguration.NOVA_ENDPOINT);
+ stopServer.execute();
+
+ // Wait until server shutdown. Or 400 error occurs.
+ Thread.sleep(5000);
+
+ ServersResource.StartServer startServer = novaClient.servers().start(servers.getList().get(0).getId());
+ startServer.endpoint(ExamplesConfiguration.NOVA_ENDPOINT);
+ startServer.execute();
+ }
+ }
}