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}
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}
def test_get_host_id(self): node = mock.sentinel.pod_uid pod = {'spec': {'nodeName': node}} self.assertEqual(node, utils.get_host_id(pod))