Exemplo n.º 1
0
    def test_failure_to_clean_up(self, mock_log, mock_pr):
        pr = mock_pr.return_value
        instance = {'hostname': 'host1'}
        action = baremetal_deploy.DeployNodeAction(instance=instance,
                                                   node='1234')
        pr.provision_node.side_effect = RuntimeError('boom')
        pr.unprovision_node.side_effect = AssertionError
        result = action.run(mock.Mock())

        self.assertIn('RuntimeError: boom', result.error)
        pr.provision_node.assert_called_once_with(
            '1234',
            image=mock.ANY,
            nics=[{
                'network': 'ctlplane'
            }],
            hostname='host1',
            root_size_gb=49,
            swap_size_mb=None,
            config=mock.ANY,
        )
        pr.unprovision_node.assert_called_once_with('1234')
        mock_log.assert_has_calls([
            mock.call('Provisioning of %s on node %s failed', instance,
                      '1234'),
            mock.call('Unable to release node %s, moving on', '1234')
        ])
Exemplo n.º 2
0
    def test_success_advanced_nic(self, mock_pr):
        action = baremetal_deploy.DeployNodeAction(instance={
            'hostname':
            'host1',
            'nics': [{
                'subnet': 'ctlplane-subnet'
            }, {
                'network': 'ctlplane',
                'fixed_ip': '10.0.0.2'
            }]
        },
                                                   node='1234')
        result = action.run(mock.Mock())

        pr = mock_pr.return_value
        self.assertEqual(pr.provision_node.return_value.to_dict.return_value,
                         result)
        pr.provision_node.assert_called_once_with(
            '1234',
            image=mock.ANY,
            nics=[{
                'subnet': 'ctlplane-subnet'
            }, {
                'network': 'ctlplane',
                'fixed_ip': '10.0.0.2'
            }],
            hostname='host1',
            root_size_gb=49,
            swap_size_mb=None,
            config=mock.ANY,
        )
        config = pr.provision_node.call_args[1]['config']
        self.assertEqual([], config.ssh_keys)
        self.assertEqual('heat-admin', config.users[0]['name'])
Exemplo n.º 3
0
    def test_success_http_partition_image(self, mock_pr):
        action = baremetal_deploy.DeployNodeAction(instance={
            'hostname':
            'host1',
            'image':
            'https://example/image',
            'image_kernel':
            'https://example/kernel',
            'image_ramdisk':
            'https://example/ramdisk',
            'image_checksum':
            'https://example/checksum'
        },
                                                   node='1234')
        result = action.run(mock.Mock())

        pr = mock_pr.return_value
        self.assertEqual(pr.provision_node.return_value.to_dict.return_value,
                         result)
        pr.provision_node.assert_called_once_with(
            '1234',
            image=mock.ANY,
            nics=[{
                'network': 'ctlplane'
            }],
            hostname='host1',
            root_size_gb=49,
            swap_size_mb=None,
            config=mock.ANY,
        )
        config = pr.provision_node.call_args[1]['config']
        self.assertEqual([], config.ssh_keys)
        self.assertEqual('heat-admin', config.users[0]['name'])
        source = pr.provision_node.call_args[1]['image']
        self.assertIsInstance(source, sources.HttpPartitionImage)
        self.assertEqual('https://example/image', source.url)
        self.assertEqual('https://example/kernel', source.kernel_url)
        self.assertEqual('https://example/ramdisk', source.ramdisk_url)
        self.assertEqual('https://example/checksum', source.checksum_url)
Exemplo n.º 4
0
    def test_success(self, mock_pr):
        pr = mock_pr.return_value
        action = baremetal_deploy.DeployNodeAction(
            instance={
                'hostname': 'host1',
                'image': 'overcloud-alt',
                'nics': [{
                    'port': 'abcd'
                }],
                'root_size_gb': 100,
                'swap_size_mb': 4096
            },
            node='1234',
            ssh_keys=['ssh key contents'],
            ssh_user_name='admin',
        )
        result = action.run(mock.Mock())

        self.assertEqual(pr.provision_node.return_value.to_dict.return_value,
                         result)
        pr.provision_node.assert_called_once_with(
            '1234',
            image=mock.ANY,
            nics=[{
                'port': 'abcd'
            }],
            hostname='host1',
            root_size_gb=100,
            swap_size_mb=4096,
            config=mock.ANY,
        )
        config = pr.provision_node.call_args[1]['config']
        self.assertEqual(['ssh key contents'], config.ssh_keys)
        self.assertEqual('admin', config.users[0]['name'])
        source = pr.provision_node.call_args[1]['image']
        self.assertIsInstance(source, sources.GlanceImage)