Fix T401 and T402 errors
Fix all the one line docstring errors in T401 and T402, now we no longer ignore any of our own rules in hacking.py Fix run_tests.sh to pick up the 'stress' directory, which tox does for pep8. Additional fixes to the stress tests for T4* tests Change-Id: Ie569a924e8eb355afbbd9b244f77dec34061b5cb
This commit is contained in:
+2
-1
@@ -75,9 +75,10 @@ function run_pep8 {
|
||||
echo "Running pep8 ..."
|
||||
srcfiles="`find tempest -type f -name "*.py"`"
|
||||
srcfiles+=" `find tools -type f -name "*.py"`"
|
||||
srcfiles+=" `find stress -type f -name "*.py"`"
|
||||
srcfiles+=" setup.py"
|
||||
|
||||
ignore='--ignore=T401,T402,E121,E122,E125,E126'
|
||||
ignore='--ignore=E121,E122,E125,E126'
|
||||
|
||||
${wrapper} python tools/hacking.py ${ignore} ${srcfiles}
|
||||
}
|
||||
|
||||
+3
-3
@@ -39,15 +39,15 @@ class StressConfig(object):
|
||||
|
||||
@property
|
||||
def nova_logdir(self):
|
||||
"""Directory containing log files on the compute nodes"""
|
||||
"""Directory containing log files on the compute nodes."""
|
||||
return self.get("nova_logdir", None)
|
||||
|
||||
@property
|
||||
def controller(self):
|
||||
"""Controller host"""
|
||||
"""Controller host."""
|
||||
return self.get("controller", None)
|
||||
|
||||
@property
|
||||
def max_instances(self):
|
||||
"""Maximum number of instances to create during test"""
|
||||
"""Maximum number of instances to create during test."""
|
||||
return self.get("max_instances", 16)
|
||||
|
||||
@@ -46,7 +46,7 @@ class PendingAction(object):
|
||||
return False
|
||||
|
||||
def check_timeout(self):
|
||||
"""Check for timeouts of TestCase actions"""
|
||||
"""Check for timeouts of TestCase actions."""
|
||||
time_diff = time.time() - self._start_time
|
||||
if time_diff > self._timeout:
|
||||
self._logger.error('%s exceeded timeout of %d' %
|
||||
@@ -76,7 +76,7 @@ class PendingServerAction(PendingAction):
|
||||
self._target = target_server
|
||||
|
||||
def _check_for_status(self, state_string):
|
||||
"""Check to see if the machine has transitioned states"""
|
||||
"""Check to see if the machine has transitioned states."""
|
||||
t = time.time() # for debugging
|
||||
target = self._target
|
||||
_resp, body = self._manager.servers_client.get_server(target['id'])
|
||||
|
||||
+1
-1
@@ -25,5 +25,5 @@ class StressTestCase(object):
|
||||
self._logger = logging.getLogger(self.__class__.__name__)
|
||||
|
||||
def run(self, nova_manager, state_obj, *pargs, **kargs):
|
||||
"""Nova API methods to call that would modify state of the cluster"""
|
||||
"""Nova API methods to call that would modify state of the cluster."""
|
||||
return
|
||||
|
||||
@@ -61,7 +61,7 @@ class TestChangeFloatingIp(test_case.StressTestCase):
|
||||
|
||||
|
||||
class VerifyChangeFloatingIp(pending_action.PendingAction):
|
||||
"""Verify that floating ip was changed"""
|
||||
"""Verify that floating ip was changed."""
|
||||
def __init__(self, manager, floating_ip, timeout, add=None):
|
||||
super(VerifyChangeFloatingIp, self).__init__(manager, timeout=timeout)
|
||||
self.floating_ip = floating_ip
|
||||
|
||||
@@ -27,7 +27,7 @@ from utils.util import *
|
||||
|
||||
|
||||
class TestRebootVM(test_case.StressTestCase):
|
||||
"""Reboot a server"""
|
||||
"""Reboot a server."""
|
||||
|
||||
def run(self, manager, state, *pargs, **kwargs):
|
||||
"""
|
||||
@@ -132,7 +132,7 @@ class VerifyRebootVM(pending_action.PendingServerAction):
|
||||
|
||||
# This code needs to be tested against a cluster that supports resize.
|
||||
#class TestResizeVM(test_case.StressTestCase):
|
||||
# """Resize a server (change flavors)"""
|
||||
# """Resize a server (change flavors)."""
|
||||
#
|
||||
# def run(self, manager, state, *pargs, **kwargs):
|
||||
# """
|
||||
@@ -193,7 +193,7 @@ class VerifyRebootVM(pending_action.PendingServerAction):
|
||||
# timeout=_timeout)
|
||||
#
|
||||
#class VerifyResizeVM(pending_action.PendingServerAction):
|
||||
# """Verify that resizing of a VM was successful"""
|
||||
# """Verify that resizing of a VM was successful."""
|
||||
# States = enum('VERIFY_RESIZE_CHECK', 'ACTIVE_CHECK')
|
||||
#
|
||||
# def __init__(self, manager, state, created_server,
|
||||
|
||||
@@ -96,7 +96,7 @@ class TestCreateVM(test_case.StressTestCase):
|
||||
|
||||
|
||||
class VerifyCreateVM(pending_action.PendingServerAction):
|
||||
"""Verify that VM was built and is running"""
|
||||
"""Verify that VM was built and is running."""
|
||||
def __init__(self, manager,
|
||||
state,
|
||||
created_server,
|
||||
@@ -175,7 +175,7 @@ class TestKillActiveVM(test_case.StressTestCase):
|
||||
|
||||
|
||||
class VerifyKillActiveVM(pending_action.PendingServerAction):
|
||||
"""Verify that server was destroyed"""
|
||||
"""Verify that server was destroyed."""
|
||||
|
||||
def retry(self):
|
||||
"""
|
||||
@@ -238,7 +238,7 @@ VerifyKillAnyVM = VerifyKillActiveVM
|
||||
|
||||
|
||||
class TestUpdateVMName(test_case.StressTestCase):
|
||||
"""Class to change the name of the active server"""
|
||||
"""Class to change the name of the active server."""
|
||||
def run(self, manager, state, *pargs, **kwargs):
|
||||
"""
|
||||
Issue HTTP POST request to change the name of active server.
|
||||
@@ -288,7 +288,7 @@ class TestUpdateVMName(test_case.StressTestCase):
|
||||
|
||||
|
||||
class VerifyUpdateVMName(pending_action.PendingServerAction):
|
||||
"""Check that VM has new name"""
|
||||
"""Check that VM has new name."""
|
||||
def retry(self):
|
||||
"""
|
||||
Check that VM has new name. Update local view of `state` to RUNNING.
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""Stress test that associates/disasssociates floating ips"""
|
||||
"""Stress test that associates/disasssociates floating ips."""
|
||||
|
||||
from stress.basher import BasherAction
|
||||
from stress.driver import *
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""Test that reboots random instances in a Nova cluster"""
|
||||
"""Test that reboots random instances in a Nova cluster."""
|
||||
|
||||
|
||||
from stress.test_servers import *
|
||||
|
||||
@@ -50,6 +50,6 @@ def execute_on_all(keypath, user, nodes, command):
|
||||
|
||||
|
||||
def enum(*sequential, **named):
|
||||
"""Create auto-incremented enumerated types"""
|
||||
"""Create auto-incremented enumerated types."""
|
||||
enums = dict(zip(sequential, range(len(sequential))), **named)
|
||||
return type('Enum', (), enums)
|
||||
|
||||
@@ -303,7 +303,7 @@ class RestClient(object):
|
||||
return resp, resp_body
|
||||
|
||||
def wait_for_resource_deletion(self, id):
|
||||
"""Waits for a resource to be deleted"""
|
||||
"""Waits for a resource to be deleted."""
|
||||
start_time = int(time.time())
|
||||
while True:
|
||||
if self.is_resource_deleted(id):
|
||||
|
||||
@@ -48,7 +48,7 @@ class Client(object):
|
||||
self.buf_size = 1024
|
||||
|
||||
def _get_ssh_connection(self):
|
||||
"""Returns an ssh connection to the specified host"""
|
||||
"""Returns an ssh connection to the specified host."""
|
||||
_timeout = True
|
||||
ssh = paramiko.SSHClient()
|
||||
ssh.set_missing_host_key_policy(
|
||||
@@ -79,7 +79,7 @@ class Client(object):
|
||||
return (time.time() - timeout) > start_time
|
||||
|
||||
def connect_until_closed(self):
|
||||
"""Connect to the server and wait until connection is lost"""
|
||||
"""Connect to the server and wait until connection is lost."""
|
||||
try:
|
||||
ssh = self._get_ssh_connection()
|
||||
_transport = ssh.get_transport()
|
||||
@@ -137,7 +137,7 @@ class Client(object):
|
||||
return ''.join(out_data)
|
||||
|
||||
def test_connection_auth(self):
|
||||
""" Returns true if ssh can connect to server"""
|
||||
"""Returns true if ssh can connect to server."""
|
||||
try:
|
||||
connection = self._get_ssh_connection()
|
||||
connection.close()
|
||||
|
||||
@@ -29,7 +29,7 @@ def rand_name(name='test'):
|
||||
|
||||
def build_url(host, port, api_version=None, path=None,
|
||||
params=None, use_ssl=False):
|
||||
"""Build the request URL from given host, port, path and parameters"""
|
||||
"""Build the request URL from given host, port, path and parameters."""
|
||||
|
||||
pattern = 'v\d\.\d'
|
||||
if re.match(pattern, path):
|
||||
@@ -59,7 +59,7 @@ def build_url(host, port, api_version=None, path=None,
|
||||
|
||||
|
||||
def parse_image_id(image_ref):
|
||||
"""Return the image id from a given image ref"""
|
||||
"""Return the image id from a given image ref."""
|
||||
return image_ref.rsplit('/')[-1]
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -458,7 +458,7 @@ def register_boto_opts(conf):
|
||||
|
||||
# TODO(jaypipes): Move this to a common utils (not data_utils...)
|
||||
def singleton(cls):
|
||||
"""Simple wrapper for classes that should only have a single instance"""
|
||||
"""Simple wrapper for classes that should only have a single instance."""
|
||||
instances = {}
|
||||
|
||||
def getinstance():
|
||||
|
||||
@@ -118,7 +118,7 @@ class SSHTimeout(TempestException):
|
||||
|
||||
|
||||
class SSHExecCommandFailed(TempestException):
|
||||
''' Raised when remotely executed command returns nonzero status. '''
|
||||
"""Raised when remotely executed command returns nonzero status."""
|
||||
message = ("Command '%(command)s', exit status: %(exit_status)d, "
|
||||
"Error:\n%(strerror)s")
|
||||
|
||||
|
||||
@@ -1417,7 +1417,7 @@ class ConfigOpts(collections.Mapping):
|
||||
logger.log(lvl, "=" * 80)
|
||||
|
||||
def _sanitize(opt, value):
|
||||
"""Obfuscate values of options declared secret"""
|
||||
"""Obfuscate values of options declared secret."""
|
||||
return value if not opt.secret else '*' * len(str(value))
|
||||
|
||||
for opt_name in sorted(self._opts):
|
||||
|
||||
@@ -100,15 +100,15 @@ class BaseParser(object):
|
||||
self._assignment(key, value)
|
||||
|
||||
def assignment(self, key, value):
|
||||
"""Called when a full assignment is parsed"""
|
||||
"""Called when a full assignment is parsed."""
|
||||
raise NotImplementedError()
|
||||
|
||||
def new_section(self, section):
|
||||
"""Called when a new section is started"""
|
||||
"""Called when a new section is started."""
|
||||
raise NotImplementedError()
|
||||
|
||||
def comment(self, comment):
|
||||
"""Called when a comment is parsed"""
|
||||
"""Called when a comment is parsed."""
|
||||
pass
|
||||
|
||||
def error_invalid_assignment(self, line):
|
||||
|
||||
@@ -73,7 +73,7 @@ class BotoClientBase(object):
|
||||
boto.config.set("Boto", "num_retries", retries)
|
||||
|
||||
def __getattr__(self, name):
|
||||
"""Automatically creates methods for the allowed methods set"""
|
||||
"""Automatically creates methods for the allowed methods set."""
|
||||
if name in self.ALLOWED_METHODS:
|
||||
def func(self, *args, **kwargs):
|
||||
with closing(self.get_connection()) as conn:
|
||||
|
||||
@@ -53,7 +53,7 @@ class FlavorsClientJSON(RestClient):
|
||||
|
||||
def create_flavor(self, name, ram, vcpus, disk, ephemeral, flavor_id,
|
||||
swap, rxtx):
|
||||
"""Creates a new flavor or instance type"""
|
||||
"""Creates a new flavor or instance type."""
|
||||
post_body = {
|
||||
'name': name,
|
||||
'ram': ram,
|
||||
@@ -72,5 +72,5 @@ class FlavorsClientJSON(RestClient):
|
||||
return resp, body['flavor']
|
||||
|
||||
def delete_flavor(self, flavor_id):
|
||||
"""Deletes the given flavor"""
|
||||
"""Deletes the given flavor."""
|
||||
return self.delete("flavors/%s" % str(flavor_id))
|
||||
|
||||
@@ -29,7 +29,7 @@ class FloatingIPsClientJSON(RestClient):
|
||||
self.service = self.config.compute.catalog_type
|
||||
|
||||
def list_floating_ips(self, params=None):
|
||||
"""Returns a list of all floating IPs filtered by any parameters"""
|
||||
"""Returns a list of all floating IPs filtered by any parameters."""
|
||||
url = 'os-floating-ips'
|
||||
if params:
|
||||
url += '?%s' % urllib.urlencode(params)
|
||||
@@ -39,7 +39,7 @@ class FloatingIPsClientJSON(RestClient):
|
||||
return resp, body['floating_ips']
|
||||
|
||||
def get_floating_ip_details(self, floating_ip_id):
|
||||
"""Get the details of a floating IP"""
|
||||
"""Get the details of a floating IP."""
|
||||
url = "os-floating-ips/%s" % str(floating_ip_id)
|
||||
resp, body = self.get(url)
|
||||
body = json.loads(body)
|
||||
@@ -48,20 +48,20 @@ class FloatingIPsClientJSON(RestClient):
|
||||
return resp, body['floating_ip']
|
||||
|
||||
def create_floating_ip(self):
|
||||
"""Allocate a floating IP to the project"""
|
||||
"""Allocate a floating IP to the project."""
|
||||
url = 'os-floating-ips'
|
||||
resp, body = self.post(url, None, None)
|
||||
body = json.loads(body)
|
||||
return resp, body['floating_ip']
|
||||
|
||||
def delete_floating_ip(self, floating_ip_id):
|
||||
"""Deletes the provided floating IP from the project"""
|
||||
"""Deletes the provided floating IP from the project."""
|
||||
url = "os-floating-ips/%s" % str(floating_ip_id)
|
||||
resp, body = self.delete(url)
|
||||
return resp, body
|
||||
|
||||
def associate_floating_ip_to_server(self, floating_ip, server_id):
|
||||
"""Associate the provided floating IP to a specific server"""
|
||||
"""Associate the provided floating IP to a specific server."""
|
||||
url = "servers/%s/action" % str(server_id)
|
||||
post_body = {
|
||||
'addFloatingIp': {
|
||||
@@ -74,7 +74,7 @@ class FloatingIPsClientJSON(RestClient):
|
||||
return resp, body
|
||||
|
||||
def disassociate_floating_ip_from_server(self, floating_ip, server_id):
|
||||
"""Disassociate the provided floating IP from a specific server"""
|
||||
"""Disassociate the provided floating IP from a specific server."""
|
||||
url = "servers/%s/action" % str(server_id)
|
||||
post_body = {
|
||||
'removeFloatingIp': {
|
||||
|
||||
@@ -11,7 +11,7 @@ class HostsClientJSON(RestClient):
|
||||
self.service = self.config.compute.catalog_type
|
||||
|
||||
def list_hosts(self):
|
||||
"""Lists all hosts"""
|
||||
"""Lists all hosts."""
|
||||
|
||||
url = 'os-hosts'
|
||||
resp, body = self.get(url)
|
||||
|
||||
@@ -33,7 +33,7 @@ class ImagesClientJSON(RestClient):
|
||||
self.build_timeout = self.config.compute.build_timeout
|
||||
|
||||
def create_image(self, server_id, name, meta=None):
|
||||
"""Creates an image of the original server"""
|
||||
"""Creates an image of the original server."""
|
||||
|
||||
post_body = {
|
||||
'createImage': {
|
||||
@@ -50,7 +50,7 @@ class ImagesClientJSON(RestClient):
|
||||
return resp, body
|
||||
|
||||
def list_images(self, params=None):
|
||||
"""Returns a list of all images filtered by any parameters"""
|
||||
"""Returns a list of all images filtered by any parameters."""
|
||||
url = 'images'
|
||||
if params:
|
||||
url += '?%s' % urllib.urlencode(params)
|
||||
@@ -60,7 +60,7 @@ class ImagesClientJSON(RestClient):
|
||||
return resp, body['images']
|
||||
|
||||
def list_images_with_detail(self, params=None):
|
||||
"""Returns a detailed list of images filtered by any parameters"""
|
||||
"""Returns a detailed list of images filtered by any parameters."""
|
||||
url = 'images/detail'
|
||||
if params:
|
||||
url += '?%s' % urllib.urlencode(params)
|
||||
@@ -70,13 +70,13 @@ class ImagesClientJSON(RestClient):
|
||||
return resp, body['images']
|
||||
|
||||
def get_image(self, image_id):
|
||||
"""Returns the details of a single image"""
|
||||
"""Returns the details of a single image."""
|
||||
resp, body = self.get("images/%s" % str(image_id))
|
||||
body = json.loads(body)
|
||||
return resp, body['image']
|
||||
|
||||
def delete_image(self, image_id):
|
||||
"""Deletes the provided image"""
|
||||
"""Deletes the provided image."""
|
||||
return self.delete("images/%s" % str(image_id))
|
||||
|
||||
def wait_for_image_resp_code(self, image_id, code):
|
||||
@@ -110,13 +110,13 @@ class ImagesClientJSON(RestClient):
|
||||
raise exceptions.TimeoutException
|
||||
|
||||
def list_image_metadata(self, image_id):
|
||||
"""Lists all metadata items for an image"""
|
||||
"""Lists all metadata items for an image."""
|
||||
resp, body = self.get("images/%s/metadata" % str(image_id))
|
||||
body = json.loads(body)
|
||||
return resp, body['metadata']
|
||||
|
||||
def set_image_metadata(self, image_id, meta):
|
||||
"""Sets the metadata for an image"""
|
||||
"""Sets the metadata for an image."""
|
||||
post_body = json.dumps({'metadata': meta})
|
||||
resp, body = self.put('images/%s/metadata' % str(image_id),
|
||||
post_body, self.headers)
|
||||
@@ -124,7 +124,7 @@ class ImagesClientJSON(RestClient):
|
||||
return resp, body['metadata']
|
||||
|
||||
def update_image_metadata(self, image_id, meta):
|
||||
"""Updates the metadata for an image"""
|
||||
"""Updates the metadata for an image."""
|
||||
post_body = json.dumps({'metadata': meta})
|
||||
resp, body = self.post('images/%s/metadata' % str(image_id),
|
||||
post_body, self.headers)
|
||||
@@ -132,13 +132,13 @@ class ImagesClientJSON(RestClient):
|
||||
return resp, body['metadata']
|
||||
|
||||
def get_image_metadata_item(self, image_id, key):
|
||||
"""Returns the value for a specific image metadata key"""
|
||||
"""Returns the value for a specific image metadata key."""
|
||||
resp, body = self.get("images/%s/metadata/%s" % (str(image_id), key))
|
||||
body = json.loads(body)
|
||||
return resp, body['meta']
|
||||
|
||||
def set_image_metadata_item(self, image_id, key, meta):
|
||||
"""Sets the value for a specific image metadata key"""
|
||||
"""Sets the value for a specific image metadata key."""
|
||||
post_body = json.dumps({'meta': meta})
|
||||
resp, body = self.put('images/%s/metadata/%s' % (str(image_id), key),
|
||||
post_body, self.headers)
|
||||
@@ -146,7 +146,7 @@ class ImagesClientJSON(RestClient):
|
||||
return resp, body['meta']
|
||||
|
||||
def delete_image_metadata_item(self, image_id, key):
|
||||
"""Deletes a single image metadata key/value pair"""
|
||||
"""Deletes a single image metadata key/value pair."""
|
||||
resp, body = self.delete("images/%s/metadata/%s" %
|
||||
(str(image_id), key))
|
||||
return resp, body
|
||||
|
||||
@@ -28,7 +28,7 @@ class QuotasClient(RestClient):
|
||||
self.service = self.config.compute.catalog_type
|
||||
|
||||
def get_quota_set(self, tenant_id):
|
||||
"""List the quota set for a tenant"""
|
||||
"""List the quota set for a tenant."""
|
||||
|
||||
url = 'os-quota-sets/%s' % str(tenant_id)
|
||||
resp, body = self.get(url)
|
||||
|
||||
@@ -30,7 +30,7 @@ class SecurityGroupsClientJSON(RestClient):
|
||||
self.service = self.config.compute.catalog_type
|
||||
|
||||
def list_security_groups(self, params=None):
|
||||
"""List all security groups for a user"""
|
||||
"""List all security groups for a user."""
|
||||
|
||||
url = 'os-security-groups'
|
||||
if params:
|
||||
@@ -41,7 +41,7 @@ class SecurityGroupsClientJSON(RestClient):
|
||||
return resp, body['security_groups']
|
||||
|
||||
def get_security_group(self, security_group_id):
|
||||
"""Get the details of a Security Group"""
|
||||
"""Get the details of a Security Group."""
|
||||
url = "os-security-groups/%s" % str(security_group_id)
|
||||
resp, body = self.get(url)
|
||||
body = json.loads(body)
|
||||
@@ -63,7 +63,7 @@ class SecurityGroupsClientJSON(RestClient):
|
||||
return resp, body['security_group']
|
||||
|
||||
def delete_security_group(self, security_group_id):
|
||||
"""Deletes the provided Security Group"""
|
||||
"""Deletes the provided Security Group."""
|
||||
return self.delete('os-security-groups/%s' % str(security_group_id))
|
||||
|
||||
def create_security_group_rule(self, parent_group_id, ip_proto, from_port,
|
||||
@@ -93,5 +93,5 @@ class SecurityGroupsClientJSON(RestClient):
|
||||
return resp, body['security_group_rule']
|
||||
|
||||
def delete_security_group_rule(self, group_rule_id):
|
||||
"""Deletes the provided Security Group rule"""
|
||||
"""Deletes the provided Security Group rule."""
|
||||
return self.delete('os-security-group-rules/%s' % str(group_rule_id))
|
||||
|
||||
@@ -110,17 +110,17 @@ class ServersClientJSON(RestClient):
|
||||
return resp, body['server']
|
||||
|
||||
def get_server(self, server_id):
|
||||
"""Returns the details of an existing server"""
|
||||
"""Returns the details of an existing server."""
|
||||
resp, body = self.get("servers/%s" % str(server_id))
|
||||
body = json.loads(body)
|
||||
return resp, body['server']
|
||||
|
||||
def delete_server(self, server_id):
|
||||
"""Deletes the given server"""
|
||||
"""Deletes the given server."""
|
||||
return self.delete("servers/%s" % str(server_id))
|
||||
|
||||
def list_servers(self, params=None):
|
||||
"""Lists all servers for a user"""
|
||||
"""Lists all servers for a user."""
|
||||
|
||||
url = 'servers'
|
||||
if params:
|
||||
@@ -131,7 +131,7 @@ class ServersClientJSON(RestClient):
|
||||
return resp, body
|
||||
|
||||
def list_servers_with_detail(self, params=None):
|
||||
"""Lists all servers in detail for a user"""
|
||||
"""Lists all servers in detail for a user."""
|
||||
|
||||
url = 'servers/detail'
|
||||
if params:
|
||||
@@ -142,7 +142,7 @@ class ServersClientJSON(RestClient):
|
||||
return resp, body
|
||||
|
||||
def wait_for_server_status(self, server_id, status):
|
||||
"""Waits for a server to reach a given status"""
|
||||
"""Waits for a server to reach a given status."""
|
||||
resp, body = self.get_server(server_id)
|
||||
server_status = body['status']
|
||||
start = int(time.time())
|
||||
@@ -165,7 +165,7 @@ class ServersClientJSON(RestClient):
|
||||
raise exceptions.TimeoutException(message)
|
||||
|
||||
def wait_for_server_termination(self, server_id, ignore_error=False):
|
||||
"""Waits for server to reach termination"""
|
||||
"""Waits for server to reach termination."""
|
||||
start_time = int(time.time())
|
||||
while True:
|
||||
try:
|
||||
@@ -183,20 +183,20 @@ class ServersClientJSON(RestClient):
|
||||
time.sleep(self.build_interval)
|
||||
|
||||
def list_addresses(self, server_id):
|
||||
"""Lists all addresses for a server"""
|
||||
"""Lists all addresses for a server."""
|
||||
resp, body = self.get("servers/%s/ips" % str(server_id))
|
||||
body = json.loads(body)
|
||||
return resp, body['addresses']
|
||||
|
||||
def list_addresses_by_network(self, server_id, network_id):
|
||||
"""Lists all addresses of a specific network type for a server"""
|
||||
"""Lists all addresses of a specific network type for a server."""
|
||||
resp, body = self.get("servers/%s/ips/%s" %
|
||||
(str(server_id), network_id))
|
||||
body = json.loads(body)
|
||||
return resp, body
|
||||
|
||||
def change_password(self, server_id, password):
|
||||
"""Changes the root password for the server"""
|
||||
"""Changes the root password for the server."""
|
||||
post_body = {
|
||||
'changePassword': {
|
||||
'adminPass': password,
|
||||
@@ -208,7 +208,7 @@ class ServersClientJSON(RestClient):
|
||||
post_body, self.headers)
|
||||
|
||||
def reboot(self, server_id, reboot_type):
|
||||
"""Reboots a server"""
|
||||
"""Reboots a server."""
|
||||
post_body = {
|
||||
'reboot': {
|
||||
'type': reboot_type,
|
||||
@@ -221,7 +221,7 @@ class ServersClientJSON(RestClient):
|
||||
|
||||
def rebuild(self, server_id, image_ref, name=None, meta=None,
|
||||
personality=None, adminPass=None, disk_config=None):
|
||||
"""Rebuilds a server with a new image"""
|
||||
"""Rebuilds a server with a new image."""
|
||||
post_body = {
|
||||
'imageRef': image_ref,
|
||||
}
|
||||
@@ -264,7 +264,7 @@ class ServersClientJSON(RestClient):
|
||||
return resp, body
|
||||
|
||||
def confirm_resize(self, server_id):
|
||||
"""Confirms the flavor change for a server"""
|
||||
"""Confirms the flavor change for a server."""
|
||||
post_body = {
|
||||
'confirmResize': None,
|
||||
}
|
||||
@@ -275,7 +275,7 @@ class ServersClientJSON(RestClient):
|
||||
return resp, body
|
||||
|
||||
def revert_resize(self, server_id):
|
||||
"""Reverts a server back to its original flavor"""
|
||||
"""Reverts a server back to its original flavor."""
|
||||
post_body = {
|
||||
'revertResize': None,
|
||||
}
|
||||
@@ -286,7 +286,7 @@ class ServersClientJSON(RestClient):
|
||||
return resp, body
|
||||
|
||||
def create_image(self, server_id, image_name):
|
||||
"""Creates an image of the given server"""
|
||||
"""Creates an image of the given server."""
|
||||
post_body = {
|
||||
'createImage': {
|
||||
'name': image_name,
|
||||
@@ -345,7 +345,7 @@ class ServersClientJSON(RestClient):
|
||||
post_body, self.headers)
|
||||
|
||||
def attach_volume(self, server_id, volume_id, device='/dev/vdz'):
|
||||
"""Attaches a volume to a server instance"""
|
||||
"""Attaches a volume to a server instance."""
|
||||
post_body = json.dumps({
|
||||
'volumeAttachment': {
|
||||
'volumeId': volume_id,
|
||||
@@ -357,13 +357,13 @@ class ServersClientJSON(RestClient):
|
||||
return resp, body
|
||||
|
||||
def detach_volume(self, server_id, volume_id):
|
||||
"""Detaches a volume from a server instance"""
|
||||
"""Detaches a volume from a server instance."""
|
||||
resp, body = self.delete('servers/%s/os-volume_attachments/%s' %
|
||||
(server_id, volume_id))
|
||||
return resp, body
|
||||
|
||||
def add_security_group(self, server_id, security_group_name):
|
||||
"""Adds a security group to the server"""
|
||||
"""Adds a security group to the server."""
|
||||
post_body = {
|
||||
'addSecurityGroup': {
|
||||
'name': security_group_name
|
||||
@@ -374,7 +374,7 @@ class ServersClientJSON(RestClient):
|
||||
post_body, self.headers)
|
||||
|
||||
def remove_security_group(self, server_id, security_group_name):
|
||||
"""Removes a security group from the server"""
|
||||
"""Removes a security group from the server."""
|
||||
post_body = {
|
||||
'removeSecurityGroup': {
|
||||
'name': security_group_name
|
||||
@@ -385,7 +385,7 @@ class ServersClientJSON(RestClient):
|
||||
post_body, self.headers)
|
||||
|
||||
def live_migrate_server(self, server_id, dest_host, use_block_migration):
|
||||
""" This should be called with administrator privileges """
|
||||
"""This should be called with administrator privileges ."""
|
||||
|
||||
migrate_params = {
|
||||
"disk_over_commit": False,
|
||||
@@ -409,7 +409,7 @@ class ServersClientJSON(RestClient):
|
||||
return resp, body['servers']
|
||||
|
||||
def migrate_server(self, server_id):
|
||||
"""Migrates a server to a new host"""
|
||||
"""Migrates a server to a new host."""
|
||||
post_body = {'migrate': 'null'}
|
||||
post_body = json.dumps(post_body)
|
||||
resp, body = self.post('servers/%s/action' % server_id,
|
||||
@@ -417,7 +417,7 @@ class ServersClientJSON(RestClient):
|
||||
return resp, body
|
||||
|
||||
def confirm_migration(self, server_id):
|
||||
"""Confirms the migration of a server"""
|
||||
"""Confirms the migration of a server."""
|
||||
post_body = {'confirmResize': 'null'}
|
||||
post_body = json.dumps(post_body)
|
||||
resp, body = self.post('servers/%s/action' % server_id,
|
||||
@@ -425,63 +425,63 @@ class ServersClientJSON(RestClient):
|
||||
return resp, body
|
||||
|
||||
def lock_server(self, server_id):
|
||||
"""Locks the given server"""
|
||||
"""Locks the given server."""
|
||||
post_body = {'lock': 'null'}
|
||||
post_body = json.dumps(post_body)
|
||||
resp, body = self.post('servers/%s/action' % server_id,
|
||||
post_body, self.headers)
|
||||
|
||||
def unlock_server(self, server_id):
|
||||
"""UNlocks the given server"""
|
||||
"""UNlocks the given server."""
|
||||
post_body = {'unlock': 'null'}
|
||||
post_body = json.dumps(post_body)
|
||||
resp, body = self.post('servers/%s/action' % server_id,
|
||||
post_body, self.headers)
|
||||
|
||||
def start_server(self, server_id):
|
||||
"""Starts the given server"""
|
||||
"""Starts the given server."""
|
||||
post_body = {'os-start': 'null'}
|
||||
post_body = json.dumps(post_body)
|
||||
resp, body = self.post('servers/%s/action' % server_id,
|
||||
post_body, self.headers)
|
||||
|
||||
def stop_server(self, server_id):
|
||||
"""Stops the given server"""
|
||||
"""Stops the given server."""
|
||||
post_body = {'os-stop': 'null'}
|
||||
post_body = json.dumps(post_body)
|
||||
resp, body = self.post('servers/%s/action' % server_id,
|
||||
post_body, self.headers)
|
||||
|
||||
def suspend_server(self, server_id):
|
||||
"""Suspends the provded server"""
|
||||
"""Suspends the provded server."""
|
||||
post_body = {'suspend': 'null'}
|
||||
post_body = json.dumps(post_body)
|
||||
resp, body = self.post('servers/%s/action' % server_id,
|
||||
post_body, self.headers)
|
||||
|
||||
def resume_server(self, server_id):
|
||||
"""Un-suspends the provded server"""
|
||||
"""Un-suspends the provded server."""
|
||||
post_body = {'resume': 'null'}
|
||||
post_body = json.dumps(post_body)
|
||||
resp, body = self.post('servers/%s/action' % server_id,
|
||||
post_body, self.headers)
|
||||
|
||||
def pause_server(self, server_id):
|
||||
"""Pauses the provded server"""
|
||||
"""Pauses the provded server."""
|
||||
post_body = {'pause': 'null'}
|
||||
post_body = json.dumps(post_body)
|
||||
resp, body = self.post('servers/%s/action' % server_id,
|
||||
post_body, self.headers)
|
||||
|
||||
def unpause_server(self, server_id):
|
||||
"""Un-pauses the provded server"""
|
||||
"""Un-pauses the provded server."""
|
||||
post_body = {'unpause': 'null'}
|
||||
post_body = json.dumps(post_body)
|
||||
resp, body = self.post('servers/%s/action' % server_id,
|
||||
post_body, self.headers)
|
||||
|
||||
def reset_state(self, server_id, new_state='error'):
|
||||
"""Resets the state of a server to active/error"""
|
||||
"""Resets the state of a server to active/error."""
|
||||
post_body = {
|
||||
'os-resetState': {
|
||||
'state': new_state
|
||||
|
||||
@@ -34,7 +34,7 @@ class VolumesExtensionsClientJSON(RestClient):
|
||||
self.build_timeout = self.config.volume.build_timeout
|
||||
|
||||
def list_volumes(self, params=None):
|
||||
"""List all the volumes created"""
|
||||
"""List all the volumes created."""
|
||||
url = 'os-volumes'
|
||||
if params:
|
||||
url += '?%s' % urllib.urlencode(params)
|
||||
@@ -44,7 +44,7 @@ class VolumesExtensionsClientJSON(RestClient):
|
||||
return resp, body['volumes']
|
||||
|
||||
def list_volumes_with_detail(self, params=None):
|
||||
"""List all the details of volumes"""
|
||||
"""List all the details of volumes."""
|
||||
url = 'os-volumes/detail'
|
||||
if params:
|
||||
url += '?%s' % urllib.urlencode(params)
|
||||
@@ -54,7 +54,7 @@ class VolumesExtensionsClientJSON(RestClient):
|
||||
return resp, body['volumes']
|
||||
|
||||
def get_volume(self, volume_id, wait=None):
|
||||
"""Returns the details of a single volume"""
|
||||
"""Returns the details of a single volume."""
|
||||
url = "os-volumes/%s" % str(volume_id)
|
||||
resp, body = self.get(url, wait=wait)
|
||||
body = json.loads(body)
|
||||
@@ -80,11 +80,11 @@ class VolumesExtensionsClientJSON(RestClient):
|
||||
return resp, body['volume']
|
||||
|
||||
def delete_volume(self, volume_id):
|
||||
"""Deletes the Specified Volume"""
|
||||
"""Deletes the Specified Volume."""
|
||||
return self.delete("os-volumes/%s" % str(volume_id))
|
||||
|
||||
def wait_for_volume_status(self, volume_id, status):
|
||||
"""Waits for a Volume to reach a given status"""
|
||||
"""Waits for a Volume to reach a given status."""
|
||||
resp, body = self.get_volume(volume_id)
|
||||
volume_name = body['displayName']
|
||||
volume_status = body['status']
|
||||
|
||||
@@ -86,7 +86,7 @@ class FlavorsClientXML(RestClientXML):
|
||||
|
||||
def create_flavor(self, name, ram, vcpus, disk, ephemeral, flavor_id,
|
||||
swap, rxtx):
|
||||
"""Creates a new flavor or instance type"""
|
||||
"""Creates a new flavor or instance type."""
|
||||
flavor = Element("flavor",
|
||||
xmlns=XMLNS_11,
|
||||
ram=ram,
|
||||
@@ -105,5 +105,5 @@ class FlavorsClientXML(RestClientXML):
|
||||
return resp, flavor
|
||||
|
||||
def delete_flavor(self, flavor_id):
|
||||
"""Deletes the given flavor"""
|
||||
"""Deletes the given flavor."""
|
||||
return self.delete("flavors/%s" % str(flavor_id), self.headers)
|
||||
|
||||
@@ -42,7 +42,7 @@ class FloatingIPsClientXML(RestClientXML):
|
||||
return json
|
||||
|
||||
def list_floating_ips(self, params=None):
|
||||
"""Returns a list of all floating IPs filtered by any parameters"""
|
||||
"""Returns a list of all floating IPs filtered by any parameters."""
|
||||
url = 'os-floating-ips'
|
||||
if params:
|
||||
url += '?%s' % urllib.urlencode(params)
|
||||
@@ -52,7 +52,7 @@ class FloatingIPsClientXML(RestClientXML):
|
||||
return resp, body
|
||||
|
||||
def get_floating_ip_details(self, floating_ip_id):
|
||||
"""Get the details of a floating IP"""
|
||||
"""Get the details of a floating IP."""
|
||||
url = "os-floating-ips/%s" % str(floating_ip_id)
|
||||
resp, body = self.get(url, self.headers)
|
||||
body = self._parse_floating_ip(etree.fromstring(body))
|
||||
@@ -61,20 +61,20 @@ class FloatingIPsClientXML(RestClientXML):
|
||||
return resp, body
|
||||
|
||||
def create_floating_ip(self):
|
||||
"""Allocate a floating IP to the project"""
|
||||
"""Allocate a floating IP to the project."""
|
||||
url = 'os-floating-ips'
|
||||
resp, body = self.post(url, None, self.headers)
|
||||
body = self._parse_floating_ip(etree.fromstring(body))
|
||||
return resp, body
|
||||
|
||||
def delete_floating_ip(self, floating_ip_id):
|
||||
"""Deletes the provided floating IP from the project"""
|
||||
"""Deletes the provided floating IP from the project."""
|
||||
url = "os-floating-ips/%s" % str(floating_ip_id)
|
||||
resp, body = self.delete(url, self.headers)
|
||||
return resp, body
|
||||
|
||||
def associate_floating_ip_to_server(self, floating_ip, server_id):
|
||||
"""Associate the provided floating IP to a specific server"""
|
||||
"""Associate the provided floating IP to a specific server."""
|
||||
url = "servers/%s/action" % str(server_id)
|
||||
doc = Document()
|
||||
server = Element("addFloatingIp")
|
||||
@@ -84,7 +84,7 @@ class FloatingIPsClientXML(RestClientXML):
|
||||
return resp, body
|
||||
|
||||
def disassociate_floating_ip_from_server(self, floating_ip, server_id):
|
||||
"""Disassociate the provided floating IP from a specific server"""
|
||||
"""Disassociate the provided floating IP from a specific server."""
|
||||
url = "servers/%s/action" % str(server_id)
|
||||
doc = Document()
|
||||
server = Element("removeFloatingIp")
|
||||
|
||||
@@ -43,7 +43,7 @@ class ImagesClientXML(RestClientXML):
|
||||
return self._parse_links(node, json)
|
||||
|
||||
def _parse_image(self, node):
|
||||
"""Parses detailed XML image information into dictionary"""
|
||||
"""Parses detailed XML image information into dictionary."""
|
||||
json = xml_to_json(node)
|
||||
|
||||
self._parse_links(node, json)
|
||||
@@ -61,7 +61,7 @@ class ImagesClientXML(RestClientXML):
|
||||
return json
|
||||
|
||||
def _parse_links(self, node, json):
|
||||
"""Append multiple links under a list"""
|
||||
"""Append multiple links under a list."""
|
||||
# look for links
|
||||
if 'link' in json:
|
||||
# remove single link element
|
||||
@@ -71,7 +71,7 @@ class ImagesClientXML(RestClientXML):
|
||||
return json
|
||||
|
||||
def create_image(self, server_id, name, meta=None):
|
||||
"""Creates an image of the original server"""
|
||||
"""Creates an image of the original server."""
|
||||
post_body = Element('createImage', name=name)
|
||||
|
||||
if meta:
|
||||
@@ -86,7 +86,7 @@ class ImagesClientXML(RestClientXML):
|
||||
return resp, body
|
||||
|
||||
def list_images(self, params=None):
|
||||
"""Returns a list of all images filtered by any parameters"""
|
||||
"""Returns a list of all images filtered by any parameters."""
|
||||
url = 'images'
|
||||
if params:
|
||||
url += '?%s' % urllib.urlencode(params)
|
||||
@@ -96,7 +96,7 @@ class ImagesClientXML(RestClientXML):
|
||||
return resp, body['images']
|
||||
|
||||
def list_images_with_detail(self, params=None):
|
||||
"""Returns a detailed list of images filtered by any parameters"""
|
||||
"""Returns a detailed list of images filtered by any parameters."""
|
||||
url = 'images/detail'
|
||||
if params:
|
||||
param_list = urllib.urlencode(params)
|
||||
@@ -108,13 +108,13 @@ class ImagesClientXML(RestClientXML):
|
||||
return resp, body['images']
|
||||
|
||||
def get_image(self, image_id):
|
||||
"""Returns the details of a single image"""
|
||||
"""Returns the details of a single image."""
|
||||
resp, body = self.get("images/%s" % str(image_id), self.headers)
|
||||
body = self._parse_image(etree.fromstring(body))
|
||||
return resp, body
|
||||
|
||||
def delete_image(self, image_id):
|
||||
"""Deletes the provided image"""
|
||||
"""Deletes the provided image."""
|
||||
return self.delete("images/%s" % str(image_id), self.headers)
|
||||
|
||||
def wait_for_image_resp_code(self, image_id, code):
|
||||
@@ -147,14 +147,14 @@ class ImagesClientXML(RestClientXML):
|
||||
raise exceptions.TimeoutException
|
||||
|
||||
def list_image_metadata(self, image_id):
|
||||
"""Lists all metadata items for an image"""
|
||||
"""Lists all metadata items for an image."""
|
||||
resp, body = self.get("images/%s/metadata" % str(image_id),
|
||||
self.headers)
|
||||
body = xml_to_json(etree.fromstring(body))
|
||||
return resp, body['metadata']
|
||||
|
||||
def set_image_metadata(self, image_id, meta):
|
||||
"""Sets the metadata for an image"""
|
||||
"""Sets the metadata for an image."""
|
||||
post_body = json.dumps({'metadata': meta})
|
||||
resp, body = self.put('images/%s/metadata' % str(image_id),
|
||||
post_body, self.headers)
|
||||
@@ -162,7 +162,7 @@ class ImagesClientXML(RestClientXML):
|
||||
return resp, body['metadata']
|
||||
|
||||
def update_image_metadata(self, image_id, meta):
|
||||
"""Updates the metadata for an image"""
|
||||
"""Updates the metadata for an image."""
|
||||
post_body = Element('metadata', meta)
|
||||
for k, v in meta:
|
||||
metadata = Element('meta', key=k)
|
||||
@@ -176,14 +176,14 @@ class ImagesClientXML(RestClientXML):
|
||||
return resp, body['metadata']
|
||||
|
||||
def get_image_metadata_item(self, image_id, key):
|
||||
"""Returns the value for a specific image metadata key"""
|
||||
"""Returns the value for a specific image metadata key."""
|
||||
resp, body = self.get("images/%s/metadata/%s.xml" %
|
||||
(str(image_id), key), self.headers)
|
||||
body = xml_to_json(etree.fromstring(body))
|
||||
return resp, body['meta']
|
||||
|
||||
def set_image_metadata_item(self, image_id, key, meta):
|
||||
"""Sets the value for a specific image metadata key"""
|
||||
"""Sets the value for a specific image metadata key."""
|
||||
post_body = json.dumps({'meta': meta})
|
||||
resp, body = self.put('images/%s/metadata/%s' % (str(image_id), key),
|
||||
post_body, self.headers)
|
||||
@@ -191,7 +191,7 @@ class ImagesClientXML(RestClientXML):
|
||||
return resp, body['meta']
|
||||
|
||||
def delete_image_metadata_item(self, image_id, key):
|
||||
"""Deletes a single image metadata key/value pair"""
|
||||
"""Deletes a single image metadata key/value pair."""
|
||||
resp, body = self.delete("images/%s/metadata/%s" % (str(image_id), key,
|
||||
self.headers))
|
||||
return resp, body
|
||||
|
||||
@@ -44,7 +44,7 @@ class SecurityGroupsClientXML(RestClientXML):
|
||||
return json
|
||||
|
||||
def list_security_groups(self, params=None):
|
||||
"""List all security groups for a user"""
|
||||
"""List all security groups for a user."""
|
||||
|
||||
url = 'os-security-groups'
|
||||
if params:
|
||||
@@ -55,7 +55,7 @@ class SecurityGroupsClientXML(RestClientXML):
|
||||
return resp, body
|
||||
|
||||
def get_security_group(self, security_group_id):
|
||||
"""Get the details of a Security Group"""
|
||||
"""Get the details of a Security Group."""
|
||||
url = "os-security-groups/%s" % str(security_group_id)
|
||||
resp, body = self.get(url, self.headers)
|
||||
body = self._parse_body(etree.fromstring(body))
|
||||
@@ -78,7 +78,7 @@ class SecurityGroupsClientXML(RestClientXML):
|
||||
return resp, body
|
||||
|
||||
def delete_security_group(self, security_group_id):
|
||||
"""Deletes the provided Security Group"""
|
||||
"""Deletes the provided Security Group."""
|
||||
return self.delete('os-security-groups/%s' %
|
||||
str(security_group_id), self.headers)
|
||||
|
||||
@@ -125,6 +125,6 @@ class SecurityGroupsClientXML(RestClientXML):
|
||||
return resp, body
|
||||
|
||||
def delete_security_group_rule(self, group_rule_id):
|
||||
"""Deletes the provided Security Group rule"""
|
||||
"""Deletes the provided Security Group rule."""
|
||||
return self.delete('os-security-group-rules/%s' %
|
||||
str(group_rule_id), self.headers)
|
||||
|
||||
@@ -41,7 +41,7 @@ class ServersClientXML(RestClientXML):
|
||||
self.service = self.config.compute.catalog_type
|
||||
|
||||
def _parse_key_value(self, node):
|
||||
"""Parse <foo key='key'>value</foo> data into {'key': 'value'}"""
|
||||
"""Parse <foo key='key'>value</foo> data into {'key': 'value'}."""
|
||||
data = {}
|
||||
for node in node.getchildren():
|
||||
data[node.get('key')] = node.text
|
||||
@@ -69,13 +69,13 @@ class ServersClientXML(RestClientXML):
|
||||
return json
|
||||
|
||||
def get_server(self, server_id):
|
||||
"""Returns the details of an existing server"""
|
||||
"""Returns the details of an existing server."""
|
||||
resp, body = self.get("servers/%s" % str(server_id), self.headers)
|
||||
server = self._parse_server(etree.fromstring(body))
|
||||
return resp, server
|
||||
|
||||
def delete_server(self, server_id):
|
||||
"""Deletes the given server"""
|
||||
"""Deletes the given server."""
|
||||
return self.delete("servers/%s" % str(server_id))
|
||||
|
||||
def _parse_array(self, node):
|
||||
@@ -179,7 +179,7 @@ class ServersClientXML(RestClientXML):
|
||||
return resp, server
|
||||
|
||||
def wait_for_server_status(self, server_id, status):
|
||||
"""Waits for a server to reach a given status"""
|
||||
"""Waits for a server to reach a given status."""
|
||||
resp, body = self.get_server(server_id)
|
||||
server_status = body['status']
|
||||
start = int(time.time())
|
||||
@@ -202,7 +202,7 @@ class ServersClientXML(RestClientXML):
|
||||
raise exceptions.TimeoutException(message)
|
||||
|
||||
def wait_for_server_termination(self, server_id, ignore_error=False):
|
||||
"""Waits for server to reach termination"""
|
||||
"""Waits for server to reach termination."""
|
||||
start_time = int(time.time())
|
||||
while True:
|
||||
try:
|
||||
@@ -227,7 +227,7 @@ class ServersClientXML(RestClientXML):
|
||||
return {node.get('id'): addrs}
|
||||
|
||||
def list_addresses(self, server_id):
|
||||
"""Lists all addresses for a server"""
|
||||
"""Lists all addresses for a server."""
|
||||
resp, body = self.get("servers/%s/ips" % str(server_id), self.headers)
|
||||
|
||||
networks = {}
|
||||
@@ -238,7 +238,7 @@ class ServersClientXML(RestClientXML):
|
||||
return resp, networks
|
||||
|
||||
def list_addresses_by_network(self, server_id, network_id):
|
||||
"""Lists all addresses of a specific network type for a server"""
|
||||
"""Lists all addresses of a specific network type for a server."""
|
||||
resp, body = self.get("servers/%s/ips/%s" % (str(server_id),
|
||||
network_id),
|
||||
self.headers)
|
||||
|
||||
@@ -54,7 +54,7 @@ class VolumesExtensionsClientXML(RestClientXML):
|
||||
return vol
|
||||
|
||||
def list_volumes(self, params=None):
|
||||
"""List all the volumes created"""
|
||||
"""List all the volumes created."""
|
||||
url = 'os-volumes'
|
||||
|
||||
if params:
|
||||
@@ -68,7 +68,7 @@ class VolumesExtensionsClientXML(RestClientXML):
|
||||
return resp, volumes
|
||||
|
||||
def list_volumes_with_detail(self, params=None):
|
||||
"""List all the details of volumes"""
|
||||
"""List all the details of volumes."""
|
||||
url = 'os-volumes/detail'
|
||||
|
||||
if params:
|
||||
@@ -82,7 +82,7 @@ class VolumesExtensionsClientXML(RestClientXML):
|
||||
return resp, volumes
|
||||
|
||||
def get_volume(self, volume_id, wait=None):
|
||||
"""Returns the details of a single volume"""
|
||||
"""Returns the details of a single volume."""
|
||||
url = "os-volumes/%s" % str(volume_id)
|
||||
resp, body = self.get(url, self.headers, wait=wait)
|
||||
body = etree.fromstring(body)
|
||||
@@ -116,11 +116,11 @@ class VolumesExtensionsClientXML(RestClientXML):
|
||||
return resp, body
|
||||
|
||||
def delete_volume(self, volume_id):
|
||||
"""Deletes the Specified Volume"""
|
||||
"""Deletes the Specified Volume."""
|
||||
return self.delete("os-volumes/%s" % str(volume_id))
|
||||
|
||||
def wait_for_volume_status(self, volume_id, status):
|
||||
"""Waits for a Volume to reach a given status"""
|
||||
"""Waits for a Volume to reach a given status."""
|
||||
resp, body = self.get_volume(volume_id)
|
||||
volume_name = body['displayName']
|
||||
volume_status = body['status']
|
||||
|
||||
@@ -25,7 +25,7 @@ class AdminClientJSON(RestClient):
|
||||
return self._has_admin_extensions
|
||||
|
||||
def create_role(self, name):
|
||||
"""Create a role"""
|
||||
"""Create a role."""
|
||||
post_body = {
|
||||
'name': name,
|
||||
}
|
||||
@@ -52,19 +52,19 @@ class AdminClientJSON(RestClient):
|
||||
return resp, body['tenant']
|
||||
|
||||
def delete_role(self, role_id):
|
||||
"""Delete a role"""
|
||||
"""Delete a role."""
|
||||
resp, body = self.delete('OS-KSADM/roles/%s' % str(role_id))
|
||||
return resp, body
|
||||
|
||||
def list_user_roles(self, tenant_id, user_id):
|
||||
"""Returns a list of roles assigned to a user for a tenant"""
|
||||
"""Returns a list of roles assigned to a user for a tenant."""
|
||||
url = '/tenants/%s/users/%s/roles' % (tenant_id, user_id)
|
||||
resp, body = self.get(url)
|
||||
body = json.loads(body)
|
||||
return resp, body['roles']
|
||||
|
||||
def assign_user_role(self, tenant_id, user_id, role_id):
|
||||
"""Add roles to a user on a tenant"""
|
||||
"""Add roles to a user on a tenant."""
|
||||
post_body = json.dumps({})
|
||||
resp, body = self.put('/tenants/%s/users/%s/roles/OS-KSADM/%s' %
|
||||
(tenant_id, user_id, role_id), post_body,
|
||||
@@ -73,29 +73,29 @@ class AdminClientJSON(RestClient):
|
||||
return resp, body['role']
|
||||
|
||||
def remove_user_role(self, tenant_id, user_id, role_id):
|
||||
"""Removes a role assignment for a user on a tenant"""
|
||||
"""Removes a role assignment for a user on a tenant."""
|
||||
return self.delete('/tenants/%s/users/%s/roles/OS-KSADM/%s' %
|
||||
(tenant_id, user_id, role_id))
|
||||
|
||||
def delete_tenant(self, tenant_id):
|
||||
"""Delete a tenant"""
|
||||
"""Delete a tenant."""
|
||||
resp, body = self.delete('tenants/%s' % str(tenant_id))
|
||||
return resp, body
|
||||
|
||||
def get_tenant(self, tenant_id):
|
||||
"""Get tenant details"""
|
||||
"""Get tenant details."""
|
||||
resp, body = self.get('tenants/%s' % str(tenant_id))
|
||||
body = json.loads(body)
|
||||
return resp, body['tenant']
|
||||
|
||||
def list_roles(self):
|
||||
"""Returns roles"""
|
||||
"""Returns roles."""
|
||||
resp, body = self.get('OS-KSADM/roles')
|
||||
body = json.loads(body)
|
||||
return resp, body['roles']
|
||||
|
||||
def list_tenants(self):
|
||||
"""Returns tenants"""
|
||||
"""Returns tenants."""
|
||||
resp, body = self.get('tenants')
|
||||
body = json.loads(body)
|
||||
return resp, body['tenants']
|
||||
@@ -108,7 +108,7 @@ class AdminClientJSON(RestClient):
|
||||
raise exceptions.NotFound('No such tenant')
|
||||
|
||||
def update_tenant(self, tenant_id, **kwargs):
|
||||
"""Updates a tenant"""
|
||||
"""Updates a tenant."""
|
||||
resp, body = self.get_tenant(tenant_id)
|
||||
name = kwargs.get('name', body['name'])
|
||||
desc = kwargs.get('description', body['description'])
|
||||
@@ -126,7 +126,7 @@ class AdminClientJSON(RestClient):
|
||||
return resp, body['tenant']
|
||||
|
||||
def create_user(self, name, password, tenant_id, email):
|
||||
"""Create a user"""
|
||||
"""Create a user."""
|
||||
post_body = {
|
||||
'name': name,
|
||||
'password': password,
|
||||
@@ -139,18 +139,18 @@ class AdminClientJSON(RestClient):
|
||||
return resp, body['user']
|
||||
|
||||
def delete_user(self, user_id):
|
||||
"""Delete a user"""
|
||||
"""Delete a user."""
|
||||
resp, body = self.delete("users/%s" % user_id)
|
||||
return resp, body
|
||||
|
||||
def get_users(self):
|
||||
"""Get the list of users"""
|
||||
"""Get the list of users."""
|
||||
resp, body = self.get("users")
|
||||
body = json.loads(body)
|
||||
return resp, body['users']
|
||||
|
||||
def enable_disable_user(self, user_id, enabled):
|
||||
"""Enables or disables a user"""
|
||||
"""Enables or disables a user."""
|
||||
put_body = {
|
||||
'enabled': enabled
|
||||
}
|
||||
@@ -161,12 +161,12 @@ class AdminClientJSON(RestClient):
|
||||
return resp, body
|
||||
|
||||
def delete_token(self, token_id):
|
||||
"""Delete a token"""
|
||||
"""Delete a token."""
|
||||
resp, body = self.delete("tokens/%s" % token_id)
|
||||
return resp, body
|
||||
|
||||
def list_users_for_tenant(self, tenant_id):
|
||||
"""List users for a Tenant"""
|
||||
"""List users for a Tenant."""
|
||||
resp, body = self.get('/tenants/%s/users' % tenant_id)
|
||||
body = json.loads(body)
|
||||
return resp, body['users']
|
||||
@@ -179,7 +179,7 @@ class AdminClientJSON(RestClient):
|
||||
raise exceptions.NotFound('No such user')
|
||||
|
||||
def create_service(self, name, type, **kwargs):
|
||||
"""Create a service"""
|
||||
"""Create a service."""
|
||||
post_body = {
|
||||
'name': name,
|
||||
'type': type,
|
||||
@@ -191,14 +191,14 @@ class AdminClientJSON(RestClient):
|
||||
return resp, body['OS-KSADM:service']
|
||||
|
||||
def get_service(self, service_id):
|
||||
"""Get Service"""
|
||||
"""Get Service."""
|
||||
url = '/OS-KSADM/services/%s' % service_id
|
||||
resp, body = self.get(url)
|
||||
body = json.loads(body)
|
||||
return resp, body['OS-KSADM:service']
|
||||
|
||||
def delete_service(self, service_id):
|
||||
"""Delete Service"""
|
||||
"""Delete Service."""
|
||||
url = '/OS-KSADM/services/%s' % service_id
|
||||
return self.delete(url)
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ class AdminClientXML(RestClientXML):
|
||||
return self._has_admin_extensions
|
||||
|
||||
def create_role(self, name):
|
||||
"""Create a role"""
|
||||
"""Create a role."""
|
||||
create_role = Element("role", xmlns=XMLNS, name=name)
|
||||
resp, body = self.post('OS-KSADM/roles', str(Document(create_role)),
|
||||
self.headers)
|
||||
@@ -89,55 +89,55 @@ class AdminClientXML(RestClientXML):
|
||||
return resp, body
|
||||
|
||||
def delete_role(self, role_id):
|
||||
"""Delete a role"""
|
||||
"""Delete a role."""
|
||||
resp, body = self.delete('OS-KSADM/roles/%s' % str(role_id),
|
||||
self.headers)
|
||||
return resp, body
|
||||
|
||||
def list_user_roles(self, tenant_id, user_id):
|
||||
"""Returns a list of roles assigned to a user for a tenant"""
|
||||
"""Returns a list of roles assigned to a user for a tenant."""
|
||||
url = '/tenants/%s/users/%s/roles' % (tenant_id, user_id)
|
||||
resp, body = self.get(url, self.headers)
|
||||
body = self._parse_array(etree.fromstring(body))
|
||||
return resp, body
|
||||
|
||||
def assign_user_role(self, tenant_id, user_id, role_id):
|
||||
"""Add roles to a user on a tenant"""
|
||||
"""Add roles to a user on a tenant."""
|
||||
resp, body = self.put('/tenants/%s/users/%s/roles/OS-KSADM/%s' %
|
||||
(tenant_id, user_id, role_id), '', self.headers)
|
||||
body = self._parse_body(etree.fromstring(body))
|
||||
return resp, body
|
||||
|
||||
def remove_user_role(self, tenant_id, user_id, role_id):
|
||||
"""Removes a role assignment for a user on a tenant"""
|
||||
"""Removes a role assignment for a user on a tenant."""
|
||||
return self.delete('/tenants/%s/users/%s/roles/OS-KSADM/%s' %
|
||||
(tenant_id, user_id, role_id), self.headers)
|
||||
|
||||
def delete_tenant(self, tenant_id):
|
||||
"""Delete a tenant"""
|
||||
"""Delete a tenant."""
|
||||
resp, body = self.delete('tenants/%s' % str(tenant_id), self.headers)
|
||||
return resp, body
|
||||
|
||||
def get_tenant(self, tenant_id):
|
||||
"""Get tenant details"""
|
||||
"""Get tenant details."""
|
||||
resp, body = self.get('tenants/%s' % str(tenant_id), self.headers)
|
||||
body = self._parse_body(etree.fromstring(body))
|
||||
return resp, body
|
||||
|
||||
def list_roles(self):
|
||||
"""Returns roles"""
|
||||
"""Returns roles."""
|
||||
resp, body = self.get('OS-KSADM/roles', self.headers)
|
||||
body = self._parse_array(etree.fromstring(body))
|
||||
return resp, body
|
||||
|
||||
def list_tenants(self):
|
||||
"""Returns tenants"""
|
||||
"""Returns tenants."""
|
||||
resp, body = self.get('tenants', self.headers)
|
||||
body = self._parse_array(etree.fromstring(body))
|
||||
return resp, body
|
||||
|
||||
def update_tenant(self, tenant_id, **kwargs):
|
||||
"""Updates a tenant"""
|
||||
"""Updates a tenant."""
|
||||
resp, body = self.get_tenant(tenant_id)
|
||||
name = kwargs.get('name', body['name'])
|
||||
desc = kwargs.get('description', body['description'])
|
||||
@@ -156,7 +156,7 @@ class AdminClientXML(RestClientXML):
|
||||
return resp, body
|
||||
|
||||
def create_user(self, name, password, tenant_id, email):
|
||||
"""Create a user"""
|
||||
"""Create a user."""
|
||||
create_user = Element("user",
|
||||
xmlns=XMLNS,
|
||||
name=name,
|
||||
@@ -169,18 +169,18 @@ class AdminClientXML(RestClientXML):
|
||||
return resp, body
|
||||
|
||||
def delete_user(self, user_id):
|
||||
"""Delete a user"""
|
||||
"""Delete a user."""
|
||||
resp, body = self.delete("users/%s" % user_id, self.headers)
|
||||
return resp, body
|
||||
|
||||
def get_users(self):
|
||||
"""Get the list of users"""
|
||||
"""Get the list of users."""
|
||||
resp, body = self.get("users", self.headers)
|
||||
body = self._parse_array(etree.fromstring(body))
|
||||
return resp, body
|
||||
|
||||
def enable_disable_user(self, user_id, enabled):
|
||||
"""Enables or disables a user"""
|
||||
"""Enables or disables a user."""
|
||||
enable_user = Element("user", enabled=str(enabled).lower())
|
||||
resp, body = self.put('users/%s/enabled' % user_id,
|
||||
str(Document(enable_user)), self.headers)
|
||||
@@ -188,18 +188,18 @@ class AdminClientXML(RestClientXML):
|
||||
return resp, body
|
||||
|
||||
def delete_token(self, token_id):
|
||||
"""Delete a token"""
|
||||
"""Delete a token."""
|
||||
resp, body = self.delete("tokens/%s" % token_id, self.headers)
|
||||
return resp, body
|
||||
|
||||
def list_users_for_tenant(self, tenant_id):
|
||||
"""List users for a Tenant"""
|
||||
"""List users for a Tenant."""
|
||||
resp, body = self.get('/tenants/%s/users' % tenant_id, self.headers)
|
||||
body = self._parse_array(etree.fromstring(body))
|
||||
return resp, body
|
||||
|
||||
def create_service(self, name, type, **kwargs):
|
||||
"""Create a service"""
|
||||
"""Create a service."""
|
||||
OS_KSADM = "http://docs.openstack.org/identity/api/ext/OS-KSADM/v1.0"
|
||||
create_service = Element("service",
|
||||
xmlns=OS_KSADM,
|
||||
@@ -213,14 +213,14 @@ class AdminClientXML(RestClientXML):
|
||||
return resp, body
|
||||
|
||||
def get_service(self, service_id):
|
||||
"""Get Service"""
|
||||
"""Get Service."""
|
||||
url = '/OS-KSADM/services/%s' % service_id
|
||||
resp, body = self.get(url, self.headers)
|
||||
body = self._parse_body(etree.fromstring(body))
|
||||
return resp, body
|
||||
|
||||
def delete_service(self, service_id):
|
||||
"""Delete Service"""
|
||||
"""Delete Service."""
|
||||
url = '/OS-KSADM/services/%s' % service_id
|
||||
return self.delete(url, self.headers)
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class AccountClient(RestClient):
|
||||
|
||||
def create_account_metadata(self, metadata,
|
||||
metadata_prefix='X-Account-Meta-'):
|
||||
"""Creates an account metadata entry"""
|
||||
"""Creates an account metadata entry."""
|
||||
headers = {}
|
||||
for key in metadata:
|
||||
headers[metadata_prefix + key] = metadata[key]
|
||||
|
||||
@@ -48,14 +48,14 @@ class ContainerClient(RestClient):
|
||||
return resp, body
|
||||
|
||||
def delete_container(self, container_name):
|
||||
"""Deletes the container (if it's empty)"""
|
||||
"""Deletes the container (if it's empty)."""
|
||||
url = str(container_name)
|
||||
resp, body = self.delete(url)
|
||||
return resp, body
|
||||
|
||||
def update_container_metadata(self, container_name, metadata,
|
||||
metadata_prefix='X-Container-Meta-'):
|
||||
"""Updates arbitrary metadata on container"""
|
||||
"""Updates arbitrary metadata on container."""
|
||||
url = str(container_name)
|
||||
headers = {}
|
||||
|
||||
@@ -68,7 +68,7 @@ class ContainerClient(RestClient):
|
||||
|
||||
def delete_container_metadata(self, container_name, metadata,
|
||||
metadata_prefix='X-Remove-Container-Meta-'):
|
||||
"""Deletes arbitrary metadata on container"""
|
||||
"""Deletes arbitrary metadata on container."""
|
||||
url = str(container_name)
|
||||
headers = {}
|
||||
|
||||
|
||||
@@ -30,25 +30,25 @@ class ObjectClient(RestClient):
|
||||
self.service = self.config.object_storage.catalog_type
|
||||
|
||||
def create_object(self, container, object_name, data):
|
||||
"""Create storage object"""
|
||||
"""Create storage object."""
|
||||
|
||||
url = "%s/%s" % (str(container), str(object_name))
|
||||
resp, body = self.put(url, data, self.headers)
|
||||
return resp, body
|
||||
|
||||
def update_object(self, container, object_name, data):
|
||||
"""Upload data to replace current storage object"""
|
||||
"""Upload data to replace current storage object."""
|
||||
return create_object(container, object_name, data)
|
||||
|
||||
def delete_object(self, container, object_name):
|
||||
"""Delete storage object"""
|
||||
"""Delete storage object."""
|
||||
url = "%s/%s" % (str(container), str(object_name))
|
||||
resp, body = self.delete(url)
|
||||
return resp, body
|
||||
|
||||
def update_object_metadata(self, container, object_name, metadata,
|
||||
metadata_prefix='X-Object-Meta-'):
|
||||
"""Add, remove, or change X-Object-Meta metadata for storage object"""
|
||||
"""Add, remove, or change X-Object-Meta metadata for storage object."""
|
||||
|
||||
headers = {}
|
||||
for key in metadata:
|
||||
@@ -59,7 +59,7 @@ class ObjectClient(RestClient):
|
||||
return resp, body
|
||||
|
||||
def list_object_metadata(self, container, object_name):
|
||||
"""List all storage object X-Object-Meta- metadata"""
|
||||
"""List all storage object X-Object-Meta- metadata."""
|
||||
|
||||
url = "%s/%s" % (str(container), str(object_name))
|
||||
resp, body = self.head(url)
|
||||
@@ -74,7 +74,7 @@ class ObjectClient(RestClient):
|
||||
|
||||
def copy_object_in_same_container(self, container, src_object_name,
|
||||
dest_object_name, metadata=None):
|
||||
"""Copy storage object's data to the new object using PUT"""
|
||||
"""Copy storage object's data to the new object using PUT."""
|
||||
|
||||
url = "{0}/{1}".format(container, dest_object_name)
|
||||
headers = {}
|
||||
@@ -91,7 +91,7 @@ class ObjectClient(RestClient):
|
||||
def copy_object_across_containers(self, src_container, src_object_name,
|
||||
dst_container, dst_object_name,
|
||||
metadata=None):
|
||||
"""Copy storage object's data to the new object using PUT"""
|
||||
"""Copy storage object's data to the new object using PUT."""
|
||||
|
||||
url = "{0}/{1}".format(dst_container, dst_object_name)
|
||||
headers = {}
|
||||
@@ -107,7 +107,7 @@ class ObjectClient(RestClient):
|
||||
|
||||
def copy_object_2d_way(self, container, src_object_name, dest_object_name,
|
||||
metadata=None):
|
||||
"""Copy storage object's data to the new object using COPY"""
|
||||
"""Copy storage object's data to the new object using COPY."""
|
||||
|
||||
url = "{0}/{1}".format(container, src_object_name)
|
||||
headers = {}
|
||||
@@ -161,7 +161,7 @@ class ObjectClientCustomizedHeader(RestClient):
|
||||
return resp, body
|
||||
|
||||
def create_object(self, container, object_name, data, metadata=None):
|
||||
"""Create storage object"""
|
||||
"""Create storage object."""
|
||||
|
||||
headers = {}
|
||||
if metadata:
|
||||
@@ -173,7 +173,7 @@ class ObjectClientCustomizedHeader(RestClient):
|
||||
return resp, body
|
||||
|
||||
def delete_object(self, container, object_name):
|
||||
"""Delete storage object"""
|
||||
"""Delete storage object."""
|
||||
|
||||
url = "%s/%s" % (str(container), str(object_name))
|
||||
resp, body = self.delete(url)
|
||||
|
||||
@@ -35,7 +35,7 @@ class VolumeTypesClientJSON(RestClient):
|
||||
self.build_timeout = self.config.volume.build_timeout
|
||||
|
||||
def list_volume_types(self, params=None):
|
||||
"""List all the volume_types created"""
|
||||
"""List all the volume_types created."""
|
||||
url = 'types'
|
||||
if params is not None:
|
||||
url += '?%s' % urllib.urlencode(params)
|
||||
@@ -45,7 +45,7 @@ class VolumeTypesClientJSON(RestClient):
|
||||
return resp, body['volume_types']
|
||||
|
||||
def get_volume_type(self, volume_id):
|
||||
"""Returns the details of a single volume_type"""
|
||||
"""Returns the details of a single volume_type."""
|
||||
url = "types/%s" % str(volume_id)
|
||||
resp, body = self.get(url)
|
||||
body = json.loads(body)
|
||||
@@ -69,11 +69,11 @@ class VolumeTypesClientJSON(RestClient):
|
||||
return resp, body['volume_type']
|
||||
|
||||
def delete_volume_type(self, volume_id):
|
||||
"""Deletes the Specified Volume_type"""
|
||||
"""Deletes the Specified Volume_type."""
|
||||
return self.delete("types/%s" % str(volume_id))
|
||||
|
||||
def list_volume_types_extra_specs(self, vol_type_id, params=None):
|
||||
"""List all the volume_types extra specs created"""
|
||||
"""List all the volume_types extra specs created."""
|
||||
url = 'types/%s/extra_specs' % str(vol_type_id)
|
||||
if params is not None:
|
||||
url += '?%s' % urllib.urlencode(params)
|
||||
@@ -83,7 +83,7 @@ class VolumeTypesClientJSON(RestClient):
|
||||
return resp, body['extra_specs']
|
||||
|
||||
def get_volume_type_extra_specs(self, vol_type_id, extra_spec_name):
|
||||
"""Returns the details of a single volume_type extra spec"""
|
||||
"""Returns the details of a single volume_type extra spec."""
|
||||
url = "types/%s/extra_specs/%s" % (str(vol_type_id),
|
||||
str(extra_spec_name))
|
||||
resp, body = self.get(url)
|
||||
@@ -103,7 +103,7 @@ class VolumeTypesClientJSON(RestClient):
|
||||
return resp, body['extra_specs']
|
||||
|
||||
def delete_volume_type_extra_specs(self, vol_id, extra_spec_name):
|
||||
"""Deletes the Specified Volume_type extra spec"""
|
||||
"""Deletes the Specified Volume_type extra spec."""
|
||||
return self.delete("types/%s/extra_specs/%s" % ((str(vol_id)),
|
||||
str(extra_spec_name)))
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class VolumesClientJSON(RestClient):
|
||||
self.build_timeout = self.config.volume.build_timeout
|
||||
|
||||
def list_volumes(self, params=None):
|
||||
"""List all the volumes created"""
|
||||
"""List all the volumes created."""
|
||||
url = 'volumes'
|
||||
if params:
|
||||
url += '?%s' % urllib.urlencode(params)
|
||||
@@ -47,7 +47,7 @@ class VolumesClientJSON(RestClient):
|
||||
return resp, body['volumes']
|
||||
|
||||
def list_volumes_with_detail(self, params=None):
|
||||
"""List the details of all volumes"""
|
||||
"""List the details of all volumes."""
|
||||
url = 'volumes/detail'
|
||||
if params:
|
||||
url += '?%s' % urllib.urlencode(params)
|
||||
@@ -57,7 +57,7 @@ class VolumesClientJSON(RestClient):
|
||||
return resp, body['volumes']
|
||||
|
||||
def get_volume(self, volume_id, wait=None):
|
||||
"""Returns the details of a single volume"""
|
||||
"""Returns the details of a single volume."""
|
||||
url = "volumes/%s" % str(volume_id)
|
||||
resp, body = self.get(url, wait=wait)
|
||||
body = json.loads(body)
|
||||
@@ -85,11 +85,11 @@ class VolumesClientJSON(RestClient):
|
||||
return resp, body['volume']
|
||||
|
||||
def delete_volume(self, volume_id):
|
||||
"""Deletes the Specified Volume"""
|
||||
"""Deletes the Specified Volume."""
|
||||
return self.delete("volumes/%s" % str(volume_id))
|
||||
|
||||
def attach_volume(self, volume_id, instance_uuid, mountpoint):
|
||||
"""Attaches a volume to a given instance on a given mountpoint"""
|
||||
"""Attaches a volume to a given instance on a given mountpoint."""
|
||||
post_body = {
|
||||
'instance_uuid': instance_uuid,
|
||||
'mountpoint': mountpoint,
|
||||
@@ -100,7 +100,7 @@ class VolumesClientJSON(RestClient):
|
||||
return resp, body
|
||||
|
||||
def detach_volume(self, volume_id):
|
||||
"""Detaches a volume from an instance"""
|
||||
"""Detaches a volume from an instance."""
|
||||
post_body = {}
|
||||
post_body = json.dumps({'os-detach': post_body})
|
||||
url = 'volumes/%s/action' % (volume_id)
|
||||
@@ -108,7 +108,7 @@ class VolumesClientJSON(RestClient):
|
||||
return resp, body
|
||||
|
||||
def wait_for_volume_status(self, volume_id, status):
|
||||
"""Waits for a Volume to reach a given status"""
|
||||
"""Waits for a Volume to reach a given status."""
|
||||
resp, body = self.get_volume(volume_id)
|
||||
volume_name = body['display_name']
|
||||
volume_status = body['status']
|
||||
|
||||
@@ -67,7 +67,7 @@ class VolumeTypesClientXML(RestClientXML):
|
||||
return extra_spec
|
||||
|
||||
def list_volume_types(self, params=None):
|
||||
"""List all the volume_types created"""
|
||||
"""List all the volume_types created."""
|
||||
url = 'types'
|
||||
if params:
|
||||
url += '?%s' % urllib.urlencode(params)
|
||||
@@ -81,7 +81,7 @@ class VolumeTypesClientXML(RestClientXML):
|
||||
return resp, volume_types
|
||||
|
||||
def get_volume_type(self, type_id):
|
||||
"""Returns the details of a single volume_type"""
|
||||
"""Returns the details of a single volume_type."""
|
||||
url = "types/%s" % str(type_id)
|
||||
resp, body = self.get(url, self.headers)
|
||||
body = etree.fromstring(body)
|
||||
@@ -114,11 +114,11 @@ class VolumeTypesClientXML(RestClientXML):
|
||||
return resp, body
|
||||
|
||||
def delete_volume_type(self, type_id):
|
||||
"""Deletes the Specified Volume_type"""
|
||||
"""Deletes the Specified Volume_type."""
|
||||
return self.delete("types/%s" % str(type_id))
|
||||
|
||||
def list_volume_types_extra_specs(self, vol_type_id, params=None):
|
||||
"""List all the volume_types extra specs created"""
|
||||
"""List all the volume_types extra specs created."""
|
||||
url = 'types/%s/extra_specs' % str(vol_type_id)
|
||||
|
||||
if params:
|
||||
@@ -133,7 +133,7 @@ class VolumeTypesClientXML(RestClientXML):
|
||||
return resp, extra_specs
|
||||
|
||||
def get_volume_type_extra_specs(self, vol_type_id, extra_spec_name):
|
||||
"""Returns the details of a single volume_type extra spec"""
|
||||
"""Returns the details of a single volume_type extra spec."""
|
||||
url = "types/%s/extra_specs/%s" % (str(vol_type_id),
|
||||
str(extra_spec_name))
|
||||
resp, body = self.get(url, self.headers)
|
||||
@@ -161,7 +161,7 @@ class VolumeTypesClientXML(RestClientXML):
|
||||
return resp, body
|
||||
|
||||
def delete_volume_type_extra_specs(self, vol_id, extra_spec_name):
|
||||
"""Deletes the Specified Volume_type extra spec"""
|
||||
"""Deletes the Specified Volume_type extra spec."""
|
||||
return self.delete("types/%s/extra_specs/%s" % ((str(vol_id)),
|
||||
str(extra_spec_name)))
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ class VolumesClientXML(RestClientXML):
|
||||
return vol
|
||||
|
||||
def list_volumes(self, params=None):
|
||||
"""List all the volumes created"""
|
||||
"""List all the volumes created."""
|
||||
url = 'volumes'
|
||||
|
||||
if params:
|
||||
@@ -70,7 +70,7 @@ class VolumesClientXML(RestClientXML):
|
||||
return resp, volumes
|
||||
|
||||
def list_volumes_with_detail(self, params=None):
|
||||
"""List all the details of volumes"""
|
||||
"""List all the details of volumes."""
|
||||
url = 'volumes/detail'
|
||||
|
||||
if params:
|
||||
@@ -84,7 +84,7 @@ class VolumesClientXML(RestClientXML):
|
||||
return resp, volumes
|
||||
|
||||
def get_volume(self, volume_id, wait=None):
|
||||
"""Returns the details of a single volume"""
|
||||
"""Returns the details of a single volume."""
|
||||
url = "volumes/%s" % str(volume_id)
|
||||
resp, body = self.get(url, self.headers, wait=wait)
|
||||
body = etree.fromstring(body)
|
||||
@@ -116,11 +116,11 @@ class VolumesClientXML(RestClientXML):
|
||||
return resp, body
|
||||
|
||||
def delete_volume(self, volume_id):
|
||||
"""Deletes the Specified Volume"""
|
||||
"""Deletes the Specified Volume."""
|
||||
return self.delete("volumes/%s" % str(volume_id))
|
||||
|
||||
def wait_for_volume_status(self, volume_id, status):
|
||||
"""Waits for a Volume to reach a given status"""
|
||||
"""Waits for a Volume to reach a given status."""
|
||||
resp, body = self.get_volume(volume_id)
|
||||
volume_name = body['displayName']
|
||||
volume_status = body['status']
|
||||
|
||||
+5
-5
@@ -122,7 +122,7 @@ def friendly_function_call_str(call_able, *args, **kwargs):
|
||||
|
||||
|
||||
class BotoTestCase(unittest.TestCase):
|
||||
"""Recommended to use as base class for boto related test"""
|
||||
"""Recommended to use as base class for boto related test."""
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
# The trash contains cleanup functions and paramaters in tuples
|
||||
@@ -148,7 +148,7 @@ class BotoTestCase(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def cancelResourceCleanUp(cls, key):
|
||||
"""Cancel Clean up request"""
|
||||
"""Cancel Clean up request."""
|
||||
del cls._resource_trash_bin[key]
|
||||
|
||||
#TODO(afazekas): Add "with" context handling
|
||||
@@ -293,7 +293,7 @@ class BotoTestCase(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def destroy_bucket(cls, connection_data, bucket):
|
||||
"""Destroys the bucket and its content, just for teardown"""
|
||||
"""Destroys the bucket and its content, just for teardown."""
|
||||
exc_num = 0
|
||||
try:
|
||||
with closing(boto.connect_s3(**connection_data)) as conn:
|
||||
@@ -316,7 +316,7 @@ class BotoTestCase(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def destroy_reservation(cls, reservation):
|
||||
"""Terminate instances in a reservation, just for teardown"""
|
||||
"""Terminate instances in a reservation, just for teardown."""
|
||||
exc_num = 0
|
||||
|
||||
def _instance_state():
|
||||
@@ -383,7 +383,7 @@ class BotoTestCase(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def destroy_snapshot_wait(cls, snapshot):
|
||||
"""delete snaphot, wait until not exists"""
|
||||
"""delete snaphot, wait until not exists."""
|
||||
snapshot.delete()
|
||||
|
||||
def _update():
|
||||
|
||||
@@ -62,7 +62,7 @@ def state_wait(lfunction, final_set=set(), valid_set=None):
|
||||
|
||||
|
||||
def re_search_wait(lfunction, regexp):
|
||||
"""Stops waiting on success"""
|
||||
"""Stops waiting on success."""
|
||||
start_time = time.time()
|
||||
while True:
|
||||
text = lfunction()
|
||||
@@ -84,7 +84,7 @@ def re_search_wait(lfunction, regexp):
|
||||
|
||||
|
||||
def wait_no_exception(lfunction, exc_class=None, exc_matcher=None):
|
||||
"""Stops waiting on success"""
|
||||
"""Stops waiting on success."""
|
||||
start_time = time.time()
|
||||
if exc_matcher is not None:
|
||||
exc_class = BotoServerError
|
||||
@@ -114,7 +114,7 @@ def wait_no_exception(lfunction, exc_class=None, exc_matcher=None):
|
||||
|
||||
#NOTE(afazekas): EC2/boto normally raise exception instead of empty list
|
||||
def wait_exception(lfunction):
|
||||
"""Returns with the exception or raises one"""
|
||||
"""Returns with the exception or raises one."""
|
||||
start_time = time.time()
|
||||
while True:
|
||||
try:
|
||||
|
||||
@@ -34,7 +34,7 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
class BaseCompTest(unittest.TestCase):
|
||||
|
||||
"""Base test case class for all Compute API tests"""
|
||||
"""Base test case class for all Compute API tests."""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
@@ -179,7 +179,7 @@ class BaseCompTest(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def create_server(cls, image_id=None, flavor=None):
|
||||
"""Wrapper utility that returns a test server"""
|
||||
"""Wrapper utility that returns a test server."""
|
||||
server_name = rand_name(cls.__name__ + "-instance")
|
||||
|
||||
if not flavor:
|
||||
@@ -212,7 +212,7 @@ class BaseCompTest(unittest.TestCase):
|
||||
return resp, server
|
||||
|
||||
def wait_for(self, condition):
|
||||
"""Repeatedly calls condition() until a timeout"""
|
||||
"""Repeatedly calls condition() until a timeout."""
|
||||
start_time = int(time.time())
|
||||
while True:
|
||||
try:
|
||||
@@ -246,7 +246,7 @@ class BaseComputeTestXML(BaseCompTest):
|
||||
|
||||
class BaseComputeAdminTest(unittest.TestCase):
|
||||
|
||||
"""Base test case class for all Compute Admin API tests"""
|
||||
"""Base test case class for all Compute Admin API tests."""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
||||
@@ -31,7 +31,7 @@ from tempest.tests.compute import base
|
||||
class ImagesTestBase(object):
|
||||
|
||||
def tearDown(self):
|
||||
"""Terminate test instances created after a test is executed"""
|
||||
"""Terminate test instances created after a test is executed."""
|
||||
for server in self.servers:
|
||||
resp, body = self.servers_client.delete_server(server['id'])
|
||||
if resp['status'] == '204':
|
||||
|
||||
@@ -36,7 +36,7 @@ class ImagesWhiteboxTest(whitebox.ComputeWhiteboxTest, base.BaseComputeTest):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
"""Terminate test instances created after a test is executed"""
|
||||
"""Terminate test instances created after a test is executed."""
|
||||
|
||||
for server in cls.servers:
|
||||
cls.update_state(server['id'], "active", None)
|
||||
@@ -51,7 +51,7 @@ class ImagesWhiteboxTest(whitebox.ComputeWhiteboxTest, base.BaseComputeTest):
|
||||
|
||||
@classmethod
|
||||
def update_state(self, server_id, vm_state, task_state, deleted=False):
|
||||
"""Update states of an instance in database for validation"""
|
||||
"""Update states of an instance in database for validation."""
|
||||
if not task_state:
|
||||
task_state = "NULL"
|
||||
|
||||
@@ -64,7 +64,7 @@ class ImagesWhiteboxTest(whitebox.ComputeWhiteboxTest, base.BaseComputeTest):
|
||||
self.connection.execute(stmt, autocommit=True)
|
||||
|
||||
def _test_create_image_409_base(self, vm_state, task_state, deleted=False):
|
||||
"""Base method for create image tests based on vm and task states"""
|
||||
"""Base method for create image tests based on vm and task states."""
|
||||
try:
|
||||
self.update_state(self.shared_server['id'], vm_state,
|
||||
task_state, deleted)
|
||||
|
||||
@@ -117,7 +117,7 @@ class ServersWhiteboxTest(whitebox.ComputeWhiteboxTest):
|
||||
self.connection.execute(stmt, autocommit=True)
|
||||
|
||||
def update_state(self, server_id, vm_state, task_state, deleted=False):
|
||||
"""Update states of an instance in database for validation"""
|
||||
"""Update states of an instance in database for validation."""
|
||||
if not task_state:
|
||||
task_state = 'NULL'
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ class DataGenerator(object):
|
||||
self.role_name = None
|
||||
|
||||
def setup_test_user(self):
|
||||
"""Set up a test user"""
|
||||
"""Set up a test user."""
|
||||
self.setup_test_tenant()
|
||||
self.test_user = rand_name('test_user_')
|
||||
self.test_password = rand_name('pass_')
|
||||
@@ -107,7 +107,7 @@ class DataGenerator(object):
|
||||
self.users.append(self.user)
|
||||
|
||||
def setup_test_tenant(self):
|
||||
"""Set up a test tenant"""
|
||||
"""Set up a test tenant."""
|
||||
self.test_tenant = rand_name('test_tenant_')
|
||||
self.test_description = rand_name('desc_')
|
||||
resp, self.tenant = self.client.create_tenant(
|
||||
@@ -116,7 +116,7 @@ class DataGenerator(object):
|
||||
self.tenants.append(self.tenant)
|
||||
|
||||
def setup_test_role(self):
|
||||
"""Set up a test role"""
|
||||
"""Set up a test role."""
|
||||
self.test_role = rand_name('role')
|
||||
resp, self.role = self.client.create_role(self.test_role)
|
||||
self.roles.append(self.role)
|
||||
|
||||
@@ -48,7 +48,7 @@ class BaseNetworkTest(unittest.TestCase):
|
||||
cls.client.delete_network(network['id'])
|
||||
|
||||
def create_network(self, network_name=None):
|
||||
"""Wrapper utility that returns a test network"""
|
||||
"""Wrapper utility that returns a test network."""
|
||||
network_name = network_name or rand_name('test-network')
|
||||
|
||||
resp, body = self.client.create_network(network_name)
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""Common utilities used in testing"""
|
||||
"""Common utilities used in testing."""
|
||||
|
||||
import nose.plugins.skip
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ from tempest.tests.volume.base import BaseVolumeTest
|
||||
|
||||
|
||||
class BaseVolumeAdminTest(BaseVolumeTest):
|
||||
"""Base test case class for all Volume Admin API tests"""
|
||||
"""Base test case class for all Volume Admin API tests."""
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(BaseVolumeAdminTest, cls).setUpClass()
|
||||
|
||||
@@ -31,7 +31,7 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
class BaseVolumeTest(unittest.TestCase):
|
||||
|
||||
"""Base test case class for all Cinder API tests"""
|
||||
"""Base test case class for all Cinder API tests."""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
@@ -122,7 +122,7 @@ class BaseVolumeTest(unittest.TestCase):
|
||||
cls.clear_isolated_creds()
|
||||
|
||||
def create_volume(self, size=1, metadata={}):
|
||||
"""Wrapper utility that returns a test volume"""
|
||||
"""Wrapper utility that returns a test volume."""
|
||||
display_name = rand_name(self.__class__.__name__ + "-volume")
|
||||
cli_resp = self.volumes_client.create_volume(size=size,
|
||||
display_name=display_name,
|
||||
@@ -133,7 +133,7 @@ class BaseVolumeTest(unittest.TestCase):
|
||||
return volume
|
||||
|
||||
def wait_for(self, condition):
|
||||
"""Repeatedly calls condition() until a timeout"""
|
||||
"""Repeatedly calls condition() until a timeout."""
|
||||
start_time = int(time.time())
|
||||
while True:
|
||||
try:
|
||||
|
||||
+4
-4
@@ -106,7 +106,7 @@ class ComputeWhiteboxTest(test.ComputeFuzzClientTest, WhiteboxTest):
|
||||
|
||||
@classmethod
|
||||
def create_server(cls, image_id=None):
|
||||
"""Wrapper utility that returns a test server"""
|
||||
"""Wrapper utility that returns a test server."""
|
||||
server_name = rand_name(cls.__name__ + "-instance")
|
||||
flavor = cls.flavor_ref
|
||||
if not image_id:
|
||||
@@ -120,7 +120,7 @@ class ComputeWhiteboxTest(test.ComputeFuzzClientTest, WhiteboxTest):
|
||||
|
||||
@classmethod
|
||||
def get_db_handle_and_meta(cls, database='nova'):
|
||||
"""Return a connection handle and metadata of an OpenStack database"""
|
||||
"""Return a connection handle and metadata of an OpenStack database."""
|
||||
engine_args = {"echo": False,
|
||||
"convert_unicode": True,
|
||||
"pool_recycle": 3600
|
||||
@@ -138,7 +138,7 @@ class ComputeWhiteboxTest(test.ComputeFuzzClientTest, WhiteboxTest):
|
||||
return connection, meta
|
||||
|
||||
def nova_manage(self, category, action, params):
|
||||
"""Executes nova-manage command for the given action"""
|
||||
"""Executes nova-manage command for the given action."""
|
||||
|
||||
nova_manage_path = os.path.join(self.compute_bin_dir, 'nova-manage')
|
||||
cmd = ' '.join([nova_manage_path, category, action, params])
|
||||
@@ -161,7 +161,7 @@ class ComputeWhiteboxTest(test.ComputeFuzzClientTest, WhiteboxTest):
|
||||
return result
|
||||
|
||||
def get_ssh_connection(self, host, username, password):
|
||||
"""Create an SSH connection object to a host"""
|
||||
"""Create an SSH connection object to a host."""
|
||||
ssh_timeout = self.config.compute.ssh_timeout
|
||||
ssh_client = Client(host, username, password, ssh_timeout)
|
||||
if not ssh_client.test_connection_auth():
|
||||
|
||||
+2
-1
@@ -273,7 +273,8 @@ def tempest_docstring_start_space(physical_line):
|
||||
T401
|
||||
"""
|
||||
pos = max([physical_line.find(i) for i in DOCSTRING_TRIPLE]) # start
|
||||
if (pos != -1 and len(physical_line) > pos + 1):
|
||||
end = max([physical_line[-4:-1] == i for i in DOCSTRING_TRIPLE]) # end
|
||||
if (pos != -1 and end and len(physical_line) > pos + 4):
|
||||
if (physical_line[pos + 3] == ' '):
|
||||
return (pos, "T401: one line docstring should not start"
|
||||
" with a space")
|
||||
|
||||
@@ -15,4 +15,4 @@ commands = nosetests {posargs}
|
||||
|
||||
[testenv:pep8]
|
||||
deps = pep8==1.3.3
|
||||
commands = python tools/hacking.py --ignore=T401,T402,E122,E125,E126 --repeat --show-source --exclude=.venv,.tox,dist,doc,openstack,*egg .
|
||||
commands = python tools/hacking.py --ignore=E122,E125,E126 --repeat --show-source --exclude=.venv,.tox,dist,doc,openstack,*egg .
|
||||
|
||||
Reference in New Issue
Block a user