Ask Your Question
0

dhcp-agent and create_port question.

asked 2013-03-25 07:28:47 -0500

Hi,

Is there a way to determine the host on which a quantum-dhcp-agent is running which called create_port in a plugin?

Currently the port details provide the device_type and device_owner. The device_owner for a dhcp port is of the form dhcp<uuidx>-<network_id>.

In the above uuidX is generated by the agent and it not the agents id and there is no mapping of uuidX to agent's id. (will it be good to have uuidX same as the agents id ? am I missing something ?).

I could not find a way to determine the agent id from the create_port call (specifically if multiple dhcp agent are serving a L2 network).

Please let me know if I am missing something here.

Thanks Chandan

edit retag flag offensive close merge delete

7 answers

Sort by ยป oldest newest most voted
0

answered 2013-03-25 15:03:14 -0500

Hello Mark,

Thanks for the pointer, so i need to compare device_id with result of the above function for each agent, right ? is there any specific reason not to use the agent_id ? Also is there a similar way of determining the host in case of multiple l3-agent ?

Thanks for the help Chandan

edit flag offensive delete link more
0

answered 2013-03-25 08:10:04 -0500

Chandan,

you're right, that it is not possible to determine agent_id from port data. Can you provide the case in which you need to know which host runs dhcp server for given l2 network? Depending on your use case it might worth filing a bug about this.

edit flag offensive delete link more
0

answered 2013-03-25 08:19:09 -0500

Hello Eugene,

I am trying to write a L2 plugin to orchestrate a physical switch. I try to add a physical switch port to a vlan (mapped to a virtual network) when a virtual device (like a vm or a network device e.g. dhcp) shows up on a host. This is done dynamically in the plugin.

For a vm case it is possible to query nova and find the hypervisor host, i am trying to get the same information for dhcp and router. Till folsom i was assuming all network devices will show up on quantum server but now due to the quantum scheduler no more the case.

Also there can be more then one dhcp server in an L2 so i am finding it hard to determine which of the network node should i add to the vlan.

Thanks for your help

Chandan

edit flag offensive delete link more
0

answered 2013-03-25 08:43:51 -0500

If you're looking from plugin perspective, you should take a look how othe L2 plugins are implemented. In particular, they inherit from agentschedulers_db.AgentSchedulerDbMixin class. You may call get_dhcp_agents_hosting_networks and get agent object, which has host field, indicating at which host it is running.

edit flag offensive delete link more
0

answered 2013-03-25 08:44:01 -0500

amotoki gravatar image

I agree that it would be better that device_id of DHCP server port should be more meaningful (i.e., use agent id as uuidX in dhcp<uuidx>-<network_id>). We need to take care of dhcp-agent or l3-agent without state report.

For your purpose, if you know the host name where dhcp-agent is running, you can identify a network node by combining results of the following commands: (a) quantum agent-list -- and quantum dhcp-agent-list-hosting-net <network-id>. (though it is not a smart way i think).

edit flag offensive delete link more
0

answered 2013-03-25 09:11:44 -0500

Hello Eugene and Akihiro,

Thanks for the suggestions, i was doing exactly the same until i found that for a L2 network there can be more then one dhcp-agent. Now get_dhcp_agents_hosting_networks() for a network_id returns me a list of dhcp agents running on different network nodes. I dont find a way to which of this agents actually called the create_port.

Note: By default only one dhcp-agent is assigned to a L2 network but it is possible to assign more agent if the user does the following

quantum dhcp-agent-network-add <agent_id> <net_id>

This results in the create_port call and the plugin code doing get_dhcp_agents_hosting_networks() get a list of agents not know which one actually called the create_port.

I agree if we can find out the agent_id finding the host is easy.

Thanks again Chandan

edit flag offensive delete link more
0

answered 2013-03-25 14:50:52 -0500

markmcclain gravatar image

If you know the available set of DHCP agent hosts, you can determine the host that created the dhcp port by calculating and comparing the uuid5 of the hostname. The format of the identifier is dhcpX-network.id X is uuid.uuid5() of the hostname where the port is created and is a repeatable operation.

Here's the method we use to build the device_id:

def get_device_id(self, network): """Return a unique DHCP device ID for this host on the network.""" # There could be more than one dhcp server per network, so create # a device id that combines host and network ids

    host_uuid = uuid.uuid5(uuid.NAMESPACE_DNS, socket.gethostname())
    return 'dhcp%s-%s' % (host_uuid, network.id)
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2013-03-25 07:28:47 -0500

Seen: 102 times

Last updated: Mar 25 '13