Beispiel #1
0
    def test_activate_and_deactivate_bootloader(self):
        self._create_node()
        instance_type = {
            'extra_specs': {
                'baremetal:deploy_kernel_id': 'eeee',
                'baremetal:deploy_ramdisk_id': 'ffff',
            }
        }
        self.instance['uuid'] = 'fake-uuid'

        self.mox.StubOutWithMock(self.driver.virtapi, 'instance_type_get')
        self.mox.StubOutWithMock(bm_utils, 'write_to_file')
        self.mox.StubOutWithMock(bm_utils, 'create_link_without_raise')
        self.mox.StubOutWithMock(bm_utils, 'unlink_without_raise')
        self.mox.StubOutWithMock(bm_utils, 'rmtree_without_raise')

        self.driver.virtapi.instance_type_get(
            self.context,
            self.instance['instance_type_id']).AndReturn(instance_type)

        # create the config file
        bm_utils.write_to_file(mox.StrContains('fake-uuid'),
                               mox.StrContains(CONF.baremetal.tftp_root))
        # unlink and link the 2 interfaces
        for i in range(2):
            bm_utils.unlink_without_raise(
                mox.Or(mox.StrContains('fake-uuid'),
                       mox.StrContains(CONF.baremetal.tftp_root)))
            bm_utils.create_link_without_raise(
                mox.StrContains('fake-uuid'),
                mox.StrContains(CONF.baremetal.tftp_root))
        # unlink all 2 interfaces, 4 images, and the config file
        for i in range(7):
            bm_utils.unlink_without_raise(
                mox.Or(mox.StrContains('fake-uuid'),
                       mox.StrContains(CONF.baremetal.tftp_root)))
        bm_utils.rmtree_without_raise(mox.StrContains('fake-uuid'))

        self.mox.ReplayAll()

        # activate and deactivate the bootloader
        # and check the deployment task_state in the database
        row = db.bm_node_get(self.context, 1)
        self.assertIsNone(row['deploy_key'])

        self.driver.activate_bootloader(self.context,
                                        self.node,
                                        self.instance,
                                        network_info=self.test_network_info)
        row = db.bm_node_get(self.context, 1)
        self.assertIsNotNone(row['deploy_key'])

        self.driver.deactivate_bootloader(self.context, self.node,
                                          self.instance)
        row = db.bm_node_get(self.context, 1)
        self.assertIsNone(row['deploy_key'])

        self.mox.VerifyAll()
Beispiel #2
0
 def testInvalidOr(self):
   """Or should be False if both Comparators return False."""
   self.failIf(mox.Or(mox.IsA(dict), mox.IsA(str)) == 0)
Beispiel #3
0
 def testValidOr(self):
   """Or should be True if either Comparator returns True."""
   self.assert_(mox.Or(mox.IsA(dict), mox.IsA(str)) == {})
   self.assert_(mox.Or(mox.IsA(dict), mox.IsA(str)) == 'test')
   self.assert_(mox.Or(mox.IsA(str), mox.IsA(str)) == 'test')