Interface ServerApi
@Consumes("application/json")
@Path("/servers")
public interface ServerApi
Provides access to the OpenStack Compute (Nova) Server API.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
changeAdminPass
(String id, String adminPass) Change the administrative password to a server.void
confirmResize
(String id) Confirm a resize operation.create
(String name, String imageRef, String flavorRef, CreateServerOptions... options) Create a new servercreateImageFromServer
(String name, String id) Create an image from a server.boolean
Terminate and delete a server.void
deleteMetadata
(String id, String key) Delete a metadata item from a server.List details of the specified servergetDiagnostics
(String id) Get usage information about the server such as CPU usage, Memory and IO.getMetadata
(String id) List all metadata for a server.getMetadata
(String id, String key) Update the metadata for a server.list()
List all servers (IDs, names, links)list
(PaginationOptions options) List all servers (all details)listInDetail
(PaginationOptions options) Lists port interfaces that are attached to a server.Lists Security Groups for a server.void
reboot
(String id, RebootType rebootType) Reboot a server.void
rebuild
(String id, RebuildServerOptions... options) Rebuild a server.void
Rename a server.void
Resize a server to a new flavor size.void
revertResize
(String id) Revert a resize operation.setMetadata
(String id, Map<String, String> metadata) Set the metadata for a server.void
Start a servervoid
Stop a serverupdateMetadata
(String id, String key, String value) Set a metadata item for a server.updateMetadata
(String id, Map<String, String> metadata) Update the metadata for a server.
-
Method Details
-
list
List all servers (IDs, names, links)- Returns:
- all servers (IDs, names, links)
-
list
-
listInDetail
List all servers (all details)- Returns:
- all servers (all details)
-
listInDetail
@Named("server:list") @GET @Path("/detail") PaginatedCollection<Server> listInDetail(PaginationOptions options) -
get
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 createimageRef
- reference to the image for the server to useflavorRef
- reference to the flavor to use when creating the serveroptions
- optional parameters to be passed into the server creation request- Returns:
- the newly created server
-
delete
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 serverrebootType
- 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 serverflavorId
- 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 serveroptions
- 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 serveradminPass
- 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 servernewName
- 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 imageid
- 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 Mapinvalid input: '<'String, String>
-
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 servermetadata
- a Map containing the metadata- Returns:
- the metadata as a Mapinvalid input: '<'String, String>
-
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 servermetadata
- a Map containing the metadata- Returns:
- the metadata as a Mapinvalid input: '<'String, String>
-
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 imagekey
- 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 imagekey
- the name of the metadata itemvalue
- 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 imagekey
- 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
-