Fixes a variety of pep8 issues
Change-Id: Ifdb161262175ca705f256511a403785ec218be0a
This commit is contained in:
@@ -13,4 +13,3 @@ 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.
|
||||
"""
|
||||
|
||||
|
||||
@@ -13,4 +13,3 @@ 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.
|
||||
"""
|
||||
|
||||
|
||||
@@ -13,4 +13,3 @@ 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.
|
||||
"""
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
|
||||
class Constants:
|
||||
LAST_REBOOT_TIME_FORMAT = '%Y-%m-%d %H:%M'
|
||||
LAST_REBOOT_TIME_FORMAT_GENTOO = '%b %d %H:%M %Y'
|
||||
|
||||
@@ -64,10 +64,10 @@ def timestamp_string(prefix=None, suffix=None, decimal_precision=6):
|
||||
|
||||
|
||||
def random_string(prefix=None, suffix=None, size=8):
|
||||
'''
|
||||
"""
|
||||
Return exactly size bytes worth of base_text as a string
|
||||
surrounded by any defined pre or suf-fixes
|
||||
'''
|
||||
"""
|
||||
|
||||
base_text = str(uuid4()).replace('-', '0')
|
||||
|
||||
@@ -90,13 +90,14 @@ def random_string(prefix=None, suffix=None, size=8):
|
||||
body = str(body) + str(suffix) if suffix is not None else body
|
||||
return body
|
||||
|
||||
|
||||
def random_ip(pattern=None):
|
||||
'''
|
||||
"""
|
||||
Takes a pattern as a string in the format of #.#.#.# where a # is an
|
||||
integer, and a can be substituded with an * to produce a random octet.
|
||||
pattern = 127.0.0.* would return a random string between 127.0.0.1 and
|
||||
127.0.0.254
|
||||
'''
|
||||
"""
|
||||
if pattern is None:
|
||||
pattern = '*.*.*.*'
|
||||
num_asterisks = 0
|
||||
@@ -108,30 +109,37 @@ def random_ip(pattern=None):
|
||||
pattern = pattern.replace('*', str(item), 1)
|
||||
return pattern
|
||||
|
||||
|
||||
def random_cidr(ip_pattern=None, mask=None, min_mask=0, max_mask=30):
|
||||
'''
|
||||
"""
|
||||
Gets a random cidr using the random_ip function in this module. If mask
|
||||
is None then a random mask between 0 and 30 inclusive will be assigned.
|
||||
'''
|
||||
"""
|
||||
if mask is None:
|
||||
mask = random.randint(min_mask, max_mask)
|
||||
ip = random_ip(ip_pattern)
|
||||
return ''.join([ip, '/', str(mask)])
|
||||
|
||||
|
||||
def random_int(min_int, max_int):
|
||||
return random.randint(min_int, max_int)
|
||||
|
||||
|
||||
def rand_name(name='test'):
|
||||
return name + str(random.randint(99999, 1000000))
|
||||
|
||||
|
||||
def random_item_in_list(selection_list):
|
||||
return random.choice(selection_list)
|
||||
|
||||
|
||||
def bytes_to_gb(val):
|
||||
return float(val) / 1073741824
|
||||
|
||||
|
||||
def gb_to_bytes(val):
|
||||
return int(val * 1073741824)
|
||||
|
||||
|
||||
def bytes_to_mb(val):
|
||||
return float(val) / 1024
|
||||
|
||||
@@ -21,7 +21,7 @@ class EqualityTools:
|
||||
|
||||
@classmethod
|
||||
def are_not_equal(expected, actual):
|
||||
return expected != None and expected != actual
|
||||
return expected is not None and expected != actual
|
||||
|
||||
@classmethod
|
||||
def are_lists_equal(expected, actual):
|
||||
@@ -51,15 +51,15 @@ class EqualityTools:
|
||||
def are_objects_equal(cls, expected_object, actual_object,
|
||||
keys_to_exclude=[]):
|
||||
|
||||
if(expected_object is None and actual_object is None):
|
||||
if expected_object is None and actual_object is None:
|
||||
return True
|
||||
|
||||
if(expected_object is None or actual_object is None):
|
||||
if expected_object is None or actual_object is None:
|
||||
return False
|
||||
|
||||
for key, expected_value in expected_object.__dict__.items():
|
||||
if key not in keys_to_exclude \
|
||||
and expected_value != actual_object.__dict__[key]:
|
||||
if (key not in keys_to_exclude
|
||||
and expected_value != actual_object.__dict__[key]):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ class ExceptionHandler:
|
||||
if resp.status_code == 500 and type == 'html':
|
||||
raise exceptions.InternalServerError()
|
||||
|
||||
if (resp.status_code == 500) and (resp_body_dict == None):
|
||||
if resp.status_code == 500 and resp_body_dict is None:
|
||||
raise exceptions.ComputeFault(resp.reason)
|
||||
|
||||
if resp.status_code in (500, 501):
|
||||
@@ -95,14 +95,13 @@ class ExceptionHandler:
|
||||
raise exceptions.BadMediaType()
|
||||
|
||||
def _parse_resp_body(self, resp_body):
|
||||
#Try parsing as JSON
|
||||
|
||||
# Try parsing as JSON
|
||||
try:
|
||||
body = json.loads(resp_body)
|
||||
type = 'json'
|
||||
return body, type
|
||||
except:
|
||||
#Not JSON
|
||||
pass
|
||||
|
||||
# Try parsing as XML
|
||||
@@ -113,7 +112,6 @@ class ExceptionHandler:
|
||||
type = 'xml'
|
||||
return {element.tag: {'message': element.find('message').text}}, type
|
||||
except:
|
||||
#Not XML Either
|
||||
pass
|
||||
|
||||
# Parse as HTML
|
||||
|
||||
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
|
||||
class TimeoutException(Exception):
|
||||
"""Exception on timeout"""
|
||||
def __init__(self, message='Request timed out'):
|
||||
|
||||
@@ -13,4 +13,3 @@ 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.
|
||||
"""
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ class Links(AutoMarshallingModel):
|
||||
|
||||
@classmethod
|
||||
def _xml_ele_to_obj(cls, element):
|
||||
'''Helper method to turn ElementTree instance to Links instance.'''
|
||||
"""Helper method to turn ElementTree instance to Links instance."""
|
||||
links = []
|
||||
'''
|
||||
When we serialize a flavor object to XML, we generate an additional
|
||||
@@ -88,8 +88,10 @@ class Links(AutoMarshallingModel):
|
||||
|
||||
@classmethod
|
||||
def _json_to_obj(cls, serialized_str):
|
||||
'''Returns an instance of links based on the json
|
||||
serialized_str passed in.'''
|
||||
"""
|
||||
Returns an instance of links based on the json
|
||||
serialized_str passed in.
|
||||
"""
|
||||
json_dict = json.loads(serialized_str)
|
||||
if 'links' in json_dict.keys():
|
||||
links_list = json_dict['links']
|
||||
@@ -103,16 +105,15 @@ class Links(AutoMarshallingModel):
|
||||
@return: True if Links objects are equal, False otherwise
|
||||
@rtype: bool
|
||||
"""
|
||||
if(self is None and other is None):
|
||||
if self is None and other is None:
|
||||
return True
|
||||
|
||||
if(self is None or other is None):
|
||||
if self is None or other is None:
|
||||
return False
|
||||
|
||||
for key in self.links:
|
||||
# Alternate links are random, equality is impossible..ignoring it
|
||||
if key != 'alternate' and \
|
||||
self.links[key] != other.links[key]:
|
||||
if key != 'alternate' and self.links[key] != other.links[key]:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
@@ -23,9 +23,9 @@ from cloudcafe.compute.common.equality_tools import EqualityTools
|
||||
|
||||
|
||||
class MetadataItem(AutoMarshallingModel):
|
||||
'''
|
||||
"""
|
||||
@summary: MetadataItem Request/Response Object for Server/Image
|
||||
'''
|
||||
"""
|
||||
ROOT_TAG = 'meta'
|
||||
|
||||
def __init__(self, metadata_dict):
|
||||
@@ -51,10 +51,10 @@ class MetadataItem(AutoMarshallingModel):
|
||||
meta = {}
|
||||
for name in dir(meta_obj):
|
||||
value = getattr(meta_obj, name)
|
||||
if not name.startswith('_') and not name.startswith('RO') \
|
||||
and not name.startswith('deser') \
|
||||
and not name.startswith('sele') \
|
||||
and not name.startswith('seria'):
|
||||
if (not name.startswith('_') and not name.startswith('RO')
|
||||
and not name.startswith('deser')
|
||||
and not name.startswith('sele')
|
||||
and not name.startswith('seria')):
|
||||
meta[name] = value
|
||||
return meta
|
||||
|
||||
@@ -125,10 +125,10 @@ class Metadata(AutoMarshallingModel):
|
||||
element.set('xmlns', Constants.XML_API_NAMESPACE)
|
||||
for name in dir(self):
|
||||
value = getattr(self, name)
|
||||
if not name.startswith('_') and not name.startswith('RO') \
|
||||
and not name.startswith('deser') \
|
||||
and not name.startswith('sele') \
|
||||
and not name.startswith('seria'):
|
||||
if (not name.startswith('_') and not name.startswith('RO')
|
||||
and not name.startswith('deser')
|
||||
and not name.startswith('sele')
|
||||
and not name.startswith('seria')):
|
||||
element.append(self._dict_to_xml(key=name, value=value))
|
||||
xml += ET.tostring(element)
|
||||
return xml
|
||||
@@ -180,8 +180,10 @@ class Metadata(AutoMarshallingModel):
|
||||
|
||||
@classmethod
|
||||
def _json_to_obj(cls, serialized_str):
|
||||
'''Returns an instance of metadata based on the json
|
||||
serialized_str passed in.'''
|
||||
"""
|
||||
Returns an instance of metadata based on the json
|
||||
serialized_str passed in.
|
||||
"""
|
||||
json_dict = json.loads(serialized_str)
|
||||
if 'metadata' in json_dict.keys():
|
||||
metadata_dict = json_dict['metadata']
|
||||
@@ -192,11 +194,11 @@ class Metadata(AutoMarshallingModel):
|
||||
meta = {}
|
||||
for name in dir(meta_obj):
|
||||
value = getattr(meta_obj, name)
|
||||
if not name.startswith('_') \
|
||||
and not name.startswith('RO') \
|
||||
and not name.startswith('deser') \
|
||||
and not name.startswith('sele') \
|
||||
and not name.startswith('seria'):
|
||||
if (not name.startswith('_')
|
||||
and not name.startswith('RO')
|
||||
and not name.startswith('deser')
|
||||
and not name.startswith('sele')
|
||||
and not name.startswith('seria')):
|
||||
meta[name] = value
|
||||
return meta
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ limitations under the License.
|
||||
|
||||
|
||||
class NovaServerStatusTypes(object):
|
||||
'''
|
||||
"""
|
||||
@summary: Types dictating an individual Server Status
|
||||
@cvar ACTIVE: Server is active and available
|
||||
@type ACTIVE: C{str}
|
||||
@@ -25,7 +25,7 @@ class NovaServerStatusTypes(object):
|
||||
@cvar ERROR: Server is in error
|
||||
@type ERROR: C{str}
|
||||
@note: This is essentially an Enumerated Type
|
||||
'''
|
||||
"""
|
||||
ACTIVE = "ACTIVE"
|
||||
BUILD = "BUILD"
|
||||
REBUILD = "REBUILD"
|
||||
@@ -40,7 +40,7 @@ class NovaServerStatusTypes(object):
|
||||
|
||||
|
||||
class NovaImageStatusTypes(object):
|
||||
'''
|
||||
"""
|
||||
@summary: Types dictating an individual Server Status
|
||||
@cvar ACTIVE: Server is active and available
|
||||
@type ACTIVE: C{str}
|
||||
@@ -49,7 +49,7 @@ class NovaImageStatusTypes(object):
|
||||
@cvar ERROR: Server is in error
|
||||
@type ERROR: C{str}
|
||||
@note: This is essentially an Enumerated Type
|
||||
'''
|
||||
"""
|
||||
ACTIVE = "ACTIVE"
|
||||
SAVING = "SAVING"
|
||||
ERROR = "ERROR"
|
||||
@@ -58,20 +58,20 @@ class NovaImageStatusTypes(object):
|
||||
|
||||
|
||||
class NovaServerRebootTypes(object):
|
||||
'''
|
||||
"""
|
||||
@summary: Types dictating server reboot types
|
||||
@cvar HARD: Hard reboot
|
||||
@type HARD: C{str}
|
||||
@cvar SOFT: Soft reboot
|
||||
@type SOFT: C{str}
|
||||
@note: This is essentially an Enumerated Type
|
||||
'''
|
||||
"""
|
||||
HARD = "HARD"
|
||||
SOFT = "SOFT"
|
||||
|
||||
|
||||
class NovaVolumeStatusTypes(object):
|
||||
'''
|
||||
"""
|
||||
@summary: Types dictating an individual Volume Status
|
||||
@cvar AVAILABLE: Volume is active and available
|
||||
@type AVAILABLE: C{str}
|
||||
@@ -86,7 +86,7 @@ class NovaVolumeStatusTypes(object):
|
||||
@cvar IN_USE: Volume is active and available
|
||||
@type IN_USE: C{str}
|
||||
@note: This is essentially an Enumerated Type
|
||||
'''
|
||||
"""
|
||||
AVAILABLE = "available"
|
||||
ATTACHING = "attaching"
|
||||
CREATING = "creating"
|
||||
|
||||
@@ -33,4 +33,3 @@ class ComputeEndpointConfig(ConfigSectionInterface):
|
||||
class ComputeAdminEndpointConfig(ComputeEndpointConfig):
|
||||
|
||||
SECTION_NAME = 'compute_admin_endpoint'
|
||||
|
||||
|
||||
@@ -13,4 +13,3 @@ 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.
|
||||
"""
|
||||
|
||||
|
||||
@@ -13,4 +13,3 @@ 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.
|
||||
"""
|
||||
|
||||
|
||||
@@ -13,4 +13,3 @@ 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.
|
||||
"""
|
||||
|
||||
|
||||
@@ -13,4 +13,3 @@ 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.
|
||||
"""
|
||||
|
||||
|
||||
@@ -13,4 +13,3 @@ 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.
|
||||
"""
|
||||
|
||||
|
||||
@@ -13,4 +13,3 @@ 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.
|
||||
"""
|
||||
|
||||
|
||||
@@ -13,4 +13,3 @@ 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.
|
||||
"""
|
||||
|
||||
|
||||
@@ -13,4 +13,3 @@ 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.
|
||||
"""
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ class Keypair(AutoMarshallingModel):
|
||||
self.name = name
|
||||
self.fingerprint = fingerprint
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
values = []
|
||||
for prop in self.__dict__:
|
||||
@@ -76,6 +75,7 @@ class Keypair(AutoMarshallingModel):
|
||||
"""
|
||||
return not self == other
|
||||
|
||||
|
||||
class Keypairs(Keypair):
|
||||
|
||||
ROOT_TAG = 'keypairs'
|
||||
|
||||
@@ -13,4 +13,3 @@ 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.
|
||||
"""
|
||||
|
||||
|
||||
@@ -47,7 +47,6 @@ class RescueClient(AutoMarshallingRestClient):
|
||||
self.default_headers['Accept'] = accept
|
||||
self.url = url
|
||||
|
||||
|
||||
def rescue(self, server_id, requestslib_kwargs=None):
|
||||
self.server_id = server_id
|
||||
url = '%s/servers/%s/action' % (self.url, self.server_id)
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
"""
|
||||
Copyright 2013 Rackspace
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
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.
|
||||
"""
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
"""
|
||||
Copyright 2013 Rackspace
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
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.
|
||||
"""
|
||||
|
||||
import json
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
"""
|
||||
Copyright 2013 Rackspace
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
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.
|
||||
"""
|
||||
|
||||
import json
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
@@ -6,7 +22,6 @@ from cafe.engine.models.base import AutoMarshallingModel
|
||||
|
||||
class RescueResponse(AutoMarshallingModel):
|
||||
|
||||
|
||||
def __init__(self, admin_pass):
|
||||
self.admin_pass = admin_pass
|
||||
|
||||
|
||||
@@ -13,4 +13,3 @@ 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.
|
||||
"""
|
||||
|
||||
|
||||
@@ -33,8 +33,6 @@ class SecurityGroup(AutoMarshallingModel):
|
||||
self.id = id
|
||||
self.tenant_id = tenant_id
|
||||
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
values = []
|
||||
for prop in self.__dict__:
|
||||
|
||||
@@ -13,4 +13,3 @@ 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.
|
||||
"""
|
||||
|
||||
|
||||
@@ -66,15 +66,14 @@ class FlavorsClient(AutoMarshallingRestClient):
|
||||
requestslib_kwargs=requestslib_kwargs)
|
||||
return resp
|
||||
|
||||
|
||||
def list_flavors(self, min_disk=None, min_ram=None, marker=None,
|
||||
limit=None, requestslib_kwargs=None):
|
||||
'''
|
||||
@summary: Returns a list of flavors
|
||||
@param min_disk: min Disk in GB, to filter by minimum Disk size in MB
|
||||
@param min_disk: min Disk in GB, to filter by minimum disk size in GB
|
||||
@type min_disk: int
|
||||
@param min_ram: min ram in GB, to filter by minimum RAM size in MB
|
||||
@type min_Disk:int
|
||||
@type min_disk: int
|
||||
@param marker: ID of last item in previous list (paginated collections)
|
||||
@type marker:C{str}
|
||||
@param limit: Sets page size
|
||||
|
||||
@@ -65,9 +65,9 @@ class Flavor(AutoMarshallingModel):
|
||||
|
||||
def __init__(self, id=None, name=None, ram=None, disk=None, vcpus=None,
|
||||
swap=None, rxtx_factor=None, links=None):
|
||||
'''
|
||||
"""
|
||||
An object that represents a flavor.
|
||||
'''
|
||||
"""
|
||||
self.id = id
|
||||
self.name = name
|
||||
self.ram = ram
|
||||
@@ -83,8 +83,10 @@ class Flavor(AutoMarshallingModel):
|
||||
|
||||
@classmethod
|
||||
def _json_to_obj(cls, serialized_str):
|
||||
'''Returns an instance of a Flavor based on the json serialized_str
|
||||
passed in.'''
|
||||
"""
|
||||
Returns an instance of a Flavor based on the json serialized_str
|
||||
passed in.
|
||||
"""
|
||||
json_dict = json.loads(serialized_str)
|
||||
|
||||
if 'flavor' in json_dict.keys():
|
||||
@@ -100,7 +102,7 @@ class Flavor(AutoMarshallingModel):
|
||||
|
||||
@classmethod
|
||||
def _dict_to_obj(cls, flavor_dict):
|
||||
'''Helper method to turn dictionary into Server instance.'''
|
||||
"""Helper method to turn dictionary into Server instance."""
|
||||
flavor = Flavor(id=flavor_dict.get('id'),
|
||||
name=flavor_dict.get('name'),
|
||||
ram=flavor_dict.get('ram'),
|
||||
@@ -111,8 +113,10 @@ class Flavor(AutoMarshallingModel):
|
||||
|
||||
@classmethod
|
||||
def _xml_to_obj(cls, serialized_str):
|
||||
'''Returns an instance of a Flavor based on the xml serialized_str
|
||||
passed in.'''
|
||||
"""
|
||||
Returns an instance of a Flavor based on the xml serialized_str
|
||||
passed in.
|
||||
"""
|
||||
element = ET.fromstring(serialized_str)
|
||||
cls._remove_xml_etree_namespace(element, Constants.XML_API_NAMESPACE)
|
||||
cls._remove_xml_etree_namespace(element,
|
||||
@@ -131,7 +135,7 @@ class Flavor(AutoMarshallingModel):
|
||||
|
||||
@classmethod
|
||||
def _xml_ele_to_obj(cls, element):
|
||||
'''Helper method to turn ElementTree instance to Flavor instance.'''
|
||||
"""Helper method to turn ElementTree instance to Flavor instance."""
|
||||
flavor_dict = element.attrib
|
||||
if 'vcpus' in flavor_dict:
|
||||
flavor_dict['vcpus'] = (flavor_dict.get('vcpus') and
|
||||
@@ -182,7 +186,7 @@ class FlavorMin(Flavor):
|
||||
@summary: Represents minimum details of a flavor
|
||||
"""
|
||||
def __init__(self, **kwargs):
|
||||
'''Flavor Min has only id, name and links '''
|
||||
"""Flavor Min has only id, name and links"""
|
||||
for keys, values in kwargs.items():
|
||||
setattr(self, keys, values)
|
||||
|
||||
@@ -208,7 +212,7 @@ class FlavorMin(Flavor):
|
||||
|
||||
@classmethod
|
||||
def _xml_ele_to_obj(cls, element):
|
||||
'''Helper method to turn ElementTree instance to Server instance.'''
|
||||
"""Helper method to turn ElementTree instance to Server instance."""
|
||||
flavor_dict = element.attrib
|
||||
flavor_min = FlavorMin(id=flavor_dict.get('id'),
|
||||
name=flavor_dict.get('name'))
|
||||
@@ -217,7 +221,7 @@ class FlavorMin(Flavor):
|
||||
|
||||
@classmethod
|
||||
def _dict_to_obj(cls, flavor_dict):
|
||||
'''Helper method to turn dictionary into Server instance.'''
|
||||
"""Helper method to turn dictionary into Server instance."""
|
||||
flavor_min = FlavorMin(id=flavor_dict.get('id'),
|
||||
name=flavor_dict.get('name'))
|
||||
flavor_min.links = Links._dict_to_obj(flavor_dict['links'])
|
||||
|
||||
@@ -50,10 +50,10 @@ class ImagesClient(AutoMarshallingRestClient):
|
||||
self.url = url
|
||||
|
||||
def list_images(self, server_ref=None, image_name=None, status=None,
|
||||
image_type=None, marker=None, changes_since=None, limit=None,
|
||||
requestslib_kwargs=None):
|
||||
image_type=None, marker=None, changes_since=None,
|
||||
limit=None, requestslib_kwargs=None):
|
||||
|
||||
'''
|
||||
"""
|
||||
@summary: Lists IDs, names, and links for all available images.
|
||||
@param server_ref: Server id or Url to server
|
||||
@type server_ref: String
|
||||
@@ -71,7 +71,7 @@ class ImagesClient(AutoMarshallingRestClient):
|
||||
@type limit:int
|
||||
@return: lists all images visible by the account filtered by the params
|
||||
@rtype: Response with Image List as response.entity
|
||||
'''
|
||||
"""
|
||||
|
||||
url = '%s/images' % (self.url)
|
||||
|
||||
|
||||
@@ -308,7 +308,7 @@ class ServersClient(AutoMarshallingRestClient):
|
||||
admin_pass=None, disk_config=None, metadata=None,
|
||||
personality=None, accessIPv4=None, accessIPv6=None,
|
||||
requestslib_kwargs=None):
|
||||
'''
|
||||
"""
|
||||
@summary: Rebuilds the server
|
||||
@param server_id: The id of an existing server.
|
||||
@type server_id: String
|
||||
@@ -318,8 +318,8 @@ class ServersClient(AutoMarshallingRestClient):
|
||||
@type image_ref: String
|
||||
@param admin_pass:The administrator password
|
||||
@type admin_pass: String
|
||||
@param disk_config:The disk configuration value, which is AUTO or MANUAL
|
||||
@type disk_config: String(AUTO/MANUAL)
|
||||
@param disk_config: The disk configuration value (AUTO or MANUAL)
|
||||
@type disk_config: String
|
||||
@param metadata:A metadata key and value pair.
|
||||
@type metadata: Dictionary
|
||||
@param personality:The file path and file contents
|
||||
@@ -331,7 +331,7 @@ class ServersClient(AutoMarshallingRestClient):
|
||||
@return: Response Object containing response code and
|
||||
the server domain object
|
||||
@rtype: Response Object
|
||||
'''
|
||||
"""
|
||||
|
||||
self.server_id = server_id
|
||||
url = '%s/servers/%s/action' % (self.url, self.server_id)
|
||||
|
||||
@@ -475,6 +475,7 @@ class Unpause(AutoMarshallingModel):
|
||||
xml += ET.tostring(element)
|
||||
return xml
|
||||
|
||||
|
||||
class CreateImage(AutoMarshallingModel):
|
||||
'''
|
||||
Create Image Server Action Request Object
|
||||
|
||||
Reference in New Issue
Block a user