Пример #1
0
    def _get_port_request(self,
                          pod,
                          project_id,
                          subnets,
                          security_groups,
                          unbound=False):
        port_req_body = {
            'project_id': project_id,
            'network_id': utils.get_network_id(subnets),
            'fixed_ips': ovu.osvif_to_neutron_fixed_ips(subnets),
            'device_owner': kl_const.DEVICE_OWNER,
            'admin_state_up': True,
            'binding:host_id': utils.get_host_id(pod)
        }

        # if unbound argument is set to true, it means the port requested
        # should not be bound and not associated to the pod. Thus the port dict
        # is filled with a generic name (constants.KURYR_PORT_NAME) if
        # port_debug is enabled, and without device_id
        if unbound and config.CONF.kubernetes.port_debug:
            port_req_body['name'] = constants.KURYR_PORT_NAME
        else:
            # only set the name if port_debug is enabled
            if config.CONF.kubernetes.port_debug:
                port_req_body['name'] = utils.get_port_name(pod)
            port_req_body['device_id'] = utils.get_device_id(pod)

        if security_groups:
            port_req_body['security_groups'] = security_groups

        return {'port': port_req_body}
Пример #2
0
    def _get_port_request(self,
                          pod,
                          project_id,
                          subnets,
                          security_groups,
                          unbound=False):
        port_req_body = {
            'project_id': project_id,
            'network_id': utils.get_network_id(subnets),
            'fixed_ips': ovu.osvif_to_neutron_fixed_ips(subnets),
            'device_owner': kl_const.DEVICE_OWNER,
            'admin_state_up': True
        }

        # only set name if port_debug is enabled
        if config.CONF.kubernetes.port_debug:
            if unbound:
                port_req_body['name'] = constants.KURYR_PORT_NAME
            else:
                port_req_body['name'] = utils.get_port_name(pod)

        if security_groups:
            port_req_body['security_groups'] = security_groups

        return port_req_body
Пример #3
0
    def test_get_network_id(self, m_to_net_ids):
        subnets = mock.sentinel.subnets
        network_id = mock.sentinel.network_id
        m_to_net_ids.return_value = [network_id]

        self.assertEqual(network_id, utils.get_network_id(subnets))
        m_to_net_ids.assert_called_once_with(subnets)
Пример #4
0
    def test_get_network_id(self):
        id_a = mock.sentinel.id_a
        net1 = mock.Mock()
        net1.id = id_a
        net2 = mock.Mock()
        net2.id = id_a
        subnets = {1: net1, 2: net2}

        ret = utils.get_network_id(subnets)

        self.assertEqual(ret, id_a)
Пример #5
0
    def request_vif(self, pod, project_id, subnets, security_groups):
        os_net = clients.get_network_client()
        compute = clients.get_compute_client()

        vm_id = self._get_parent_port(pod).device_id
        net_id = utils.get_network_id(subnets)

        try:
            result = compute.create_server_interface(vm_id, net_id=net_id)
        except o_exc.SDKException:
            LOG.warning("Unable to create interface for server %s.", vm_id)
            raise
        port = os_net.get_port(result.port_id)
        return ovu.neutron_to_osvif_vif_dpdk(port, subnets, pod)
Пример #6
0
    def _get_port_request(self, pod, project_id, subnets, security_groups):
        port_req_body = {
            'project_id': project_id,
            'name': c_utils.get_port_name(pod),
            'network_id': c_utils.get_network_id(subnets),
            'fixed_ips': ovu.osvif_to_neutron_fixed_ips(subnets),
            'device_owner': kl_const.DEVICE_OWNER + ':sriov',
            'device_id': c_utils.get_device_id(pod),
            'admin_state_up': True,
            'binding:vnic_type': 'direct',
            'binding:host_id': c_utils.get_host_id(pod),
        }

        if security_groups:
            port_req_body['security_groups'] = security_groups

        return {'port': port_req_body}