nvidia tested and working, added options for web and api port in jenkinsfile
This commit is contained in:
@ -49,16 +49,25 @@ class Component:
|
||||
# store static properties
|
||||
self.multi_check = self.is_multi()
|
||||
self.virt_ignore = self._descriptor.get('virt_ignore', [])
|
||||
self.multi_metrics = self._descriptor.get('multi_metrics', [])
|
||||
#if 'precheck' in self._descriptor:
|
||||
# precheck_command = self._descriptor.get('precheck', [])
|
||||
# precheck_value = int(run_command(precheck_command, zero_only = True))
|
||||
# if precheck_value == 0:
|
||||
# raise ValueError(f"No devices of type {self.type}")
|
||||
if self.is_virtual:
|
||||
self.virt_ignore = []
|
||||
self._properties: Dict[str, str] = {}
|
||||
self._properties: Dict[str, str | list[str]] = {}
|
||||
for key, command in descriptor.get('properties', {}).items():
|
||||
return_string = True
|
||||
if key in self.multi_metrics:
|
||||
return_string = False
|
||||
if self.this_device != "None":
|
||||
# this means this component type is a multi and the commands need templating for each device
|
||||
formatted_command = command.format(this_device=self.this_device)
|
||||
self._properties[key] = run_command(formatted_command, True)
|
||||
self._properties[key] = run_command(formatted_command, zero_only = return_string)
|
||||
else:
|
||||
self._properties[key] = run_command(command, zero_only = True)
|
||||
self._properties[key] = run_command(command, zero_only = return_string)
|
||||
print(self._properties[key])
|
||||
# build the description string
|
||||
self._description_template: str | None = descriptor.get("description")
|
||||
@ -114,31 +123,32 @@ class Component:
|
||||
component_properties = self._properties.items()
|
||||
else:
|
||||
component_properties = self.get_property(component)
|
||||
for name, value in component_properties:
|
||||
this_property = {
|
||||
"Source": self.name,
|
||||
"Property": name,
|
||||
"Value": value
|
||||
}
|
||||
if name not in self.virt_ignore:
|
||||
result.append(this_property)
|
||||
for name, values in component_properties:
|
||||
for value in (values if isinstance(values, list) else [values]):
|
||||
this_property = {
|
||||
"Source": self.name,
|
||||
"Property": name,
|
||||
"Value": value
|
||||
}
|
||||
if name not in self.virt_ignore:
|
||||
result.append(this_property)
|
||||
return result
|
||||
|
||||
def get_properties_strings(self, return_simple = False):
|
||||
result = []
|
||||
component_properties = self._properties.items()
|
||||
print(component_properties)
|
||||
for name, value in component_properties:
|
||||
simple_property = f"{name}: {value}"
|
||||
complex_property = {
|
||||
"Source": self.name,
|
||||
"Property": simple_property
|
||||
}
|
||||
if name not in self.virt_ignore:
|
||||
if return_simple:
|
||||
result.append(simple_property)
|
||||
else:
|
||||
result.append(complex_property)
|
||||
for name, values in component_properties:
|
||||
for value in (values if isinstance(values, list) else [values]):
|
||||
simple_property = f"{name}: {value}"
|
||||
complex_property = {
|
||||
"Source": self.name,
|
||||
"Property": simple_property
|
||||
}
|
||||
if name not in self.virt_ignore:
|
||||
if return_simple:
|
||||
result.append(simple_property)
|
||||
else:
|
||||
result.append(complex_property)
|
||||
return result
|
||||
|
||||
def get_metrics_keys(self):
|
||||
@ -318,15 +328,15 @@ class System:
|
||||
multi_check = component["multi_check"]
|
||||
# if multi, note that the command in device_list creates the list of things to pipe into this_device
|
||||
if multi_check:
|
||||
letters = [chr(c) for c in range(ord('A'), ord('Z')+1)]
|
||||
print(f"Creating one component of type {component_name} for each one found")
|
||||
component_type_device_list = get_device_list(component_name)
|
||||
|
||||
component_id = 0
|
||||
for this_device in component_type_device_list:
|
||||
this_component_letter = letters[component_type_device_list.index(this_device)]
|
||||
this_component_name = f"{component_name} {this_component_letter}"
|
||||
this_component_ID = component_type_device_list.index(this_device)
|
||||
this_component_name = f"{component_name} {this_component_ID}"
|
||||
print(f"{this_component_name} - {component_name} - {this_device}")
|
||||
self.add_components(Component(name = this_component_name, comp_type = component_name, this_device = this_device))
|
||||
new_component = Component(name = this_component_name, comp_type = component_name, this_device = this_device)
|
||||
self.add_components(new_component)
|
||||
|
||||
else:
|
||||
if debug_output:
|
||||
@ -538,7 +548,13 @@ def run_command(cmd, zero_only=False, use_shell=True, req_check = True):
|
||||
def get_device_list(device_type_name: str):
|
||||
result = []
|
||||
for component in component_class_tree:
|
||||
if component["name"] == device_type_name:
|
||||
precheck_value = 1
|
||||
if "precheck" in component:
|
||||
precheck_command = component["precheck"]
|
||||
precheck_value_output = run_command(precheck_command, zero_only = True)
|
||||
precheck_value = int(precheck_value_output)
|
||||
print(f"Precheck found - {precheck_command} - {precheck_value}")
|
||||
if component["name"] == device_type_name and precheck_value != 0:
|
||||
device_list_command = component["device_list"]
|
||||
device_list_result = run_command(device_list_command)
|
||||
result = device_list_result
|
||||
|
||||
Reference in New Issue
Block a user