Add docstring for create/update methods([s-v]*)

As we discussed on
http://lists.openstack.org/pipermail/openstack-dev/2015-July/068864.html
we need to write docstring for http POST/PUT methods.
This patch adds docstring for create/update methods of compute client
[s-v]*. In addition, this patch fixes some inconsistencies like "Creates"
is changed to "Create".

Change-Id: I48917b6ddd40f1b959f2a1e1f2c6306524aeec99
This commit is contained in:
Ken'ichi Ohmichi
2015-12-02 02:11:48 +00:00
parent ca166499b5
commit 66a44f95c4
7 changed files with 40 additions and 43 deletions

View File

@@ -23,13 +23,16 @@ from tempest_lib.common import rest_client
class SecurityGroupDefaultRulesClient(rest_client.RestClient): class SecurityGroupDefaultRulesClient(rest_client.RestClient):
def create_security_default_group_rule(self, **kwargs): def create_security_default_group_rule(self, **kwargs):
"""Creating security group default rules. """Create security group default rule.
ip_protocol : ip_protocol (icmp, tcp, udp). Available params: see http://developer.openstack.org/
from_port: Port at start of range. api-ref-compute-v2.1.html#createSecGroupRule
to_port : Port at end of range.
cidr : CIDR for address range.
""" """
# TODO(oomichi): We can see the API doc of the above method with
# the above link, but the link is wrong because the link doesn't
# contain "Default" and the link is duplicated to non default sg.
# After fixing api-site, we will fix the above link also.
# LP: https://bugs.launchpad.net/openstack-api-site/+bug/1521826
post_body = json.dumps({'security_group_default_rule': kwargs}) post_body = json.dumps({'security_group_default_rule': kwargs})
url = 'os-security-group-default-rules' url = 'os-security-group-default-rules'
resp, body = self.post(url, post_body) resp, body = self.post(url, post_body)
@@ -40,7 +43,7 @@ class SecurityGroupDefaultRulesClient(rest_client.RestClient):
def delete_security_group_default_rule(self, def delete_security_group_default_rule(self,
security_group_default_rule_id): security_group_default_rule_id):
"""Deletes the provided Security Group default rule.""" """Delete the provided Security Group default rule."""
resp, body = self.delete('os-security-group-default-rules/%s' % ( resp, body = self.delete('os-security-group-default-rules/%s' % (
security_group_default_rule_id)) security_group_default_rule_id))
self.validate_response(schema.delete_security_group_default_rule, self.validate_response(schema.delete_security_group_default_rule,

View File

@@ -23,15 +23,10 @@ from tempest_lib.common import rest_client
class SecurityGroupRulesClient(rest_client.RestClient): class SecurityGroupRulesClient(rest_client.RestClient):
def create_security_group_rule(self, **kwargs): def create_security_group_rule(self, **kwargs):
"""Creating a new security group rules. """Create a new security group rule.
parent_group_id :ID of Security group. Available params: see http://developer.openstack.org/
ip_protocol : ip_proto (icmp, tcp, udp). api-ref-compute-v2.1.html#createSecGroupRule
from_port: Port at start of range.
to_port : Port at end of range.
Following optional keyword arguments are accepted:
cidr : CIDR for address range.
group_id : ID of the Source group.
""" """
post_body = json.dumps({'security_group_rule': kwargs}) post_body = json.dumps({'security_group_rule': kwargs})
url = 'os-security-group-rules' url = 'os-security-group-rules'

View File

@@ -45,11 +45,10 @@ class SecurityGroupsClient(rest_client.RestClient):
return rest_client.ResponseBody(resp, body) return rest_client.ResponseBody(resp, body)
def create_security_group(self, **kwargs): def create_security_group(self, **kwargs):
"""Creates a new security group. """Create a new security group.
name (Required): Name of security group.
description (Required): Description of security group.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#createSecGroup
""" """
post_body = json.dumps({'security_group': kwargs}) post_body = json.dumps({'security_group': kwargs})
resp, body = self.post('os-security-groups', post_body) resp, body = self.post('os-security-groups', post_body)
@@ -60,10 +59,8 @@ class SecurityGroupsClient(rest_client.RestClient):
def update_security_group(self, security_group_id, **kwargs): def update_security_group(self, security_group_id, **kwargs):
"""Update a security group. """Update a security group.
security_group_id: a security_group to update Available params: see http://developer.openstack.org/
name: new name of security group api-ref-compute-v2.1.html#updateSecGroup
description: new description of security group
""" """
post_body = json.dumps({'security_group': kwargs}) post_body = json.dumps({'security_group': kwargs})
resp, body = self.put('os-security-groups/%s' % security_group_id, resp, body = self.put('os-security-groups/%s' % security_group_id,
@@ -73,7 +70,7 @@ class SecurityGroupsClient(rest_client.RestClient):
return rest_client.ResponseBody(resp, body) return rest_client.ResponseBody(resp, body)
def delete_security_group(self, security_group_id): def delete_security_group(self, security_group_id):
"""Deletes the provided Security Group.""" """Delete the provided Security Group."""
resp, body = self.delete( resp, body = self.delete(
'os-security-groups/%s' % security_group_id) 'os-security-groups/%s' % security_group_id)
self.validate_response(schema.delete_security_group, resp, body) self.validate_response(schema.delete_security_group, resp, body)
@@ -88,5 +85,5 @@ class SecurityGroupsClient(rest_client.RestClient):
@property @property
def resource_type(self): def resource_type(self):
"""Returns the primary type of resource this client works with.""" """Return the primary type of resource this client works with."""
return 'security_group' return 'security_group'

View File

@@ -25,11 +25,10 @@ class ServerGroupsClient(rest_client.RestClient):
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
def create_server_group(self, **kwargs): def create_server_group(self, **kwargs):
"""Create the server group """Create the server group.
name : Name of the server-group
policies : List of the policies - affinity/anti-affinity)
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#createServerGroup
""" """
post_body = json.dumps({'server_group': kwargs}) post_body = json.dumps({'server_group': kwargs})
resp, body = self.post('os-server-groups', post_body) resp, body = self.post('os-server-groups', post_body)

View File

@@ -34,10 +34,10 @@ class ServicesClient(rest_client.RestClient):
return rest_client.ResponseBody(resp, body) return rest_client.ResponseBody(resp, body)
def enable_service(self, **kwargs): def enable_service(self, **kwargs):
"""Enable service on a host """Enable service on a host.
host_name: Name of host Available params: see http://developer.openstack.org/
binary: Service binary api-ref-compute-v2.1.html#enableScheduling
""" """
post_body = json.dumps(kwargs) post_body = json.dumps(kwargs)
resp, body = self.put('os-services/enable', post_body) resp, body = self.put('os-services/enable', post_body)
@@ -46,10 +46,10 @@ class ServicesClient(rest_client.RestClient):
return rest_client.ResponseBody(resp, body) return rest_client.ResponseBody(resp, body)
def disable_service(self, **kwargs): def disable_service(self, **kwargs):
"""Disable service on a host """Disable service on a host.
host_name: Name of host Available params: see http://developer.openstack.org/
binary: Service binary api-ref-compute-v2.1.html#disableScheduling
""" """
post_body = json.dumps(kwargs) post_body = json.dumps(kwargs)
resp, body = self.put('os-services/disable', post_body) resp, body = self.put('os-services/disable', post_body)

View File

@@ -24,6 +24,11 @@ from tempest_lib import exceptions as lib_exc
class SnapshotsClient(rest_client.RestClient): class SnapshotsClient(rest_client.RestClient):
def create_snapshot(self, volume_id, **kwargs): def create_snapshot(self, volume_id, **kwargs):
"""Create a snapshot.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#createSnapshot
"""
post_body = { post_body = {
'volume_id': volume_id 'volume_id': volume_id
} }
@@ -67,5 +72,5 @@ class SnapshotsClient(rest_client.RestClient):
@property @property
def resource_type(self): def resource_type(self):
"""Returns the primary type of resource this client works with.""" """Return the primary type of resource this client works with."""
return 'snapshot' return 'snapshot'

View File

@@ -38,7 +38,7 @@ class VolumesClient(rest_client.RestClient):
return rest_client.ResponseBody(resp, body) return rest_client.ResponseBody(resp, body)
def show_volume(self, volume_id): def show_volume(self, volume_id):
"""Returns the details of a single volume.""" """Return the details of a single volume."""
url = "os-volumes/%s" % volume_id url = "os-volumes/%s" % volume_id
resp, body = self.get(url) resp, body = self.get(url)
body = json.loads(body) body = json.loads(body)
@@ -46,12 +46,10 @@ class VolumesClient(rest_client.RestClient):
return rest_client.ResponseBody(resp, body) return rest_client.ResponseBody(resp, body)
def create_volume(self, **kwargs): def create_volume(self, **kwargs):
"""Creates a new Volume. """Create a new Volume.
size(Required): Size of volume in GB. Available params: see http://developer.openstack.org/
Following optional keyword arguments are accepted: api-ref-compute-v2.1.html#createVolume
display_name: Optional Volume Name.
metadata: A dictionary of values to be used as metadata.
""" """
post_body = json.dumps({'volume': kwargs}) post_body = json.dumps({'volume': kwargs})
resp, body = self.post('os-volumes', post_body) resp, body = self.post('os-volumes', post_body)
@@ -60,7 +58,7 @@ class VolumesClient(rest_client.RestClient):
return rest_client.ResponseBody(resp, body) return rest_client.ResponseBody(resp, body)
def delete_volume(self, volume_id): def delete_volume(self, volume_id):
"""Deletes the Specified Volume.""" """Delete the Specified Volume."""
resp, body = self.delete("os-volumes/%s" % volume_id) resp, body = self.delete("os-volumes/%s" % volume_id)
self.validate_response(schema.delete_volume, resp, body) self.validate_response(schema.delete_volume, resp, body)
return rest_client.ResponseBody(resp, body) return rest_client.ResponseBody(resp, body)
@@ -74,5 +72,5 @@ class VolumesClient(rest_client.RestClient):
@property @property
def resource_type(self): def resource_type(self):
"""Returns the primary type of resource this client works with.""" """Return the primary type of resource this client works with."""
return 'volume' return 'volume'