def test_config_upload_multinode(self):
        cluster_id = 1
        fake_configs = [
            utils.get_fake_openstack_config(
                cluster_id=cluster_id, node_id=42),
            utils.get_fake_openstack_config(
                cluster_id=cluster_id, node_id=44)
        ]

        m_post = self.m_request.post(self.uri, json=fake_configs)

        m_open = mock.mock_open(read_data=yaml.safe_dump({
            'configuration': fake_configs[0]['configuration']
        }))
        with mock.patch(
                'fuelclient.cli.serializers.open', m_open, create=True), \
                mock.patch('os.path.exists', mock.Mock(return_value=True)):
            self.client.upload(
                '/path/to/config', cluster_id, node_ids=[42, 44])

        self.assertTrue(m_post.called)
        body = m_post.last_request.json()
        self.assertEqual(body['cluster_id'], cluster_id)
        self.assertEqual(body['node_ids'], [42, 44])
        self.assertNotIn('node_role', body)
 def test_config_list(self):
     m_get = self.m_request.get(
         '/api/v1/openstack-config/?cluster_id=84', json=[
             utils.get_fake_openstack_config(id=1, cluster_id=32),
             utils.get_fake_openstack_config(id=2, cluster_id=64)
         ])
     self.execute(['fuel', 'openstack-config', '--env', '84', '--list'])
     self.assertTrue(m_get.called)
Exemple #3
0
 def test_config_list(self):
     m_get = self.m_request.get(
         '/api/v1/openstack-config/?cluster_id=84',
         json=[
             utils.get_fake_openstack_config(id=1, cluster_id=32),
             utils.get_fake_openstack_config(id=2, cluster_id=64)
         ])
     self.execute(['fuel', 'openstack-config', '--env', '84', '--list'])
     self.assertTrue(m_get.called)
Exemple #4
0
    def test_config_list_for_multinode(self):
        cluster_id = 1
        fake_configs = [
            utils.get_fake_openstack_config(cluster_id=cluster_id, node_id=22),
            utils.get_fake_openstack_config(cluster_id=cluster_id, node_id=44),
        ]

        uri = self.uri + '?cluster_id={0}&node_ids=22,44' \
                         '&is_active=True'.format(cluster_id)
        m_get = self.m_request.get(uri, complete_qs=True, json=fake_configs)
        data = self.client.get_filtered(cluster_id=1, node_ids=[22, 44])

        self.assertTrue(m_get.called)
        self.assertEqual(data[0]['cluster_id'], cluster_id)
    def test_config_list_w_filters(self):
        m_get = self.m_request.get(
            '/api/v1/openstack-config/?cluster_id=84&node_role=controller',
            json=[utils.get_fake_openstack_config(id=1, cluster_id=32)])
        self.execute(['fuel', 'openstack-config', '--env', '84',
                      '--role', 'controller', '--list'])
        self.assertTrue(m_get.called)

        m_get = self.m_request.get(
            '/api/v1/openstack-config/?cluster_id=84&node_id=42', json=[
                utils.get_fake_openstack_config(id=1, cluster_id=32),
            ])
        self.execute(['fuel', 'openstack-config', '--env', '84',
                      '--node', '42', '--list'])
        self.assertTrue(m_get.called)
    def test_config_list_for_multinode(self):
        cluster_id = 1
        fake_configs = [
            utils.get_fake_openstack_config(
                cluster_id=cluster_id, node_id=22),
            utils.get_fake_openstack_config(
                cluster_id=cluster_id, node_id=44),
        ]

        uri = self.uri + '?cluster_id={0}&node_ids=22,44' \
                         '&is_active=True'.format(cluster_id)
        m_get = self.m_request.get(uri, complete_qs=True, json=fake_configs)
        data = self.client.get_filtered(cluster_id=1, node_ids=[22, 44])

        self.assertTrue(m_get.called)
        self.assertEqual(data[0]['cluster_id'], cluster_id)
    def test_config_delete(self):
        config_id = 42
        uri = self.uri + '{0}/'.format(config_id)
        fake_config = utils.get_fake_openstack_config(id=config_id)

        m_del = self.m_request.delete(uri, json=fake_config)

        self.client.delete(config_id)
        self.assertTrue(m_del.called)
    def test_config_list_multinode(self):
        m_get = self.m_request.get(
            '/api/v1/openstack-config/?cluster_id=84&node_ids=1,2,3',
            json=[utils.get_fake_openstack_config(
                id=1, cluster_id=32, node_id=1)])

        self.execute(['fuel', 'openstack-config', '--env', '84',
                      '--node', '1,2,3', '--list'])
        self.assertTrue(m_get.called)
Exemple #9
0
    def test_config_delete(self):
        config_id = 42
        uri = self.uri + '{0}/'.format(config_id)
        fake_config = utils.get_fake_openstack_config(id=config_id)

        m_del = self.m_request.delete(uri, json=fake_config)

        self.client.delete(config_id)
        self.assertTrue(m_del.called)
Exemple #10
0
    def test_config_list_for_cluster(self):
        cluster_id = 1
        fake_configs = [utils.get_fake_openstack_config(cluster_id=cluster_id)]

        uri = self.uri + '?cluster_id={0}&is_active=True'.format(cluster_id)
        m_get = self.m_request.get(uri, complete_qs=True, json=fake_configs)
        data = self.client.get_filtered(cluster_id=1)

        self.assertTrue(m_get.called)
        self.assertEqual(data[0]['cluster_id'], cluster_id)
Exemple #11
0
    def test_config_list_w_filters(self):
        m_get = self.m_request.get(
            '/api/v1/openstack-config/?cluster_id=84&node_role=controller',
            json=[utils.get_fake_openstack_config(id=1, cluster_id=32)])
        self.execute([
            'fuel', 'openstack-config', '--env', '84', '--role', 'controller',
            '--list'
        ])
        self.assertTrue(m_get.called)

        m_get = self.m_request.get(
            '/api/v1/openstack-config/?cluster_id=84&node_ids=42',
            json=[
                utils.get_fake_openstack_config(id=1, cluster_id=32),
            ])
        self.execute([
            'fuel', 'openstack-config', '--env', '84', '--node', '42', '--list'
        ])
        self.assertTrue(m_get.called)
Exemple #12
0
    def test_config_list_multinode(self):
        m_get = self.m_request.get(
            '/api/v1/openstack-config/?cluster_id=84&node_ids=1,2,3',
            json=[
                utils.get_fake_openstack_config(id=1, cluster_id=32, node_id=1)
            ])

        self.execute([
            'fuel', 'openstack-config', '--env', '84', '--node', '1,2,3',
            '--list'
        ])
        self.assertTrue(m_get.called)
Exemple #13
0
    def test_config_upload(self):
        self.m_client.upload.return_value = [utils.get_fake_openstack_config()
                                             for i in range(10)]

        cmd = 'openstack-config upload --env {0} --node {1} --file ' \
              'config.yaml'.format(self.CLUSTER_ID, self.NODE_ID)
        self.exec_command(cmd)

        self.m_get_client.assert_called_once_with('openstack-config', mock.ANY)
        self.m_client.upload.assert_called_once_with(
            path='config.yaml', cluster_id=self.CLUSTER_ID,
            node_ids=[self.NODE_ID], node_role=None)
    def test_config_list_for_cluster(self):
        cluster_id = 1
        fake_configs = [
            utils.get_fake_openstack_config(cluster_id=cluster_id)
        ]

        uri = self.uri + '?cluster_id={0}&is_active=True'.format(cluster_id)
        m_get = self.m_request.get(uri, complete_qs=True, json=fake_configs)
        data = self.client.get_filtered(cluster_id=1)

        self.assertTrue(m_get.called)
        self.assertEqual(data[0]['cluster_id'], cluster_id)
Exemple #15
0
    def test_config_upload_multinode(self):
        cluster_id = 1
        fake_configs = [
            utils.get_fake_openstack_config(cluster_id=cluster_id, node_id=42),
            utils.get_fake_openstack_config(cluster_id=cluster_id, node_id=44)
        ]

        m_post = self.m_request.post(self.uri, json=fake_configs)

        m_open = mock.mock_open(read_data=yaml.safe_dump(
            {'configuration': fake_configs[0]['configuration']}))
        with mock.patch(
                'fuelclient.cli.serializers.open', m_open, create=True), \
                mock.patch('os.path.exists', mock.Mock(return_value=True)):
            self.client.upload('/path/to/config',
                               cluster_id,
                               node_ids=[42, 44])

        self.assertTrue(m_post.called)
        body = m_post.last_request.json()
        self.assertEqual(body['cluster_id'], cluster_id)
        self.assertEqual(body['node_ids'], [42, 44])
        self.assertNotIn('node_role', body)
    def test_config_download(self):
        config_id = 42
        uri = self.uri + '{0}/'.format(42)
        fake_config = utils.get_fake_openstack_config(id=config_id)

        m_get = self.m_request.get(uri, json=fake_config)

        m_open = mock.mock_open()
        with mock.patch('fuelclient.cli.serializers.open',
                        m_open, create=True):
            self.client.download(config_id, '/path/to/config')

        self.assertTrue(m_get.called)
        written_yaml = yaml.safe_load(m_open().write.mock_calls[0][1][0])
        self.assertEqual(written_yaml,
                         {'configuration': fake_config['configuration']})
Exemple #17
0
    def test_config_download(self):
        config_id = 42
        uri = self.uri + '{0}/'.format(42)
        fake_config = utils.get_fake_openstack_config(id=config_id)

        m_get = self.m_request.get(uri, json=fake_config)

        m_open = mock.mock_open()
        with mock.patch('fuelclient.cli.serializers.open', m_open,
                        create=True):
            self.client.download(config_id, '/path/to/config')

        self.assertTrue(m_get.called)
        written_yaml = yaml.safe_load(m_open().write.mock_calls[0][1][0])
        self.assertEqual(written_yaml,
                         {'configuration': fake_config['configuration']})
    def test_config_upload_multinode(self):
        configs = [utils.get_fake_openstack_config(node_id=node_id)
                   for node_id in [1, 2, 3]]

        m_post = self.m_request.post(
            '/api/v1/openstack-config/', json=configs)

        m_open = mock.mock_open(read_data=yaml.safe_dump(
            {'configuration': self.config['configuration']}))
        with mock.patch('fuelclient.cli.serializers.open',
                        m_open, create=True):
            with mock.patch('fuelclient.objects.openstack_config.os'):
                self.execute(['fuel', 'openstack-config', '--env', '1',
                              '--node', '1,2,3',
                              '--upload', '--file', 'config.yaml'])
                self.assertTrue(m_post.called)

        req = json.loads(m_post.last_request.text)
        self.assertEqual(req['node_ids'], [1, 2, 3])
        self.assertEqual(req['cluster_id'], 1)
Exemple #19
0
    def test_config_upload_multinode(self):
        configs = [
            utils.get_fake_openstack_config(node_id=node_id)
            for node_id in [1, 2, 3]
        ]

        m_post = self.m_request.post('/api/v1/openstack-config/', json=configs)

        m_open = mock.mock_open(read_data=yaml.safe_dump(
            {'configuration': self.config['configuration']}))
        with mock.patch('fuelclient.cli.serializers.open', m_open,
                        create=True):
            with mock.patch('fuelclient.objects.openstack_config.os'):
                self.execute([
                    'fuel', 'openstack-config', '--env', '1', '--node',
                    '1,2,3', '--upload', '--file', 'config.yaml'
                ])
                self.assertTrue(m_post.called)

        req = json.loads(m_post.last_request.text)
        self.assertEqual(req['node_ids'], [1, 2, 3])
        self.assertEqual(req['cluster_id'], 1)
Exemple #20
0
    def setUp(self):
        super(TestOpenstackConfigActions, self).setUp()

        self.config = utils.get_fake_openstack_config()
    def setUp(self):
        super(TestOpenstackConfigActions, self).setUp()

        self.config = utils.get_fake_openstack_config()