fixing unittests step 2/?.
This commit is contained in:
parent
1c25a51bff
commit
6d802cd63e
@ -118,7 +118,7 @@ class ComputeBackend(KindBackend, ActionBackend):
|
||||
|
||||
mixin = new.mixins[0]
|
||||
if isinstance(mixin, os_mixins.ResourceTemplate):
|
||||
flavor_id = mixin.term
|
||||
flavor_id = mixin.res_id
|
||||
vm.resize_vm(uid, flavor_id, context)
|
||||
old.attributes['occi.compute.state'] = 'inactive'
|
||||
# now update the mixin info
|
||||
|
@ -41,7 +41,14 @@ class ResourceTemplate(core_model.Mixin):
|
||||
"""
|
||||
Here to make identification of template type easier in backends.
|
||||
"""
|
||||
pass
|
||||
|
||||
def __init__(self, scheme, term, flavor_id=None, related=None,
|
||||
actions=None, title='',
|
||||
attributes=None, location=None):
|
||||
super(ResourceTemplate, self).__init__(scheme, term, related,
|
||||
actions, title, attributes,
|
||||
location)
|
||||
self.res_id = flavor_id
|
||||
|
||||
|
||||
class UserSecurityGroupMixin(core_model.Mixin):
|
||||
|
@ -103,7 +103,7 @@ def create_vm(entity, context):
|
||||
|
||||
if resource_template:
|
||||
inst_type = compute.instance_types.\
|
||||
get_instance_type_by_flavor_id(resource_template.term)
|
||||
get_instance_type_by_flavor_id(resource_template.res_id)
|
||||
else:
|
||||
inst_type = compute.instance_types.get_default_instance_type()
|
||||
msg = ('No resource template was found in the request. '
|
||||
|
@ -176,16 +176,16 @@ class OCCIApplication(occi_wsgi.Application, wsgi.Application):
|
||||
msg = 'Not registering kernel/RAM image.'
|
||||
LOG.debug(msg)
|
||||
continue
|
||||
|
||||
ctg_term = occify_terms(img['name'])
|
||||
os_template = os_mixins.OsTemplate(
|
||||
term=img['id'],
|
||||
term=ctg_term,
|
||||
scheme=template_schema,
|
||||
os_id=img['id'],
|
||||
related=[infrastructure.OS_TEMPLATE],
|
||||
attributes=None,
|
||||
title='This is an OS ' + img['name'] + \
|
||||
' VM image',
|
||||
location='/' + quote(img['id']) + '/')
|
||||
location='/' + ctg_term + '/')
|
||||
|
||||
try:
|
||||
self.registry.get_backend(os_template, extras)
|
||||
@ -202,12 +202,14 @@ class OCCIApplication(occi_wsgi.Application, wsgi.Application):
|
||||
os_flavours = instance_types.get_all_types()
|
||||
|
||||
for itype in os_flavours.values():
|
||||
ctg_term = occify_terms(itype['name'])
|
||||
resource_template = os_mixins.ResourceTemplate(
|
||||
term=itype["flavorid"],
|
||||
term=quote(ctg_term),
|
||||
flavor_id=itype['flavorid'],
|
||||
scheme=template_schema,
|
||||
related=[infrastructure.RESOURCE_TEMPLATE],
|
||||
title='This is an openstack ' + itype["name"] + ' flavor.',
|
||||
location='/' + quote(itype["flavorid"]) + '/')
|
||||
title='This is an openstack ' + itype['name'] + ' flavor.',
|
||||
location='/' + quote(ctg_term) + '/')
|
||||
|
||||
try:
|
||||
self.registry.get_backend(resource_template, extras)
|
||||
@ -248,3 +250,10 @@ class OCCIApplication(occi_wsgi.Application, wsgi.Application):
|
||||
self.registry.get_backend(sec_mix, extras)
|
||||
except AttributeError:
|
||||
self.register_backend(sec_mix, MIXIN_BACKEND)
|
||||
|
||||
def occify_terms(term_name):
|
||||
'''
|
||||
Occifies a term_name so that it is compliant with GFD 185.
|
||||
'''
|
||||
term = term_name.strip().replace(' ', '_').replace('.','-').lower()
|
||||
return term
|
@ -188,9 +188,9 @@ class SystemTest(unittest.TestCase):
|
||||
get_qi_listing(self.token)
|
||||
|
||||
# create VM
|
||||
cats = ['m1.tiny; scheme="http://schemas.openstack'
|
||||
cats = ['m1-tiny; scheme="http://schemas.openstack'
|
||||
'.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#"',
|
||||
'compute; scheme="http://schemas.ogf'
|
||||
'.org/occi/infrastructure#"']
|
||||
@ -261,10 +261,11 @@ class SystemTest(unittest.TestCase):
|
||||
'occi.network.security.to="22"',
|
||||
'occi.network.security.from="22"',
|
||||
'occi.network.security.range="0.0.0.0/0"']
|
||||
print cats
|
||||
sec_rule_loc = create_node(self.token, cats, attrs)
|
||||
|
||||
# list
|
||||
LOG.debug(list_nodes(self.token, '/mygroups/'))
|
||||
LOG.error(list_nodes(self.token, '/mygroups/'))
|
||||
LOG.debug(do_request('GET', sec_rule_loc, heads))
|
||||
|
||||
# FIXME: add VM to sec group - see #22
|
||||
@ -272,9 +273,9 @@ class SystemTest(unittest.TestCase):
|
||||
#print do_request('POST', '/mygroups/', heads)
|
||||
|
||||
# create new VM
|
||||
cats = ['m1.tiny; scheme="http://schemas.openstack'
|
||||
cats = ['m1-tiny; scheme="http://schemas.openstack'
|
||||
'.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#"',
|
||||
name + '; scheme="http://www.mystuff.org/sec#"',
|
||||
'compute; scheme="http://schemas.ogf'
|
||||
@ -330,9 +331,9 @@ class SystemTest(unittest.TestCase):
|
||||
"""
|
||||
|
||||
# create new VM
|
||||
cats = ['m1.tiny; scheme="http://schemas.openstack'
|
||||
cats = ['m1-tiny; scheme="http://schemas.openstack'
|
||||
'.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#"',
|
||||
'compute; scheme="http://schemas.ogf.org/occi/infrastructure#"']
|
||||
vm_location = create_node(self.token, cats)
|
||||
@ -400,7 +401,7 @@ class SystemTest(unittest.TestCase):
|
||||
# create new VM
|
||||
cats = ['itsy; scheme="http://schemas.openstack'
|
||||
'.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#"',
|
||||
'compute; scheme="http://schemas.ogf.org/occi/infrastructure#"']
|
||||
vm_location = create_node(self.token, cats)
|
||||
|
Loading…
x
Reference in New Issue
Block a user