Interface ServerApi


  • @Consumes("application/json")
    @Path("/servers")
    public interface ServerApi
    Provides access to the OpenStack Compute (Nova) Server API.
    • Method Detail

      • list

        @Named("server:list")
        @GET
        PagedIterable<Resource> list()
        List all servers (IDs, names, links)
        Returns:
        all servers (IDs, names, links)
      • listInDetail

        @Named("server:list")
        @GET
        @Path("/detail")
        PagedIterable<Server> listInDetail()
        List all servers (all details)
        Returns:
        all servers (all details)
      • get

        @Named("server:get")
        @GET
        @Path("/{id}")
        @Nullable
        Server get​(@PathParam("id")
                   String id)
        List details of the specified server
        Parameters:
        id - id of the server
        Returns:
        server or null if not found
      • create

        @Named("server:create")
        @POST
        ServerCreated create​(String name,
                             String imageRef,
                             String flavorRef,
                             CreateServerOptions... options)
        Create a new server
        Parameters:
        name - name of the server to create
        imageRef - reference to the image for the server to use
        flavorRef - reference to the flavor to use when creating the server
        options - optional parameters to be passed into the server creation request
        Returns:
        the newly created server
      • delete

        @Named("server:delete")
        @DELETE
        @Path("/{id}")
        boolean delete​(@PathParam("id")
                       String id)
        Terminate and delete a server.
        Parameters:
        id - id of the server
        Returns:
        True if successful, False otherwise
      • start

        @Named("server:start")
        @POST
        @Path("/{id}/action")
        @Produces("application/json")
        void start​(@PathParam("id")
                   String id)
        Start a server
        Parameters:
        id - id of the server
      • stop

        @Named("server:stop")
        @POST
        @Path("/{id}/action")
        @Produces("application/json")
        void stop​(@PathParam("id")
                  String id)
        Stop a server
        Parameters:
        id - id of the server
      • reboot

        @Named("server:reboot")
        @POST
        @Path("/{id}/action")
        @Produces("application/json")
        void reboot​(@PathParam("id")
                    String id,
                    RebootType rebootType)
        Reboot a server.
        Parameters:
        id - id of the server
        rebootType - The type of reboot to perform (Hard/Soft)
      • resize

        @Named("server:resize")
        @POST
        @Path("/{id}/action")
        @Produces("application/json")
        void resize​(@PathParam("id")
                    String id,
                    String flavorId)
        Resize a server to a new flavor size.
        Parameters:
        id - id of the server
        flavorId - id of the new flavor to use
      • confirmResize

        @Named("server:confirmResize")
        @POST
        @Path("/{id}/action")
        @Produces("application/json")
        void confirmResize​(@PathParam("id")
                           String id)
        Confirm a resize operation.
        Parameters:
        id - id of the server
      • revertResize

        @Named("server:revertResize")
        @POST
        @Path("/{id}/action")
        @Produces("application/json")
        void revertResize​(@PathParam("id")
                          String id)
        Revert a resize operation.
        Parameters:
        id - id of the server
      • rebuild

        @Named("server:rebuild")
        @POST
        @Path("/{id}/action")
        void rebuild​(@PathParam("id")
                     String id,
                     RebuildServerOptions... options)
        Rebuild a server.
        Parameters:
        id - id of the server
        options - Optional parameters to the rebuilding operation.
      • changeAdminPass

        @Named("server:changeAdminPass")
        @POST
        @Path("/{id}/action")
        @Produces("application/json")
        void changeAdminPass​(@PathParam("id")
                             String id,
                             String adminPass)
        Change the administrative password to a server.
        Parameters:
        id - id of the server
        adminPass - The new administrative password to use
      • rename

        @Named("server:rename")
        @PUT
        @Path("/{id}")
        @Produces("application/json")
        void rename​(@PathParam("id")
                    String id,
                    String newName)
        Rename a server.
        Parameters:
        id - id of the server
        newName - The new name for the server
      • createImageFromServer

        @Named("server:createImageFromServer")
        @POST
        @Path("/{id}/action")
        @Produces("application/json")
        String createImageFromServer​(String name,
                                     @PathParam("id")
                                     String id)
        Create an image from a server.
        Parameters:
        name - The name of the new image
        id - id of the server
        Returns:
        ID of the new / updated image
      • getMetadata

        @Named("server:getMetadata")
        @GET
        @Path("/{id}/metadata")
        Map<String,​String> getMetadata​(@PathParam("id")
                                             String id)
        List all metadata for a server.
        Parameters:
        id - id of the server
        Returns:
        the metadata as a Map
      • setMetadata

        @Named("server:setMetadata")
        @PUT
        @Path("/{id}/metadata")
        @Produces("application/json")
        Map<String,​String> setMetadata​(@PathParam("id")
                                             String id,
                                             Map<String,​String> metadata)
        Set the metadata for a server.
        Parameters:
        id - id of the server
        metadata - a Map containing the metadata
        Returns:
        the metadata as a Map
      • updateMetadata

        @Named("server:updateMetadata")
        @POST
        @Path("/{id}/metadata")
        @Produces("application/json")
        Map<String,​String> updateMetadata​(@PathParam("id")
                                                String id,
                                                Map<String,​String> metadata)
        Update the metadata for a server.
        Parameters:
        id - id of the server
        metadata - a Map containing the metadata
        Returns:
        the metadata as a Map
      • getMetadata

        @Named("server:getMetadata")
        @GET
        @Path("/{id}/metadata/{key}")
        @Nullable
        String getMetadata​(@PathParam("id")
                           String id,
                           @PathParam("key")
                           String key)
        Update the metadata for a server.
        Parameters:
        id - id of the image
        key - a key containing the metadata
        Returns:
        the value or null if not present
      • updateMetadata

        @Named("server:updateMetadata")
        @PUT
        @Path("/{id}/metadata/{key}")
        @Produces("application/json")
        String updateMetadata​(@PathParam("id")
                              String id,
                              @PathParam("key")
                              String key,
                              @PathParam("value")
                              String value)
        Set a metadata item for a server.
        Parameters:
        id - id of the image
        key - the name of the metadata item
        value - the value of the metadata item
        Returns:
        the value you updated
      • deleteMetadata

        @Named("server:deleteMetadata")
        @DELETE
        @Path("/{id}/metadata/{key}")
        void deleteMetadata​(@PathParam("id")
                            String id,
                            @PathParam("key")
                            String key)
        Delete a metadata item from a server.
        Parameters:
        id - id of the image
        key - the name of the metadata item
      • getDiagnostics

        @Named("server:getDiagnostics")
        @GET
        @Path("/{id}/diagnostics")
        com.google.common.base.Optional<Map<String,​String>> getDiagnostics​(@PathParam("id")
                                                                                 String id)
        Get usage information about the server such as CPU usage, Memory and IO. The information returned by this method is dependent on the hypervisor in use by the OpenStack installation and whether that hypervisor supports this method. More information can be found in the OpenStack API reference.
        At the moment the returned response is a generic map. In future versions of OpenStack this might be subject to change.
        Parameters:
        id - id of the server
        Returns:
        A Map containing the collected values organized by key - value.
      • listSecurityGroupForServer

        @Named("server:getSecurityGroups")
        @GET
        @Path("/{id}/os-security-groups")
        Set<SecurityGroup> listSecurityGroupForServer​(@PathParam("id")
                                                      String id)
        Lists Security Groups for a server.
        Parameters:
        id - id of the server
        Returns:
        a list of security groups attached to the server
      • listPortInterfaces

        @Named("server:getPortInterfaces")
        @GET
        @Path("/{id}/os-interface")
        Set<PortInterface> listPortInterfaces​(@PathParam("id")
                                              String id)
        Lists port interfaces that are attached to a server.
        Parameters:
        id - id of the server
        Returns:
        a list of ports attached to the server