def setUp(self):
        super(TestShowBaremetalPortGroup, self).setUp()

        self.baremetal_mock.portgroup.get.return_value = (
            baremetal_fakes.FakeBaremetalResource(
                None, copy.deepcopy(baremetal_fakes.PORTGROUP), loaded=True))

        self.baremetal_mock.portgroup.get_by_address.return_value = (
            baremetal_fakes.FakeBaremetalResource(
                None, copy.deepcopy(baremetal_fakes.PORTGROUP), loaded=True))

        self.cmd = baremetal_portgroup.ShowBaremetalPortGroup(self.app, None)
    def setUp(self):
        super(TestChassisCreate, self).setUp()

        self.baremetal_mock.chassis.create.return_value = (
            baremetal_fakes.FakeBaremetalResource(
                None,
                copy.deepcopy(baremetal_fakes.BAREMETAL_CHASSIS),
                loaded=True,
            ))

        # Get the command object to test
        self.cmd = baremetal_chassis.CreateBaremetalChassis(self.app, None)
        self.arglist = []
        self.verifylist = []
        self.collist = (
            'description',
            'extra',
            'uuid',
        )
        self.datalist = (
            baremetal_fakes.baremetal_chassis_description,
            baremetal_fakes.baremetal_chassis_extra,
            baremetal_fakes.baremetal_chassis_uuid,
        )
        self.actual_kwargs = {}
예제 #3
0
    def test_baremetal_create_with_driver(self):
        self.baremetal_mock = self.app.client_manager.baremetal
        self.baremetal_mock.reset_mock()
        self.baremetal_mock.node.create.return_value = (
            baremetal_fakes.FakeBaremetalResource(
                None,
                copy.deepcopy(baremetal_fakes.BAREMETAL),
                loaded=True,
            ))

        arglist = ['--driver', 'fake_driver']
        verifylist = [('driver', 'fake_driver')]
        parsed_args = self.check_parser(self.cmd, arglist, verifylist)

        # DisplayCommandBase.take_action() returns two tuples
        columns, data = self.cmd.take_action(parsed_args)

        self.assertEqual(('instance_uuid', 'maintenance', 'name',
                          'power_state', 'provision_state', 'uuid'), columns)
        self.assertEqual(
            ('yyy-yyyyyy-yyyy', baremetal_fakes.baremetal_maintenance,
             baremetal_fakes.baremetal_name,
             baremetal_fakes.baremetal_power_state,
             baremetal_fakes.baremetal_provision_state,
             baremetal_fakes.baremetal_uuid), tuple(data))
        self.baremetal_mock.node.create.assert_called_once_with(
            driver='fake_driver')
예제 #4
0
    def test_conductor_show_fields_multiple(self):
        arglist = [
            'xxxxx',
            '--fields', 'hostname', 'alive',
            '--fields', 'conductor_group',
        ]
        verifylist = [
            ('conductor', 'xxxxx'),
            ('fields', [['hostname', 'alive'], ['conductor_group']])
        ]

        fake_cond = copy.deepcopy(baremetal_fakes.CONDUCTOR)
        fake_cond.pop('drivers')
        self.baremetal_mock.conductor.get.return_value = (
            baremetal_fakes.FakeBaremetalResource(None, fake_cond,
                                                  loaded=True))

        parsed_args = self.check_parser(self.cmd, arglist, verifylist)

        columns, data = self.cmd.take_action(parsed_args)
        self.assertNotIn('drivers', columns)
        # Set expected values
        args = ['xxxxx']
        fields = ['hostname', 'alive', 'conductor_group']

        self.baremetal_mock.conductor.get.assert_called_with(
            *args, fields=fields
        )
    def test_baremetal_volume_connector_list_fields_multiple(self):
        arglist = ['--fields', 'uuid', 'connector_id', '--fields', 'extra']
        verifylist = [('fields', [['uuid', 'connector_id'], ['extra']])]

        fake_vc = copy.deepcopy(baremetal_fakes.VOLUME_CONNECTOR)
        fake_vc.pop('type')
        fake_vc.pop('node_uuid')
        self.baremetal_mock.volume_connector.list.return_value = [
            baremetal_fakes.FakeBaremetalResource(
                None,
                fake_vc,
                loaded=True)
        ]

        parsed_args = self.check_parser(self.cmd, arglist, verifylist)
        columns, data = self.cmd.take_action(parsed_args)

        kwargs = {
            'detail': False,
            'marker': None,
            'limit': None,
            'fields': ('uuid', 'connector_id', 'extra')
        }
        self.baremetal_mock.volume_connector.list.assert_called_with(**kwargs)

        collist = ('UUID', 'Connector ID', 'Extra')
        self.assertEqual(collist, columns)

        datalist = ((baremetal_fakes.baremetal_volume_connector_uuid,
                     baremetal_fakes.baremetal_volume_connector_connector_id,
                     baremetal_fakes.baremetal_volume_connector_extra),)
        self.assertEqual(datalist, tuple(data))
    def test_baremetal_volume_target_show_fields_multiple(self):
        arglist = ['vvv-tttttt-vvvv', '--fields', 'uuid', 'volume_id',
                   '--fields', 'volume_type']
        verifylist = [('fields', [['uuid', 'volume_id'], ['volume_type']]),
                      ('volume_target',
                       baremetal_fakes.baremetal_volume_target_uuid)]

        fake_vt = copy.deepcopy(baremetal_fakes.VOLUME_TARGET)
        fake_vt.pop('node_uuid')
        fake_vt.pop('boot_index')
        fake_vt.pop('extra')
        fake_vt.pop('properties')
        self.baremetal_mock.volume_target.get.return_value = (
            baremetal_fakes.FakeBaremetalResource(
                None,
                fake_vt,
                loaded=True))

        parsed_args = self.check_parser(self.cmd, arglist, verifylist)
        columns, data = self.cmd.take_action(parsed_args)

        args = ['vvv-tttttt-vvvv']
        fields = ['uuid', 'volume_id', 'volume_type']
        self.baremetal_mock.volume_target.get.assert_called_once_with(
            *args, fields=fields)
        collist = ('uuid', 'volume_id', 'volume_type')
        self.assertEqual(collist, columns)

        datalist = (
            baremetal_fakes.baremetal_volume_target_uuid,
            baremetal_fakes.baremetal_volume_target_volume_id,
            baremetal_fakes.baremetal_volume_target_volume_type,
        )
        self.assertEqual(datalist, tuple(data))
    def test_baremetal_volume_connector_show_fields_multiple(self):
        arglist = ['vvv-cccccc-vvvv', '--fields', 'uuid', 'connector_id',
                   '--fields', 'type']
        verifylist = [('fields', [['uuid', 'connector_id'], ['type']]),
                      ('volume_connector',
                       baremetal_fakes.baremetal_volume_connector_uuid)]

        fake_vc = copy.deepcopy(baremetal_fakes.VOLUME_CONNECTOR)
        fake_vc.pop('extra')
        fake_vc.pop('node_uuid')
        self.baremetal_mock.volume_connector.get.return_value = (
            baremetal_fakes.FakeBaremetalResource(
                None,
                fake_vc,
                loaded=True))

        parsed_args = self.check_parser(self.cmd, arglist, verifylist)
        columns, data = self.cmd.take_action(parsed_args)

        args = ['vvv-cccccc-vvvv']
        fields = ['uuid', 'connector_id', 'type']
        self.baremetal_mock.volume_connector.get.assert_called_once_with(
            *args, fields=fields)
        collist = ('connector_id', 'type', 'uuid')
        self.assertEqual(collist, columns)

        datalist = (
            baremetal_fakes.baremetal_volume_connector_connector_id,
            baremetal_fakes.baremetal_volume_connector_type,
            baremetal_fakes.baremetal_volume_connector_uuid,
        )
        self.assertEqual(datalist, tuple(data))
    def test_baremetal_volume_target_list_fields_multiple(self):
        arglist = ['--fields', 'uuid', 'boot_index', '--fields', 'extra']
        verifylist = [('fields', [['uuid', 'boot_index'], ['extra']])]

        fake_vt = copy.deepcopy(baremetal_fakes.VOLUME_TARGET)
        fake_vt.pop('volume_type')
        fake_vt.pop('properties')
        fake_vt.pop('volume_id')
        fake_vt.pop('node_uuid')
        self.baremetal_mock.volume_target.list.return_value = [
            baremetal_fakes.FakeBaremetalResource(
                None,
                fake_vt,
                loaded=True)
        ]

        parsed_args = self.check_parser(self.cmd, arglist, verifylist)
        columns, data = self.cmd.take_action(parsed_args)

        kwargs = {
            'detail': False,
            'marker': None,
            'limit': None,
            'fields': ('uuid', 'boot_index', 'extra')
        }
        self.baremetal_mock.volume_target.list.assert_called_with(**kwargs)

        collist = ('UUID', 'Boot Index', 'Extra')
        self.assertEqual(collist, columns)

        datalist = ((baremetal_fakes.baremetal_volume_target_uuid,
                     baremetal_fakes.baremetal_volume_target_boot_index,
                     baremetal_fakes.baremetal_volume_target_extra),)
        self.assertEqual(datalist, tuple(data))
    def setUp(self):
        super(TestShowBaremetalPort, self).setUp()

        self.baremetal_mock.port.get.return_value = (
            baremetal_fakes.FakeBaremetalResource(
                None,
                copy.deepcopy(baremetal_fakes.BAREMETAL_PORT),
                loaded=True))

        self.baremetal_mock.port.get_by_address.return_value = (
            baremetal_fakes.FakeBaremetalResource(
                None,
                copy.deepcopy(baremetal_fakes.BAREMETAL_PORT),
                loaded=True))

        self.cmd = baremetal_port.ShowBaremetalPort(self.app, None)
예제 #10
0
    def setUp(self):
        super(TestBaremetalCreate, self).setUp()

        self.baremetal_mock.node.create.return_value = (
            baremetal_fakes.FakeBaremetalResource(
                None,
                copy.deepcopy(baremetal_fakes.BAREMETAL),
                loaded=True,
            ))

        # Get the command object to test
        self.cmd = baremetal.CreateBaremetal(self.app, None)
        self.arglist = ['--driver', 'fake_driver']
        self.verifylist = [('driver', 'fake_driver')]
        self.collist = (
            'instance_uuid',
            'maintenance',
            'name',
            'power_state',
            'provision_state',
            'uuid'
        )
        self.datalist = (
            'yyy-yyyyyy-yyyy',
            baremetal_fakes.baremetal_maintenance,
            baremetal_fakes.baremetal_name,
            baremetal_fakes.baremetal_power_state,
            baremetal_fakes.baremetal_provision_state,
            baremetal_fakes.baremetal_uuid,
        )
        self.actual_kwargs = {
            'driver': 'fake_driver',
        }
예제 #11
0
    def setUp(self):
        super(TestBaremetalAllocationSet, self).setUp()

        self.baremetal_mock.allocation.update.return_value = (
            baremetal_fakes.FakeBaremetalResource(
                None, copy.deepcopy(baremetal_fakes.ALLOCATION), loaded=True))

        self.cmd = baremetal_allocation.SetBaremetalAllocation(self.app, None)
    def setUp(self):
        super(TestBaremetalPortGroupUnset, self).setUp()

        self.baremetal_mock.portgroup.update.return_value = (
            baremetal_fakes.FakeBaremetalResource(
                None, copy.deepcopy(baremetal_fakes.PORTGROUP), loaded=True))

        self.cmd = baremetal_portgroup.UnsetBaremetalPortGroup(self.app, None)
예제 #13
0
    def setUp(self):
        super(TestShowBaremetalDriver, self).setUp()

        self.baremetal_mock.driver.get.return_value = (
            baremetal_fakes.FakeBaremetalResource(
                None,
                copy.deepcopy(baremetal_fakes.BAREMETAL_DRIVER),
                loaded=True))
        self.cmd = baremetal_driver.ShowBaremetalDriver(self.app, None)
예제 #14
0
    def setUp(self):
        super(TestListBaremetalVolumeTarget, self).setUp()

        self.baremetal_mock.volume_target.list.return_value = [
            baremetal_fakes.FakeBaremetalResource(
                None,
                copy.deepcopy(baremetal_fakes.VOLUME_TARGET),
                loaded=True)
        ]
        self.cmd = (bm_vol_target.ListBaremetalVolumeTarget(self.app, None))
예제 #15
0
    def setUp(self):
        super(TestBaremetalShow, self).setUp()

        self.baremetal_mock.node.get.return_value = (
            baremetal_fakes.FakeBaremetalResource(
                None,
                copy.deepcopy(baremetal_fakes.BAREMETAL),
                loaded=True,
            ))

        self.baremetal_mock.node.get_by_instance_uuid.return_value = (
            baremetal_fakes.FakeBaremetalResource(
                None,
                copy.deepcopy(baremetal_fakes.BAREMETAL),
                loaded=True,
            ))

        # Get the command object to test
        self.cmd = baremetal.ShowBaremetal(self.app, None)
    def setUp(self):
        super(TestBaremetalPortSet, self).setUp()

        self.baremetal_mock.port.update.return_value = (
            baremetal_fakes.FakeBaremetalResource(
                None,
                copy.deepcopy(baremetal_fakes.BAREMETAL_PORT),
                loaded=True))

        self.cmd = baremetal_port.SetBaremetalPort(self.app, None)
예제 #17
0
    def setUp(self):
        super(TestCreateBaremetalAllocation, self).setUp()

        self.baremetal_mock.allocation.create.return_value = (
            baremetal_fakes.FakeBaremetalResource(
                None,
                copy.deepcopy(baremetal_fakes.ALLOCATION),
                loaded=True,
            ))

        self.baremetal_mock.allocation.wait.return_value = (
            baremetal_fakes.FakeBaremetalResource(
                None,
                copy.deepcopy(baremetal_fakes.ALLOCATION),
                loaded=True,
            ))

        # Get the command object to test
        self.cmd = baremetal_allocation.CreateBaremetalAllocation(
            self.app, None)
    def setUp(self):
        super(TestListBaremetalVolumeConnector, self).setUp()

        self.baremetal_mock.volume_connector.list.return_value = [
            baremetal_fakes.FakeBaremetalResource(
                None,
                copy.deepcopy(baremetal_fakes.VOLUME_CONNECTOR),
                loaded=True)
        ]
        self.cmd = (
            bm_vol_connector.ListBaremetalVolumeConnector(self.app, None))
예제 #19
0
    def setUp(self):
        super(TestBaremetalDeployTemplateUnset, self).setUp()

        self.baremetal_mock.deploy_template.update.return_value = (
            baremetal_fakes.FakeBaremetalResource(
                None,
                copy.deepcopy(baremetal_fakes.DEPLOY_TEMPLATE),
                loaded=True))

        self.cmd = baremetal_deploy_template.UnsetBaremetalDeployTemplate(
            self.app, None)
예제 #20
0
    def setUp(self):
        super(TestCreateBaremetalVolumeTarget, self).setUp()

        self.baremetal_mock.volume_target.create.return_value = (
            baremetal_fakes.FakeBaremetalResource(
                None,
                copy.deepcopy(baremetal_fakes.VOLUME_TARGET),
                loaded=True,
            ))

        # Get the command object to test
        self.cmd = (bm_vol_target.CreateBaremetalVolumeTarget(self.app, None))
예제 #21
0
    def setUp(self):
        super(TestBaremetalConductorShow, self).setUp()

        self.baremetal_mock.conductor.get.return_value = (
            baremetal_fakes.FakeBaremetalResource(
                None,
                copy.deepcopy(baremetal_fakes.CONDUCTOR),
                loaded=True,
            ))

        # Get the command object to test
        self.cmd = baremetal_conductor.ShowBaremetalConductor(self.app, None)
예제 #22
0
    def setUp(self):
        super(TestBaremetalUnset, self).setUp()

        self.baremetal_mock.node.update.return_value = (
            baremetal_fakes.FakeBaremetalResource(
                None,
                copy.deepcopy(baremetal_fakes.BAREMETAL),
                loaded=True,
            ))

        # Get the command object to test
        self.cmd = baremetal.UnsetBaremetal(self.app, None)
    def setUp(self):
        super(TestChassisUnset, self).setUp()

        self.baremetal_mock.chassis.update.return_value = (
            baremetal_fakes.FakeBaremetalResource(
                None,
                copy.deepcopy(baremetal_fakes.BAREMETAL_CHASSIS),
                loaded=True,
            ))

        # Get the command object to test
        self.cmd = baremetal_chassis.UnsetBaremetalChassis(self.app, None)
    def setUp(self):
        super(TestCreateBaremetalPort, self).setUp()

        self.baremetal_mock.port.create.return_value = (
            baremetal_fakes.FakeBaremetalResource(
                None,
                copy.deepcopy(baremetal_fakes.BAREMETAL_PORT),
                loaded=True,
            ))

        # Get the command object to test
        self.cmd = baremetal_port.CreateBaremetalPort(self.app, None)
예제 #25
0
    def setUp(self):
        super(TestCreateBaremetalDeployTemplate, self).setUp()

        self.baremetal_mock.deploy_template.create.return_value = (
            baremetal_fakes.FakeBaremetalResource(
                None,
                copy.deepcopy(baremetal_fakes.DEPLOY_TEMPLATE),
                loaded=True,
            ))

        # Get the command object to test
        self.cmd = baremetal_deploy_template.CreateBaremetalDeployTemplate(
            self.app, None)
    def setUp(self):
        super(TestCreateBaremetalVolumeConnector, self).setUp()

        self.baremetal_mock.volume_connector.create.return_value = (
            baremetal_fakes.FakeBaremetalResource(
                None,
                copy.deepcopy(baremetal_fakes.VOLUME_CONNECTOR),
                loaded=True,
            ))

        # Get the command object to test
        self.cmd = (
            bm_vol_connector.CreateBaremetalVolumeConnector(self.app, None))
    def setUp(self):
        super(TestBaremetalList, self).setUp()

        self.baremetal_mock.node.list.return_value = [
            baremetal_fakes.FakeBaremetalResource(
                None,
                copy.deepcopy(baremetal_fakes.BAREMETAL),
                loaded=True,
            ),
        ]

        # Get the command object to test
        self.cmd = baremetal_node.ListBaremetalNode(self.app, None)