示例#1
0
    def test_stack_list(self):
        stack = self.start_wordpress_stack('test_stack_list')
        rt = {}
        rt['template'] = stack.t
        rt['stack_name'] = stack.name
        new_rt = db_api.raw_template_create(None, rt)
        s = {}
        s['name'] = stack.name
        s['raw_template_id'] = new_rt.id
        new_s = db_api.stack_create(None, s)
        stack.id = new_s.id
        pt = {}
        pt['template'] = stack.t
        pt['raw_template_id'] = new_rt.id
        new_pt = db_api.parsed_template_create(None, pt)
        instances.Instance.nova().AndReturn(self.fc)
        self.m.ReplayAll()
        stack.create_blocking()

        f = open('../../templates/WordPress_Single_Instance_gold.template')
        t = json.loads(f.read())
        params = {}
        parameters = {}
        params['KeyStoneCreds'] = None
        t['Parameters']['KeyName']['Value'] = 'test'
        stack = parser.Stack('test_stack_list', t, 0, params)

        man = manager.EngineManager()
        sl = man.list_stacks(None, params)

        assert(len(sl) > 0)
        for s in sl['stacks']:
            assert(s['stack_id'] > 0)
            assert(s['template_description'].find('WordPress') != -1)
示例#2
0
 def setUpClass(cls):
     # Create a dummy stack in the DB as WatchRule instances
     # must be associated with a stack
     ctx = context.get_admin_context()
     tmpl = db_api.raw_template_create(ctx, {'foo': 'bar'})
     dummy_stack = {'id': '6754d843-bed2-40dc-a325-84882bb90a98',
                     'name': 'dummystack',
                     'raw_template_id': tmpl.id,
                     'user_creds_id': 1,
                     'username': '******',
                     'owner_id': None,
                     'status': 'CREATE_COMPLETE',
                     'status_reason': 'foo status',
                     'parameters': {'foo': 'bar'},
                     'timeout': 60,
                     'tenant': 123456}
     db_ret = db_api.stack_create(ctx, dummy_stack)
     cls.stack_id = db_ret.id
示例#3
0
 def setUpClass(cls):
     # Create a dummy stack in the DB as WatchRule instances
     # must be associated with a stack
     ctx = context.get_admin_context()
     tmpl = db_api.raw_template_create(ctx, {'foo': 'bar'})
     dummy_stack = {
         'id': '6754d843-bed2-40dc-a325-84882bb90a98',
         'name': 'dummystack',
         'raw_template_id': tmpl.id,
         'user_creds_id': 1,
         'username': '******',
         'owner_id': None,
         'status': 'CREATE_COMPLETE',
         'status_reason': 'foo status',
         'parameters': {
             'foo': 'bar'
         },
         'timeout': 60,
         'tenant': 123456
     }
     db_ret = db_api.stack_create(ctx, dummy_stack)
     cls.stack_id = db_ret.id
示例#4
0
    def test_stack_event_list(self):
        stack = self.start_wordpress_stack('test_event_list_stack')
        self.m.ReplayAll()
        rt = {}
        rt['template'] = stack.t
        rt['stack_name'] = stack.name
        new_rt = db_api.raw_template_create(None, rt)
        s = {}
        s['name'] = stack.name
        s['raw_template_id'] = new_rt.id
        new_s = db_api.stack_create(None, s)
        stack.id = new_s.id
        pt = {}
        pt['template'] = stack.t
        pt['raw_template_id'] = new_rt.id
        new_pt = db_api.parsed_template_create(None, pt)
        stack.create_blocking()
        assert(stack.resources['WebServer'] != None)
        assert(stack.resources['WebServer'].instance_id > 0)

        m = manager.EngineManager()
        events = db_api.event_get_all_by_stack(None, stack.id)
        for ev in events:
            result = m.parse_event(ev)
            assert(result['EventId'] > 0)
            assert(result['StackName'] == "test_event_list_stack")
            # This is one of CREATE_COMPLETE or CREATE_IN_PROGRESS,
            # just did this to make it easy.
            assert(result['ResourceStatus'].find('CREATE') != -1)
            assert(result['ResourceType'] == 'AWS::EC2::Instance')
            assert(result['ResourceStatusReason'] == 'state changed')
            assert(result['LogicalResourceId'] == 'WebServer')
            # Big long user data field.. it mentions 'wordpress'
            # a few times so this should work.
            assert(result['ResourceProperties']['UserData'].find('wordpress')\
                   != -1)
            assert(result['ResourceProperties']['ImageId']\
                   == 'F16-x86_64-gold')
            assert(result['ResourceProperties']['InstanceType'] == 'm1.large')
示例#5
0
 def test_wordpress_single_instance_stack_delete(self):
     stack = self.start_wordpress_stack('test_stack')
     self.m.ReplayAll()
     rt = {}
     rt['template'] = stack.t
     rt['stack_name'] = stack.name
     new_rt = db_api.raw_template_create(None, rt)
     s = {}
     s['name'] = stack.name
     s['raw_template_id'] = new_rt.id
     new_s = db_api.stack_create(None, s)
     stack.id = new_s.id
     pt = {}
     pt['template'] = stack.t
     pt['raw_template_id'] = new_rt.id
     new_pt = db_api.parsed_template_create(None, pt)
     stack.create_blocking()
     assert(stack.resources['WebServer'] != None)
     assert(stack.resources['WebServer'].instance_id > 0)
     stack.delete_blocking()
     assert(stack.resources['WebServer'].state == 'DELETE_COMPLETE')
     assert(stack.t['stack_status'] == 'DELETE_COMPLETE')