Example #1
0
    def get_chassis(self, identity):
        """Given the identity return a Chassis object

        :param identity: The identity of the Chassis resource
        :returns: The Chassis object
        """
        return chassis.Chassis(self._conn,
                               identity,
                               redfish_version=self.redfish_version)
Example #2
0
    def setUp(self):
        super(TestChassis, self).setUp()
        self.conn = mock.Mock()

        with open('rsd_lib/tests/unit/json_samples/v2_1/chassis.json',
                  'r') as f:
            self.conn.get.return_value.json.return_value = json.loads(f.read())

        self.chassis_inst = chassis.Chassis(self.conn,
                                            '/redfish/v1/Chassis/chassis1',
                                            redfish_version='1.0.2')
    def setUp(self, mock_connector, pod_conn):
        """Initial setup of mocks for all of the unit tests."""
        super(TestRSDDriver, self).setUp()
        # Mock out the connection to the RSD redfish API
        self.root_conn = mock.MagicMock()
        mock_connector.return_value = self.root_conn

        # Create sample collections and instances of Chassis/System/Nodes
        with open('rsd_virt_for_nova/tests/json_samples/root.json', 'r') as f:
            self.root_conn.get.return_value.json.return_value = json.loads(
                f.read())
        self.rsd = rsd_lib.main.RSDLib('http://foo.bar:8442',
                                       username='******',
                                       password='******',
                                       verify=False).factory()

        with open('rsd_virt_for_nova/tests/json_samples/chassis_col.json',
                  'r') as f:
            self.root_conn.get.return_value.json.return_value = json.loads(
                f.read())
        self.chassis_col = chassis.ChassisCollection(self.root_conn,
                                                     '/redfish/v1/Chassis',
                                                     redfish_version='1.0.2')

        with open('rsd_virt_for_nova/tests/json_samples/chassis.json',
                  'r') as f:
            self.root_conn.get.return_value.json.return_value = json.loads(
                f.read())

        self.chassis_inst = chassis.Chassis(self.root_conn,
                                            '/redfish/v1/Chassis/Chassis1',
                                            redfish_version='1.0.2')

        with open('rsd_virt_for_nova/tests/json_samples/node_col.json',
                  'r') as f:
            self.root_conn.get.return_value.json.return_value = json.loads(
                f.read())
        self.node_collection = node.NodeCollection(self.root_conn,
                                                   '/redfish/v1/Nodes',
                                                   redfish_version='1.0.2')

        with open('rsd_virt_for_nova/tests/json_samples/node.json', 'r') as f:
            self.root_conn.get.return_value.json.return_value = json.loads(
                f.read())
        self.node_inst = node.Node(self.root_conn,
                                   '/redfish/v1/Nodes/Node1',
                                   redfish_version='1.0.2')

        with open('rsd_virt_for_nova/tests/json_samples/node_assembled.json',
                  'r') as f:
            self.root_conn.get.return_value.json.return_value = json.loads(
                f.read())
        self.node_ass_inst = node.Node(self.root_conn,
                                       '/redfish/v1/Nodes/Node1',
                                       redfish_version='1.0.2')

        with open('rsd_virt_for_nova/tests/json_samples/sys_collection.json',
                  'r') as f:
            self.root_conn.get.return_value.json.return_value = \
                json.loads(f.read())
        self.system_col = system.SystemCollection(self.root_conn,
                                                  '/redfish/v1/Systems',
                                                  redfish_version='1.0.2')

        with open('rsd_virt_for_nova/tests/json_samples/system.json',
                  'r') as f:
            self.root_conn.get.return_value.json.return_value = json.loads(
                f.read())
        self.system_inst = system.System(self.root_conn,
                                         '/redfish/v1/Systems/System1',
                                         redfish_version='1.0.2')

        # Mock out a fake virt driver and its dependencies/parameters
        self.RSD = driver.RSDDriver(fake.FakeVirtAPI())

        # Create Fake flavors and instances
        gb = self.system_inst.memory_summary.size_gib
        mem = self.RSD.conv_GiB_to_MiB(gb)
        proc = self.system_inst.processors.summary.count
        flav_id = str(mem) + 'MB-' + str(proc) + 'vcpus'
        res = fields.ResourceClass.normalize_name(self.system_inst.identity)
        spec = 'resources:' + res
        # Mock out some instances for testing
        self.flavor = FakeFlavor(gb, mem, str('RSD.' + flav_id),
                                 self.system_inst.identity, spec)
        self.inst1 = FakeInstance('inst1', power_state.RUNNING, 'inst1id',
                                  self.flavor)
        self.invalid_inst = FakeInstance('inv_inst', power_state.RUNNING,
                                         'inv_inst_id', self.flavor)
        self.RSD.instances = {self.inst1.uuid: self.inst1}

        # A provider tree for testing on the placement API
        self.ptree = provider_tree.ProviderTree()

        self.test_image_meta = {
            "disk_format": "raw",
        }