Class ServerServiceImpl

    • Constructor Detail

      • ServerServiceImpl

        public ServerServiceImpl()
    • Method Detail

      • list

        public List<? extends Server> list()
        List all servers (detailed) that the current tenant has access to
        Specified by:
        list in interface ServerService
        Returns:
        list of all servers
      • list

        public List<? extends Server> list​(boolean detail)
        List all servers (detailed / brief) that the current tenant has access to
        Specified by:
        list in interface ServerService
        Parameters:
        detail - if true all attributes will be populated, false (brief) will be ID, Name and Links
        Returns:
        list of all servers
      • listAll

        public List<? extends Server> listAll​(boolean detail)
        List all servers for all tenants (detailed / brief)
        Specified by:
        listAll in interface ServerService
        Parameters:
        detail - if true all attributes will be populated, false (brief) will be ID, Name and Links
        Returns:
        list of all servers
      • list

        public List<? extends Server> list​(Map<String,​String> filteringParams)
        Returns list of servers filtered by parameters.
        Specified by:
        list in interface ServerService
        Parameters:
        filteringParams - map (name, value) of filtering parameters
      • get

        public Server get​(String serverId)
        Get the specified server by ID
        Specified by:
        get in interface ServerService
        Parameters:
        serverId - the server id
        Returns:
        the server or null if not found
      • boot

        public Server boot​(ServerCreate server)
        Create (boot) a new Server
        Specified by:
        boot in interface ServerService
        Parameters:
        server - the server to boot
        Returns:
        the newly created server
      • bootAndWaitActive

        public Server bootAndWaitActive​(ServerCreate server,
                                        int maxWaitTime)
        Create (boot) a new Server
        Specified by:
        bootAndWaitActive in interface ServerService
        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

        public ActionResponse delete​(String serverId)
        Delete (i.e shut down and delete the image) of the server
        Specified by:
        delete in interface ServerService
        Parameters:
        serverId - the server identifier
        Returns:
        the action response
      • action

        public ActionResponse action​(String serverId,
                                     Action action)
        Executes the specified Action such as RESUME, PAUSE, START, STOP ... see (@link Action for all possible actions
        Specified by:
        action in interface ServerService
        Parameters:
        serverId - the server identifier to execute the action against
        action - the action the specified action
        Returns:
        the action response
      • createSnapshot

        public String createSnapshot​(String serverId,
                                     String snapshotName)
        Creates the snapshot for a Server
        Specified by:
        createSnapshot in interface ServerService
        Parameters:
        serverId - the server id
        snapshotName - the snapshot name
        Returns:
        the newly created snapshot UUID
      • createSnapshot

        public String createSnapshot​(String serverId,
                                     String snapshotName,
                                     Map<String,​String> metadata)
        Creates the snapshot from a server
        Specified by:
        createSnapshot in interface ServerService
        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
      • reboot

        public ActionResponse reboot​(String serverId,
                                     RebootType type)
        Reboot a server by SOFT (software-level) or HARD (hardware power cycle)
        Specified by:
        reboot in interface ServerService
        Parameters:
        serverId - the server id
        type - the type of reboot
        Returns:
        the action response
      • rebuild

        public ActionResponse rebuild​(String serverId,
                                      RebuildOptions options)
        Rebuilds the specified server
        Specified by:
        rebuild in interface ServerService
        Parameters:
        serverId - the server id
        options - additional options used during the rebuild. (OPTIONAL, can be null)
        Returns:
        the action response
      • addSecurityGroup

        public ActionResponse addSecurityGroup​(String serverId,
                                               String secGroupName)
        Associates the specified Server Group by name to the Server by it's identifier
        Specified by:
        addSecurityGroup in interface ServerService
        Parameters:
        serverId - the server identifier
        secGroupName - the security group name
        Returns:
        the action response
      • removeSecurityGroup

        public ActionResponse removeSecurityGroup​(String serverId,
                                                  String secGroupName)
        Removes the specified Server Group by name from the Server by it's identifier
        Specified by:
        removeSecurityGroup in interface ServerService
        Parameters:
        serverId - the server identifier
        secGroupName - the security group name
        Returns:
        the action response
      • confirmResize

        public ActionResponse confirmResize​(String serverId)
        Confirm that the resize worked, thus removing the original server
        Specified by:
        confirmResize in interface ServerService
        Parameters:
        serverId - the server identifier
        Returns:
        the action response
      • revertResize

        public ActionResponse revertResize​(String serverId)
        Revert a previous resize, switching back to the old server
        Specified by:
        revertResize in interface ServerService
        Parameters:
        serverId - the server identifier
        Returns:
        the action response
      • getConsoleOutput

        public String getConsoleOutput​(String serverId,
                                       int numLines)
        Will attempt to tail and return the last numLines from the given servers console.
        Specified by:
        getConsoleOutput in interface ServerService
        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

        public VNCConsole getVNCConsole​(String serverId,
                                        VNCConsole.Type type)
        Obtains the VNC Console connection information for the given server and VNC Console Type
        Specified by:
        getVNCConsole in interface ServerService
        Parameters:
        serverId - the server identifier
        type - the VNC Console type
        Returns:
        VNCConsole or null if not applicable
      • diagnostics

        public 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
        Specified by:
        diagnostics in interface ServerService
        Parameters:
        serverId - the server id
        Returns:
        Map of collected usage statistics organized by key and value
      • attachVolume

        public VolumeAttachment attachVolume​(String serverId,
                                             String volumeId,
                                             String device)
        attach the volume to the given server
        Specified by:
        attachVolume in interface ServerService
        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
      • detachVolume

        public ActionResponse detachVolume​(String serverId,
                                           String attachmentId)
        detach the volume to the given server
        Specified by:
        detachVolume in interface ServerService
        Parameters:
        serverId - the server identifier
        attachmentId - the attachment identifier
        Returns:
        the action response
      • liveMigrate

        public ActionResponse liveMigrate​(String serverId,
                                          LiveMigrateOptions options)
        Live-migrates a server identified with serverId to a new host without rebooting
        Specified by:
        liveMigrate in interface ServerService
        Parameters:
        serverId - the server identifier
        options - live migration options
        Returns:
        ActionResponse
      • resetState

        public ActionResponse resetState​(String serverId,
                                         Server.Status state)
        Resets the state of a server to a specified state
        Specified by:
        resetState in interface ServerService
        Parameters:
        serverId - the server identifier
        state - the new server state
        Returns:
        ActionResponse
      • changeAdminPassword

        public ActionResponse changeAdminPassword​(String serverId,
                                                  String adminPassword)
        Changes the admin/root password on the server
        Specified by:
        changeAdminPassword in interface ServerService
        Parameters:
        serverId - the server identifier
        adminPassword - the new password
        Returns:
        ActionResponse
      • waitForServerStatus

        public 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
        Specified by:
        waitForServerStatus in interface ServerService
        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

        public Map<String,​String> getMetadata​(String serverId)
        Returns the metadata for the specified server
        Specified by:
        getMetadata in interface ServerService
        Parameters:
        serverId - the server identifier
        Returns:
        Map of metadata of key and value
      • updateMetadata

        public Map<String,​String> updateMetadata​(String serverId,
                                                       Map<String,​String> metadata)
        Creates or replaces metadata items for the specified server
        Specified by:
        updateMetadata in interface ServerService
        Parameters:
        serverId - the server identifier
        metadata - the metadata to create or update
        Returns:
        Map of metadata as the current state on the server
      • deleteMetadataItem

        public ActionResponse deleteMetadataItem​(String serverId,
                                                 String key)
        Removes the specified metadata item via the specified key and serverId
        Specified by:
        deleteMetadataItem in interface ServerService
        Parameters:
        serverId - the server identifier
        key - the metadata key to remove
        Returns:
        the action response
      • update

        public Server update​(String serverId,
                             ServerUpdateOptions options)
        Description copied from interface: ServerService
        Updates an existing Server instance
        Specified by:
        update in interface ServerService
        Parameters:
        serverId - the server identifier
        options - the options used to update
        Returns:
        the updated server
      • getPassword

        public ServerPassword getPassword​(String serverId)
        Returns the encrypted password for the specified server which can be decrypted with the private key
        Specified by:
        getPassword in interface ServerService
        Parameters:
        serverId - the server identifier
        Returns:
        the encrypted server password
      • evacuate

        public ServerPassword evacuate​(String serverId,
                                       EvacuateOptions options)
        Evacuates a server identified with serverId from a failed host to a new host
        Specified by:
        evacuate in interface ServerService
        Parameters:
        serverId - the server identifier
        options - evaucate options
        Returns:
        an administrative password to access the evacuated or rebuilt instance.