Example #1
0
    def test_get_bay_list_with_filters(self):
        bm1 = utils.get_test_baymodel(id=1, uuid=magnum_utils.generate_uuid())
        bm2 = utils.get_test_baymodel(id=2, uuid=magnum_utils.generate_uuid())
        self.dbapi.create_baymodel(bm1)
        self.dbapi.create_baymodel(bm2)

        bay1 = utils.create_test_bay(name='bay-one',
                                     uuid=magnum_utils.generate_uuid(),
                                     baymodel_id=bm1['uuid'])
        bay2 = utils.create_test_bay(name='bay-two',
                                     uuid=magnum_utils.generate_uuid(),
                                     baymodel_id=bm2['uuid'],
                                     node_count=1)

        res = self.dbapi.get_bay_list(self.context,
                                      filters={'baymodel_id': bm1['uuid']})
        self.assertEqual([bay1.id], [r.id for r in res])

        res = self.dbapi.get_bay_list(self.context,
                                      filters={'baymodel_id': bm2['uuid']})
        self.assertEqual([bay2.id], [r.id for r in res])

        res = self.dbapi.get_bay_list(self.context,
                                      filters={'name': 'bay-one'})
        self.assertEqual([bay1.id], [r.id for r in res])

        res = self.dbapi.get_bay_list(self.context,
                                      filters={'name': 'bad-bay'})
        self.assertEqual([], [r.id for r in res])

        res = self.dbapi.get_bay_list(self.context, filters={'node_count': 3})
        self.assertEqual([bay1.id], [r.id for r in res])

        res = self.dbapi.get_bay_list(self.context, filters={'node_count': 1})
        self.assertEqual([bay2.id], [r.id for r in res])
Example #2
0
    def test_get_bay_list_with_filters(self):
        bm1 = utils.get_test_baymodel(id=1, uuid=uuidutils.generate_uuid())
        bm2 = utils.get_test_baymodel(id=2, uuid=uuidutils.generate_uuid())
        self.dbapi.create_baymodel(bm1)
        self.dbapi.create_baymodel(bm2)

        bay1 = utils.create_test_bay(name='bay-one',
                                     uuid=uuidutils.generate_uuid(),
                                     baymodel_id=bm1['uuid'],
                                     status=bay_status.CREATE_IN_PROGRESS)
        bay2 = utils.create_test_bay(name='bay-two',
                                     uuid=uuidutils.generate_uuid(),
                                     baymodel_id=bm2['uuid'],
                                     node_count=1,
                                     master_count=1,
                                     status=bay_status.UPDATE_IN_PROGRESS)
        bay3 = utils.create_test_bay(name='bay-three',
                                     node_count=2,
                                     master_count=5,
                                     status=bay_status.DELETE_IN_PROGRESS)

        res = self.dbapi.get_bay_list(self.context,
                                      filters={'baymodel_id': bm1['uuid']})
        self.assertEqual([bay1.id], [r.id for r in res])

        res = self.dbapi.get_bay_list(self.context,
                                      filters={'baymodel_id': bm2['uuid']})
        self.assertEqual([bay2.id], [r.id for r in res])

        res = self.dbapi.get_bay_list(self.context,
                                      filters={'name': 'bay-one'})
        self.assertEqual([bay1.id], [r.id for r in res])

        res = self.dbapi.get_bay_list(self.context,
                                      filters={'name': 'bad-bay'})
        self.assertEqual([], [r.id for r in res])

        res = self.dbapi.get_bay_list(self.context, filters={'node_count': 3})
        self.assertEqual([bay1.id], [r.id for r in res])

        res = self.dbapi.get_bay_list(self.context, filters={'node_count': 1})
        self.assertEqual([bay2.id], [r.id for r in res])

        res = self.dbapi.get_bay_list(self.context,
                                      filters={'master_count': 3})
        self.assertEqual([bay1.id], [r.id for r in res])

        res = self.dbapi.get_bay_list(self.context,
                                      filters={'master_count': 1})
        self.assertEqual([bay2.id], [r.id for r in res])

        filters = {
            'status':
            [bay_status.CREATE_IN_PROGRESS, bay_status.DELETE_IN_PROGRESS]
        }
        res = self.dbapi.get_bay_list(self.context, filters=filters)
        self.assertEqual([bay1.id, bay3.id], [r.id for r in res])
Example #3
0
    def test_get_bay_list_with_filters(self):
        bm1 = utils.get_test_baymodel(id=1, uuid=magnum_utils.generate_uuid())
        bm2 = utils.get_test_baymodel(id=2, uuid=magnum_utils.generate_uuid())
        self.dbapi.create_baymodel(bm1)
        self.dbapi.create_baymodel(bm2)

        bay1 = utils.create_test_bay(
            name='bay-one',
            uuid=magnum_utils.generate_uuid(),
            baymodel_id=bm1['uuid'],
            status=bay_status.CREATE_IN_PROGRESS)
        bay2 = utils.create_test_bay(
            name='bay-two',
            uuid=magnum_utils.generate_uuid(),
            baymodel_id=bm2['uuid'],
            node_count=1,
            status=bay_status.UPDATE_IN_PROGRESS)
        bay3 = utils.create_test_bay(
            name='bay-three',
            node_count=2,
            status=bay_status.DELETE_IN_PROGRESS)

        res = self.dbapi.get_bay_list(self.context,
                                      filters={'baymodel_id': bm1['uuid']})
        self.assertEqual([bay1.id], [r.id for r in res])

        res = self.dbapi.get_bay_list(self.context,
                                      filters={'baymodel_id': bm2['uuid']})
        self.assertEqual([bay2.id], [r.id for r in res])

        res = self.dbapi.get_bay_list(self.context,
                                      filters={'name': 'bay-one'})
        self.assertEqual([bay1.id], [r.id for r in res])

        res = self.dbapi.get_bay_list(self.context,
                                      filters={'name': 'bad-bay'})
        self.assertEqual([], [r.id for r in res])

        res = self.dbapi.get_bay_list(self.context,
                                      filters={'node_count': 3})
        self.assertEqual([bay1.id], [r.id for r in res])

        res = self.dbapi.get_bay_list(self.context,
                                      filters={'node_count': 1})
        self.assertEqual([bay2.id], [r.id for r in res])

        filters = {'status': [bay_status.CREATE_IN_PROGRESS,
                              bay_status.DELETE_IN_PROGRESS]}
        res = self.dbapi.get_bay_list(self.context,
                                      filters=filters)
        self.assertEqual([bay1.id, bay3.id], [r.id for r in res])
Example #4
0
 def setUp(self):
     super(TestHandler, self).setUp()
     self.handler = bay_conductor.Handler()
     baymodel_dict = utils.get_test_baymodel()
     self.baymodel = objects.BayModel(self.context, **baymodel_dict)
     self.baymodel.create()
     bay_dict = utils.get_test_bay(node_count=1)
     self.bay = objects.Bay(self.context, **bay_dict)
     self.bay.create()
Example #5
0
 def setUp(self):
     super(TestHandler, self).setUp()
     self.handler = bay_conductor.Handler()
     baymodel_dict = utils.get_test_baymodel()
     self.baymodel = objects.BayModel(self.context, **baymodel_dict)
     self.baymodel.create()
     bay_dict = utils.get_test_bay(node_count=1)
     self.bay = objects.Bay(self.context, **bay_dict)
     self.bay.create()
Example #6
0
 def test_get_baymodel_list(self):
     uuids = []
     for i in range(1, 6):
         bm = utils.get_test_baymodel(id=i,
                                      uuid=magnum_utils.generate_uuid())
         self.dbapi.create_baymodel(bm)
         uuids.append(six.text_type(bm['uuid']))
     res = self.dbapi.get_baymodel_list(self.context)
     res_uuids = [r.uuid for r in res]
     self.assertEqual(sorted(uuids), sorted(res_uuids))
Example #7
0
 def test_get_baymodel_list(self):
     uuids = []
     for i in range(1, 6):
         bm = utils.get_test_baymodel(id=i,
                                      uuid=magnum_utils.generate_uuid())
         self.dbapi.create_baymodel(bm)
         uuids.append(six.text_type(bm['uuid']))
     res = self.dbapi.get_baymodel_list(self.context)
     res_uuids = [r.uuid for r in res]
     self.assertEqual(sorted(uuids), sorted(res_uuids))
Example #8
0
 def setup_poll_test(self, mock_openstack_client, cfg,
                     mock_retrieve_baymodel):
     cfg.CONF.bay_heat.max_attempts = 10
     bay = mock.MagicMock()
     baymodel_dict = utils.get_test_baymodel(coe='kubernetes')
     mock_heat_stack = mock.MagicMock()
     mock_heat_client = mock.MagicMock()
     mock_heat_client.stacks.get.return_value = mock_heat_stack
     mock_openstack_client.heat.return_value = mock_heat_client
     baymodel = objects.BayModel(self.context, **baymodel_dict)
     mock_retrieve_baymodel.return_value = baymodel
     poller = bay_conductor.HeatPoller(mock_openstack_client, bay)
     return (mock_heat_stack, bay, poller)
Example #9
0
    def test_get_bay_list_with_filters(self):
        bm1 = utils.get_test_baymodel(id=1, uuid=magnum_utils.generate_uuid())
        bm2 = utils.get_test_baymodel(id=2, uuid=magnum_utils.generate_uuid())
        self.dbapi.create_baymodel(bm1)
        self.dbapi.create_baymodel(bm2)

        bay1 = utils.create_test_bay(
            name='bay-one',
            uuid=magnum_utils.generate_uuid(),
            baymodel_id=bm1['uuid'])
        bay2 = utils.create_test_bay(
            name='bay-two',
            uuid=magnum_utils.generate_uuid(),
            baymodel_id=bm2['uuid'],
            node_count=1)

        res = self.dbapi.get_bay_list(self.context,
                                      filters={'baymodel_id': bm1['uuid']})
        self.assertEqual([bay1.id], [r.id for r in res])

        res = self.dbapi.get_bay_list(self.context,
                                      filters={'baymodel_id': bm2['uuid']})
        self.assertEqual([bay2.id], [r.id for r in res])

        res = self.dbapi.get_bay_list(self.context,
                                      filters={'name': 'bay-one'})
        self.assertEqual([bay1.id], [r.id for r in res])

        res = self.dbapi.get_bay_list(self.context,
                                      filters={'name': 'bad-bay'})
        self.assertEqual([], [r.id for r in res])

        res = self.dbapi.get_bay_list(self.context,
                                      filters={'node_count': 3})
        self.assertEqual([bay1.id], [r.id for r in res])

        res = self.dbapi.get_bay_list(self.context,
                                      filters={'node_count': 1})
        self.assertEqual([bay2.id], [r.id for r in res])
Example #10
0
 def setup_poll_test(self, mock_openstack_client, cfg,
                     mock_retrieve_baymodel):
     cfg.CONF.bay_heat.max_attempts = 10
     bay = mock.MagicMock()
     baymodel_dict = utils.get_test_baymodel(coe='kubernetes')
     mock_heat_stack = mock.MagicMock()
     mock_heat_client = mock.MagicMock()
     mock_heat_client.stacks.get.return_value = mock_heat_stack
     mock_openstack_client.heat.return_value = mock_heat_client
     baymodel = objects.BayModel(self.context, **baymodel_dict)
     mock_retrieve_baymodel.return_value = baymodel
     poller = bay_conductor.HeatPoller(mock_openstack_client, bay)
     return (mock_heat_stack, bay, poller)
Example #11
0
def get_test_baymodel(context, **kw):
    """Return a BayModel object with appropriate attributes.

    NOTE: The object leaves the attributes marked as changed, such
    that a create() could be used to commit it to the DB.
    """
    db_baymodel = db_utils.get_test_baymodel(**kw)
    # Let DB generate ID if it isn't specified explicitly
    if 'id' not in kw:
        del db_baymodel['id']
    baymodel = objects.BayModel(context)
    for key in db_baymodel:
        setattr(baymodel, key, db_baymodel[key])
    return baymodel
Example #12
0
    def setUp(self):
        super(TestHandler, self).setUp()
        self.handler = bay_conductor.Handler()
        baymodel_dict = utils.get_test_baymodel()
        self.baymodel = objects.BayModel(self.context, **baymodel_dict)
        self.baymodel.create()
        bay_dict = utils.get_test_bay(node_count=1)
        self.bay = objects.Bay(self.context, **bay_dict)
        self.bay.create()

        self.p = patch(
            'magnum.conductor.handlers.bay_conductor.Handler.'
            '_create_trustee_and_trust')

        def create_trustee_and_trust(osc, bay):
            bay.trust_id = 'trust_id'
            bay.trustee_username = '******'
            bay.trustee_user_id = 'user_id'
            bay.trustee_password = '******'

        self.p.side_effect = create_trustee_and_trust
        self.p.start()
Example #13
0
 def setUp(self):
     super(TestBayModelObject, self).setUp()
     self.fake_baymodel = utils.get_test_baymodel()
Example #14
0
def baymodel_post_data(**kw):
    baymodel = utils.get_test_baymodel(**kw)
    internal = baymodel_controller.BayModelPatchType.internal_attrs()
    return remove_internal(baymodel, internal)
Example #15
0
 def setUp(self):
     super(TestBayModelObject, self).setUp()
     self.fake_baymodel = utils.get_test_baymodel()
Example #16
0
def cluster_template_post_data(**kw):
    cluster_template = utils.get_test_baymodel(**kw)
    internal = cluster_tmp_ctrl.ClusterTemplatePatchType.internal_attrs()
    return remove_internal(cluster_template, internal)
Example #17
0
 def _create_test_baymodel(self, **kwargs):
     bm = utils.get_test_baymodel(**kwargs)
     self.dbapi.create_baymodel(bm)
     return bm
Example #18
0
 def _create_test_baymodel(self, **kwargs):
     bm = utils.get_test_baymodel(**kwargs)
     self.dbapi.create_baymodel(bm)
     return bm