def test_nokey_create(self):
    stack_name = 'instance_create_test_nokey_stack'
    t = template_format.parse(nokey_template)
    stack = utils.parse_stack(t, stack_name=stack_name)
    t['Resources']['WebServer']['Properties']['ImageId'] = 'CentOS 5.2'
    t['Resources']['WebServer']['Properties']['InstanceType'] = '256 MB Server'
    instance = instances.Instance('create_instance_name', t['Resources']['WebServer'], stack)
    self.m.StubOutWithMock(instance, 'nova')
    instance.nova().MultipleTimes().AndReturn(self.fc)
    instance.t = instance.stack.resolve_runtime_data(instance.t)
    server_userdata = nova_utils.build_userdata(instance, instance.t['Properties']['UserData'])
    instance.mime_string = server_userdata
    self.m.StubOutWithMock(self.fc.servers, 'create')
    self.fc.servers.create(image=1, flavor=1, key_name=None, name=utils.PhysName(stack_name, instance.name), security_groups=None, userdata=server_userdata, scheduler_hints=None, meta=None, nics=None, availability_zone=None).AndReturn(self.fc.servers.list()[1])
    self.m.ReplayAll()
    scheduler.TaskRunner(instance.create)()
def test_nokey_create(self):
    stack_name = 'instance_create_test_nokey_stack'
    t = template_format.parse(nokey_template)
    stack = utils.parse_stack(t, stack_name=stack_name)
    t['Resources']['WebServer']['Properties']['ImageId'] = 'CentOS 5.2'
    t['Resources']['WebServer']['Properties']['InstanceType'] = '256 MB Server'
    instance = instances.Instance('create_instance_name', t['Resources']['WebServer'], stack)
    self.m.StubOutWithMock(instance, 'nova')
    instance.nova().MultipleTimes().AndReturn(self.fc)
    instance.t = instance.stack.resolve_runtime_data(instance.t)
    server_userdata = nova_utils.build_userdata(instance, instance.t['Properties']['UserData'])
    instance.mime_string = server_userdata
    self.m.StubOutWithMock(self.fc.servers, 'create')
    self.fc.servers.create(image=1, flavor=1, key_name=None, name=utils.PhysName(stack_name, instance.name), security_groups=None, userdata=server_userdata, scheduler_hints=None, meta=None, nics=None, availability_zone=None).AndReturn(self.fc.servers.list()[1])
    self.m.ReplayAll()
    scheduler.TaskRunner(instance.create)()