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):
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).
from_port: Port at start of range.
to_port : Port at end of range.
cidr : CIDR for address range.
Available params: see http://developer.openstack.org/
api-ref-compute-v2.1.html#createSecGroupRule
"""
# 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})
url = 'os-security-group-default-rules'
resp, body = self.post(url, post_body)
@@ -40,7 +43,7 @@ class SecurityGroupDefaultRulesClient(rest_client.RestClient):
def delete_security_group_default_rule(self,
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' % (
security_group_default_rule_id))
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):
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.
ip_protocol : ip_proto (icmp, tcp, udp).
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.
Available params: see 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

@@ -45,11 +45,10 @@ class SecurityGroupsClient(rest_client.RestClient):
return rest_client.ResponseBody(resp, body)
def create_security_group(self, **kwargs):
"""Creates a new security group.
name (Required): Name of security group.
description (Required): Description of security group.
"""Create a new security group.
Available params: see 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)
@@ -60,10 +59,8 @@ class SecurityGroupsClient(rest_client.RestClient):
def update_security_group(self, security_group_id, **kwargs):
"""Update a security group.
security_group_id: a security_group to update
name: new name of security group
description: new description of security group
Available params: see 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,
@@ -73,7 +70,7 @@ class SecurityGroupsClient(rest_client.RestClient):
return rest_client.ResponseBody(resp, body)
def delete_security_group(self, security_group_id):
"""Deletes the provided Security Group."""
"""Delete the provided Security Group."""
resp, body = self.delete(
'os-security-groups/%s' % security_group_id)
self.validate_response(schema.delete_security_group, resp, body)
@@ -88,5 +85,5 @@ class SecurityGroupsClient(rest_client.RestClient):
@property
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'

View File

@@ -25,11 +25,10 @@ class ServerGroupsClient(rest_client.RestClient):
LOG = logging.getLogger(__name__)
def create_server_group(self, **kwargs):
"""Create the server group
name : Name of the server-group
policies : List of the policies - affinity/anti-affinity)
"""Create the server group.
Available params: see 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

@@ -34,10 +34,10 @@ class ServicesClient(rest_client.RestClient):
return rest_client.ResponseBody(resp, body)
def enable_service(self, **kwargs):
"""Enable service on a host
"""Enable service on a host.
host_name: Name of host
binary: Service binary
Available params: see 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)
@@ -46,10 +46,10 @@ class ServicesClient(rest_client.RestClient):
return rest_client.ResponseBody(resp, body)
def disable_service(self, **kwargs):
"""Disable service on a host
"""Disable service on a host.
host_name: Name of host
binary: Service binary
Available params: see 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

@@ -24,6 +24,11 @@ from tempest_lib import exceptions as lib_exc
class SnapshotsClient(rest_client.RestClient):
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 = {
'volume_id': volume_id
}
@@ -67,5 +72,5 @@ class SnapshotsClient(rest_client.RestClient):
@property
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'

View File

@@ -38,7 +38,7 @@ class VolumesClient(rest_client.RestClient):
return rest_client.ResponseBody(resp, body)
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
resp, body = self.get(url)
body = json.loads(body)
@@ -46,12 +46,10 @@ class VolumesClient(rest_client.RestClient):
return rest_client.ResponseBody(resp, body)
def create_volume(self, **kwargs):
"""Creates a new Volume.
"""Create a new Volume.
size(Required): Size of volume in GB.
Following optional keyword arguments are accepted:
display_name: Optional Volume Name.
metadata: A dictionary of values to be used as metadata.
Available params: see 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)
@@ -60,7 +58,7 @@ class VolumesClient(rest_client.RestClient):
return rest_client.ResponseBody(resp, body)
def delete_volume(self, volume_id):
"""Deletes the Specified Volume."""
"""Delete the Specified Volume."""
resp, body = self.delete("os-volumes/%s" % volume_id)
self.validate_response(schema.delete_volume, resp, body)
return rest_client.ResponseBody(resp, body)
@@ -74,5 +72,5 @@ class VolumesClient(rest_client.RestClient):
@property
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'