def _generate_port_context(self, port_config,<EOL>override_host_name=None,<EOL>override_netid=None,<EOL>unbind_port=False):
if override_host_name:<EOL><INDENT>host_name = override_host_name<EOL><DEDENT>else:<EOL><INDENT>host_name = port_config.host_name<EOL><DEDENT>instance_id = port_config.instance_id<EOL>vlan_id = port_config.vlan_id<EOL>vxlan_id = port_config.vxlan_id<EOL>mcast_group = port_config.mcast_group<EOL>device_owner = port_config.device_owner<EOL>profile = port_config.profile<EOL>vnic_type = port_config.vnic_type<EOL>dns_name = port_config.dns_name<EOL>if override_netid:<EOL><INDENT>netid = override_netid<EOL><DEDENT>else:<EOL><INDENT>netid = None<EOL><DEDENT>network_context = FakeNetworkContext(vlan_id, NETWORK_TYPE, netid)<EOL>if vxlan_id != NO_VXLAN_ID:<EOL><INDENT>vxlan_network_context = FakeNetworkContext(vxlan_id,<EOL>const.TYPE_NEXUS_VXLAN, mcast_group, netid)<EOL>if unbind_port:<EOL><INDENT>port_context = FakeUnbindPortContext(<EOL>instance_id, host_name, device_owner,<EOL>vxlan_network_context, network_context,<EOL>profile, vnic_type, dns_name, netid)<EOL><DEDENT>else:<EOL><INDENT>port_context = FakePortContext(<EOL>instance_id, host_name, device_owner,<EOL>vxlan_network_context, network_context,<EOL>profile, vnic_type, dns_name, netid)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if unbind_port:<EOL><INDENT>port_context = FakeUnbindPortContext(<EOL>instance_id, host_name, device_owner,<EOL>network_context, None,<EOL>profile, vnic_type, dns_name, netid)<EOL><DEDENT>else:<EOL><INDENT>port_context = FakePortContext(<EOL>instance_id, host_name, device_owner,<EOL>network_context, None,<EOL>profile, vnic_type, dns_name, netid)<EOL><DEDENT><DEDENT>return port_context<EOL>
Returns port context from port_config.