forked from shaba/openuds
Small opennebula fix for better control of certain situations...
This commit is contained in:
parent
0c7a4911d2
commit
22313a517f
@ -39,7 +39,7 @@ from defusedxml import minidom
|
|||||||
# Python bindings for OpenNebula
|
# Python bindings for OpenNebula
|
||||||
from .common import VmState
|
from .common import VmState
|
||||||
|
|
||||||
__updated__ = '2017-02-22'
|
__updated__ = '2017-03-03'
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -157,11 +157,15 @@ def getNetInfo(api, machineId, networkId=None):
|
|||||||
md = minidom.parseString(api.VMInfo(machineId)[1])
|
md = minidom.parseString(api.VMInfo(machineId)[1])
|
||||||
node = md
|
node = md
|
||||||
|
|
||||||
for nic in md.getElementsByTagName('NIC'):
|
try:
|
||||||
netId = nic.getElementsByTagName('NETWORK_ID')[0].childNodes[0].data
|
for nic in md.getElementsByTagName('NIC'):
|
||||||
if networkId is None or int(netId) == int(networkId):
|
netId = nic.getElementsByTagName('NETWORK_ID')[0].childNodes[0].data
|
||||||
node = nic
|
if networkId is None or int(netId) == int(networkId):
|
||||||
break
|
node = nic
|
||||||
|
break
|
||||||
|
except Exception:
|
||||||
|
raise Exception('No network interface found on template. Please, add a network and republish.')
|
||||||
|
|
||||||
logger.debug(node.toxml())
|
logger.debug(node.toxml())
|
||||||
|
|
||||||
# Default, returns first MAC found (or raise an exception if there is no MAC)
|
# Default, returns first MAC found (or raise an exception if there is no MAC)
|
||||||
|
Loading…
Reference in New Issue
Block a user