public UpdateServer update(String serverId, String name, String accessIPv4, String accessIPv6) { Server server = new Server(); //server.setName(name); //server.setAccessIPv4(accessIPv4); //server.setAccessIPv6(accessIPv6); return new UpdateServer(serverId, server); }
/** * This method is called to load the hypervisor attachment, if it has not already been loaded. If it has been * loaded, then the call is ignored. * * @param context * The context that represents the connection we are servicing * @throws ZoneException * If the attachments cannot be obtained, or if a hypervisor cannot be listed, or a hypervisor does not * exist */ private void loadHypervisorAttachment(Context context) throws ZoneException { if (hypervisorAttachmentProcessed.compareAndSet(false, true)) { ComputeService computeService = context.getComputeService(); List<Hypervisor> hypervisors = computeService.getHypervisors(); if (this.novaModel.getHypervisorHostname() != null && !this.novaModel.getHypervisorHostname().isEmpty()) { String hypervisorName = this.novaModel.getHypervisorHostname(); for (Hypervisor h : hypervisors) { if (h.getHostName().equals(hypervisorName)) { this.setHypervisor(h); return; } } } } }
/** * @see com.att.cdp.zones.ComputeService#findAllServersUsingKey(java.lang.String) */ @SuppressWarnings("nls") @Override public List<String> findAllServersUsingKey(String keyPair) throws ZoneException { checkArg(keyPair, "keyPair"); connect(); trackRequest(); RequestState.put(RequestState.SERVICE, "Compute"); RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint()); RequestState.put(RequestState.KEYPAIR, keyPair); List<String> users = new ArrayList<String>(); try { Servers servers = nova.getClient().servers().list(false).execute(); for (com.woorea.openstack.nova.model.Server server : servers.getList()) { if (keyPair.equals(server.getKeyName())) { users.add(server.getId()); } } } catch (OpenStackBaseException ex) { ExceptionMapper.mapException(ex); } return users; }
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(); } } }
for (com.woorea.openstack.nova.model.Server s : servers.getList()) { if (name != null) { if (s.getName().matches(name)) { list.add(new OpenStackServer(context, s));
com.woorea.openstack.nova.model.Flavor flavor = server.getFlavor(); if (flavor != null) { setTemplate(new OpenStackTemplate(context, flavor)); com.woorea.openstack.nova.model.Server.Fault osFault = server.getFault(); if (osFault != null) { OpenStackFault fault = new OpenStackFault(context, osFault);
try { NetworkService netService = context.getNetworkService(); com.woorea.openstack.nova.model.Server.Addresses addresses = novaModel.getAddresses(); if (addresses != null) { for (Map.Entry<String, List<com.woorea.openstack.nova.model.Server.Addresses.Address>> entry : addresses
/** * @see com.att.cdp.zones.ComputeService#findAllServersUsingKey(java.lang.String) */ @SuppressWarnings("nls") @Override public List<String> findAllServersUsingKey(String keyPair) throws ZoneException { checkArg(keyPair, "keyPair"); connect(); Context context = getContext(); trackRequest(); RequestState.put(RequestState.KEYPAIR, keyPair); RequestState.put(RequestState.SERVICE, "Compute"); RequestState.put(RequestState.SERVICE_URL, nova.getEndpoint()); List<String> users = new ArrayList<>(); try { Servers servers = nova.getClient().servers().list(false).execute(); for (com.woorea.openstack.nova.model.Server server : servers .getList()) { if (keyPair.equals(server.getKeyName())) { users.add(server.getId()); } } } catch (OpenStackBaseException ex) { ExceptionMapper.mapException(ex); } return users; }
for (com.woorea.openstack.nova.model.Server s : servers.getList()) { if (name != null) { if (s.getName().matches(name)) { list.add(new OpenStackServer(context, s));
Addresses allocatedAddresses = server.getAddresses(); Map<String, List<Address>> addressMap = allocatedAddresses.getAddresses(); for (Map.Entry<String, List<Address>> entry : addressMap.entrySet()) {
public UpdateServer update(String serverId, String name, String accessIPv4, String accessIPv6) { Server server = new Server(); // server.setName(name); // server.setAccessIPv4(accessIPv4); // server.setAccessIPv6(accessIPv6); return new UpdateServer(serverId, server); }