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
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
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
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
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
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class Constants:
|
class Constants:
|
||||||
LAST_REBOOT_TIME_FORMAT = '%Y-%m-%d %H:%M'
|
LAST_REBOOT_TIME_FORMAT = '%Y-%m-%d %H:%M'
|
||||||
LAST_REBOOT_TIME_FORMAT_GENTOO = '%b %d %H:%M %Y'
|
LAST_REBOOT_TIME_FORMAT_GENTOO = '%b %d %H:%M %Y'
|
||||||
|
|||||||
@@ -26,18 +26,18 @@ TEMP_LOCATION = '/tmp'
|
|||||||
#Binary prefixes
|
#Binary prefixes
|
||||||
#IEE_MAGNITUDE = int(pow(2,10))
|
#IEE_MAGNITUDE = int(pow(2,10))
|
||||||
EXACT_BYTE = 8
|
EXACT_BYTE = 8
|
||||||
EXACT_KIBIBYTE = int(pow(2,10))
|
EXACT_KIBIBYTE = int(pow(2, 10))
|
||||||
EXACT_MEBIBYTE = int(pow(2,20))
|
EXACT_MEBIBYTE = int(pow(2, 20))
|
||||||
EXACT_GIBIBYTE = int(pow(2,30))
|
EXACT_GIBIBYTE = int(pow(2, 30))
|
||||||
EXACT_TEBIBYTE = int(pow(2,40))
|
EXACT_TEBIBYTE = int(pow(2, 40))
|
||||||
|
|
||||||
#Decimal prefixes
|
#Decimal prefixes
|
||||||
#SI_MAGNITURE = int(pow(10,3))
|
#SI_MAGNITURE = int(pow(10,3))
|
||||||
|
|
||||||
EXACT_KILOBYTE = int(pow(10,3))
|
EXACT_KILOBYTE = int(pow(10, 3))
|
||||||
EXACT_MEGABYTE = int(pow(10,6))
|
EXACT_MEGABYTE = int(pow(10, 6))
|
||||||
EXACT_GIGABYTE = int(pow(10,9))
|
EXACT_GIGABYTE = int(pow(10, 9))
|
||||||
EXACT_TERABYTE = int(pow(10,12))
|
EXACT_TERABYTE = int(pow(10, 12))
|
||||||
|
|
||||||
|
|
||||||
def timestamp_string(prefix=None, suffix=None, decimal_precision=6):
|
def timestamp_string(prefix=None, suffix=None, decimal_precision=6):
|
||||||
@@ -48,7 +48,7 @@ def timestamp_string(prefix=None, suffix=None, decimal_precision=6):
|
|||||||
t = str('%f' % time.time())
|
t = str('%f' % time.time())
|
||||||
int_seconds, dec_seconds = t.split('.')
|
int_seconds, dec_seconds = t.split('.')
|
||||||
for x in range(6 - decimal_precision):
|
for x in range(6 - decimal_precision):
|
||||||
dec_seconds=dec_seconds[:-1]
|
dec_seconds = dec_seconds[:-1]
|
||||||
|
|
||||||
int_seconds = str(int_seconds)
|
int_seconds = str(int_seconds)
|
||||||
dec_seconds = str(dec_seconds)
|
dec_seconds = str(dec_seconds)
|
||||||
@@ -56,20 +56,20 @@ def timestamp_string(prefix=None, suffix=None, decimal_precision=6):
|
|||||||
suffix = suffix or ''
|
suffix = suffix or ''
|
||||||
final = None
|
final = None
|
||||||
if len(dec_seconds) > 0:
|
if len(dec_seconds) > 0:
|
||||||
final = '%s%s%s' % ( prefix, int_seconds, suffix)
|
final = '%s%s%s' % (prefix, int_seconds, suffix)
|
||||||
else:
|
else:
|
||||||
final = '%s%s.%s%s' % ( prefix, int_seconds, dec_seconds, suffix)
|
final = '%s%s.%s%s' % (prefix, int_seconds, dec_seconds, suffix)
|
||||||
|
|
||||||
return final
|
return final
|
||||||
|
|
||||||
|
|
||||||
def random_string(prefix=None, suffix=None, size=8):
|
def random_string(prefix=None, suffix=None, size=8):
|
||||||
'''
|
"""
|
||||||
Return exactly size bytes worth of base_text as a string
|
Return exactly size bytes worth of base_text as a string
|
||||||
surrounded by any defined pre or suf-fixes
|
surrounded by any defined pre or suf-fixes
|
||||||
'''
|
"""
|
||||||
|
|
||||||
base_text = str(uuid4()).replace('-','0')
|
base_text = str(uuid4()).replace('-', '0')
|
||||||
|
|
||||||
if size <= 0:
|
if size <= 0:
|
||||||
return '%s%s' % (prefix, suffix)
|
return '%s%s' % (prefix, suffix)
|
||||||
@@ -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
|
body = str(body) + str(suffix) if suffix is not None else body
|
||||||
return body
|
return body
|
||||||
|
|
||||||
|
|
||||||
def random_ip(pattern=None):
|
def random_ip(pattern=None):
|
||||||
'''
|
"""
|
||||||
Takes a pattern as a string in the format of #.#.#.# where a # is an
|
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.
|
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
|
pattern = 127.0.0.* would return a random string between 127.0.0.1 and
|
||||||
127.0.0.254
|
127.0.0.254
|
||||||
'''
|
"""
|
||||||
if pattern is None:
|
if pattern is None:
|
||||||
pattern = '*.*.*.*'
|
pattern = '*.*.*.*'
|
||||||
num_asterisks = 0
|
num_asterisks = 0
|
||||||
@@ -108,30 +109,37 @@ def random_ip(pattern=None):
|
|||||||
pattern = pattern.replace('*', str(item), 1)
|
pattern = pattern.replace('*', str(item), 1)
|
||||||
return pattern
|
return pattern
|
||||||
|
|
||||||
|
|
||||||
def random_cidr(ip_pattern=None, mask=None, min_mask=0, max_mask=30):
|
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
|
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.
|
is None then a random mask between 0 and 30 inclusive will be assigned.
|
||||||
'''
|
"""
|
||||||
if mask is None:
|
if mask is None:
|
||||||
mask = random.randint(min_mask, max_mask)
|
mask = random.randint(min_mask, max_mask)
|
||||||
ip = random_ip(ip_pattern)
|
ip = random_ip(ip_pattern)
|
||||||
return ''.join([ip, '/', str(mask)])
|
return ''.join([ip, '/', str(mask)])
|
||||||
|
|
||||||
|
|
||||||
def random_int(min_int, max_int):
|
def random_int(min_int, max_int):
|
||||||
return random.randint(min_int, max_int)
|
return random.randint(min_int, max_int)
|
||||||
|
|
||||||
|
|
||||||
def rand_name(name='test'):
|
def rand_name(name='test'):
|
||||||
return name + str(random.randint(99999, 1000000))
|
return name + str(random.randint(99999, 1000000))
|
||||||
|
|
||||||
|
|
||||||
def random_item_in_list(selection_list):
|
def random_item_in_list(selection_list):
|
||||||
return random.choice(selection_list)
|
return random.choice(selection_list)
|
||||||
|
|
||||||
|
|
||||||
def bytes_to_gb(val):
|
def bytes_to_gb(val):
|
||||||
return float(val) / 1073741824
|
return float(val) / 1073741824
|
||||||
|
|
||||||
|
|
||||||
def gb_to_bytes(val):
|
def gb_to_bytes(val):
|
||||||
return int(val * 1073741824)
|
return int(val * 1073741824)
|
||||||
|
|
||||||
|
|
||||||
def bytes_to_mb(val):
|
def bytes_to_mb(val):
|
||||||
return float(val) / 1024
|
return float(val) / 1024
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class EqualityTools:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def are_not_equal(expected, actual):
|
def are_not_equal(expected, actual):
|
||||||
return expected != None and expected != actual
|
return expected is not None and expected != actual
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def are_lists_equal(expected, actual):
|
def are_lists_equal(expected, actual):
|
||||||
@@ -51,15 +51,15 @@ class EqualityTools:
|
|||||||
def are_objects_equal(cls, expected_object, actual_object,
|
def are_objects_equal(cls, expected_object, actual_object,
|
||||||
keys_to_exclude=[]):
|
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
|
return True
|
||||||
|
|
||||||
if(expected_object is None or actual_object is None):
|
if expected_object is None or actual_object is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
for key, expected_value in expected_object.__dict__.items():
|
for key, expected_value in expected_object.__dict__.items():
|
||||||
if key not in keys_to_exclude \
|
if (key not in keys_to_exclude
|
||||||
and expected_value != actual_object.__dict__[key]:
|
and expected_value != actual_object.__dict__[key]):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class ExceptionHandler:
|
|||||||
if resp.status_code == 500 and type == 'html':
|
if resp.status_code == 500 and type == 'html':
|
||||||
raise exceptions.InternalServerError()
|
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)
|
raise exceptions.ComputeFault(resp.reason)
|
||||||
|
|
||||||
if resp.status_code in (500, 501):
|
if resp.status_code in (500, 501):
|
||||||
@@ -95,17 +95,16 @@ class ExceptionHandler:
|
|||||||
raise exceptions.BadMediaType()
|
raise exceptions.BadMediaType()
|
||||||
|
|
||||||
def _parse_resp_body(self, resp_body):
|
def _parse_resp_body(self, resp_body):
|
||||||
#Try parsing as JSON
|
|
||||||
|
|
||||||
|
# Try parsing as JSON
|
||||||
try:
|
try:
|
||||||
body = json.loads(resp_body)
|
body = json.loads(resp_body)
|
||||||
type = 'json'
|
type = 'json'
|
||||||
return body, type
|
return body, type
|
||||||
except:
|
except:
|
||||||
#Not JSON
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#Try parsing as XML
|
# Try parsing as XML
|
||||||
try:
|
try:
|
||||||
element = ET.fromstring(resp_body)
|
element = ET.fromstring(resp_body)
|
||||||
# Handle the case where the API returns the exception in HTML
|
# Handle the case where the API returns the exception in HTML
|
||||||
@@ -113,10 +112,9 @@ class ExceptionHandler:
|
|||||||
type = 'xml'
|
type = 'xml'
|
||||||
return {element.tag: {'message': element.find('message').text}}, type
|
return {element.tag: {'message': element.find('message').text}}, type
|
||||||
except:
|
except:
|
||||||
#Not XML Either
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#Parse as HTML
|
# Parse as HTML
|
||||||
finally:
|
finally:
|
||||||
split_resp = resp_body.split("\n\n")
|
split_resp = resp_body.split("\n\n")
|
||||||
type = 'html'
|
type = 'html'
|
||||||
|
|||||||
@@ -14,8 +14,9 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class TimeoutException(Exception):
|
class TimeoutException(Exception):
|
||||||
""" Exception on timeout """
|
"""Exception on timeout"""
|
||||||
def __init__(self, message='Request timed out'):
|
def __init__(self, message='Request timed out'):
|
||||||
self.message = message
|
self.message = message
|
||||||
|
|
||||||
@@ -24,7 +25,7 @@ class TimeoutException(Exception):
|
|||||||
|
|
||||||
|
|
||||||
class BuildErrorException(Exception):
|
class BuildErrorException(Exception):
|
||||||
""" Exception on server build """
|
"""Exception on server build"""
|
||||||
def __init__(self, message='Build Error'):
|
def __init__(self, message='Build Error'):
|
||||||
self.message = message
|
self.message = message
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class Links(AutoMarshallingModel):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _xml_ele_to_obj(cls, element):
|
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 = []
|
links = []
|
||||||
'''
|
'''
|
||||||
When we serialize a flavor object to XML, we generate an additional
|
When we serialize a flavor object to XML, we generate an additional
|
||||||
@@ -88,8 +88,10 @@ class Links(AutoMarshallingModel):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _json_to_obj(cls, serialized_str):
|
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)
|
json_dict = json.loads(serialized_str)
|
||||||
if 'links' in json_dict.keys():
|
if 'links' in json_dict.keys():
|
||||||
links_list = json_dict['links']
|
links_list = json_dict['links']
|
||||||
@@ -103,16 +105,15 @@ class Links(AutoMarshallingModel):
|
|||||||
@return: True if Links objects are equal, False otherwise
|
@return: True if Links objects are equal, False otherwise
|
||||||
@rtype: bool
|
@rtype: bool
|
||||||
"""
|
"""
|
||||||
if(self is None and other is None):
|
if self is None and other is None:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if(self is None or other is None):
|
if self is None or other is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
for key in self.links:
|
for key in self.links:
|
||||||
#Alternate links are random, equality is impossible..ignoring it
|
# Alternate links are random, equality is impossible..ignoring it
|
||||||
if key != 'alternate' and \
|
if key != 'alternate' and self.links[key] != other.links[key]:
|
||||||
self.links[key] != other.links[key]:
|
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ from cloudcafe.compute.common.equality_tools import EqualityTools
|
|||||||
|
|
||||||
|
|
||||||
class MetadataItem(AutoMarshallingModel):
|
class MetadataItem(AutoMarshallingModel):
|
||||||
'''
|
"""
|
||||||
@summary: MetadataItem Request/Response Object for Server/Image
|
@summary: MetadataItem Request/Response Object for Server/Image
|
||||||
'''
|
"""
|
||||||
ROOT_TAG = 'meta'
|
ROOT_TAG = 'meta'
|
||||||
|
|
||||||
def __init__(self, metadata_dict):
|
def __init__(self, metadata_dict):
|
||||||
@@ -51,10 +51,10 @@ class MetadataItem(AutoMarshallingModel):
|
|||||||
meta = {}
|
meta = {}
|
||||||
for name in dir(meta_obj):
|
for name in dir(meta_obj):
|
||||||
value = getattr(meta_obj, name)
|
value = getattr(meta_obj, name)
|
||||||
if not name.startswith('_') and not name.startswith('RO') \
|
if (not name.startswith('_') and not name.startswith('RO')
|
||||||
and not name.startswith('deser') \
|
and not name.startswith('deser')
|
||||||
and not name.startswith('sele') \
|
and not name.startswith('sele')
|
||||||
and not name.startswith('seria'):
|
and not name.startswith('seria')):
|
||||||
meta[name] = value
|
meta[name] = value
|
||||||
return meta
|
return meta
|
||||||
|
|
||||||
@@ -125,10 +125,10 @@ class Metadata(AutoMarshallingModel):
|
|||||||
element.set('xmlns', Constants.XML_API_NAMESPACE)
|
element.set('xmlns', Constants.XML_API_NAMESPACE)
|
||||||
for name in dir(self):
|
for name in dir(self):
|
||||||
value = getattr(self, name)
|
value = getattr(self, name)
|
||||||
if not name.startswith('_') and not name.startswith('RO') \
|
if (not name.startswith('_') and not name.startswith('RO')
|
||||||
and not name.startswith('deser') \
|
and not name.startswith('deser')
|
||||||
and not name.startswith('sele') \
|
and not name.startswith('sele')
|
||||||
and not name.startswith('seria'):
|
and not name.startswith('seria')):
|
||||||
element.append(self._dict_to_xml(key=name, value=value))
|
element.append(self._dict_to_xml(key=name, value=value))
|
||||||
xml += ET.tostring(element)
|
xml += ET.tostring(element)
|
||||||
return xml
|
return xml
|
||||||
@@ -180,8 +180,10 @@ class Metadata(AutoMarshallingModel):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _json_to_obj(cls, serialized_str):
|
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)
|
json_dict = json.loads(serialized_str)
|
||||||
if 'metadata' in json_dict.keys():
|
if 'metadata' in json_dict.keys():
|
||||||
metadata_dict = json_dict['metadata']
|
metadata_dict = json_dict['metadata']
|
||||||
@@ -192,11 +194,11 @@ class Metadata(AutoMarshallingModel):
|
|||||||
meta = {}
|
meta = {}
|
||||||
for name in dir(meta_obj):
|
for name in dir(meta_obj):
|
||||||
value = getattr(meta_obj, name)
|
value = getattr(meta_obj, name)
|
||||||
if not name.startswith('_') \
|
if (not name.startswith('_')
|
||||||
and not name.startswith('RO') \
|
and not name.startswith('RO')
|
||||||
and not name.startswith('deser') \
|
and not name.startswith('deser')
|
||||||
and not name.startswith('sele') \
|
and not name.startswith('sele')
|
||||||
and not name.startswith('seria'):
|
and not name.startswith('seria')):
|
||||||
meta[name] = value
|
meta[name] = value
|
||||||
return meta
|
return meta
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ limitations under the License.
|
|||||||
|
|
||||||
|
|
||||||
class NovaServerStatusTypes(object):
|
class NovaServerStatusTypes(object):
|
||||||
'''
|
"""
|
||||||
@summary: Types dictating an individual Server Status
|
@summary: Types dictating an individual Server Status
|
||||||
@cvar ACTIVE: Server is active and available
|
@cvar ACTIVE: Server is active and available
|
||||||
@type ACTIVE: C{str}
|
@type ACTIVE: C{str}
|
||||||
@@ -25,7 +25,7 @@ class NovaServerStatusTypes(object):
|
|||||||
@cvar ERROR: Server is in error
|
@cvar ERROR: Server is in error
|
||||||
@type ERROR: C{str}
|
@type ERROR: C{str}
|
||||||
@note: This is essentially an Enumerated Type
|
@note: This is essentially an Enumerated Type
|
||||||
'''
|
"""
|
||||||
ACTIVE = "ACTIVE"
|
ACTIVE = "ACTIVE"
|
||||||
BUILD = "BUILD"
|
BUILD = "BUILD"
|
||||||
REBUILD = "REBUILD"
|
REBUILD = "REBUILD"
|
||||||
@@ -40,7 +40,7 @@ class NovaServerStatusTypes(object):
|
|||||||
|
|
||||||
|
|
||||||
class NovaImageStatusTypes(object):
|
class NovaImageStatusTypes(object):
|
||||||
'''
|
"""
|
||||||
@summary: Types dictating an individual Server Status
|
@summary: Types dictating an individual Server Status
|
||||||
@cvar ACTIVE: Server is active and available
|
@cvar ACTIVE: Server is active and available
|
||||||
@type ACTIVE: C{str}
|
@type ACTIVE: C{str}
|
||||||
@@ -49,7 +49,7 @@ class NovaImageStatusTypes(object):
|
|||||||
@cvar ERROR: Server is in error
|
@cvar ERROR: Server is in error
|
||||||
@type ERROR: C{str}
|
@type ERROR: C{str}
|
||||||
@note: This is essentially an Enumerated Type
|
@note: This is essentially an Enumerated Type
|
||||||
'''
|
"""
|
||||||
ACTIVE = "ACTIVE"
|
ACTIVE = "ACTIVE"
|
||||||
SAVING = "SAVING"
|
SAVING = "SAVING"
|
||||||
ERROR = "ERROR"
|
ERROR = "ERROR"
|
||||||
@@ -58,20 +58,20 @@ class NovaImageStatusTypes(object):
|
|||||||
|
|
||||||
|
|
||||||
class NovaServerRebootTypes(object):
|
class NovaServerRebootTypes(object):
|
||||||
'''
|
"""
|
||||||
@summary: Types dictating server reboot types
|
@summary: Types dictating server reboot types
|
||||||
@cvar HARD: Hard reboot
|
@cvar HARD: Hard reboot
|
||||||
@type HARD: C{str}
|
@type HARD: C{str}
|
||||||
@cvar SOFT: Soft reboot
|
@cvar SOFT: Soft reboot
|
||||||
@type SOFT: C{str}
|
@type SOFT: C{str}
|
||||||
@note: This is essentially an Enumerated Type
|
@note: This is essentially an Enumerated Type
|
||||||
'''
|
"""
|
||||||
HARD = "HARD"
|
HARD = "HARD"
|
||||||
SOFT = "SOFT"
|
SOFT = "SOFT"
|
||||||
|
|
||||||
|
|
||||||
class NovaVolumeStatusTypes(object):
|
class NovaVolumeStatusTypes(object):
|
||||||
'''
|
"""
|
||||||
@summary: Types dictating an individual Volume Status
|
@summary: Types dictating an individual Volume Status
|
||||||
@cvar AVAILABLE: Volume is active and available
|
@cvar AVAILABLE: Volume is active and available
|
||||||
@type AVAILABLE: C{str}
|
@type AVAILABLE: C{str}
|
||||||
@@ -86,7 +86,7 @@ class NovaVolumeStatusTypes(object):
|
|||||||
@cvar IN_USE: Volume is active and available
|
@cvar IN_USE: Volume is active and available
|
||||||
@type IN_USE: C{str}
|
@type IN_USE: C{str}
|
||||||
@note: This is essentially an Enumerated Type
|
@note: This is essentially an Enumerated Type
|
||||||
'''
|
"""
|
||||||
AVAILABLE = "available"
|
AVAILABLE = "available"
|
||||||
ATTACHING = "attaching"
|
ATTACHING = "attaching"
|
||||||
CREATING = "creating"
|
CREATING = "creating"
|
||||||
|
|||||||
@@ -33,4 +33,3 @@ class ComputeEndpointConfig(ConfigSectionInterface):
|
|||||||
class ComputeAdminEndpointConfig(ComputeEndpointConfig):
|
class ComputeAdminEndpointConfig(ComputeEndpointConfig):
|
||||||
|
|
||||||
SECTION_NAME = 'compute_admin_endpoint'
|
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
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
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
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
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
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
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
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
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
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
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
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
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
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
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
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class KeypairsClient(AutoMarshallingRestClient):
|
|||||||
@type deserialize_format: String
|
@type deserialize_format: String
|
||||||
"""
|
"""
|
||||||
super(KeypairsClient, self).__init__(serialize_format,
|
super(KeypairsClient, self).__init__(serialize_format,
|
||||||
deserialize_format)
|
deserialize_format)
|
||||||
self.auth_token = auth_token
|
self.auth_token = auth_token
|
||||||
self.default_headers['X-Auth-Token'] = auth_token
|
self.default_headers['X-Auth-Token'] = auth_token
|
||||||
ct = ''.join(['application/', self.serialize_format])
|
ct = ''.join(['application/', self.serialize_format])
|
||||||
@@ -75,4 +75,4 @@ class KeypairsClient(AutoMarshallingRestClient):
|
|||||||
url = '%s/os-keypairs/%s' % (self.url, keypair_name)
|
url = '%s/os-keypairs/%s' % (self.url, keypair_name)
|
||||||
resp = self.request('DELETE', url,
|
resp = self.request('DELETE', url,
|
||||||
requestslib_kwargs=requestslib_kwargs)
|
requestslib_kwargs=requestslib_kwargs)
|
||||||
return resp
|
return resp
|
||||||
|
|||||||
@@ -12,4 +12,4 @@ distributed under the License is distributed on an "AS IS" BASIS,
|
|||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ class Keypair(AutoMarshallingModel):
|
|||||||
self.name = name
|
self.name = name
|
||||||
self.fingerprint = fingerprint
|
self.fingerprint = fingerprint
|
||||||
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
values = []
|
values = []
|
||||||
for prop in self.__dict__:
|
for prop in self.__dict__:
|
||||||
@@ -76,6 +75,7 @@ class Keypair(AutoMarshallingModel):
|
|||||||
"""
|
"""
|
||||||
return not self == other
|
return not self == other
|
||||||
|
|
||||||
|
|
||||||
class Keypairs(Keypair):
|
class Keypairs(Keypair):
|
||||||
|
|
||||||
ROOT_TAG = 'keypairs'
|
ROOT_TAG = 'keypairs'
|
||||||
|
|||||||
@@ -45,4 +45,4 @@ class CreateKeypair(AutoMarshallingModel):
|
|||||||
raise NotImplemented
|
raise NotImplemented
|
||||||
|
|
||||||
def _obj_to_xml_ele(self):
|
def _obj_to_xml_ele(self):
|
||||||
raise NotImplemented
|
raise NotImplemented
|
||||||
|
|||||||
@@ -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
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class RescueClient(AutoMarshallingRestClient):
|
|||||||
@type deserialize_format: String
|
@type deserialize_format: String
|
||||||
"""
|
"""
|
||||||
super(RescueClient, self).__init__(serialize_format,
|
super(RescueClient, self).__init__(serialize_format,
|
||||||
deserialize_format)
|
deserialize_format)
|
||||||
self.auth_token = auth_token
|
self.auth_token = auth_token
|
||||||
self.default_headers['X-Auth-Token'] = auth_token
|
self.default_headers['X-Auth-Token'] = auth_token
|
||||||
ct = ''.join(['application/', self.serialize_format])
|
ct = ''.join(['application/', self.serialize_format])
|
||||||
@@ -47,7 +47,6 @@ class RescueClient(AutoMarshallingRestClient):
|
|||||||
self.default_headers['Accept'] = accept
|
self.default_headers['Accept'] = accept
|
||||||
self.url = url
|
self.url = url
|
||||||
|
|
||||||
|
|
||||||
def rescue(self, server_id, requestslib_kwargs=None):
|
def rescue(self, server_id, requestslib_kwargs=None):
|
||||||
self.server_id = server_id
|
self.server_id = server_id
|
||||||
url = '%s/servers/%s/action' % (self.url, self.server_id)
|
url = '%s/servers/%s/action' % (self.url, self.server_id)
|
||||||
@@ -64,4 +63,4 @@ class RescueClient(AutoMarshallingRestClient):
|
|||||||
'POST', url, response_entity_type=Server,
|
'POST', url, response_entity_type=Server,
|
||||||
request_entity=ExitRescueMode(),
|
request_entity=ExitRescueMode(),
|
||||||
requestslib_kwargs=requestslib_kwargs)
|
requestslib_kwargs=requestslib_kwargs)
|
||||||
return resp
|
return resp
|
||||||
|
|||||||
@@ -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 json
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
@@ -32,4 +48,4 @@ class ExitRescueMode(AutoMarshallingModel):
|
|||||||
element = ET.Element(self.ROOT_TAG)
|
element = ET.Element(self.ROOT_TAG)
|
||||||
element.set('xmlns', Constants.XML_API_UNRESCUE)
|
element.set('xmlns', Constants.XML_API_UNRESCUE)
|
||||||
xml += ET.tostring(element)
|
xml += ET.tostring(element)
|
||||||
return xml
|
return xml
|
||||||
|
|||||||
@@ -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 json
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
@@ -6,7 +22,6 @@ from cafe.engine.models.base import AutoMarshallingModel
|
|||||||
|
|
||||||
class RescueResponse(AutoMarshallingModel):
|
class RescueResponse(AutoMarshallingModel):
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, admin_pass):
|
def __init__(self, admin_pass):
|
||||||
self.admin_pass = admin_pass
|
self.admin_pass = admin_pass
|
||||||
|
|
||||||
@@ -31,4 +46,4 @@ class RescueResponse(AutoMarshallingModel):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _xml_ele_to_obj(cls, xml_ele):
|
def _xml_ele_to_obj(cls, xml_ele):
|
||||||
raise NotImplemented
|
raise NotImplemented
|
||||||
|
|||||||
@@ -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
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class SecurityGroupsClient(AutoMarshallingRestClient):
|
|||||||
def __init__(self, url, auth_token, serialize_format=None,
|
def __init__(self, url, auth_token, serialize_format=None,
|
||||||
deserialize_format=None):
|
deserialize_format=None):
|
||||||
super(SecurityGroupsClient, self).__init__(serialize_format,
|
super(SecurityGroupsClient, self).__init__(serialize_format,
|
||||||
deserialize_format)
|
deserialize_format)
|
||||||
self.auth_token = auth_token
|
self.auth_token = auth_token
|
||||||
self.default_headers['X-Auth-Token'] = auth_token
|
self.default_headers['X-Auth-Token'] = auth_token
|
||||||
ct = ''.join(['application/', self.serialize_format])
|
ct = ''.join(['application/', self.serialize_format])
|
||||||
@@ -66,4 +66,4 @@ class SecurityGroupsClient(AutoMarshallingRestClient):
|
|||||||
url = '%s/os-security-groups/%s' % (self.url, group_id)
|
url = '%s/os-security-groups/%s' % (self.url, group_id)
|
||||||
resp = self.request('DELETE', url,
|
resp = self.request('DELETE', url,
|
||||||
requestslib_kwargs=requestslib_kwargs)
|
requestslib_kwargs=requestslib_kwargs)
|
||||||
return resp
|
return resp
|
||||||
|
|||||||
@@ -44,4 +44,4 @@ class CreateSecurityGroup(AutoMarshallingModel):
|
|||||||
raise NotImplemented
|
raise NotImplemented
|
||||||
|
|
||||||
def _obj_to_xml_ele(self):
|
def _obj_to_xml_ele(self):
|
||||||
raise NotImplemented
|
raise NotImplemented
|
||||||
|
|||||||
@@ -33,8 +33,6 @@ class SecurityGroup(AutoMarshallingModel):
|
|||||||
self.id = id
|
self.id = id
|
||||||
self.tenant_id = tenant_id
|
self.tenant_id = tenant_id
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
values = []
|
values = []
|
||||||
for prop in self.__dict__:
|
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
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|||||||
@@ -66,15 +66,14 @@ class FlavorsClient(AutoMarshallingRestClient):
|
|||||||
requestslib_kwargs=requestslib_kwargs)
|
requestslib_kwargs=requestslib_kwargs)
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
|
||||||
def list_flavors(self, min_disk=None, min_ram=None, marker=None,
|
def list_flavors(self, min_disk=None, min_ram=None, marker=None,
|
||||||
limit=None, requestslib_kwargs=None):
|
limit=None, requestslib_kwargs=None):
|
||||||
'''
|
'''
|
||||||
@summary: Returns a list of flavors
|
@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
|
@type min_disk: int
|
||||||
@param min_ram: min ram in GB, to filter by minimum RAM size in MB
|
@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)
|
@param marker: ID of last item in previous list (paginated collections)
|
||||||
@type marker:C{str}
|
@type marker:C{str}
|
||||||
@param limit: Sets page size
|
@param limit: Sets page size
|
||||||
|
|||||||
@@ -54,20 +54,20 @@ class CreateFlavor(AutoMarshallingModel):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _xml_to_obj(cls, serialized_str):
|
def _xml_to_obj(cls, serialized_str):
|
||||||
raise NotImplemented
|
raise NotImplemented
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _xml_list_to_obj(cls, xml_list):
|
def _xml_list_to_obj(cls, xml_list):
|
||||||
raise NotImplemented
|
raise NotImplemented
|
||||||
|
|
||||||
|
|
||||||
class Flavor(AutoMarshallingModel):
|
class Flavor(AutoMarshallingModel):
|
||||||
|
|
||||||
def __init__(self, id=None, name=None, ram=None, disk=None, vcpus=None,
|
def __init__(self, id=None, name=None, ram=None, disk=None, vcpus=None,
|
||||||
swap=None, rxtx_factor=None, links=None):
|
swap=None, rxtx_factor=None, links=None):
|
||||||
'''
|
"""
|
||||||
An object that represents a flavor.
|
An object that represents a flavor.
|
||||||
'''
|
"""
|
||||||
self.id = id
|
self.id = id
|
||||||
self.name = name
|
self.name = name
|
||||||
self.ram = ram
|
self.ram = ram
|
||||||
@@ -83,8 +83,10 @@ class Flavor(AutoMarshallingModel):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _json_to_obj(cls, serialized_str):
|
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)
|
json_dict = json.loads(serialized_str)
|
||||||
|
|
||||||
if 'flavor' in json_dict.keys():
|
if 'flavor' in json_dict.keys():
|
||||||
@@ -100,7 +102,7 @@ class Flavor(AutoMarshallingModel):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _dict_to_obj(cls, flavor_dict):
|
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'),
|
flavor = Flavor(id=flavor_dict.get('id'),
|
||||||
name=flavor_dict.get('name'),
|
name=flavor_dict.get('name'),
|
||||||
ram=flavor_dict.get('ram'),
|
ram=flavor_dict.get('ram'),
|
||||||
@@ -111,8 +113,10 @@ class Flavor(AutoMarshallingModel):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _xml_to_obj(cls, serialized_str):
|
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)
|
element = ET.fromstring(serialized_str)
|
||||||
cls._remove_xml_etree_namespace(element, Constants.XML_API_NAMESPACE)
|
cls._remove_xml_etree_namespace(element, Constants.XML_API_NAMESPACE)
|
||||||
cls._remove_xml_etree_namespace(element,
|
cls._remove_xml_etree_namespace(element,
|
||||||
@@ -131,7 +135,7 @@ class Flavor(AutoMarshallingModel):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _xml_ele_to_obj(cls, element):
|
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
|
flavor_dict = element.attrib
|
||||||
if 'vcpus' in flavor_dict:
|
if 'vcpus' in flavor_dict:
|
||||||
flavor_dict['vcpus'] = (flavor_dict.get('vcpus') and
|
flavor_dict['vcpus'] = (flavor_dict.get('vcpus') and
|
||||||
@@ -182,7 +186,7 @@ class FlavorMin(Flavor):
|
|||||||
@summary: Represents minimum details of a flavor
|
@summary: Represents minimum details of a flavor
|
||||||
"""
|
"""
|
||||||
def __init__(self, **kwargs):
|
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():
|
for keys, values in kwargs.items():
|
||||||
setattr(self, keys, values)
|
setattr(self, keys, values)
|
||||||
|
|
||||||
@@ -208,7 +212,7 @@ class FlavorMin(Flavor):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _xml_ele_to_obj(cls, element):
|
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_dict = element.attrib
|
||||||
flavor_min = FlavorMin(id=flavor_dict.get('id'),
|
flavor_min = FlavorMin(id=flavor_dict.get('id'),
|
||||||
name=flavor_dict.get('name'))
|
name=flavor_dict.get('name'))
|
||||||
@@ -217,7 +221,7 @@ class FlavorMin(Flavor):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _dict_to_obj(cls, flavor_dict):
|
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'),
|
flavor_min = FlavorMin(id=flavor_dict.get('id'),
|
||||||
name=flavor_dict.get('name'))
|
name=flavor_dict.get('name'))
|
||||||
flavor_min.links = Links._dict_to_obj(flavor_dict['links'])
|
flavor_min.links = Links._dict_to_obj(flavor_dict['links'])
|
||||||
|
|||||||
@@ -50,10 +50,10 @@ class ImagesClient(AutoMarshallingRestClient):
|
|||||||
self.url = url
|
self.url = url
|
||||||
|
|
||||||
def list_images(self, server_ref=None, image_name=None, status=None,
|
def list_images(self, server_ref=None, image_name=None, status=None,
|
||||||
image_type=None, marker=None, changes_since=None, limit=None,
|
image_type=None, marker=None, changes_since=None,
|
||||||
requestslib_kwargs=None):
|
limit=None, requestslib_kwargs=None):
|
||||||
|
|
||||||
'''
|
"""
|
||||||
@summary: Lists IDs, names, and links for all available images.
|
@summary: Lists IDs, names, and links for all available images.
|
||||||
@param server_ref: Server id or Url to server
|
@param server_ref: Server id or Url to server
|
||||||
@type server_ref: String
|
@type server_ref: String
|
||||||
@@ -71,7 +71,7 @@ class ImagesClient(AutoMarshallingRestClient):
|
|||||||
@type limit:int
|
@type limit:int
|
||||||
@return: lists all images visible by the account filtered by the params
|
@return: lists all images visible by the account filtered by the params
|
||||||
@rtype: Response with Image List as response.entity
|
@rtype: Response with Image List as response.entity
|
||||||
'''
|
"""
|
||||||
|
|
||||||
url = '%s/images' % (self.url)
|
url = '%s/images' % (self.url)
|
||||||
|
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ class ServersClient(AutoMarshallingRestClient):
|
|||||||
admin_pass=None, disk_config=None, metadata=None,
|
admin_pass=None, disk_config=None, metadata=None,
|
||||||
personality=None, accessIPv4=None, accessIPv6=None,
|
personality=None, accessIPv4=None, accessIPv6=None,
|
||||||
requestslib_kwargs=None):
|
requestslib_kwargs=None):
|
||||||
'''
|
"""
|
||||||
@summary: Rebuilds the server
|
@summary: Rebuilds the server
|
||||||
@param server_id: The id of an existing server.
|
@param server_id: The id of an existing server.
|
||||||
@type server_id: String
|
@type server_id: String
|
||||||
@@ -318,8 +318,8 @@ class ServersClient(AutoMarshallingRestClient):
|
|||||||
@type image_ref: String
|
@type image_ref: String
|
||||||
@param admin_pass:The administrator password
|
@param admin_pass:The administrator password
|
||||||
@type admin_pass: String
|
@type admin_pass: String
|
||||||
@param disk_config:The disk configuration value, which is AUTO or MANUAL
|
@param disk_config: The disk configuration value (AUTO or MANUAL)
|
||||||
@type disk_config: String(AUTO/MANUAL)
|
@type disk_config: String
|
||||||
@param metadata:A metadata key and value pair.
|
@param metadata:A metadata key and value pair.
|
||||||
@type metadata: Dictionary
|
@type metadata: Dictionary
|
||||||
@param personality:The file path and file contents
|
@param personality:The file path and file contents
|
||||||
@@ -331,7 +331,7 @@ class ServersClient(AutoMarshallingRestClient):
|
|||||||
@return: Response Object containing response code and
|
@return: Response Object containing response code and
|
||||||
the server domain object
|
the server domain object
|
||||||
@rtype: Response Object
|
@rtype: Response Object
|
||||||
'''
|
"""
|
||||||
|
|
||||||
self.server_id = server_id
|
self.server_id = server_id
|
||||||
url = '%s/servers/%s/action' % (self.url, self.server_id)
|
url = '%s/servers/%s/action' % (self.url, self.server_id)
|
||||||
|
|||||||
@@ -475,6 +475,7 @@ class Unpause(AutoMarshallingModel):
|
|||||||
xml += ET.tostring(element)
|
xml += ET.tostring(element)
|
||||||
return xml
|
return xml
|
||||||
|
|
||||||
|
|
||||||
class CreateImage(AutoMarshallingModel):
|
class CreateImage(AutoMarshallingModel):
|
||||||
'''
|
'''
|
||||||
Create Image Server Action Request Object
|
Create Image Server Action Request Object
|
||||||
|
|||||||
Reference in New Issue
Block a user