Ejemplo n.º 1
0
    def test__build_client_noauth(self, mock_client_init):
        self.config(auth_strategy='noauth', group='neutron')
        expected = {'ca_cert': 'test-file',
                    'insecure': False,
                    'endpoint_url': 'test-url',
                    'timeout': 30,
                    'auth_strategy': 'noauth'}

        mock_client_init.return_value = None
        neutron._build_client(token=None)
        mock_client_init.assert_called_once_with(**expected)
Ejemplo n.º 2
0
    def test__build_client_noauth(self, mock_client_init):
        self.config(auth_strategy='noauth', group='neutron')
        expected = {'ca_cert': 'test-file',
                    'insecure': False,
                    'endpoint_url': 'test-url',
                    'timeout': 30,
                    'retries': 2,
                    'auth_strategy': 'noauth'}

        mock_client_init.return_value = None
        neutron._build_client(token=None)
        mock_client_init.assert_called_once_with(**expected)
Ejemplo n.º 3
0
    def test__build_client_with_token(self, mock_client_init):
        token = 'test-token-123'
        expected = {'timeout': 30,
                    'insecure': False,
                    'ca_cert': 'test-file',
                    'token': token,
                    'endpoint_url': 'test-url',
                    'auth_strategy': None}

        mock_client_init.return_value = None
        neutron._build_client(token=token)
        mock_client_init.assert_called_once_with(**expected)
Ejemplo n.º 4
0
    def test__build_client_with_token(self, mock_client_init):
        token = 'test-token-123'
        expected = {'timeout': 30,
                    'retries': 2,
                    'insecure': False,
                    'ca_cert': 'test-file',
                    'token': token,
                    'endpoint_url': 'test-url',
                    'auth_strategy': None}

        mock_client_init.return_value = None
        neutron._build_client(token=token)
        mock_client_init.assert_called_once_with(**expected)
Ejemplo n.º 5
0
    def test__build_client_without_token(self, mock_client_init):
        expected = {'timeout': 30,
                    'insecure': False,
                    'ca_cert': 'test-file',
                    'endpoint_url': 'test-url',
                    'username': '******',
                    'tenant_name': 'test-admin-tenant',
                    'password': '******',
                    'auth_url': 'test-auth-uri'}

        mock_client_init.return_value = None
        neutron._build_client(token=None)
        mock_client_init.assert_called_once_with(**expected)
Ejemplo n.º 6
0
    def test__build_client_without_token(self, mock_client_init):
        expected = {'timeout': 30,
                    'retries': 2,
                    'insecure': False,
                    'ca_cert': 'test-file',
                    'endpoint_url': 'test-url',
                    'username': '******',
                    'tenant_name': 'test-admin-tenant',
                    'password': '******',
                    'auth_url': 'test-auth-uri'}

        mock_client_init.return_value = None
        neutron._build_client(token=None)
        mock_client_init.assert_called_once_with(**expected)
Ejemplo n.º 7
0
    def test__build_client_noauth(self, mock_client_init):
        self.config(auth_strategy="noauth", group="neutron")
        expected = {
            "ca_cert": "test-file",
            "insecure": False,
            "endpoint_url": "test-url",
            "timeout": 30,
            "retries": 2,
            "auth_strategy": "noauth",
        }

        mock_client_init.return_value = None
        neutron._build_client(token=None)
        mock_client_init.assert_called_once_with(**expected)
Ejemplo n.º 8
0
    def test__build_client_with_token(self, mock_client_init):
        token = "test-token-123"
        expected = {
            "timeout": 30,
            "retries": 2,
            "insecure": False,
            "ca_cert": "test-file",
            "token": token,
            "endpoint_url": "test-url",
            "auth_strategy": None,
        }

        mock_client_init.return_value = None
        neutron._build_client(token=token)
        mock_client_init.assert_called_once_with(**expected)
Ejemplo n.º 9
0
    def test__build_client_without_token(self, mock_client_init):
        expected = {
            "timeout": 30,
            "retries": 2,
            "insecure": False,
            "ca_cert": "test-file",
            "endpoint_url": "test-url",
            "username": "******",
            "tenant_name": "test-admin-tenant",
            "password": "******",
            "auth_url": "test-auth-uri",
        }

        mock_client_init.return_value = None
        neutron._build_client(token=None)
        mock_client_init.assert_called_once_with(**expected)
Ejemplo n.º 10
0
    def _plug_provisioning(self, task, **kwargs):
        LOG.debug("Plugging the provisioning!")
        if task.node.power_state != states.POWER_ON:
            manager_utils.node_power_action(task, states.REBOOT)

        client = neutron._build_client(task.context.auth_token)
        port = client.create_port({
            'port': {
                "network_id":
                    CONF.neutron.cleaning_network_uuid,
                "extra_dhcp_opts":
                    pxe_utils.dhcp_options_for_instance(task),
            }
        })

        name = port['port']['id']
        network = client.show_network(port['port']['network_id'])
        seg_id = network['network']['provider:segmentation_id']

        try:
            common.add_vnic(
                task, name, port['port']['mac_address'], seg_id, True)
        except imcsdk.ImcException:
            client.delete_port(name)
            raise

        new_port = objects.Port(
            task.context, node_id=task.node.id,
            address=port['port']['mac_address'],
            extra={"vif_port_id": port['port']['id'],
                   "type": "deploy", "state": "ACTIVE"})
        new_port.create()
        return port['port']['fixed_ips'][0]['ip_address']
Ejemplo n.º 11
0
    def test__build_client_with_region(self, mock_client_init):
        expected = {'timeout': 30,
                    'retries': 2,
                    'insecure': False,
                    'ca_cert': 'test-file',
                    'endpoint_url': 'test-url',
                    'username': '******',
                    'tenant_name': 'test-admin-tenant',
                    'password': '******',
                    'auth_url': 'test-auth-uri',
                    'region_name': 'test-region'}

        self.config(region_name='test-region',
                    group='keystone')
        mock_client_init.return_value = None
        neutron._build_client(token=None)
        mock_client_init.assert_called_once_with(**expected)
Ejemplo n.º 12
0
    def test__build_client_with_region(self, mock_client_init):
        expected = {
            'timeout': 30,
            'retries': 2,
            'insecure': False,
            'ca_cert': 'test-file',
            'token': None,
            'endpoint_url': 'test-url',
            'username': '******',
            'tenant_name': 'test-admin-tenant',
            'password': '******',
            'auth_url': 'test-auth-uri',
            'region_name': 'test-region'
        }

        self.config(region_name='test-region', group='keystone')
        mock_client_init.return_value = None
        neutron._build_client(token=None)
        mock_client_init.assert_called_once_with(**expected)
Ejemplo n.º 13
0
    def _unplug_provisioning(self, task, **kwargs):
        LOG.debug("Unplugging the provisioning!")
        if task.node.power_state != states.POWER_ON:
            manager_utils.node_power_action(task, states.REBOOT)

        client = neutron._build_client(task.context.auth_token)

        ports = objects.Port.list_by_node_id(task.context, task.node.id)
        for port in ports:
            if port['extra'].get('type') == "deploy":
                common.delete_vnic(task, port['extra']['vif_port_id'])
                client.delete_port(port['extra']['vif_port_id'])
                port.destroy()