Beispiel #1
0
 def test_migration(self):
     main_flavors = len(db.flavor_get_all(self.context))
     match, done = flavor_obj.migrate_flavors(self.context, 50)
     self.assertEqual(main_flavors, match)
     self.assertEqual(main_flavors, done)
     self.assertEqual(0, len(db.flavor_get_all(self.context)))
     self.assertEqual(main_flavors,
                      len(objects.FlavorList.get_all(self.context)))
Beispiel #2
0
    def test_rxtx_factor_must_be_within_sql_float_range(self):
        _context = context.get_admin_context()
        db.flavor_get_all(_context)
        # We do * 10 since this is an approximation and we need to make sure
        # the difference is noticeble.
        over_rxtx_factor = flavors.SQL_SP_FLOAT_MAX * 10

        self.assertInvalidInput("flavor1", 64, 1, 120, rxtx_factor=over_rxtx_factor)

        flavor = flavors.create("flavor2", 64, 1, 120, rxtx_factor=flavors.SQL_SP_FLOAT_MAX)
        self.assertEqual(flavors.SQL_SP_FLOAT_MAX, flavor.rxtx_factor)
 def test_migration(self):
     # create a flavor in the main database that will be migrated
     _create_main_flavor(self.context)
     main_flavors = len(db.flavor_get_all(self.context))
     self.assertEqual(1, main_flavors)
     match, done = flavor_obj.migrate_flavors(self.context, 50)
     self.assertEqual(main_flavors, match)
     self.assertEqual(main_flavors, done)
     self.assertEqual(0, len(db.flavor_get_all(self.context)))
     self.assertEqual(main_flavors,
                      len(objects.FlavorList.get_all(self.context)))
Beispiel #4
0
    def test_rxtx_factor_must_be_within_sql_float_range(self):
        _context = context.get_admin_context()
        db.flavor_get_all(_context)
        # We do * 10 since this is an approximation and we need to make sure
        # the difference is noticeble.
        over_rxtx_factor = db.SQL_SP_FLOAT_MAX * 10

        self.assertInvalidInput('flavor1', 64, 1, 120,
                                rxtx_factor=over_rxtx_factor)

        flavor = flavors.create('flavor2', 64, 1, 120,
                                rxtx_factor=db.SQL_SP_FLOAT_MAX)
        self.assertEqual(db.SQL_SP_FLOAT_MAX, flavor.rxtx_factor)
    def get_all(cls, context, inactive=False, filters=None,
                sort_key='flavorid', sort_dir='asc', limit=None, marker=None):
        try:
            api_db_flavors = _flavor_get_all_from_db(context,
                                                     inactive=inactive,
                                                     filters=filters,
                                                     sort_key=sort_key,
                                                     sort_dir=sort_dir,
                                                     limit=limit,
                                                     marker=marker)
            # NOTE(danms): If we were asked for a marker and found it in
            # results from the API DB, we must continue our pagination with
            # just the limit (if any) to the main DB.
            marker = None
        except exception.MarkerNotFound:
            api_db_flavors = []

        if limit is not None:
            limit_more = limit - len(api_db_flavors)
        else:
            limit_more = None

        if limit_more is None or limit_more > 0:
            db_flavors = db.flavor_get_all(context, inactive=inactive,
                                           filters=filters, sort_key=sort_key,
                                           sort_dir=sort_dir, limit=limit_more,
                                           marker=marker)
        else:
            db_flavors = []
        return base.obj_make_list(context, cls(context), objects.Flavor,
                                  api_db_flavors + db_flavors,
                                  expected_attrs=['extra_specs'])
Beispiel #6
0
    def get_all(cls, context, inactive=False, filters=None,
                sort_key='flavorid', sort_dir='asc', limit=None, marker=None):
        try:
            api_db_flavors = _flavor_get_all_from_db(context,
                                                     inactive=inactive,
                                                     filters=filters,
                                                     sort_key=sort_key,
                                                     sort_dir=sort_dir,
                                                     limit=limit,
                                                     marker=marker)
            # NOTE(danms): If we were asked for a marker and found it in
            # results from the API DB, we must continue our pagination with
            # just the limit (if any) to the main DB.
            marker = None
        except exception.MarkerNotFound:
            api_db_flavors = []

        if limit is not None:
            limit_more = limit - len(api_db_flavors)
        else:
            limit_more = None

        if limit_more is None or limit_more > 0:
            db_flavors = db.flavor_get_all(context, inactive=inactive,
                                           filters=filters, sort_key=sort_key,
                                           sort_dir=sort_dir, limit=limit_more,
                                           marker=marker)
        else:
            db_flavors = []
        return base.obj_make_list(context, cls(context), objects.Flavor,
                                  api_db_flavors + db_flavors,
                                  expected_attrs=['extra_specs'])
Beispiel #7
0
 def get_all(cls, context, inactive=False, filters=None,
             sort_key='flavorid', sort_dir='asc', limit=None, marker=None):
     db_flavors = db.flavor_get_all(context, inactive=inactive,
                                    filters=filters, sort_key=sort_key,
                                    sort_dir=sort_dir, limit=limit,
                                    marker=marker)
     return base.obj_make_list(context, cls(), Flavor, db_flavors,
                               expected_attrs=['extra_specs'])
Beispiel #8
0
 def get_all(cls, context, inactive=False, filters=None,
             sort_key='flavorid', sort_dir='asc', limit=None, marker=None):
     db_flavors = db.flavor_get_all(context, inactive=inactive,
                                    filters=filters, sort_key=sort_key,
                                    sort_dir=sort_dir, limit=limit,
                                    marker=marker)
     return base.obj_make_list(context, cls(context), objects.Flavor,
                               db_flavors, expected_attrs=['extra_specs'])
    def test_instance_type_get_all(self):
        types = db.flavor_get_all(self.context)

        name2specs = {}
        for instance_type in types:
            name = instance_type['name']
            name2specs[name] = instance_type['extra_specs']

        self.assertEqual(name2specs['cg1.4xlarge'], self.specs)
        self.assertEqual(name2specs['m1.small'], {})
    def test_instance_type_get_all(self):
        types = db.flavor_get_all(self.context)

        name2specs = {}
        for instance_type in types:
            name = instance_type['name']
            name2specs[name] = instance_type['extra_specs']

        self.assertEqual(name2specs['cg1.4xlarge'], self.specs)
        self.assertEqual(name2specs['m1.small'], {})
Beispiel #11
0
    def setUp(self):
        super(DisabledFlavorsWithRealDBTestV21, self).setUp()

        # Add a new disabled type to the list of flavors
        self.req = self.fake_request.blank(self._prefix + "/flavors")
        self.context = self.req.environ["nova.context"]
        self.admin_context = context.get_admin_context()

        self.disabled_type = self._create_disabled_instance_type()
        self.inst_types = db.flavor_get_all(self.admin_context)
        self.controller = self.Controller()
Beispiel #12
0
    def setUp(self):
        super(DisabledFlavorsWithRealDBTest, self).setUp()
        self.controller = flavors.FlavorsController()

        # Add a new disabled type to the list of flavors
        self.req = fakes.HTTPRequestV3.blank('/flavors')
        self.context = self.req.environ['nova.context']
        self.admin_context = context.get_admin_context()

        self.disabled_type = self._create_disabled_instance_type()
        self.inst_types = db.flavor_get_all(self.admin_context)
Beispiel #13
0
def get_all_flavors_sorted_list(
    ctxt=None, inactive=False, filters=None, sort_key="flavorid", sort_dir="asc", limit=None, marker=None
):
    """Get all non-deleted flavors as a sorted list.

    Pass true as argument if you want deleted flavors returned also.
    """
    if ctxt is None:
        ctxt = context.get_admin_context()

    return db.flavor_get_all(ctxt, filters=filters, sort_key=sort_key, sort_dir=sort_dir, limit=limit, marker=marker)
    def setUp(self):
        super(DisabledFlavorsWithRealDBTest, self).setUp()
        self.controller = flavors.FlavorsController()

        # Add a new disabled type to the list of flavors
        self.req = fakes.HTTPRequestV3.blank('/flavors')
        self.context = self.req.environ['nova.context']
        self.admin_context = context.get_admin_context()

        self.disabled_type = self._create_disabled_instance_type()
        self.inst_types = db.flavor_get_all(self.admin_context)
Beispiel #15
0
def get_all_flavors_sorted_list(ctxt=None, inactive=False, filters=None,
                                sort_key='flavorid', sort_dir='asc',
                                limit=None, marker=None):
    """Get all non-deleted flavors as a sorted list.

    Pass true as argument if you want deleted flavors returned also.
    """
    if ctxt is None:
        ctxt = context.get_admin_context()

    return db.flavor_get_all(ctxt, filters=filters, sort_key=sort_key,
                             sort_dir=sort_dir, limit=limit, marker=marker)
Beispiel #16
0
    def _create_disabled_instance_type(self):
        inst_types = db.flavor_get_all(self.admin_context)

        inst_type = inst_types[0]

        del inst_type["id"]
        inst_type["name"] += ".disabled"
        inst_type["flavorid"] = six.text_type(max([int(flavor["flavorid"]) for flavor in inst_types]) + 1)
        inst_type["disabled"] = True

        disabled_type = db.flavor_create(self.admin_context, inst_type)

        return disabled_type
Beispiel #17
0
 def get_all(
     cls, context, inactive=False, filters=None, sort_key="flavorid", sort_dir="asc", limit=None, marker=None
 ):
     db_flavors = db.flavor_get_all(
         context,
         inactive=inactive,
         filters=filters,
         sort_key=sort_key,
         sort_dir=sort_dir,
         limit=limit,
         marker=marker,
     )
     return base.obj_make_list(context, cls(context), objects.Flavor, db_flavors, expected_attrs=["extra_specs"])
Beispiel #18
0
def get_all_flavors(ctxt=None, inactive=False, filters=None):
    """Get all non-deleted flavors as a dict.

    Pass true as argument if you want deleted flavors returned also.
    """
    if ctxt is None:
        ctxt = context.get_admin_context()

    inst_types = db.flavor_get_all(ctxt, inactive=inactive, filters=filters)

    inst_type_dict = {}
    for inst_type in inst_types:
        inst_type_dict[inst_type["name"]] = inst_type
    return inst_type_dict
    def _create_disabled_instance_type(self):
        inst_types = db.flavor_get_all(self.admin_context)

        inst_type = inst_types[0]

        del inst_type['id']
        inst_type['name'] += '.disabled'
        inst_type['flavorid'] = unicode(
            max([int(flavor['flavorid']) for flavor in inst_types]) + 1)
        inst_type['disabled'] = True

        disabled_type = db.flavor_create(self.admin_context, inst_type)

        return disabled_type
Beispiel #20
0
def get_all_flavors(ctxt=None, inactive=False, filters=None):
    """Get all non-deleted flavors as a dict.

    Pass true as argument if you want deleted flavors returned also.
    """
    if ctxt is None:
        ctxt = context.get_admin_context()

    inst_types = db.flavor_get_all(ctxt, inactive=inactive, filters=filters)

    inst_type_dict = {}
    for inst_type in inst_types:
        inst_type_dict[inst_type['id']] = inst_type
    return inst_type_dict
Beispiel #21
0
    def _create_disabled_instance_type(self):
        inst_types = db.flavor_get_all(self.admin_context)

        inst_type = inst_types[0]

        del inst_type['id']
        inst_type['name'] += '.disabled'
        inst_type['flavorid'] = six.text_type(max(
                [int(flavor['flavorid']) for flavor in inst_types]) + 1)
        inst_type['disabled'] = True

        disabled_type = db.flavor_create(
                self.admin_context, inst_type)

        return disabled_type
    def test_instance_type_get_all(self):
        specs = dict(cpu_arch="x86_64",
                        cpu_model="Nehalem",
                        xpu_arch="fermi",
                        xpus='2',
                        xpu_model="Tesla 2050")

        types = db.flavor_get_all(self.context)

        name2specs = {}
        for instance_type in types:
            name = instance_type['name']
            name2specs[name] = instance_type['extra_specs']

        self.assertEquals(name2specs['cg1.4xlarge'], specs)
        self.assertEquals(name2specs['m1.small'], {})
Beispiel #23
0
    def test_instance_type_get_all(self):
        specs = dict(cpu_arch="x86_64",
                     cpu_model="Nehalem",
                     xpu_arch="fermi",
                     xpus='2',
                     xpu_model="Tesla 2050")

        types = db.flavor_get_all(self.context)

        name2specs = {}
        for instance_type in types:
            name = instance_type['name']
            name2specs[name] = instance_type['extra_specs']

        self.assertEquals(name2specs['cg1.4xlarge'], specs)
        self.assertEquals(name2specs['m1.small'], {})
Beispiel #24
0
 def assertFilterResults(self, filters, expected):
     inst_types = db.flavor_get_all(self.context, filters=filters)
     inst_names = [i['name'] for i in inst_types]
     self.assertEqual(inst_names, expected)
Beispiel #25
0
 def assertFilterResults(self, filters, expected):
     inst_types = db.flavor_get_all(
             self.context, filters=filters)
     inst_names = [i['name'] for i in inst_types]
     self.assertEqual(inst_names, expected)