Ejemplo n.º 1
0
    def test_get_inactive_flavors_with_same_flavorid(self):
        flav1 = flavors.create('flavor', 256, 1, 120, 100, "flavid")
        flavors.destroy('flavor')
        flav2 = flavors.create('flavor', 512, 4, 250, 100, "flavid")

        returned_flavors_ids = flavors.get_all_flavors().keys()
        self.assertNotIn(flav1.id, returned_flavors_ids)
        self.assertIn(flav2.id, returned_flavors_ids)

        returned_flavors_ids = flavors.get_all_flavors(inactive=True).keys()
        self.assertIn(flav1.id, returned_flavors_ids)
        self.assertIn(flav2.id, returned_flavors_ids)
Ejemplo n.º 2
0
    def test_get_inactive_flavors(self):
        flav1 = flavors.create('flavor1', 256, 1, 120)
        flav2 = flavors.create('flavor2', 512, 4, 250)
        flavors.destroy('flavor1')

        returned_flavors_ids = flavors.get_all_flavors().keys()
        self.assertNotIn(flav1.id, returned_flavors_ids)
        self.assertIn(flav2.id, returned_flavors_ids)

        returned_flavors_ids = flavors.get_all_flavors(inactive=True).keys()
        self.assertIn(flav1.id, returned_flavors_ids)
        self.assertIn(flav2.id, returned_flavors_ids)
Ejemplo n.º 3
0
    def test_basic_create(self):
        # Ensure instance types can be created.
        original_list = flavors.get_all_flavors()

        # Create new type and make sure values stick
        flavor = flavors.create('flavor', 64, 1, 120)
        self.assertEqual(flavor.name, 'flavor')
        self.assertEqual(flavor.memory_mb, 64)
        self.assertEqual(flavor.vcpus, 1)
        self.assertEqual(flavor.root_gb, 120)

        # Ensure new type shows up in list
        new_list = flavors.get_all_flavors()
        self.assertNotEqual(len(original_list), len(new_list),
                            'flavor was not created')
Ejemplo n.º 4
0
 def _generate_name(self):
     """return a name not in the DB."""
     nonexistent_flavor = str(int(time.time()))
     all_flavors = flavors.get_all_flavors()
     while nonexistent_flavor in all_flavors:
         nonexistent_flavor += "z"
     else:
         return nonexistent_flavor
Ejemplo n.º 5
0
 def _generate_flavorid(self):
     """return a flavorid not in the DB."""
     nonexistent_flavor = 2700
     flavor_ids = [value.id for key, value in
                   flavors.get_all_flavors().iteritems()]
     while nonexistent_flavor in flavor_ids:
         nonexistent_flavor += 1
     else:
         return nonexistent_flavor
Ejemplo n.º 6
0
    def test_create_then_delete(self):
        original_list = flavors.get_all_flavors()

        flavor = flavors.create('flavor', 64, 1, 120)

        # Ensure new type shows up in list
        new_list = flavors.get_all_flavors()
        self.assertNotEqual(len(original_list), len(new_list),
                            'instance type was not created')

        flavors.destroy('flavor')
        self.assertRaises(exception.FlavorNotFound,
                          flavors.get_flavor, flavor.id)

        # Deleted instance should not be in list anymore
        new_list = flavors.get_all_flavors()
        self.assertEqual(len(original_list), len(new_list))
        for k in original_list.keys():
            f = original_list[k]
            self.assertIsInstance(f, objects.Flavor)
            self.assertEqual(f.flavorid, new_list[k].flavorid)
Ejemplo n.º 7
0
 def test_get_all_instance_types(self):
     # Ensures that all flavors can be retrieved.
     session = sql_session.get_session()
     total_instance_types = session.query(models.InstanceTypes).count()
     inst_types = flavors.get_all_flavors()
     self.assertEqual(total_instance_types, len(inst_types))
Ejemplo n.º 8
0
 def _existing_flavor(self):
     """return first flavor name."""
     return flavors.get_all_flavors().keys()[0]