Merge "Fix bug when checking dhcp in network node"

This commit is contained in:
Jenkins 2016-04-05 02:59:09 +00:00 committed by Gerrit Code Review
commit 716083ac95
2 changed files with 13 additions and 6 deletions

View File

@ -15,6 +15,7 @@
# under the License.
import random
import sys
from oslo_config import cfg
@ -48,3 +49,9 @@ def get_port_attr(port_id, attr):
return
return res['port'][attr]
def choose_one_network_agent(network_id):
client = get_neutronclient()
dhcp_agents = client.list_dhcp_agent_hosting_networks(network_id)
return random.choice(dhcp_agents['agents'])['host']

View File

@ -143,13 +143,13 @@ class CheckDHCPonNetworkNodes(Lister):
sys.exit()
self.log.debug("port ip addr is %s" % port_ip_addr)
# get port's host info
host_id = neutron.get_port_attr(parsed_args.port_id, 'binding:host_id')
# choose one network agent
host_id = neutron.choose_one_network_agent(port_network_id)
if not host_id:
utils.Logger.log_fail("Port %s doesn't attach to any vms."
% parsed_args.port_id)
utils.Logger.log_fail("Network %s has no dhcp services."
% port_network_id)
sys.exit()
self.log.debug("port host id is %s" % host_id)
self.log.debug("Get host %s" % host_id)
# setup steth server
try:
@ -172,5 +172,5 @@ class CheckDHCPonNetworkNodes(Lister):
return (['Device Name', 'Result'],
(['br-int', data['br-int']],
['ovsbr3', data['ovsbr3']],
['eth0', data['eth0']]))
[physical_interface, data[physical_interface]]))
return (['Error Mssage', ' '], [('message', res['message'])])