@Override public void execute(Nova nova, CommandLine cmd) { final Servers servers = nova.servers().list(true).execute(); Table t = new Table(new TableModel<Server>(servers.getList()) { @Override public Column[] getHeaders() { return new Column[]{ new Column("id", 32, Column.ALIGN_LEFT), new Column("name", 10, Column.ALIGN_LEFT) }; } @Override public String[] getRow(Server server) { return new String[]{ server.getId(), server.getName() }; } }); System.out.println(t.render()); }
@Override public void terminateVM(String instanceId) throws IaasException { try { this.novaClient.servers().delete(instanceId).execute(); synchronized(ipAssociations) { for(Map.Entry<String, String> entry : ipAssociations.entrySet()) { if(instanceId.equals(entry.getValue())) { ipAssociations.remove(entry.getKey()); break; } } } } catch(Exception e) { throw new IaasException(e); } }
/** * Evacuate the server * * @param serverId * The server to be evacuated * @return The evacuate action to be performed * @see #evacuate(String, String, String, Boolean) */ public EvacuateAction evacuate(String serverId) { return evacuate(serverId, null, null, null); }
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(); } } }
final Server server = this.novaClient.servers().boot(serverForCreate).execute(); mountPoint = "/dev/vdb"; this.novaClient.servers().attachVolume(server.getId(), volumeIdToAttach, mountPoint).execute(); this.novaClient.servers().associateFloatingIp( server.getId(), ip.getIp()).execute();
Boot boot = resource.boot(create); osServer = boot.execute(); com.woorea.openstack.nova.model.Server.Fault osFault = osServer.getFault();
@Override public void run() { Server checked = IaasOpenstack.this.novaClient.servers().show(server.getId()).execute(); if("ACTIVE".equals(checked.getStatus())) { timer.shutdown(); } } }, 10, 5, TimeUnit.SECONDS);
public Nova(String endpoint, OpenStackClientConnector connector) { super(endpoint, connector); EXTENSIONS = new ExtensionsResource(this); SERVERS = new ServersResource(this); IMAGES = new ImagesResource(this); FLAVORS = new FlavorsResource(this); KEY_PAIRS = new KeyPairsExtension(this); FLOATING_IPS = new FloatingIpsExtension(this); SECURITY_GROUPS = new SecurityGroupsExtension(this); SNAPSHOTS = new SnapshotsExtension(this); VOLUMES = new VolumesExtension(this); AGGREGATES = new AggregatesExtension(this); QUOTA_SETS = new QuotaSetsResource(this); HOSTS = new HostsExtension(this); SERVICES = new ServicesResource(this); HYPERVISORS = new HypervisorsResource(this); }
/** * @see com.att.cdp.zones.ComputeService#assignIpAddress(java.lang.String, java.lang.String) */ @SuppressWarnings("nls") @Override public void assignIpAddress(String serverId, String address) throws ZoneException { checkArg(serverId, "serverId"); checkArg(address, "address"); connect(); trackRequest(); RequestState.put(RequestState.SERVER, serverId); RequestState.put(RequestState.IPADDRESS, address); RequestState.put(RequestState.SERVICE, "Compute"); RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint()); try { nova.getClient().servers().associateFloatingIp(serverId, address).execute(); } catch (OpenStackBaseException ex) { ExceptionMapper.mapException(ex); } }
/** * Starts the indicated server * * @param id * The id of the server to be started * @throws ZoneException * If the server is in an invalid state or it does not exist. * @see com.att.cdp.zones.ComputeService#startServer(java.lang.String) */ @SuppressWarnings("nls") @Override public void startServer(String id) throws ZoneException { checkOpen(); checkArg(id, "id"); connect(); trackRequest(); RequestState.put(RequestState.SERVER, id); RequestState.put(RequestState.SERVICE, "Compute"); RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint()); try { nova.getClient().servers().start(id).execute(); } catch (OpenStackBaseException ex) { ExceptionMapper.mapException(ex); } }
/** * Stops the indicated server * * @param id * The id of the server to be stopped * @throws ZoneException * If the server is in an invalid state or it does not exist. * @see com.att.cdp.zones.ComputeService#stopServer(java.lang.String) */ @SuppressWarnings("nls") @Override public void stopServer(String id) throws ZoneException { checkArg(id, "id"); connect(); trackRequest(); RequestState.put(RequestState.SERVER, id); RequestState.put(RequestState.SERVICE, "Compute"); RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint()); try { nova.getClient().servers().stop(id).execute(); } catch (OpenStackBaseException ex) { ExceptionMapper.mapException(ex); } }
nova.getClient().servers().attachVolume(server.getId(), volume.getId(), deviceName).execute(); } catch (OpenStackBaseException ex) { ExceptionMapper.mapException(ex);
Boot boot = resource.boot(create); osServer = boot.execute(); com.woorea.openstack.nova.model.Server.Fault osFault = osServer
logger.info(new Date().toString()+ " " +logId+":OpenStackComputeService.refreshServerStatus() -mapServerStatus - in"); ((OpenStackServer) server).mapServerStatus(nova.getClient().servers().show(server.getId()).execute()); logger.info(new Date().toString()+ " " +logId+":OpenStackComputeService.refreshServerStatus() -mapServerStatus - out"); } catch (OpenStackBaseException ex) {
public Nova(String endpoint, OpenStackClientConnector connector) { super(endpoint, connector); EXTENSIONS = new ExtensionsResource(this); SERVERS = new ServersResource(this); IMAGES = new ImagesResource(this); FLAVORS = new FlavorsResource(this); KEY_PAIRS = new KeyPairsExtension(this); FLOATING_IPS = new FloatingIpsExtension(this); SECURITY_GROUPS = new SecurityGroupsExtension(this); SNAPSHOTS = new SnapshotsExtension(this); VOLUMES = new VolumesExtension(this); AGGREGATES = new AggregatesExtension(this); QUOTA_SETS = new QuotaSetsResource(this); HOSTS = new HostsExtension(this); SERVICES = new ServicesResource(this); HYPERVISORS = new HypervisorsResource(this); NETWORKS = new NetworksExtension(this); }
/** * @see com.att.cdp.zones.ComputeService#assignIpAddress(java.lang.String, * java.lang.String) */ @SuppressWarnings("nls") @Override public void assignIpAddress(String serverId, String address) throws ZoneException { checkArg(serverId, "serverId"); checkArg(address, "address"); connect(); Context context = getContext(); trackRequest(); RequestState.put(RequestState.SERVER, serverId); RequestState.put(RequestState.IPADDRESS, address); RequestState.put(RequestState.SERVICE, "Compute"); RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint()); try { nova.getClient().servers().associateFloatingIp(serverId, address) .execute(); } catch (OpenStackBaseException ex) { ExceptionMapper.mapException(ex); } }
/** * Starts the indicated server * * @param id * The id of the server to be started * @throws ZoneException * If the server is in an invalid state or it does not exist. * @see com.att.cdp.zones.ComputeService#startServer(java.lang.String) */ @SuppressWarnings("nls") @Override public void startServer(String id) throws ZoneException { checkOpen(); checkArg(id, "id"); connect(); Context context = getContext(); trackRequest(); RequestState.put(RequestState.SERVER, id); RequestState.put(RequestState.SERVICE, "Compute"); RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint()); try { nova.getClient().servers().start(id).execute(); } catch (OpenStackBaseException ex) { ExceptionMapper.mapException(ex); } }
/** * Stops the indicated server * * @param id * The id of the server to be stopped * @throws ZoneException * If the server is in an invalid state or it does not exist. * @see com.att.cdp.zones.ComputeService#stopServer(java.lang.String) */ @SuppressWarnings("nls") @Override public void stopServer(String id) throws ZoneException { checkArg(id, "id"); connect(); Context context = getContext(); trackRequest(); RequestState.put(RequestState.SERVER, id); RequestState.put(RequestState.SERVICE, "Compute"); RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint()); try { nova.getClient().servers().stop(id).execute(); } catch (OpenStackBaseException ex) { ExceptionMapper.mapException(ex); } }
nova.getClient() .servers() .attachVolume(server.getId(), volume.getId(), deviceName).execute(); } catch (OpenStackBaseException ex) {
Servers servers = client.servers().list(true).execute(); for (com.woorea.openstack.nova.model.Server server : servers.getList()) { Addresses allocatedAddresses = server.getAddresses();