Fix bug when checking dhcp in network node
Change-Id: Icb8282c2993c407e20dab3613f0e788956735519
This commit is contained in:
parent
67a9b7749c
commit
3916f6e265
@ -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']
|
||||
|
@ -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'])])
|
||||
|
Loading…
x
Reference in New Issue
Block a user