Add NovaSchedulerHints and correct the implementation of Tags

Change-Id: Iaa7ea182414a8fc48a78f5aa6c2c3e1baddb4034
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
This commit is contained in:
Angus Salkeld 2012-07-06 18:10:57 +10:00
parent fd83855600
commit a0da17b39f
3 changed files with 18 additions and 9 deletions

View File

@ -93,6 +93,8 @@ class Instance(resources.Resource):
'Implemented': False},
'Tags': {'Type': 'List',
'Schema': tags_schema},
'NovaSchedulerHints': {'Type': 'List',
'Schema': tags_schema},
'Tenancy': {'Type': 'String',
'AllowedValues': ['dedicated', 'default'],
'Implemented': False},
@ -223,10 +225,16 @@ class Instance(resources.Resource):
if o.name == flavor:
flavor_id = o.id
tags = {}
if self.properties['Tags']:
for tm in self.properties['Tags']:
tags[tm['Key']] = tm['Value']
else:
tags = None
scheduler_hints = {}
prop_tags = self.properties['Tags']
if prop_tags:
for tm in prop_tags:
if self.properties['NovaSchedulerHints']:
for tm in self.properties['NovaSchedulerHints']:
scheduler_hints[tm['Key']] = tm['Value']
else:
scheduler_hints = None
@ -237,6 +245,7 @@ class Instance(resources.Resource):
key_name=key_name,
security_groups=security_groups,
userdata=server_userdata,
meta=tags,
scheduler_hints=scheduler_hints)
while server.status == 'BUILD':
server.get()

View File

@ -77,8 +77,8 @@ class instancesTest(unittest.TestCase):
self.m.StubOutWithMock(self.fc.servers, 'create')
self.fc.servers.create(image=1, flavor=1, key_name='test',
name='test_resource_name', security_groups=None,
userdata=server_userdata, scheduler_hints=None).\
AndReturn(self.fc.servers.list()[1])
userdata=server_userdata, scheduler_hints=None,
meta=None).AndReturn(self.fc.servers.list()[1])
self.m.ReplayAll()
instance.itype_oflavor['256 MB Server'] = '256 MB Server'
@ -123,8 +123,8 @@ class instancesTest(unittest.TestCase):
self.m.StubOutWithMock(self.fc.servers, 'create')
self.fc.servers.create(image=1, flavor=1, key_name='test',
name='test_resource_name', security_groups=None,
userdata=server_userdata, scheduler_hints=None).\
AndReturn(self.fc.servers.list()[1])
userdata=server_userdata, scheduler_hints=None,
meta=None).AndReturn(self.fc.servers.list()[1])
self.m.ReplayAll()
instance.instance_id = 1234

View File

@ -78,8 +78,8 @@ class stacksTest(unittest.TestCase):
self.m.StubOutWithMock(self.fc.servers, 'create')
self.fc.servers.create(image=744, flavor=3, key_name='test',
name='WebServer', security_groups=None,
userdata=server_userdata, scheduler_hints=None).\
AndReturn(self.fc.servers.list()[-1])
userdata=server_userdata, scheduler_hints=None,
meta=None).AndReturn(self.fc.servers.list()[-1])
return stack