Interface ServerService

  • All Known Implementing Classes:
    ServerServiceImpl

    public interface ServerService
    Server Operations API
    Author:
    Jeremy Unruh
    • 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 boot
        maxWaitTime - 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 (@link Action for all possible actions
        Parameters:
        serverId - the server identifier to execute the action against
        action - 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 id
        type - the type of reboot
        Returns:
        the action response
      • rebuild

        ActionResponse rebuild​(String serverId,
                               RebuildOptions options)
        Rebuilds the specified server
        Parameters:
        serverId - the server id
        options - 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 confirmed confirmResize(String), the old server will be kept around and you'll be able to roll back to the old flavor quick with revertResize(String). All resizes will be automatically confirmed after 24 hours.
        Parameters:
        serverId - the server identifier
        flavorId - 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 id
        snapshotName - 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 server
        snapshotName - the display name of the snapshot
        metadata - 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 identifier
        secGroupName - 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 identifier
        secGroupName - 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 last numLines from the given servers console.
        Parameters:
        serverId - the server identifier
        numLines - 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 identifier
        type - 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 identifier
        volumeId - the volume identifier
        device - 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 identifier
        adminPassword - the new password
        Returns:
        ActionResponse
      • detachVolume

        ActionResponse detachVolume​(String serverId,
                                    String attachmentId)
        detach the volume to the given server
        Parameters:
        serverId - the server identifier
        attachmentId - 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 confirmed confirmResize(String), the old server will be kept around and you'll be able to roll back to the old host quick with revertResize(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 with serverId to a new host without rebooting
        Parameters:
        serverId - the server identifier
        options - live migration options
        Returns:
        ActionResponse
      • resetState

        ActionResponse resetState​(String serverId,
                                  Server.Status state)
        Resets the state of a server to a specified state
        Parameters:
        serverId - the server identifier
        state - the new server state
        Returns:
        ActionResponse
      • backupServer

        ActionResponse backupServer​(String serverId,
                                    BackupOptions options)
        Sets up a new backup schedule service for the given serverId
        Parameters:
        serverId - the server identifier
        options - the backup options
        Returns:
        ActionResponse
      • waitForServerStatus

        Server waitForServerStatus​(String serverId,
                                   Server.Status status,
                                   int maxWait,
                                   TimeUnit maxWaitUnit)
        Will poll the Server waiting for the Status to match or an Error state occurs for the maxWait
        Parameters:
        serverId - the server identifier
        status - the status to wait for
        maxWait - the max wait time
        maxWaitUnit - 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 identifier
        metadata - 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 specified key and serverId
        Parameters:
        serverId - the server identifier
        key - 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 identifier
        options - 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 with serverId from a failed host to a new host
        Parameters:
        serverId - the server identifier
        options - evaucate options
        Returns:
        an administrative password to access the evacuated or rebuilt instance.