Mentions légales du service

Skip to content
Snippets Groups Projects
Commit cde892b5 authored by IMBERT Matthieu's avatar IMBERT Matthieu
Browse files

[execo_g5k] api_utils

- canonical_host_name: fix for ifname != ethX (eg. fpgaX)
- add get_host_interface
parent 6d59de27
No related branches found
No related tags found
No related merge requests found
......@@ -559,7 +559,7 @@ def get_host_site(host):
return m.group(3)
else:
return get_cluster_site(m.group(1))
else: return None
else: return None
def get_host_network_equipments(host):
""""""
......@@ -611,12 +611,12 @@ def get_network_equipment_attributes(equip):
site = get_network_equipment_site(equip)
return get_api_data()['network'][site][equip]
__canonical_host_name_regex = re.compile("^([a-zA-Z]+\d*-\d+)(-eth\d+)?(-kavlan-\d+)?(-ipv6)?(\.([.\w]+))?")
__canonical_host_name_regex = re.compile("^([a-zA-Z]+\d*-\d+)(-(?!kavlan-\d+)(?!ipv6)(\w+))?(-kavlan-\d+)?(-ipv6)?(\.([.\w]+))?$")
def __canonical_sub_func(matchobj):
n = matchobj.group(1)
if matchobj.lastindex >= 5:
n += matchobj.group(5)
if matchobj.lastindex >= 6:
n += matchobj.group(6)
return n
def canonical_host_name(host):
......@@ -633,6 +633,18 @@ def canonical_host_name(host):
else:
return h.address
__host_interface_regex = __canonical_host_name_regex
def get_host_interface(host):
eth = None
h = execo.Host(host)
m = __host_interface_regex.search(h.address)
if m:
eth = m.group(3)
if not eth:
eth = 'eth0'
return eth
def get_host_shortname(host):
"""Convert, if needed, the host name to its shortname"""
if isinstance(host, execo.Host):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment