Merge "Merge the separated link lines on compute client"

This commit is contained in:
Jenkins 2016-11-03 18:55:55 +00:00 committed by Gerrit Code Review
commit 853b84a76d
13 changed files with 271 additions and 184 deletions

View File

@ -26,8 +26,9 @@ class AgentsClient(base_compute_client.BaseComputeClient):
def list_agents(self, **params):
"""List all agent builds.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#listbuilds
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#listbuilds
"""
url = 'os-agents'
if params:
@ -40,8 +41,9 @@ class AgentsClient(base_compute_client.BaseComputeClient):
def create_agent(self, **kwargs):
"""Create an agent build.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#agentbuild
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#agentbuild
"""
post_body = json.dumps({'agent': kwargs})
resp, body = self.post('os-agents', post_body)
@ -52,8 +54,9 @@ class AgentsClient(base_compute_client.BaseComputeClient):
def delete_agent(self, agent_id):
"""Delete an existing agent build.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#deleteBuild
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#deleteBuild
"""
resp, body = self.delete("os-agents/%s" % agent_id)
self.validate_response(schema.delete_agent, resp, body)
@ -62,8 +65,9 @@ class AgentsClient(base_compute_client.BaseComputeClient):
def update_agent(self, agent_id, **kwargs):
"""Update an agent build.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#updatebuild
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#updatebuild
"""
put_body = json.dumps({'para': kwargs})
resp, body = self.put('os-agents/%s' % agent_id, put_body)

View File

@ -40,8 +40,9 @@ class AggregatesClient(base_compute_client.BaseComputeClient):
def create_aggregate(self, **kwargs):
"""Create a new aggregate.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#createAggregate
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#createAggregate
"""
post_body = json.dumps({'aggregate': kwargs})
resp, body = self.post('os-aggregates', post_body)
@ -53,8 +54,9 @@ class AggregatesClient(base_compute_client.BaseComputeClient):
def update_aggregate(self, aggregate_id, **kwargs):
"""Update an aggregate.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#updateAggregate
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#updateAggregate
"""
put_body = json.dumps({'aggregate': kwargs})
resp, body = self.put('os-aggregates/%s' % aggregate_id, put_body)
@ -84,8 +86,9 @@ class AggregatesClient(base_compute_client.BaseComputeClient):
def add_host(self, aggregate_id, **kwargs):
"""Add a host to the given aggregate.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#addHost
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#addHost
"""
post_body = json.dumps({'add_host': kwargs})
resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
@ -97,8 +100,9 @@ class AggregatesClient(base_compute_client.BaseComputeClient):
def remove_host(self, aggregate_id, **kwargs):
"""Remove a host from the given aggregate.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#removeAggregateHost
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#removeAggregateHost
"""
post_body = json.dumps({'remove_host': kwargs})
resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
@ -110,8 +114,9 @@ class AggregatesClient(base_compute_client.BaseComputeClient):
def set_metadata(self, aggregate_id, **kwargs):
"""Replace the aggregate's existing metadata with new metadata.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#addAggregateMetadata
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#addAggregateMetadata
"""
post_body = json.dumps({'set_metadata': kwargs})
resp, body = self.post('os-aggregates/%s/action' % aggregate_id,

View File

@ -32,8 +32,9 @@ class FixedIPsClient(base_compute_client.BaseComputeClient):
def reserve_fixed_ip(self, fixed_ip, **kwargs):
"""Reserve/Unreserve a fixed IP.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#reserveIP
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#reserveIP
"""
url = "os-fixed-ips/%s/action" % fixed_ip
resp, body = self.post(url, json.dumps(kwargs))

View File

@ -30,8 +30,9 @@ class FlavorsClient(base_compute_client.BaseComputeClient):
def list_flavors(self, detail=False, **params):
"""Lists flavors.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#listFlavors
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#listFlavors
"""
url = 'flavors'
_schema = schema.list_flavors
@ -50,8 +51,9 @@ class FlavorsClient(base_compute_client.BaseComputeClient):
def show_flavor(self, flavor_id):
"""Shows details for a flavor.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#showFlavor
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#showFlavor
"""
resp, body = self.get("flavors/%s" % flavor_id)
body = json.loads(body)
@ -61,8 +63,9 @@ class FlavorsClient(base_compute_client.BaseComputeClient):
def create_flavor(self, **kwargs):
"""Create a new flavor or instance type.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#createFlavor
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#createFlavor
"""
if kwargs.get('ephemeral'):
kwargs['OS-FLV-EXT-DATA:ephemeral'] = kwargs.pop('ephemeral')
@ -79,8 +82,9 @@ class FlavorsClient(base_compute_client.BaseComputeClient):
def delete_flavor(self, flavor_id):
"""Delete the given flavor.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#deleteFlavor
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#deleteFlavor
"""
resp, body = self.delete("flavors/{0}".format(flavor_id))
self.validate_response(schema.delete_flavor, resp, body)
@ -104,8 +108,9 @@ class FlavorsClient(base_compute_client.BaseComputeClient):
def set_flavor_extra_spec(self, flavor_id, **kwargs):
"""Set extra Specs to the mentioned flavor.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#createFlavorExtraSpec
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#createFlavorExtraSpec
"""
post_body = json.dumps({'extra_specs': kwargs})
resp, body = self.post('flavors/%s/os-extra_specs' % flavor_id,
@ -118,8 +123,9 @@ class FlavorsClient(base_compute_client.BaseComputeClient):
def list_flavor_extra_specs(self, flavor_id):
"""Get extra Specs details of the mentioned flavor.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#listFlavorExtraSpecs
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#listFlavorExtraSpecs
"""
resp, body = self.get('flavors/%s/os-extra_specs' % flavor_id)
body = json.loads(body)
@ -130,8 +136,9 @@ class FlavorsClient(base_compute_client.BaseComputeClient):
def show_flavor_extra_spec(self, flavor_id, key):
"""Get extra Specs key-value of the mentioned flavor and key.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#showFlavorExtraSpec
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#showFlavorExtraSpec
"""
resp, body = self.get('flavors/%s/os-extra_specs/%s' % (flavor_id,
key))
@ -144,8 +151,9 @@ class FlavorsClient(base_compute_client.BaseComputeClient):
def update_flavor_extra_spec(self, flavor_id, key, **kwargs):
"""Update specified extra Specs of the mentioned flavor and key.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#updateFlavorExtraSpec
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#updateFlavorExtraSpec
"""
resp, body = self.put('flavors/%s/os-extra_specs/%s' %
(flavor_id, key), json.dumps(kwargs))
@ -160,8 +168,9 @@ class FlavorsClient(base_compute_client.BaseComputeClient):
# to keep backwards compatibility.
"""Unset extra Specs from the mentioned flavor.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#deleteFlavorExtraSpec
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#deleteFlavorExtraSpec
"""
resp, body = self.delete('flavors/%s/os-extra_specs/%s' %
(flavor_id, key))
@ -171,8 +180,9 @@ class FlavorsClient(base_compute_client.BaseComputeClient):
def list_flavor_access(self, flavor_id):
"""Get flavor access information given the flavor id.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#listFlavorAccess
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#listFlavorAccess
"""
resp, body = self.get('flavors/%s/os-flavor-access' % flavor_id)
body = json.loads(body)
@ -183,8 +193,9 @@ class FlavorsClient(base_compute_client.BaseComputeClient):
def add_flavor_access(self, flavor_id, tenant_id):
"""Add flavor access for the specified tenant.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#addFlavorAccess
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#addFlavorAccess
"""
post_body = {
'addTenantAccess': {
@ -201,8 +212,9 @@ class FlavorsClient(base_compute_client.BaseComputeClient):
def remove_flavor_access(self, flavor_id, tenant_id):
"""Remove flavor access from the specified tenant.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#removeFlavorAccess
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#removeFlavorAccess
"""
post_body = {
'removeTenantAccess': {

View File

@ -27,8 +27,9 @@ class FloatingIPsClient(base_compute_client.BaseComputeClient):
def list_floating_ips(self, **params):
"""Returns a list of all floating IPs filtered by any parameters.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#listfloatingipsObject
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#listfloatingipsObject
"""
url = 'os-floating-ips'
if params:
@ -42,8 +43,9 @@ class FloatingIPsClient(base_compute_client.BaseComputeClient):
def show_floating_ip(self, floating_ip_id):
"""Get the details of a floating IP.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#showFloatingIP
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#showFloatingIP
"""
url = "os-floating-ips/%s" % floating_ip_id
resp, body = self.get(url)
@ -54,8 +56,9 @@ class FloatingIPsClient(base_compute_client.BaseComputeClient):
def create_floating_ip(self, **kwargs):
"""Allocate a floating IP to the project.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#createFloatingIP
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#createFloatingIP
"""
url = 'os-floating-ips'
post_body = json.dumps(kwargs)
@ -67,8 +70,9 @@ class FloatingIPsClient(base_compute_client.BaseComputeClient):
def delete_floating_ip(self, floating_ip_id):
"""Deletes the provided floating IP from the project.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#deleteFloatingIP
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#deleteFloatingIP
"""
url = "os-floating-ips/%s" % floating_ip_id
resp, body = self.delete(url)

View File

@ -26,9 +26,9 @@ class SecurityGroupDefaultRulesClient(base_compute_client.BaseComputeClient):
def create_security_default_group_rule(self, **kwargs):
"""Create security group default rule.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html
#createSecGroupDefaultRule
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#createSecGroupDefaultRule
"""
post_body = json.dumps({'security_group_default_rule': kwargs})
url = 'os-security-group-default-rules'

View File

@ -26,8 +26,9 @@ class SecurityGroupRulesClient(base_compute_client.BaseComputeClient):
def create_security_group_rule(self, **kwargs):
"""Create a new security group rule.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#createSecGroupRule
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#createSecGroupRule
"""
post_body = json.dumps({'security_group_rule': kwargs})
url = 'os-security-group-rules'

View File

@ -28,8 +28,9 @@ class SecurityGroupsClient(base_compute_client.BaseComputeClient):
def list_security_groups(self, **params):
"""List all security groups for a user.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#listSecGroups
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#listSecGroups
"""
url = 'os-security-groups'
@ -44,8 +45,9 @@ class SecurityGroupsClient(base_compute_client.BaseComputeClient):
def show_security_group(self, security_group_id):
"""Get the details of a Security Group.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#showSecGroup
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#showSecGroup
"""
url = "os-security-groups/%s" % security_group_id
resp, body = self.get(url)
@ -56,8 +58,9 @@ class SecurityGroupsClient(base_compute_client.BaseComputeClient):
def create_security_group(self, **kwargs):
"""Create a new security group.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#createSecGroup
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#createSecGroup
"""
post_body = json.dumps({'security_group': kwargs})
resp, body = self.post('os-security-groups', post_body)
@ -68,8 +71,9 @@ class SecurityGroupsClient(base_compute_client.BaseComputeClient):
def update_security_group(self, security_group_id, **kwargs):
"""Update a security group.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#updateSecGroup
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#updateSecGroup
"""
post_body = json.dumps({'security_group': kwargs})
resp, body = self.put('os-security-groups/%s' % security_group_id,
@ -81,8 +85,9 @@ class SecurityGroupsClient(base_compute_client.BaseComputeClient):
def delete_security_group(self, security_group_id):
"""Delete the provided Security Group.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#deleteSecGroup
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#deleteSecGroup
"""
resp, body = self.delete(
'os-security-groups/%s' % security_group_id)

View File

@ -26,8 +26,9 @@ class ServerGroupsClient(base_compute_client.BaseComputeClient):
def create_server_group(self, **kwargs):
"""Create the server group.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#createServerGroup
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#createServerGroup
"""
post_body = json.dumps({'server_group': kwargs})
resp, body = self.post('os-server-groups', post_body)

View File

@ -92,8 +92,9 @@ class ServersClient(base_compute_client.BaseComputeClient):
def update_server(self, server_id, **kwargs):
"""Update server.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#updateServer
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#updateServer
Most parameters except the following are passed to the API without
any changes.
@ -112,8 +113,9 @@ class ServersClient(base_compute_client.BaseComputeClient):
def show_server(self, server_id):
"""Get server details.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#showServer
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#showServer
"""
resp, body = self.get("servers/%s" % server_id)
body = json.loads(body)
@ -124,8 +126,9 @@ class ServersClient(base_compute_client.BaseComputeClient):
def delete_server(self, server_id):
"""Delete server.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#deleteServer
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#deleteServer
"""
resp, body = self.delete("servers/%s" % server_id)
self.validate_response(schema.delete_server, resp, body)
@ -134,10 +137,10 @@ class ServersClient(base_compute_client.BaseComputeClient):
def list_servers(self, detail=False, **params):
"""List servers.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#listServers
and http://developer.openstack.org/
api-ref-compute-v2.1.html#listDetailServers
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#listServers
http://developer.openstack.org/api-ref-compute-v2.1.html#listDetailServers
"""
url = 'servers'
@ -158,8 +161,9 @@ class ServersClient(base_compute_client.BaseComputeClient):
def list_addresses(self, server_id):
"""Lists all addresses for a server.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#list-ips
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#list-ips
"""
resp, body = self.get("servers/%s/ips" % server_id)
body = json.loads(body)
@ -188,16 +192,18 @@ class ServersClient(base_compute_client.BaseComputeClient):
def create_backup(self, server_id, **kwargs):
"""Backup a server instance.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#createBackup
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#createBackup
"""
return self.action(server_id, "createBackup", **kwargs)
def change_password(self, server_id, **kwargs):
"""Change the root password for the server.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#changePassword
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#changePassword
"""
return self.action(server_id, 'changePassword', **kwargs)
@ -223,16 +229,18 @@ class ServersClient(base_compute_client.BaseComputeClient):
def reboot_server(self, server_id, **kwargs):
"""Reboot a server.
Available params: http://developer.openstack.org/
api-ref-compute-v2.1.html#reboot
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#reboot
"""
return self.action(server_id, 'reboot', **kwargs)
def rebuild_server(self, server_id, image_ref, **kwargs):
"""Rebuild a server with a new image.
Available params: http://developer.openstack.org/
api-ref-compute-v2.1.html#rebuild
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#rebuild
Most parameters except the following are passed to the API without
any changes.
@ -252,8 +260,9 @@ class ServersClient(base_compute_client.BaseComputeClient):
def resize_server(self, server_id, flavor_ref, **kwargs):
"""Change the flavor of a server.
Available params: http://developer.openstack.org/
api-ref-compute-v2.1.html#resize
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#resize
Most parameters except the following are passed to the API without
any changes.
@ -267,8 +276,9 @@ class ServersClient(base_compute_client.BaseComputeClient):
def confirm_resize_server(self, server_id, **kwargs):
"""Confirm the flavor change for a server.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#confirmResize
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#confirmResize
"""
return self.action(server_id, 'confirmResize',
schema.server_actions_confirm_resize,
@ -277,16 +287,18 @@ class ServersClient(base_compute_client.BaseComputeClient):
def revert_resize_server(self, server_id, **kwargs):
"""Revert a server back to its original flavor.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#revertResize
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#revertResize
"""
return self.action(server_id, 'revertResize', **kwargs)
def list_server_metadata(self, server_id):
"""Lists all metadata for a server.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#listServerMetadata
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#listServerMetadata
"""
resp, body = self.get("servers/%s/metadata" % server_id)
body = json.loads(body)
@ -296,8 +308,9 @@ class ServersClient(base_compute_client.BaseComputeClient):
def set_server_metadata(self, server_id, meta, no_metadata_field=False):
"""Sets one or more metadata items for a server.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#createServerMetadata
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#createServerMetadata
"""
if no_metadata_field:
post_body = ""
@ -312,8 +325,9 @@ class ServersClient(base_compute_client.BaseComputeClient):
def update_server_metadata(self, server_id, meta):
"""Updates one or more metadata items for a server.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#updateServerMetadata
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#updateServerMetadata
"""
post_body = json.dumps({'metadata': meta})
resp, body = self.post('servers/%s/metadata' % server_id,
@ -326,8 +340,9 @@ class ServersClient(base_compute_client.BaseComputeClient):
def show_server_metadata_item(self, server_id, key):
"""Shows details for a metadata item, by key, for a server.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#showServerMetadataItem
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#showServerMetadataItem
"""
resp, body = self.get("servers/%s/metadata/%s" % (server_id, key))
body = json.loads(body)
@ -338,8 +353,9 @@ class ServersClient(base_compute_client.BaseComputeClient):
def set_server_metadata_item(self, server_id, key, meta):
"""Sets a metadata item, by key, for a server.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#setServerMetadataItem
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#setServerMetadataItem
"""
post_body = json.dumps({'meta': meta})
resp, body = self.put('servers/%s/metadata/%s' % (server_id, key),
@ -352,8 +368,9 @@ class ServersClient(base_compute_client.BaseComputeClient):
def delete_server_metadata_item(self, server_id, key):
"""Deletes a metadata item, by key, from a server.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#deleteServerMetadataItem
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#deleteServerMetadataItem
"""
resp, body = self.delete("servers/%s/metadata/%s" %
(server_id, key))
@ -364,24 +381,27 @@ class ServersClient(base_compute_client.BaseComputeClient):
def stop_server(self, server_id, **kwargs):
"""Stops a running server and changes its status to SHUTOFF.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#stop
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#stop
"""
return self.action(server_id, 'os-stop', **kwargs)
def start_server(self, server_id, **kwargs):
"""Starts a stopped server and changes its status to ACTIVE.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#start
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#start
"""
return self.action(server_id, 'os-start', **kwargs)
def attach_volume(self, server_id, **kwargs):
"""Attaches a volume to a server instance.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#attachVolume
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#attachVolume
"""
post_body = json.dumps({'volumeAttachment': kwargs})
resp, body = self.post('servers/%s/os-volume_attachments' % server_id,
@ -402,8 +422,9 @@ class ServersClient(base_compute_client.BaseComputeClient):
def detach_volume(self, server_id, volume_id): # noqa
"""Detaches a volume from a server instance.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#deleteVolumeAttachment
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#deleteVolumeAttachment
"""
resp, body = self.delete('servers/%s/os-volume_attachments/%s' %
(server_id, volume_id))
@ -413,9 +434,9 @@ class ServersClient(base_compute_client.BaseComputeClient):
def show_volume_attachment(self, server_id, volume_id):
"""Return details about the given volume attachment.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#
getVolumeAttachmentDetails
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#getVolumeAttachmentDetails
"""
resp, body = self.get('servers/%s/os-volume_attachments/%s' % (
server_id, volume_id))
@ -426,8 +447,9 @@ class ServersClient(base_compute_client.BaseComputeClient):
def list_volume_attachments(self, server_id):
"""Returns the list of volume attachments for a given instance.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#listVolumeAttachments
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#listVolumeAttachments
"""
resp, body = self.get('servers/%s/os-volume_attachments' % (
server_id))
@ -438,8 +460,9 @@ class ServersClient(base_compute_client.BaseComputeClient):
def add_security_group(self, server_id, **kwargs):
"""Add a security group to the server.
Available params: http://developer.openstack.org/
api-ref-compute-v2.1.html#addSecurityGroup
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#addSecurityGroup
"""
# TODO(oomichi): The api-site doesn't contain this API description.
# So the above should be changed to the api-site link after
@ -450,8 +473,9 @@ class ServersClient(base_compute_client.BaseComputeClient):
def remove_security_group(self, server_id, **kwargs):
"""Remove a security group from the server.
Available params: http://developer.openstack.org/
api-ref-compute-v2.1.html#removeSecurityGroup
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#removeSecurityGroup
"""
# TODO(oomichi): The api-site doesn't contain this API description.
# So the above should be changed to the api-site link after
@ -462,104 +486,117 @@ class ServersClient(base_compute_client.BaseComputeClient):
def live_migrate_server(self, server_id, **kwargs):
"""This should be called with administrator privileges.
Available params: http://developer.openstack.org/
api-ref-compute-v2.1.html#migrateLive
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#migrateLive
"""
return self.action(server_id, 'os-migrateLive', **kwargs)
def migrate_server(self, server_id, **kwargs):
"""Migrate a server to a new host.
Available params: http://developer.openstack.org/
api-ref-compute-v2.1.html#migrate
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#migrate
"""
return self.action(server_id, 'migrate', **kwargs)
def lock_server(self, server_id, **kwargs):
"""Lock the given server.
Available params: http://developer.openstack.org/
api-ref-compute-v2.1.html#lock
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#lock
"""
return self.action(server_id, 'lock', **kwargs)
def unlock_server(self, server_id, **kwargs):
"""UNlock the given server.
Available params: http://developer.openstack.org/
api-ref-compute-v2.1.html#unlock
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#unlock
"""
return self.action(server_id, 'unlock', **kwargs)
def suspend_server(self, server_id, **kwargs):
"""Suspend the provided server.
Available params: http://developer.openstack.org/
api-ref-compute-v2.1.html#suspend
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#suspend
"""
return self.action(server_id, 'suspend', **kwargs)
def resume_server(self, server_id, **kwargs):
"""Un-suspend the provided server.
Available params: http://developer.openstack.org/
api-ref-compute-v2.1.html#resume
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#resume
"""
return self.action(server_id, 'resume', **kwargs)
def pause_server(self, server_id, **kwargs):
"""Pause the provided server.
Available params: http://developer.openstack.org/
api-ref-compute-v2.1.html#pause
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#pause
"""
return self.action(server_id, 'pause', **kwargs)
def unpause_server(self, server_id, **kwargs):
"""Un-pause the provided server.
Available params: http://developer.openstack.org/
api-ref-compute-v2.1.html#unpause
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#unpause
"""
return self.action(server_id, 'unpause', **kwargs)
def reset_state(self, server_id, **kwargs):
"""Reset the state of a server to active/error.
Available params: http://developer.openstack.org/
api-ref-compute-v2.1.html#resetState
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#resetState
"""
return self.action(server_id, 'os-resetState', **kwargs)
def shelve_server(self, server_id, **kwargs):
"""Shelve the provided server.
Available params: http://developer.openstack.org/
api-ref-compute-v2.1.html#shelve
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#shelve
"""
return self.action(server_id, 'shelve', **kwargs)
def unshelve_server(self, server_id, **kwargs):
"""Un-shelve the provided server.
Available params: http://developer.openstack.org/
api-ref-compute-v2.1.html#unshelve
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#unshelve
"""
return self.action(server_id, 'unshelve', **kwargs)
def shelve_offload_server(self, server_id, **kwargs):
"""Shelve-offload the provided server.
Available params: http://developer.openstack.org/
api-ref-compute-v2.1.html#shelveOffload
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#shelveOffload
"""
return self.action(server_id, 'shelveOffload', **kwargs)
def get_console_output(self, server_id, **kwargs):
"""Get console output.
Available params: http://developer.openstack.org/
api-ref-compute-v2.1.html#getConsoleOutput
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#getConsoleOutput
"""
return self.action(server_id, 'os-getConsoleOutput',
schema.get_console_output, **kwargs)
@ -575,16 +612,18 @@ class ServersClient(base_compute_client.BaseComputeClient):
def rescue_server(self, server_id, **kwargs):
"""Rescue the provided server.
Available params: http://developer.openstack.org/
api-ref-compute-v2.1.html#rescue
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#rescue
"""
return self.action(server_id, 'rescue', schema.rescue_server, **kwargs)
def unrescue_server(self, server_id):
"""Unrescue the provided server.
Available params: http://developer.openstack.org/
api-ref-compute-v2.1.html#unrescue
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#unrescue
"""
return self.action(server_id, 'unrescue')
@ -612,40 +651,45 @@ class ServersClient(base_compute_client.BaseComputeClient):
def force_delete_server(self, server_id, **kwargs):
"""Force delete a server.
Available params: http://developer.openstack.org/
api-ref-compute-v2.1.html#forceDelete
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#forceDelete
"""
return self.action(server_id, 'forceDelete', **kwargs)
def restore_soft_deleted_server(self, server_id, **kwargs):
"""Restore a soft-deleted server.
Available params: http://developer.openstack.org/
api-ref-compute-v2.1.html#restore
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#restore
"""
return self.action(server_id, 'restore', **kwargs)
def reset_network(self, server_id, **kwargs):
"""Reset the Network of a server.
Available params: http://developer.openstack.org/
api-ref-compute-v2.1.html#resetNetwork
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#resetNetwork
"""
return self.action(server_id, 'resetNetwork', **kwargs)
def inject_network_info(self, server_id, **kwargs):
"""Inject the Network Info into server.
Available params: http://developer.openstack.org/
api-ref-compute-v2.1.html#injectNetworkInfo
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#injectNetworkInfo
"""
return self.action(server_id, 'injectNetworkInfo', **kwargs)
def get_vnc_console(self, server_id, **kwargs):
"""Get URL of VNC console.
Available params: http://developer.openstack.org/
api-ref-compute-v2.1.html#getVNCConsole
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#getVNCConsole
"""
return self.action(server_id, "os-getVNCConsole",
schema.get_vnc_console, **kwargs)
@ -653,15 +697,17 @@ class ServersClient(base_compute_client.BaseComputeClient):
def add_fixed_ip(self, server_id, **kwargs):
"""Add a fixed IP to server instance.
Available params: http://developer.openstack.org/
api-ref-compute-v2.1.html#addFixedIp
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#addFixedIp
"""
return self.action(server_id, 'addFixedIp', **kwargs)
def remove_fixed_ip(self, server_id, **kwargs):
"""Remove input fixed IP from input server instance.
Available params: http://developer.openstack.org/
api-ref-compute-v2.1.html#removeFixedIp
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#removeFixedIp
"""
return self.action(server_id, 'removeFixedIp', **kwargs)

View File

@ -27,8 +27,9 @@ class ServicesClient(base_compute_client.BaseComputeClient):
def list_services(self, **params):
"""Lists all running Compute services for a tenant.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#listServices
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#listServices
"""
url = 'os-services'
if params:
@ -42,8 +43,9 @@ class ServicesClient(base_compute_client.BaseComputeClient):
def enable_service(self, **kwargs):
"""Enable service on a host.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#enableScheduling
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#enableScheduling
"""
post_body = json.dumps(kwargs)
resp, body = self.put('os-services/enable', post_body)
@ -54,8 +56,9 @@ class ServicesClient(base_compute_client.BaseComputeClient):
def disable_service(self, **kwargs):
"""Disable service on a host.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#disableScheduling
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#disableScheduling
"""
post_body = json.dumps(kwargs)
resp, body = self.put('os-services/disable', post_body)

View File

@ -27,8 +27,9 @@ class SnapshotsClient(base_compute_client.BaseComputeClient):
def create_snapshot(self, volume_id, **kwargs):
"""Create a snapshot.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#createSnapshot
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#createSnapshot
"""
post_body = {
'volume_id': volume_id

View File

@ -27,8 +27,9 @@ class VolumesClient(base_compute_client.BaseComputeClient):
def list_volumes(self, detail=False, **params):
"""List all the volumes created.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#listVolumes
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#listVolumes
"""
url = 'os-volumes'
@ -45,8 +46,9 @@ class VolumesClient(base_compute_client.BaseComputeClient):
def show_volume(self, volume_id):
"""Return the details of a single volume.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#showVolume
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#showVolume
"""
url = "os-volumes/%s" % volume_id
resp, body = self.get(url)
@ -57,8 +59,9 @@ class VolumesClient(base_compute_client.BaseComputeClient):
def create_volume(self, **kwargs):
"""Create a new Volume.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#createVolume
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#createVolume
"""
post_body = json.dumps({'volume': kwargs})
resp, body = self.post('os-volumes', post_body)
@ -69,8 +72,9 @@ class VolumesClient(base_compute_client.BaseComputeClient):
def delete_volume(self, volume_id):
"""Delete the Specified Volume.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#deleteVolume
For a full list of available parameters, please refer to the official
API reference:
http://developer.openstack.org/api-ref-compute-v2.1.html#deleteVolume
"""
resp, body = self.delete("os-volumes/%s" % volume_id)
self.validate_response(schema.delete_volume, resp, body)