Package org.openstack4j.api.compute
Interface ServerService
-
- All Known Implementing Classes:
ServerServiceImpl
public interface ServerServiceServer Operations API- Author:
- Jeremy Unruh
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ActionResponseaction(String serverId, Action action)Executes the specified Action such as RESUME, PAUSE, START, STOP ...ActionResponseaddSecurityGroup(String serverId, String secGroupName)Associates the specified Server Group by name to the Server by it's identifierVolumeAttachmentattachVolume(String serverId, String volumeId, String device)attach the volume to the given serverActionResponsebackupServer(String serverId, BackupOptions options)Sets up a new backup schedule service for the givenserverIdServerboot(ServerCreate server)Create (boot) a new ServerServerbootAndWaitActive(ServerCreate server, int maxWaitTime)Create (boot) a new ServerActionResponsechangeAdminPassword(String serverId, String adminPassword)Changes the admin/root password on the serverActionResponseconfirmResize(String serverId)Confirm that the resize worked, thus removing the original serverStringcreateSnapshot(String serverId, String snapshotName)Creates the snapshot for a ServerStringcreateSnapshot(String serverId, String snapshotName, Map<String,String> metadata)Creates the snapshot from a serverActionResponsedelete(String serverId)Delete (i.e shut down and delete the image) of the serverActionResponsedeleteMetadataItem(String serverId, String key)Removes the specified metadata item via the specifiedkeyandserverIdActionResponsedetachVolume(String serverId, String attachmentId)detach the volume to the given serverMap<String,? extends Number>diagnostics(String serverId)Gets usage information about the server.ServerPasswordevacuate(String serverId, EvacuateOptions options)Evacuates a server identified withserverIdfrom a failed host to a new hostServerget(String serverId)Get the specified server by IDStringgetConsoleOutput(String serverId, int numLines)Will attempt to tail and return the lastnumLinesfrom the given servers console.Map<String,String>getMetadata(String serverId)Returns the metadata for the specified serverServerPasswordgetPassword(String serverId)Returns the encrypted password for the specified server which can be decrypted with the private keyVNCConsolegetVNCConsole(String serverId, VNCConsole.Type type)Obtains the VNC Console connection information for the given server and VNC Console TypeInstanceActionsServiceinstanceActions()The instance actions service extension (os-instance-actions)InterfaceServiceinterfaces()The interface attachment service extension (os-interface)List<? extends Server>list()List all servers (detailed) that the current tenant has access toList<? extends Server>list(boolean detail)List all servers (detailed / brief) that the current tenant has access toList<? extends Server>list(Map<String,String> filteringParams)Returns list of servers filtered by parameters.List<? extends Server>listAll(boolean detail)List all servers for all tenants (detailed / brief)ActionResponseliveMigrate(String serverId, LiveMigrateOptions options)Live-migrates a server identified withserverIdto a new host without rebootingActionResponsemigrateServer(String serverId)Only user with admin role can do this.ActionResponsereboot(String serverId, RebootType type)Reboot a server by SOFT (software-level) or HARD (hardware power cycle)ActionResponserebuild(String serverId, RebuildOptions options)Rebuilds the specified serverActionResponseremoveSecurityGroup(String serverId, String secGroupName)Removes the specified Server Group by name from the Server by it's identifierActionResponseresetState(String serverId, Server.Status state)Resets the state of a server to a specifiedstateActionResponseresize(String serverId, String flavorId)Resize a server's resources.ActionResponserevertResize(String serverId)Revert a previous resize, switching back to the old serverServerCreateBuilderserverBuilder()Serverupdate(String serverId, ServerUpdateOptions options)Updates an existing Server instanceMap<String,String>updateMetadata(String serverId, Map<String,String> metadata)Creates or replaces metadata items for the specified serverServerwaitForServerStatus(String serverId, Server.Status status, int maxWait, TimeUnit maxWaitUnit)Will poll the Server waiting for theStatusto match or an Error state occurs for themaxWait
-
-
-
Method Detail
-
list
List<? extends Server> list()
List all servers (detailed) that the current tenant has access to- Returns:
- list of all servers
-
list
List<? extends Server> list(boolean detail)
List all servers (detailed / brief) that the current tenant has access to- Parameters:
detail- if true all attributes will be populated, false (brief) will be ID, Name and Links- Returns:
- list of all servers
-
list
List<? extends Server> list(Map<String,String> filteringParams)
Returns list of servers filtered by parameters.- Parameters:
filteringParams- map (name, value) of filtering parameters
-
listAll
List<? extends Server> listAll(boolean detail)
List all servers for all tenants (detailed / brief)- Parameters:
detail- if true all attributes will be populated, false (brief) will be ID, Name and Links- Returns:
- list of all servers
-
get
Server get(String serverId)
Get the specified server by ID- Parameters:
serverId- the server id- Returns:
- the server or null if not found
-
boot
Server boot(ServerCreate server)
Create (boot) a new Server- Parameters:
server- the server to boot- Returns:
- the newly created server
-
bootAndWaitActive
Server bootAndWaitActive(ServerCreate server, int maxWaitTime)
Create (boot) a new Server- Parameters:
server- the server to bootmaxWaitTime- the max time to wait in milliseconds for the server to become ACTIVE- Returns:
- the newly created server
-
delete
ActionResponse delete(String serverId)
Delete (i.e shut down and delete the image) of the server- Parameters:
serverId- the server identifier- Returns:
- the action response
-
action
ActionResponse action(String serverId, Action action)
Executes the specified Action such as RESUME, PAUSE, START, STOP ... see (@linkActionfor all possible actions- Parameters:
serverId- the server identifier to execute the action againstaction- the action the specified action- Returns:
- the action response
-
reboot
ActionResponse reboot(String serverId, RebootType type)
Reboot a server by SOFT (software-level) or HARD (hardware power cycle)- Parameters:
serverId- the server idtype- the type of reboot- Returns:
- the action response
-
rebuild
ActionResponse rebuild(String serverId, RebuildOptions options)
Rebuilds the specified server- Parameters:
serverId- the server idoptions- additional options used during the rebuild. (OPTIONAL, can be null)- Returns:
- the action response
-
resize
ActionResponse resize(String serverId, String flavorId)
Resize a server's resources. Until a resize event is confirmedconfirmResize(String), the old server will be kept around and you'll be able to roll back to the old flavor quick withrevertResize(String). All resizes will be automatically confirmed after 24 hours.- Parameters:
serverId- the server identifierflavorId- the new flavor id to resize to- Returns:
- the action response
-
confirmResize
ActionResponse confirmResize(String serverId)
Confirm that the resize worked, thus removing the original server- Parameters:
serverId- the server identifier- Returns:
- the action response
-
revertResize
ActionResponse revertResize(String serverId)
Revert a previous resize, switching back to the old server- Parameters:
serverId- the server identifier- Returns:
- the action response
-
createSnapshot
String createSnapshot(String serverId, String snapshotName)
Creates the snapshot for a Server- Parameters:
serverId- the server idsnapshotName- the snapshot name- Returns:
- the newly created snapshot UUID
-
createSnapshot
String createSnapshot(String serverId, String snapshotName, Map<String,String> metadata)
Creates the snapshot from a server- Parameters:
serverId- the UUID of the serversnapshotName- the display name of the snapshotmetadata- the key/value properties for the snapshot- Returns:
- the UUID for the resulting image snapshot
-
addSecurityGroup
ActionResponse addSecurityGroup(String serverId, String secGroupName)
Associates the specified Server Group by name to the Server by it's identifier- Parameters:
serverId- the server identifiersecGroupName- the security group name- Returns:
- the action response
-
removeSecurityGroup
ActionResponse removeSecurityGroup(String serverId, String secGroupName)
Removes the specified Server Group by name from the Server by it's identifier- Parameters:
serverId- the server identifiersecGroupName- the security group name- Returns:
- the action response
-
diagnostics
Map<String,? extends Number> diagnostics(String serverId)
Gets usage information about the server. Usage includes CPU, Memory, IO. Information is dependent on the hypervisor used by the OpenStack installation and whether that hypervisor supports diagnostics- Parameters:
serverId- the server id- Returns:
- Map of collected usage statistics organized by key and value
-
serverBuilder
ServerCreateBuilder serverBuilder()
- Returns:
- a builder to create a ServerCreate
-
getConsoleOutput
String getConsoleOutput(String serverId, int numLines)
Will attempt to tail and return the lastnumLinesfrom the given servers console.- Parameters:
serverId- the server identifiernumLines- the number of console lines to return. If lower or equal than zero, the whole console content will be returned.- Returns:
- console output as string or null
-
getVNCConsole
VNCConsole getVNCConsole(String serverId, VNCConsole.Type type)
Obtains the VNC Console connection information for the given server and VNC Console Type- Parameters:
serverId- the server identifiertype- the VNC Console type- Returns:
- VNCConsole or null if not applicable
-
attachVolume
VolumeAttachment attachVolume(String serverId, String volumeId, String device)
attach the volume to the given server- Parameters:
serverId- the server identifiervolumeId- the volume identifierdevice- the device to attach the volume to, ex /dev/vda- Returns:
- volumeAttachment or null if not applicable
-
changeAdminPassword
ActionResponse changeAdminPassword(String serverId, String adminPassword)
Changes the admin/root password on the server- Parameters:
serverId- the server identifieradminPassword- the new password- Returns:
- ActionResponse
-
detachVolume
ActionResponse detachVolume(String serverId, String attachmentId)
detach the volume to the given server- Parameters:
serverId- the server identifierattachmentId- the attachment identifier- Returns:
- the action response
-
migrateServer
ActionResponse migrateServer(String serverId)
Only user with admin role can do this. Migrate a server. The new host will be selected by the scheduler. Until a resize event is confirmedconfirmResize(String), the old server will be kept around and you'll be able to roll back to the old host quick withrevertResize(String). All resizes will be automatically confirmed after 24 hours.- Parameters:
serverId- the server identifier- Returns:
- the action response
-
liveMigrate
ActionResponse liveMigrate(String serverId, LiveMigrateOptions options)
Live-migrates a server identified withserverIdto a new host without rebooting- Parameters:
serverId- the server identifieroptions- live migration options- Returns:
- ActionResponse
-
resetState
ActionResponse resetState(String serverId, Server.Status state)
Resets the state of a server to a specifiedstate- Parameters:
serverId- the server identifierstate- the new server state- Returns:
- ActionResponse
-
backupServer
ActionResponse backupServer(String serverId, BackupOptions options)
Sets up a new backup schedule service for the givenserverId- Parameters:
serverId- the server identifieroptions- the backup options- Returns:
- ActionResponse
-
waitForServerStatus
Server waitForServerStatus(String serverId, Server.Status status, int maxWait, TimeUnit maxWaitUnit)
Will poll the Server waiting for theStatusto match or an Error state occurs for themaxWait- Parameters:
serverId- the server identifierstatus- the status to wait formaxWait- the max wait timemaxWaitUnit- the unit the max wait time was specified in- Returns:
- the last Server polled or null. User should re-check status in case max wait was hit and the status was still not in the desired state.
-
getMetadata
Map<String,String> getMetadata(String serverId)
Returns the metadata for the specified server- Parameters:
serverId- the server identifier- Returns:
- Map of metadata of key and value
-
updateMetadata
Map<String,String> updateMetadata(String serverId, Map<String,String> metadata)
Creates or replaces metadata items for the specified server- Parameters:
serverId- the server identifiermetadata- the metadata to create or update- Returns:
- Map of metadata as the current state on the server
-
deleteMetadataItem
ActionResponse deleteMetadataItem(String serverId, String key)
Removes the specified metadata item via the specifiedkeyandserverId- Parameters:
serverId- the server identifierkey- the metadata key to remove- Returns:
- the action response
-
update
Server update(String serverId, ServerUpdateOptions options)
Updates an existing Server instance- Parameters:
serverId- the server identifieroptions- the options used to update- Returns:
- the updated server
-
interfaces
InterfaceService interfaces()
The interface attachment service extension (os-interface)- Returns:
- the interface service
-
instanceActions
InstanceActionsService instanceActions()
The instance actions service extension (os-instance-actions)- Returns:
- the instance actions service
-
getPassword
ServerPassword getPassword(String serverId)
Returns the encrypted password for the specified server which can be decrypted with the private key- Parameters:
serverId- the server identifier- Returns:
- the encrypted server password
-
evacuate
ServerPassword evacuate(String serverId, EvacuateOptions options)
Evacuates a server identified withserverIdfrom a failed host to a new host- Parameters:
serverId- the server identifieroptions- evaucate options- Returns:
- an administrative password to access the evacuated or rebuilt instance.
-
-