Interface ServerApi
-
@Consumes("application/json") @Path("/servers") public interface ServerApi
Provides access to the OpenStack Compute (Nova) Server API.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
changeAdminPass(String id, String adminPass)
Change the administrative password to a server.void
confirmResize(String id)
Confirm a resize operation.ServerCreated
create(String name, String imageRef, String flavorRef, CreateServerOptions... options)
Create a new serverString
createImageFromServer(String name, String id)
Create an image from a server.boolean
delete(String id)
Terminate and delete a server.void
deleteMetadata(String id, String key)
Delete a metadata item from a server.Server
get(String id)
List details of the specified servercom.google.common.base.Optional<Map<String,String>>
getDiagnostics(String id)
Get usage information about the server such as CPU usage, Memory and IO.Map<String,String>
getMetadata(String id)
List all metadata for a server.String
getMetadata(String id, String key)
Update the metadata for a server.PagedIterable<Resource>
list()
List all servers (IDs, names, links)PaginatedCollection<Resource>
list(PaginationOptions options)
PagedIterable<Server>
listInDetail()
List all servers (all details)PaginatedCollection<Server>
listInDetail(PaginationOptions options)
Set<PortInterface>
listPortInterfaces(String id)
Lists port interfaces that are attached to a server.Set<SecurityGroup>
listSecurityGroupForServer(String id)
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(String id, String newName)
Rename a server.void
resize(String id, String flavorId)
Resize a server to a new flavor size.void
revertResize(String id)
Revert a resize operation.Map<String,String>
setMetadata(String id, Map<String,String> metadata)
Set the metadata for a server.void
start(String id)
Start a servervoid
stop(String id)
Stop a serverString
updateMetadata(String id, String key, String value)
Set a metadata item for a server.Map<String,String>
updateMetadata(String id, Map<String,String> metadata)
Update the metadata for a server.
-
-
-
Method Detail
-
list
@Named("server:list") @GET PagedIterable<Resource> list()
List all servers (IDs, names, links)- Returns:
- all servers (IDs, names, links)
-
list
@Named("server:list") @GET PaginatedCollection<Resource> list(PaginationOptions options)
-
listInDetail
@Named("server:list") @GET @Path("/detail") PagedIterable<Server> listInDetail()
List all servers (all details)- Returns:
- all servers (all details)
-
listInDetail
@Named("server:list") @GET @Path("/detail") PaginatedCollection<Server> listInDetail(PaginationOptions options)
-
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 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
@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 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 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 servermetadata
- 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 servermetadata
- 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 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
-
-