Skip to content

Commit

Permalink
Merge pull request #96 from sdgtt/dev
Browse files Browse the repository at this point in the history
Incremental Fixes
  • Loading branch information
tagoylo authored Jun 1, 2023
2 parents c5fa175 + 48f0ef7 commit 6286b20
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 17 deletions.
8 changes: 4 additions & 4 deletions nebula/netbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,15 +429,15 @@ def to_config(self, template): # noqa: C901
template_dict[name][field["name"]] = value

except Exception as ex:
if "optional" in field and bool(field["optional"]) is True:
log.warning(str(ex) + "." + " Skipping since optional")
continue

if "default" in field:
template_dict[name][field["name"]] = field["default"]
log.warning(str(ex) + "." + " Will try to use default")
continue

if "optional" in field and bool(field["optional"]) is True:
log.warning(str(ex) + "." + " Skipping since optional")
continue

log.error("Cannot parse {}".format(field["name"]))
raise Exception("Template mapping failed")
finally:
Expand Down
12 changes: 6 additions & 6 deletions nebula/pdu.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ def __init__(
yamlfilename=None,
board_name=None,
):
self.pduip = pduip
self.outlet = outlet
self.pdu_type = pdu_type
self.username = username
self.password = password
self.board_name = board_name
props = ["pduip", "outlet", "pdu_type", "username", "password", "board_name"]
for prop in props:
setattr(self, prop, None)
self.update_defaults_from_yaml(
yamlfilename, __class__.__name__, board_name=board_name
)
for prop in props:
if eval(prop) is not None:
setattr(self, prop, eval(prop))

if self.pdu_type == "cyberpower":
if not self.pduip:
Expand Down
12 changes: 12 additions & 0 deletions nebula/resources/template_rpi_gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ network-config:
help: "NIC connected to development board ip address"
optional: depends
netbox_field: devices.interfaces.mgmt.custom_fields.nicip
field_5:
name: dutusername
default: analog
help: "Username to access Device"
optional: True
netbox_field: devices.custom_fields.username
field_6:
name: dutpassword
default: analog
help: "Password associated with the username."
optional: True
netbox_field: devices.custom_fields.password
pdu-config:
field_1:
name: pdu_type
Expand Down
14 changes: 7 additions & 7 deletions nebula/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,8 @@ def repo(
)
def power_cycle(
c,
pdutype,
outlet,
pdutype=None,
outlet=None,
pduip=None,
username=None,
password=None,
Expand Down Expand Up @@ -609,9 +609,9 @@ def power_cycle(
)
def power_onoff(
c,
pdutype,
outlet,
onoff,
pdutype=None,
outlet=None,
onoff=None,
pduip=None,
username=None,
password=None,
Expand Down Expand Up @@ -1306,8 +1306,8 @@ def run_command(
def check_board_booted(
c,
ip=None,
user="root",
password="analog",
user=None,
password=None,
yamlfilename="/etc/default/nebula",
board_name=None,
):
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ artifactory
usbsdmux
pyudev
decorator
numpy<=1.24.3

0 comments on commit 6286b20

Please sign in to comment.