mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-30 20:43:02 +02:00
infamy: Set hostname from logical topology
If no hostname is specified, set it to the dut-name in logical topology
This commit is contained in:
@@ -16,7 +16,7 @@ import lxml
|
||||
import netconf_client.connect
|
||||
import netconf_client.ncclient
|
||||
import infamy.iface as iface
|
||||
from infamy.transport import Transport
|
||||
from infamy.transport import Transport,infer_put_dict
|
||||
from netconf_client.error import RpcError
|
||||
from . import env
|
||||
|
||||
@@ -315,6 +315,7 @@ class Device(Transport):
|
||||
|
||||
def put_config_dicts(self, models):
|
||||
config = ""
|
||||
infer_put_dict(self.name, models)
|
||||
|
||||
for model in models.keys():
|
||||
mod = self.ly.get_module(model)
|
||||
|
||||
@@ -10,7 +10,7 @@ import time
|
||||
from requests.auth import HTTPBasicAuth
|
||||
from urllib3.exceptions import InsecureRequestWarning
|
||||
from dataclasses import dataclass
|
||||
from infamy.transport import Transport
|
||||
from infamy.transport import Transport, infer_put_dict
|
||||
from . import env
|
||||
|
||||
# We know we have a self-signed certificate, silence warning about it
|
||||
@@ -263,6 +263,7 @@ class Device(Transport):
|
||||
return {container: v}
|
||||
|
||||
def put_config_dicts(self, models):
|
||||
infer_put_dict(self.name, models)
|
||||
running = self.get_running()
|
||||
|
||||
for model in models.keys():
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from infamy.neigh import ll6ping
|
||||
|
||||
def infer_put_dict(name, models):
|
||||
if not models.get("ietf-system"):
|
||||
models["ietf-system"] = { "system": { "hostname": name} }
|
||||
else:
|
||||
if not models["ietf-system"].get("system"):
|
||||
models["ieft-system"]["system"] = {}
|
||||
if not models["ietf-system"]["system"].get("hostname"):
|
||||
models["ietf-system"]["system"]["hostname"] = name
|
||||
|
||||
class Transport(ABC):
|
||||
"""Common functions for NETCONF/RESTCONF"""
|
||||
|
||||
Reference in New Issue
Block a user