Example #1
0
 def test_find_flavor_differences_no_differences(self):
     empty_flavor_diff = {'new': set(), 'retired': set()}
     self.assertEqual(empty_flavor_diff,
                      sb.find_flavor_differences([], []))
     self.assertEqual(empty_flavor_diff,
                      sb.find_flavor_differences(TEST_FLAVORS,
                                                 TEST_FLAVORS))
Example #2
0
 def test_find_flavor_differences_no_differences(self):
     empty_flavor_diff = {'new': set(), 'retired': set()}
     self.assertEqual(empty_flavor_diff,
                      sb.find_flavor_differences([], []))
     self.assertEqual(empty_flavor_diff,
                      sb.find_flavor_differences(TEST_FLAVORS,
                                                 TEST_FLAVORS))
Example #3
0
 def test_find_flavor_differences_retired_flavors(self):
     flavors_with_retired = copy.deepcopy(TEST_FLAVORS)
     flavors_with_retired.pop(0)
     self.assertEqual(
         {"new": set(), "retired": set(["IO"])}, sb.find_flavor_differences(TEST_FLAVORS, flavors_with_retired)
     )
     flavors_with_retired.pop(0)
     self.assertEqual(
         {"new": set(), "retired": set(["IO", "Compute"])},
         sb.find_flavor_differences(TEST_FLAVORS, flavors_with_retired),
     )
Example #4
0
 def test_find_flavor_differences_retired_flavors(self):
     flavors_with_retired = copy.deepcopy(TEST_FLAVORS)
     flavors_with_retired.pop(0)
     self.assertEqual({'new': set(),
                       'retired': set(['IO'])},
                      sb.find_flavor_differences(TEST_FLAVORS,
                                                 flavors_with_retired))
     flavors_with_retired.pop(0)
     self.assertEqual({'new': set(),
                       'retired': set(['IO', 'Compute'])},
                      sb.find_flavor_differences(TEST_FLAVORS,
                                                 flavors_with_retired))
Example #5
0
 def test_find_flavor_differences_retired_flavors(self):
     flavors_with_retired = copy.deepcopy(TEST_FLAVORS)
     flavors_with_retired.pop(0)
     self.assertEqual({'new': set(),
                       'retired': set(['IO'])},
                      sb.find_flavor_differences(TEST_FLAVORS,
                                                 flavors_with_retired))
     flavors_with_retired.pop(0)
     self.assertEqual({'new': set(),
                       'retired': set(['IO', 'Compute'])},
                      sb.find_flavor_differences(TEST_FLAVORS,
                                                 flavors_with_retired))
Example #6
0
 def test_find_flavor_differences_new_flavors(self):
     flavors_with_new = copy.deepcopy(TEST_FLAVORS)
     flavors_with_new.append(sb.FlavorInput("GraphicalCompute", lambda node: True))
     self.assertEqual(
         {"new": set(["GraphicalCompute"]), "retired": set()},
         sb.find_flavor_differences(TEST_FLAVORS, flavors_with_new),
     )
     flavors_with_new.append(sb.FlavorInput("BitcoinMiner", lambda node: False))
     self.assertEqual(
         {"new": set(["GraphicalCompute", "BitcoinMiner"]), "retired": set()},
         sb.find_flavor_differences(TEST_FLAVORS, flavors_with_new),
     )
Example #7
0
 def test_find_flavor_differences_new_flavors(self):
     flavors_with_new = copy.deepcopy(TEST_FLAVORS)
     flavors_with_new.append(sb.FlavorInput('GraphicalCompute',
                                            lambda node: True))
     self.assertEqual({'new': set(['GraphicalCompute']),
                       'retired': set()},
                      sb.find_flavor_differences(TEST_FLAVORS,
                                                 flavors_with_new))
     flavors_with_new.append(sb.FlavorInput("BitcoinMiner",
                                            lambda node: False))
     self.assertEqual({'new': set(["GraphicalCompute", "BitcoinMiner"]),
                       'retired': set()},
                      sb.find_flavor_differences(TEST_FLAVORS,
                                                 flavors_with_new))
Example #8
0
 def test_find_flavor_differences_all_diffs(self):
     flavors_with_all_diffs = copy.deepcopy(TEST_FLAVORS)
     flavors_with_all_diffs.pop(0)
     flavors_with_all_diffs.append(sb.FlavorInput("GraphicalCompute", lambda node: True))
     self.assertEqual(
         {"new": set(["GraphicalCompute"]), "retired": set(["IO"])},
         sb.find_flavor_differences(TEST_FLAVORS, flavors_with_all_diffs),
     )
Example #9
0
 def test_find_flavor_differences_all_diffs(self):
     flavors_with_all_diffs = copy.deepcopy(TEST_FLAVORS)
     flavors_with_all_diffs.pop(0)
     flavors_with_all_diffs.append(sb.FlavorInput('GraphicalCompute',
                                                  lambda node: True))
     self.assertEqual({'new': set(['GraphicalCompute']),
                       'retired': set(['IO'])},
                      sb.find_flavor_differences(TEST_FLAVORS,
                                                 flavors_with_all_diffs))
Example #10
0
 def test_find_flavor_differences_all_diffs(self):
     flavors_with_all_diffs = copy.deepcopy(TEST_FLAVORS)
     flavors_with_all_diffs.pop(0)
     flavors_with_all_diffs.append(sb.FlavorInput('GraphicalCompute',
                                                  lambda node: True))
     self.assertEqual({'new': set(['GraphicalCompute']),
                       'retired': set(['IO'])},
                      sb.find_flavor_differences(TEST_FLAVORS,
                                                 flavors_with_all_diffs))
    def update_current_state(self, nodes, images, flavors):
        # For now, flavors should remain static.
        # In the future we'll handle changing flavor profiles if needed,
        # but it seems unlikely that flavors will change often enough.
        self.flavor_diff = sb.find_flavor_differences(self.current_flavors, flavors)
        sb.log_flavor_differences(self.flavor_diff)
        self.current_flavors = flavors

        # Image differences are important because changed or retired
        # images should be ejected from the cache.
        self.image_diff = sb.find_image_differences(self.current_images, images)
        sb.log_image_differences(self.image_diff)
        self.current_images = images
        self.current_image_uuids = sb.build_attribute_set(images, "uuid")

        # We don't compare old node state versus new, because that would be
        # a relatively large and complicated task. Instead, we only rely on
        # the current state of nodes to inform ourselves whether we're meeting
        # our stated goals or not.
        self.current_nodes = nodes
    def update_current_state(self, nodes, images, flavors):
        # For now, flavors should remain static.
        # In the future we'll handle changing flavor profiles if needed,
        # but it seems unlikely that flavors will change often enough.
        self.flavor_diff = sb.find_flavor_differences(self.current_flavors,
                                                      flavors)
        sb.log_flavor_differences(self.flavor_diff)
        self.current_flavors = flavors

        # Image differences are important because changed or retired
        # images should be ejected from the cache.
        self.image_diff = sb.find_image_differences(self.current_images,
                                                    images)
        sb.log_image_differences(self.image_diff)
        self.current_images = images
        self.current_image_uuids = sb.build_attribute_set(images, 'uuid')

        # We don't compare old node state versus new, because that would be
        # a relatively large and complicated task. Instead, we only rely on
        # the current state of nodes to inform ourselves whether we're meeting
        # our stated goals or not.
        self.current_nodes = nodes