rename interface
Change-Id: I413e3d1770401e58cbf5b801892b46378d7840b0
This commit is contained in:
parent
375abedb8a
commit
2f9857d3cb
|
@ -1473,6 +1473,12 @@ class ApplyNodeNetworking(BaseMaasAction):
|
||||||
machine.refresh()
|
machine.refresh()
|
||||||
|
|
||||||
for i in n.interfaces:
|
for i in n.interfaces:
|
||||||
|
|
||||||
|
# rename only ens ones
|
||||||
|
if [val for key, val in i.items() if "ens" in val]:
|
||||||
|
|
||||||
|
machine.rename_interface(i.name, i.id)
|
||||||
|
|
||||||
if not i.network_link:
|
if not i.network_link:
|
||||||
self.logger.debug(
|
self.logger.debug(
|
||||||
"Interface %s has no network link, skipping configuration."
|
"Interface %s has no network link, skipping configuration."
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
"""Model representing MAAS node/machine resource."""
|
"""Model representing MAAS node/machine resource."""
|
||||||
import logging
|
import logging
|
||||||
import base64
|
import base64
|
||||||
|
import json
|
||||||
|
|
||||||
from threading import Lock, Condition
|
from threading import Lock, Condition
|
||||||
|
|
||||||
|
@ -82,6 +83,37 @@ class Machine(model_base.ResourceBase):
|
||||||
return i
|
return i
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def get_commissioning_results(self):
|
||||||
|
"""Load the commissioning script results"""
|
||||||
|
url = self.interpolate_url()
|
||||||
|
|
||||||
|
resp = self.api_client.get(url, op='results', params={"filters": "99-netiface-names.sh"})
|
||||||
|
|
||||||
|
output_str = resp.decode('utf-8')
|
||||||
|
data_dict = json.loads(output_str)
|
||||||
|
|
||||||
|
if resp.status_code == 200:
|
||||||
|
self.results = data_dict
|
||||||
|
|
||||||
|
def rename_interface(self, interface_name, interface_id):
|
||||||
|
"""rename interface"""
|
||||||
|
url = self.interpolate_url()
|
||||||
|
|
||||||
|
int_names = self.get_commissioning_results()
|
||||||
|
path_name = int_names.get(interface_name, "")
|
||||||
|
if path_name:
|
||||||
|
self.logger.info("Interface %s rename to %s" %
|
||||||
|
(interface_name, path_name))
|
||||||
|
resp = self.api_client.put(url, op='interfaces',
|
||||||
|
params={"name": path_name, "id":interface_id})
|
||||||
|
|
||||||
|
if not resp.ok:
|
||||||
|
brief_msg = ("Error updating interface name, received HTTP %s from MaaS" %
|
||||||
|
resp.status_code)
|
||||||
|
self.logger.error(brief_msg)
|
||||||
|
self.logger.debug("MaaS response: %s" % resp.text)
|
||||||
|
raise errors.DriverError(brief_msg)
|
||||||
|
|
||||||
def interface_for_mac(self, mac_address):
|
def interface_for_mac(self, mac_address):
|
||||||
"""Find the machine interface that owns the specified ``mac_address``.
|
"""Find the machine interface that owns the specified ``mac_address``.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue