Skip to content

Commit

Permalink
Minor improvement to log messages styling
Browse files Browse the repository at this point in the history
  • Loading branch information
emersonfelipesp committed Oct 14, 2024
1 parent aba695c commit 77153ba
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions netbox_proxbox/backend/routes/proxbox/clusters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ async def get_nodes(
await log(websocket, f"<span class='badge text-bg-yellow' title='Syncing'><strong><i class='mdi mdi-download'></i></strong></span> Searching children interface of bridge interface <strong><a href='{create_interface.display_url}' target='_blank'>{create_interface.name}</a></strong>.")
print(f"current_node.id: {current_node.id} / current_node: {current_node} / current_node.name: {current_node.name}")

log(websocket, f"<span class='text-yellow'>Searching</span> child interface <strong>{port}</strong> with Device ID <strong>{current_node.id}</strong>")
await log(websocket, f"<span class='badge text-bg-yellow' title='Syncing'><strong><i class='mdi mdi-download'></i></strong></span> Child interface <strong>{port}</strong> with Device ID <strong>{current_node.id}</strong>")
netbox_port = await Interface(nb=nb, websocket=websocket, primary_field_value=current_node.id).get(
name=port
)
Expand Down Expand Up @@ -310,7 +310,7 @@ async def get_nodes(
if create_interface:
if create_interface.device == current_node.id:

await log(websocket, f"Creating interface <strong>{port}</strong>...")
await log(websocket, f"<span class='badge text-bg-blue' title='Get'><strong><i class='mdi mdi-download'></i></strong></span> Creating interface <strong>{port}</strong>...")

try:
new_netbox_port = await Interface(nb=nb, websocket=websocket, primary_field_value=current_node.id).post(data={
Expand Down Expand Up @@ -339,7 +339,7 @@ async def get_nodes(
print(f"[2] cidr: {cidr}")

if cidr:
await log(websocket, f"<span class='text-yellow'><strong><i class='mdi mdi-sync'></i></strong></span> If interface with network configured, create IP Address <strong>{cidr}</strong> and attach interface to it.")
await log(websocket, f"<span class='badge text-bg-yellow' title='Syncing'><strong><i class='mdi mdi-download'></i></strong></span> If interface with network configured, create IP Address <strong>{cidr}</strong> and attach interface to it.")
try:
create_ipaddress = await IPAddress(nb=nb, websocket=websocket, primary_field_value=cidr).post(data={
"address": cidr,
Expand Down Expand Up @@ -371,7 +371,7 @@ async def get_nodes(
print("\n")


await log(websocket, f"<span class='text-yellow'><strong><i class='mdi mdi-exclamation'></i></strong></span> Nodes: {nodes}", "debug")
await log(websocket, f"<span class='badge text-bg-yellow' title='Syncing'><strong><i class='mdi mdi-download'></i></strong></span> Nodes: {nodes}", "debug")


result.append({
Expand Down Expand Up @@ -680,7 +680,7 @@ class VirtualMachineStatus(Enum):
}

try:
await log(websocket, f"<span class='text-yellow'><strong><i class='mdi mdi-sync'></i></strong></span> Creating Virtual Machine <strong>{vm.get("name")}</strong> on Netbox...")
await log(websocket, f"<span class='badge text-bg-yellow' title='Syncing'><strong><i class='mdi mdi-download'></i></strong></span> Creating Virtual Machine <strong>{vm.get("name")}</strong> on Netbox...")
new_virtual_machine = await VirtualMachine(nb = nb, websocket = websocket).post(data = virtual_machine_data)

if new_virtual_machine:
Expand All @@ -692,7 +692,7 @@ class VirtualMachineStatus(Enum):
if "Virtual machine name must be unique per cluster." in str(error):
print("\nDUPLICATED VIRTUAL MACHINE NAME\n")

log(websocket, f"<span class='text-yellow'><strong><i class='mdi mdi-warning'></i></strong></span> Duplicated virtual machine NAME <strong>{virtual_machine_data["name"]}</strong> found within the same cluster. Appending '(2)' to the name")
log(websocket, f"<span class='badge text-bg-yellow' title='Syncing'><strong><i class='mdi mdi-download'></i></strong></span> Duplicated virtual machine NAME <strong>{virtual_machine_data["name"]}</strong> found within the same cluster. Appending '(2)' to the name")
virtual_machine_data["name"] = f"{virtual_machine_data["name"]} (2)"

duplicated_virtual_machine = await VirtualMachine(nb = nb, websocket = websocket).post(data = virtual_machine_data)
Expand All @@ -715,7 +715,7 @@ class VirtualMachineStatus(Enum):
vm_networks = []
network_id = 0

await log(websocket, "<span class='text-yellow'><strong><i class='mdi mdi-sync'></i></strong></span> Getting network info and parsing data into JSON (dict)")
await log(websocket, "<span class='badge text-bg-yellow' title='Syncing'><strong><i class='mdi mdi-download'></i></strong></span> Getting network info and parsing data into JSON (dict)")

while True:
network_name = f"net{network_id}"
Expand Down Expand Up @@ -758,7 +758,7 @@ class VirtualMachineStatus(Enum):
hwaddr = v.get("hwaddr", None)
if hwaddr: mac_address=hwaddr

await log(websocket, f"<span class='text-yellow'><strong><i class='mdi mdi-sync'></i></strong></span> Try creating VirtualMachine Interface <strong>{str(k)}</strong> on Netbox...")
await log(websocket, f"<span class='badge text-bg-yellow' title='Syncing'><strong><i class='mdi mdi-download'></i></strong></span> Try creating VirtualMachine Interface <strong>{str(k)}</strong> on Netbox...")
try:


Expand Down

0 comments on commit 77153ba

Please sign in to comment.