Exemplo n.º 1
0
 def _insert_dummy_vim_barbican(self):
     session = self.context.session
     vim_db = meo_db.Vim(id='6261579e-d6f3-49ad-8bc3-a9cb974778ff',
                         tenant_id='ad7ebc56538745a08ef7c5e97f8bd437',
                         name='fake_vim',
                         description='fake_vim_description',
                         type='openstack',
                         status='Active',
                         deleted_at=datetime.min,
                         placement_attr={'regions': ['RegionOne']})
     vim_auth_db = meo_db.VimAuth(
         vim_id='6261579e-d6f3-49ad-8bc3-a9cb974778ff',
         password='******',
         auth_url='http://localhost:5000',
         vim_project={'name': 'test_project'},
         auth_cred={
             'username': '******',
             'user_domain_id': 'default',
             'project_domain_id': 'default',
             'key_type': 'barbican_key',
             'secret_uuid': 'fake-secret-uuid'
         })
     session.add(vim_db)
     session.add(vim_auth_db)
     session.flush()
Exemplo n.º 2
0
    def create_vim(self, context, vim):
        self._validate_default_vim(context, vim)
        vim_cred = vim['auth_cred']

        try:
            with context.session.begin(subtransactions=True):
                vim_db = meo_db.Vim(id=vim.get('id'),
                                    type=vim.get('type'),
                                    tenant_id=vim.get('tenant_id'),
                                    name=vim.get('name'),
                                    description=vim.get('description'),
                                    placement_attr=vim.get('placement_attr'),
                                    is_default=vim.get('is_default'),
                                    status=vim.get('status'),
                                    deleted_at=datetime.min)
                context.session.add(vim_db)
                vim_auth_db = meo_db.VimAuth(
                    id=uuidutils.generate_uuid(),
                    vim_id=vim.get('id'),
                    password=vim_cred.pop('password'),
                    vim_project=vim.get('vim_project'),
                    auth_url=vim.get('auth_url'),
                    auth_cred=vim_cred)
                context.session.add(vim_auth_db)
        except DBDuplicateEntry as e:
            raise exceptions.DuplicateEntity(_type="vim", entry=e.columns)
        vim_dict = self._make_vim_dict(vim_db)
        self._cos_db_plg.create_event(context,
                                      res_id=vim_dict['id'],
                                      res_type=constants.RES_TYPE_VIM,
                                      res_state=vim_dict['status'],
                                      evt_type=constants.RES_EVT_CREATE,
                                      tstamp=vim_dict['created_at'])
        return vim_dict