Added config-context in hostvars (#47394)
* Added config-contexts in hostvars * Changed config-contexts to config-context in hostvars
This commit is contained in:
parent
a8b5d30a9e
commit
f3583cebd6
1 changed files with 9 additions and 0 deletions
|
@ -198,6 +198,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
|
||||||
"device_roles": self.extract_device_role,
|
"device_roles": self.extract_device_role,
|
||||||
"platforms": self.extract_platform,
|
"platforms": self.extract_platform,
|
||||||
"device_types": self.extract_device_type,
|
"device_types": self.extract_device_type,
|
||||||
|
"config_context": self.extract_config_context,
|
||||||
"manufacturers": self.extract_manufacturer
|
"manufacturers": self.extract_manufacturer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,6 +247,14 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
|
||||||
except Exception:
|
except Exception:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def extract_config_context(self, host):
|
||||||
|
try:
|
||||||
|
url = urljoin(self.api_endpoint, "/api/dcim/devices/" + str(host["id"]))
|
||||||
|
device_lookup = self._fetch_information(url)
|
||||||
|
return [device_lookup["config_context"]]
|
||||||
|
except Exception:
|
||||||
|
return
|
||||||
|
|
||||||
def extract_manufacturer(self, host):
|
def extract_manufacturer(self, host):
|
||||||
try:
|
try:
|
||||||
return [self.manufacturers_lookup[host["device_type"]["manufacturer"]["id"]]]
|
return [self.manufacturers_lookup[host["device_type"]["manufacturer"]["id"]]]
|
||||||
|
|
Loading…
Reference in a new issue