pep8 compliance cleanup.

This commit is contained in:
tmetsch
2013-05-03 14:00:57 +02:00
parent eaa0bb5e70
commit 1fe13f62bc
13 changed files with 226 additions and 198 deletions

View File

@@ -81,14 +81,16 @@ class NetworkInterfaceBackend(backend.KindBackend):
if link.target.identifier == '/network/public': if link.target.identifier == '/network/public':
# public means floating IP in OS! # public means floating IP in OS!
# if the os_net_link mixin is avail. a pool must be provided: # if the os_net_link mixin is avail. a pool must be provided:
if not 'org.openstack.network.floating.pool' in link.attributes and os_addon.OS_NET_LINK in link.mixins: if not 'org.openstack.network.floating.pool' in link.attributes\
raise AttributeError('Please specify the pool name when using this mixin!') and os_addon.OS_NET_LINK in link.mixins:
raise AttributeError('Please specify the pool name when using'
' this mixin!')
elif os_addon.OS_NET_LINK in link.mixins: elif os_addon.OS_NET_LINK in link.mixins:
pool = link.attributes['org.openstack.network.floating.pool'] pool = link.attributes['org.openstack.network.floating.pool']
else: else:
pool = None pool = None
address = net.add_floating_ip(link.source.attributes[ address = net.add_floating_ip(link.source.attributes['occi.'
'occi.core.id'], 'core.id'],
pool, pool,
extras['nova_ctx']) extras['nova_ctx'])
link.attributes['occi.networkinterface.interface'] = 'eth0' link.attributes['occi.networkinterface.interface'] = 'eth0'
@@ -113,5 +115,6 @@ class NetworkInterfaceBackend(backend.KindBackend):
if link.target.identifier == '/network/public': if link.target.identifier == '/network/public':
# public means floating IP in OS! # public means floating IP in OS!
net.remove_floating_ip(link.source.attributes['occi.core.id'], net.remove_floating_ip(link.source.attributes['occi.core.id'],
link.attributes['occi.networkinterface.address'], link.attributes['occi.networkinterface.'
'address'],
extras['nova_ctx']) extras['nova_ctx'])

View File

@@ -93,7 +93,6 @@ class OsNetLinkBackend(backend.MixinBackend, backend.ActionBackend):
pass pass
class SecurityGroupBackend(backend.UserDefinedMixinBackend): class SecurityGroupBackend(backend.UserDefinedMixinBackend):
""" """
Security Group backend. Security Group backend.
@@ -104,8 +103,8 @@ class SecurityGroupBackend(backend.UserDefinedMixinBackend):
Creates the security group as specified in the request. Creates the security group as specified in the request.
""" """
#do not recreate default openstack security groups #do not recreate default openstack security groups
if (category.scheme == if category.scheme == \
'http://schemas.openstack.org/infrastructure/security/group#'): 'http://schemas.openstack.org/infrastructure/security/group#':
return return
context = extras['nova_ctx'] context = extras['nova_ctx']

View File

@@ -49,8 +49,9 @@ class StorageBackend(backend.KindBackend, backend.ActionBackend):
if 'occi.storage.size' not in entity.attributes: if 'occi.storage.size' not in entity.attributes:
raise AttributeError('size attribute not found!') raise AttributeError('size attribute not found!')
new_volume = storage.create_storage(entity.attributes['occi.storage' \ new_volume = storage.create_storage(entity.attributes['occi.storage'
'.size'], context) '.size'],
context)
vol_id = new_volume['id'] vol_id = new_volume['id']
# Work around problem that instance is lazy-loaded... # Work around problem that instance is lazy-loaded...

View File

@@ -260,8 +260,8 @@ def start_vm(uid, context):
try: try:
COMPUTE_API.resume(context, instance) COMPUTE_API.resume(context, instance)
except Exception as error: except Exception as error:
raise exceptions.HTTPError(500, 'Error while starting VM: ' + str raise exceptions.HTTPError(500, 'Error while starting VM: ' +
(error)) str(error))
def stop_vm(uid, context): def stop_vm(uid, context):
@@ -281,8 +281,8 @@ def stop_vm(uid, context):
# self.compute_api.stop(context, instance) # self.compute_api.stop(context, instance)
COMPUTE_API.suspend(context, instance) COMPUTE_API.suspend(context, instance)
except Exception as error: except Exception as error:
raise exceptions.HTTPError(500, 'Error while stopping VM: ' + str raise exceptions.HTTPError(500, 'Error while stopping VM: ' +
(error)) str(error))
def restart_vm(uid, method, context): def restart_vm(uid, method, context):

View File

@@ -39,6 +39,7 @@ from occi_os_api.nova_glue import net
from nova.flags import FLAGS from nova.flags import FLAGS
class OCCIRegistry(occi_registry.NonePersistentRegistry): class OCCIRegistry(occi_registry.NonePersistentRegistry):
""" """
Registry for OpenStack. Registry for OpenStack.
@@ -51,9 +52,11 @@ class OCCIRegistry(occi_registry.NonePersistentRegistry):
super(OCCIRegistry, self).__init__() super(OCCIRegistry, self).__init__()
self.cache = {} self.cache = {}
self.adm_net = core_model.Resource('/network/admin', self.adm_net = core_model.Resource('/network/admin',
infrastructure.NETWORK, [infrastructure.IPNETWORK]) infrastructure.NETWORK,
[infrastructure.IPNETWORK])
self.pub_net = core_model.Resource('/network/public', self.pub_net = core_model.Resource('/network/public',
infrastructure.NETWORK, [infrastructure.IPNETWORK]) infrastructure.NETWORK,
[infrastructure.IPNETWORK])
self._setup_network() self._setup_network()
@@ -215,8 +218,8 @@ class OCCIRegistry(occi_registry.NonePersistentRegistry):
stor_res_ids = [item['id'] for item in stors] stor_res_ids = [item['id'] for item in stors]
for item in self.cache.values(): for item in self.cache.values():
if item.extras is not None and item.extras['user_id'] != context\ if item.extras is not None and item.extras['user_id'] != \
.user_id: context.user_id:
# filter out items not belonging to this user! # filter out items not belonging to this user!
continue continue
item_id = item.identifier[item.identifier.rfind('/') + 1:] item_id = item.identifier[item.identifier.rfind('/') + 1:]
@@ -355,7 +358,8 @@ class OCCIRegistry(occi_registry.NonePersistentRegistry):
str(stor['instance_uuid']), extras) str(stor['instance_uuid']), extras)
link = core_model.Link(infrastructure.STORAGELINK.location + link = core_model.Link(infrastructure.STORAGELINK.location +
str(uuid.uuid4()), str(uuid.uuid4()),
infrastructure.STORAGELINK, [], source, entity) infrastructure.STORAGELINK, [], source,
entity)
link.extras = self.get_extras(extras) link.extras = self.get_extras(extras)
source.links.append(link) source.links.append(link)
result.append(link) result.append(link)
@@ -402,7 +406,8 @@ class OCCIRegistry(occi_registry.NonePersistentRegistry):
link = core_model.Link(infrastructure.NETWORKINTERFACE.location + link = core_model.Link(infrastructure.NETWORKINTERFACE.location +
str(uuid.uuid4()), str(uuid.uuid4()),
infrastructure.NETWORKINTERFACE, infrastructure.NETWORKINTERFACE,
[infrastructure.IPNETWORKINTERFACE], source, target) [infrastructure.IPNETWORKINTERFACE], source,
target)
link.attributes = { link.attributes = {
'occi.networkinterface.interface': net_desc['interface'], 'occi.networkinterface.interface': net_desc['interface'],
'occi.networkinterface.mac': net_desc['mac'], 'occi.networkinterface.mac': net_desc['mac'],

View File

@@ -177,14 +177,14 @@ class OCCIApplication(occi_wsgi.Application, wsgi.Application):
LOG.debug(msg) LOG.debug(msg)
continue continue
ctg_term = occify_terms(img['name']) ctg_term = occify_terms(img['name'])
os_template = os_mixins.OsTemplate( os_template = os_mixins.OsTemplate(term=ctg_term,
term=ctg_term,
scheme=template_schema, scheme=template_schema,
os_id=img['id'], os_id=img['id'],
related=[infrastructure.OS_TEMPLATE], related=[infrastructure.
OS_TEMPLATE],
attributes=None, attributes=None,
title='This is an OS ' + img['name'] + \ title='This is an OS ' +
' VM image', img['name'] + ' VM image',
location='/' + ctg_term + '/') location='/' + ctg_term + '/')
try: try:
@@ -234,23 +234,25 @@ class OCCIApplication(occi_wsgi.Application, wsgi.Application):
excld_grps.append(cat.term) excld_grps.append(cat.term)
groups = db.security_group_get_by_project(extras['nova_ctx'], groups = db.security_group_get_by_project(extras['nova_ctx'],
extras['nova_ctx'].project_id) extras['nova_'
'ctx'].project_id)
sec_grp = 'http://schemas.openstack.org/infrastructure/security/group#' sec_grp = 'http://schemas.openstack.org/infrastructure/security/group#'
for group in groups: for group in groups:
if group['name'] not in excld_grps: if group['name'] not in excld_grps:
sec_mix = os_mixins.UserSecurityGroupMixin( sec_mix = os_mixins.UserSecurityGroupMixin(
term=str(group["id"]), # NOTE(aloga): group.id is a long term=str(group["id"]),
scheme=sec_grp, scheme=sec_grp,
related=[os_addon.SEC_GROUP], related=[os_addon.SEC_GROUP],
attributes=None, attributes=None,
title=group['name'], title=group['name'],
location='/security/' + quote(str(group['id'])) + '/') location='/security/' + quote(str(group['name'])) + '/')
try: try:
self.registry.get_backend(sec_mix, extras) self.registry.get_backend(sec_mix, extras)
except AttributeError: except AttributeError:
self.register_backend(sec_mix, MIXIN_BACKEND) self.register_backend(sec_mix, MIXIN_BACKEND)
def occify_terms(term_name): def occify_terms(term_name):
''' '''
Occifies a term_name so that it is compliant with GFD 185. Occifies a term_name so that it is compliant with GFD 185.

View File

@@ -30,8 +30,7 @@ import random
HEADS = {'Content-Type': 'text/occi', HEADS = {'Content-Type': 'text/occi',
'Accept': 'text/occi' 'Accept': 'text/occi'}
}
KEYSTONE_HOST = '127.0.0.1:5000' KEYSTONE_HOST = '127.0.0.1:5000'
OCCI_HOST = '127.0.0.1:8787' OCCI_HOST = '127.0.0.1:8787'
@@ -196,43 +195,43 @@ class SystemTest(unittest.TestCase):
'.org/occi/infrastructure#"'] '.org/occi/infrastructure#"']
vm_location = create_node(self.token, cats) vm_location = create_node(self.token, cats)
# list computes # list computes
if 'http://' + OCCI_HOST + vm_location not in list_nodes(self.token, if 'http://' + OCCI_HOST + vm_location not \
'/compute/'): in list_nodes(self.token, '/compute/'):
LOG.error('VM should be listed!') LOG.error('VM should be listed!')
# wait # wait
cont = False cont = False
while not cont: while not cont:
if 'occi.compute.state="active"' in get_node(self.token, if 'occi.compute.state="active"' in \
vm_location)['x-occi-attribute']: get_node(self.token, vm_location)['x-occi-attribute']:
cont = True cont = True
else: else:
time.sleep(5) time.sleep(5)
# trigger stop # trigger stop
trigger_action(self.token, vm_location + '?action=stop', trigger_action(self.token, vm_location + '?action=stop',
'stop; scheme="http://schemas.ogf' 'stop; scheme="http://schemas.ogf.org/occi/'
'.org/occi/infrastructure/compute/action#"') 'infrastructure/compute/action#"')
# wait # wait
cont = False cont = False
while not cont: while not cont:
if 'occi.compute.state="inactive"' in get_node(self.token, if 'occi.compute.state="inactive"' in \
vm_location)['x-occi-attribute']: get_node(self.token, vm_location)['x-occi-attribute']:
cont = True cont = True
else: else:
time.sleep(5) time.sleep(5)
# trigger start # trigger start
trigger_action(self.token, vm_location + '?action=start', trigger_action(self.token, vm_location + '?action=start',
'start; scheme="http://schemas.ogf' 'start; scheme="http://schemas.ogf.org/occi/'
'.org/occi/infrastructure/compute/action#"') 'infrastructure/compute/action#"')
# wait # wait
cont = False cont = False
while not cont: while not cont:
if 'occi.compute.state="active"' in get_node(self.token, if 'occi.compute.state="active"' in \
vm_location)['x-occi-attribute']: get_node(self.token, vm_location)['x-occi-attribute']:
cont = True cont = True
else: else:
time.sleep(5) time.sleep(5)
@@ -249,7 +248,8 @@ class SystemTest(unittest.TestCase):
heads['X-Auth-Token'] = self.token heads['X-Auth-Token'] = self.token
name = 'my_grp' + str(random.randint(1, 999999)) name = 'my_grp' + str(random.randint(1, 999999))
heads['Category'] = name + '; scheme="http://www.mystuff.org/sec#"; ' \ heads['Category'] = name + '; scheme="http://www.mystuff.org/sec#"; ' \
' rel="http://schemas.ogf.org/occi/infrastructure/security#group"; ' \ 'rel="http://schemas.ogf.org/occi/' \
'infrastructure/security#group"; ' \
'location="/mygroups/"' 'location="/mygroups/"'
do_request('POST', '/-/', heads) do_request('POST', '/-/', heads)
@@ -284,8 +284,8 @@ class SystemTest(unittest.TestCase):
# wait # wait
cont = False cont = False
while not cont: while not cont:
if 'occi.compute.state="active"' in get_node(self.token, if 'occi.compute.state="active"' in \
vm_location)['x-occi-attribute']: get_node(self.token, vm_location)['x-occi-attribute']:
cont = True cont = True
else: else:
time.sleep(5) time.sleep(5)
@@ -307,8 +307,10 @@ class SystemTest(unittest.TestCase):
# change pw # change pw
LOG.debug(trigger_action(self.token, vm_location + '?action=chg_pwd', LOG.debug(trigger_action(self.token, vm_location + '?action=chg_pwd',
'chg_pwd; scheme="http://schemas.openstack.org/instance/action#"', 'chg_pwd; scheme="http://schemas.'
'org.openstack.credentials.admin_pwd="new_pass"')) 'openstack.org/instance/action#"',
'org.openstack.credentials.admin_pwd'
'="new_pass"'))
# clean VM # clean VM
destroy_node(self.token, vm_location) destroy_node(self.token, vm_location)
@@ -322,7 +324,7 @@ class SystemTest(unittest.TestCase):
heads = HEADS.copy() heads = HEADS.copy()
heads['X-Auth-Token'] = self.token heads['X-Auth-Token'] = self.token
heads['Category'] = name + '; scheme="http://www.mystuff.org/sec#"' heads['Category'] = name + '; scheme="http://www.mystuff.org/sec#"'
do_request('DELETE', '/-/', heads) #do_request('DELETE', '/-/', heads)
def test_storage_stuff(self): def test_storage_stuff(self):
""" """
@@ -334,7 +336,8 @@ class SystemTest(unittest.TestCase):
'.org/template/resource#"', '.org/template/resource#"',
'cirros-0-3-0-x86_64-uec; scheme="http://schemas.openstack' 'cirros-0-3-0-x86_64-uec; scheme="http://schemas.openstack'
'.org/template/os#"', '.org/template/os#"',
'compute; scheme="http://schemas.ogf.org/occi/infrastructure#"'] 'compute; scheme="http://schemas.ogf.org/occi/'
'infrastructure#"']
vm_location = create_node(self.token, cats) vm_location = create_node(self.token, cats)
# create volume # create volume
@@ -378,18 +381,19 @@ class SystemTest(unittest.TestCase):
# wait # wait
cont = False cont = False
while not cont: while not cont:
if 'occi.compute.state="active"' in get_node(self.token, if 'occi.compute.state="active"' in \
vm_location)['x-occi-attribute']: get_node(self.token, vm_location)['x-occi-attribute']:
cont = True cont = True
else: else:
time.sleep(5) time.sleep(5)
# Create a Image from an Active VM # Create a Image from an Active VM
LOG.debug(trigger_action(self.token, vm_location + LOG.debug(trigger_action(self.token, vm_location + '?action='
'?action=create_image', 'create_image',
'create_image; scheme="http://schemas.openstack' 'create_image; scheme="http://schemas.'
'.org/instance/action#"', 'openstack.org/instance/action#"',
'org.openstack.snapshot.image_name="awesome_ware"')) 'org.openstack.snapshot.image_name='
'"awesome_ware"'))
destroy_node(self.token, vm_location) destroy_node(self.token, vm_location)
@@ -402,14 +406,15 @@ class SystemTest(unittest.TestCase):
'.org/template/resource#"', '.org/template/resource#"',
'cirros-0-3-0-x86_64-uec; scheme="http://schemas.openstack' 'cirros-0-3-0-x86_64-uec; scheme="http://schemas.openstack'
'.org/template/os#"', '.org/template/os#"',
'compute; scheme="http://schemas.ogf.org/occi/infrastructure#"'] 'compute; scheme="http://schemas.ogf.org/occi/'
'infrastructure#"']
vm_location = create_node(self.token, cats) vm_location = create_node(self.token, cats)
# wait # wait
cont = False cont = False
while not cont: while not cont:
if 'occi.compute.state="active"' in get_node(self.token, if 'occi.compute.state="active"' in \
vm_location)['x-occi-attribute']: get_node(self.token, vm_location)['x-occi-attribute']:
cont = True cont = True
else: else:
time.sleep(5) time.sleep(5)
@@ -424,8 +429,8 @@ class SystemTest(unittest.TestCase):
# wait # wait
cont = False cont = False
while not cont: while not cont:
if 'occi.compute.state="active"' in get_node(self.token, if 'occi.compute.state="active"' in \
vm_location)['x-occi-attribute']: get_node(self.token, vm_location)['x-occi-attribute']:
cont = True cont = True
else: else:
time.sleep(5) time.sleep(5)

View File

@@ -91,7 +91,8 @@ class TestComputeBackend(unittest.TestCase):
self.sec_obj) self.sec_obj)
res2 = core_model.Resource('/foo/bar', infrastructure.COMPUTE, res2 = core_model.Resource('/foo/bar', infrastructure.COMPUTE,
[core_model.Category('http://foo.com', 'bar', '', '', '')]) [core_model.Category('http://foo.com',
'bar', '', '', '')])
self.assertRaises(AttributeError, self.backend.update, res1, res2, self.assertRaises(AttributeError, self.backend.update, res1, res2,
self.sec_obj) self.sec_obj)
@@ -144,8 +145,8 @@ class TestComputeBackend(unittest.TestCase):
}) })
self.mox.StubOutWithMock(nova_glue.storage, 'get_image_architecture') self.mox.StubOutWithMock(nova_glue.storage, 'get_image_architecture')
nova_glue.storage.get_image_architecture(mox.IsA(object), nova_glue.storage.get_image_architecture(mox.IsA(object),
mox.IsA(object)).AndReturn( mox.IsA(object)).\
'foo') AndReturn('foo')
self.mox.ReplayAll() self.mox.ReplayAll()
@@ -176,7 +177,8 @@ class TestComputeBackend(unittest.TestCase):
self.mox.StubOutWithMock(nova_glue.vm, 'get_occi_state') self.mox.StubOutWithMock(nova_glue.vm, 'get_occi_state')
nova_glue.vm.get_occi_state(mox.IsA(object), nova_glue.vm.get_occi_state(mox.IsA(object),
mox.IsA(object)).AndReturn(('active', [infrastructure.STOP, mox.IsA(object)).\
AndReturn(('active', [infrastructure.STOP,
infrastructure.SUSPEND, infrastructure.SUSPEND,
infrastructure.RESTART])) infrastructure.RESTART]))
self.mox.StubOutWithMock(nova_glue.vm, 'get_vm') self.mox.StubOutWithMock(nova_glue.vm, 'get_vm')
@@ -188,8 +190,8 @@ class TestComputeBackend(unittest.TestCase):
}) })
self.mox.StubOutWithMock(nova_glue.storage, 'get_image_architecture') self.mox.StubOutWithMock(nova_glue.storage, 'get_image_architecture')
nova_glue.storage.get_image_architecture(mox.IsA(object), nova_glue.storage.get_image_architecture(mox.IsA(object),
mox.IsA(object)).AndReturn( mox.IsA(object)).\
'foo') AndReturn('foo')
self.mox.ReplayAll() self.mox.ReplayAll()
self.backend.retrieve(res, self.sec_obj) self.backend.retrieve(res, self.sec_obj)
@@ -312,8 +314,7 @@ class TestComputeBackend(unittest.TestCase):
}) })
self.mox.ReplayAll() self.mox.ReplayAll()
self.backend.action(res1, infrastructure.RESTART, self.backend.action(res1, infrastructure.RESTART,
{'method': 'graceful'}, {'method': 'graceful'}, self.sec_obj)
self.sec_obj)
self.mox.VerifyAll() self.mox.VerifyAll()
# suspend # suspend

View File

@@ -72,7 +72,8 @@ class TestNetworkInterfaceBackend(unittest.TestCase):
# should have pool name in attribute... # should have pool name in attribute...
target.identifier = '/network/public' target.identifier = '/network/public'
link = core_model.Link('foo', None, [os_addon.OS_NET_LINK], source, target) link = core_model.Link('foo', None, [os_addon.OS_NET_LINK], source,
target)
self.mox.ReplayAll() self.mox.ReplayAll()
self.assertRaises(AttributeError, self.backend.create, link, self.assertRaises(AttributeError, self.backend.create, link,
@@ -103,7 +104,7 @@ class TestNetworkInterfaceBackend(unittest.TestCase):
link.attributes = {'org.openstack.network.floating.pool': 'nova'} link.attributes = {'org.openstack.network.floating.pool': 'nova'}
self.mox.StubOutWithMock(nova_glue.net, 'add_floating_ip') self.mox.StubOutWithMock(nova_glue.net, 'add_floating_ip')
nova_glue.net.add_floating_ip(mox.IsA(object), mox.IsA(str), nova_glue.net.add_floating_ip(mox.IsA(str), mox.IsA(str),
mox.IsA(object)).AndReturn('10.0.0.1') mox.IsA(object)).AndReturn('10.0.0.1')
self.mox.ReplayAll() self.mox.ReplayAll()
@@ -120,16 +121,18 @@ class TestNetworkInterfaceBackend(unittest.TestCase):
# self.assertIn(infrastructure.IPNETWORKINTERFACE, link.mixins) # self.assertIn(infrastructure.IPNETWORKINTERFACE, link.mixins)
# self.assertIn(infrastructure.NETWORKINTERFACE, link.mixins) # self.assertIn(infrastructure.NETWORKINTERFACE, link.mixins)
self.mox.VerifyAll()
# test without pool name... # test without pool name...
self.mox.UnsetStubs() self.mox.UnsetStubs()
self.mox.StubOutWithMock(nova_glue.net, 'add_floating_ip')
link = core_model.Link('foo', None, [], source, target) link = core_model.Link('foo', None, [], source, target)
nova_glue.net.add_floating_ip(mox.IsA(object), mox.IsA(str),
mox.IsA(object)).AndReturn('10.0.0.1')
self.mox.StubOutWithMock(nova_glue.net, 'add_floating_ip')
nova_glue.net.add_floating_ip(mox.IsA(str), mox.IsA(None),
mox.IsA(object)).AndReturn('10.0.0.2')
self.mox.ReplayAll()
self.backend.create(link, self.sec_obj) self.backend.create(link, self.sec_obj)
self.mox.VerifyAll()
def test_delete_for_sanity(self): def test_delete_for_sanity(self):
""" """

View File

@@ -69,10 +69,12 @@ class TestStorageBackend(unittest.TestCase):
self.mox.StubOutWithMock(nova_glue.storage, 'create_storage') self.mox.StubOutWithMock(nova_glue.storage, 'create_storage')
nova_glue.storage.create_storage(mox.IsA(object), nova_glue.storage.create_storage(mox.IsA(object),
mox.IsA(object)).AndReturn({'id': '1'}) mox.IsA(object)).\
AndReturn({'id': '1'})
self.mox.StubOutWithMock(nova_glue.storage, 'get_storage') self.mox.StubOutWithMock(nova_glue.storage, 'get_storage')
nova_glue.storage.get_storage(mox.IsA(object), nova_glue.storage.get_storage(mox.IsA(object),
mox.IsA(object)).AndReturn({'status': 'error'}) mox.IsA(object)).\
AndReturn({'status': 'error'})
self.mox.ReplayAll() self.mox.ReplayAll()
@@ -103,10 +105,12 @@ class TestStorageBackend(unittest.TestCase):
self.mox.StubOutWithMock(nova_glue.storage, 'create_storage') self.mox.StubOutWithMock(nova_glue.storage, 'create_storage')
nova_glue.storage.create_storage(mox.IsA(object), nova_glue.storage.create_storage(mox.IsA(object),
mox.IsA(object)).AndReturn({'id': '1'}) mox.IsA(object)).\
AndReturn({'id': '1'})
self.mox.StubOutWithMock(nova_glue.storage, 'get_storage') self.mox.StubOutWithMock(nova_glue.storage, 'get_storage')
nova_glue.storage.get_storage(mox.IsA(object), nova_glue.storage.get_storage(mox.IsA(object),
mox.IsA(object)).AndReturn({'status': 'available'}) mox.IsA(object)).\
AndReturn({'status': 'available'})
self.mox.ReplayAll() self.mox.ReplayAll()
@@ -129,7 +133,8 @@ class TestStorageBackend(unittest.TestCase):
self.mox.StubOutWithMock(nova_glue.storage, 'get_storage') self.mox.StubOutWithMock(nova_glue.storage, 'get_storage')
nova_glue.storage.get_storage(mox.IsA(object), nova_glue.storage.get_storage(mox.IsA(object),
mox.IsA(object)).AndReturn({'status': 'available', 'size': '1'}) mox.IsA(object)).\
AndReturn({'status': 'available', 'size': '1'})
self.mox.ReplayAll() self.mox.ReplayAll()
@@ -146,7 +151,8 @@ class TestStorageBackend(unittest.TestCase):
self.mox.UnsetStubs() self.mox.UnsetStubs()
self.mox.StubOutWithMock(nova_glue.storage, 'get_storage') self.mox.StubOutWithMock(nova_glue.storage, 'get_storage')
nova_glue.storage.get_storage(mox.IsA(object), nova_glue.storage.get_storage(mox.IsA(object),
mox.IsA(object)).AndReturn({'status': 'bla', 'size': '1'}) mox.IsA(object)).\
AndReturn({'status': 'bla', 'size': '1'})
self.mox.ReplayAll() self.mox.ReplayAll()
@@ -164,8 +170,8 @@ class TestStorageBackend(unittest.TestCase):
res1 = mox.MockObject(core_model.Resource) res1 = mox.MockObject(core_model.Resource)
res1.attributes = {} res1.attributes = {}
res2 = mox.MockObject(core_model.Resource) res2 = mox.MockObject(core_model.Resource)
res2.attributes = {'occi.core.title': 'foo', 'occi.core.summary': res2.attributes = {'occi.core.title': 'foo',
'bar'} 'occi.core.summary': 'bar'}
self.mox.ReplayAll() self.mox.ReplayAll()
@@ -207,7 +213,9 @@ class TestStorageBackend(unittest.TestCase):
self.mox.StubOutWithMock(nova_glue.storage, self.mox.StubOutWithMock(nova_glue.storage,
'snapshot_storage_instance') 'snapshot_storage_instance')
nova_glue.storage.snapshot_storage_instance(mox.IsA(object), nova_glue.storage.snapshot_storage_instance(mox.IsA(object),
mox.IsA(object), mox.IsA(object), mox.IsA(object)) mox.IsA(object),
mox.IsA(object),
mox.IsA(object))
self.mox.ReplayAll() self.mox.ReplayAll()
self.backend.action(res, infrastructure.SNAPSHOT, {}, self.sec_obj) self.backend.action(res, infrastructure.SNAPSHOT, {}, self.sec_obj)
self.mox.VerifyAll() self.mox.VerifyAll()
@@ -253,7 +261,8 @@ class TestStorageLinkBackend(unittest.TestCase):
self.mox.StubOutWithMock(nova_glue.vm, 'attach_volume') self.mox.StubOutWithMock(nova_glue.vm, 'attach_volume')
nova_glue.vm.attach_volume(mox.IsA(object), mox.IsA(object), nova_glue.vm.attach_volume(mox.IsA(object), mox.IsA(object),
mox.IsA(object), mox.IsA(object)).AndReturn({}) mox.IsA(object), mox.IsA(object)).\
AndReturn({})
self.mox.ReplayAll() self.mox.ReplayAll()