osism 0.20250331.0__py3-none-any.whl → 0.20250407.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,120 +0,0 @@
1
- # SPDX-License-Identifier: CC-BY-NC-4.0
2
- # Copyright OSISM GmbH, 2022-2023
3
-
4
- from loguru import logger
5
- from pottery import Redlock
6
-
7
- from osism import utils
8
-
9
-
10
- def get_state(device):
11
- """Gets the state (device_state) stored in the Netbox for a device."""
12
-
13
- result = None
14
- device_a = utils.nb.dcim.devices.get(name=device)
15
- result = device_a.custom_fields["device_state"]
16
-
17
- return result
18
-
19
-
20
- def get_states(devices):
21
- """Gets the state (device_state) stored in the Netbox for a list of devices."""
22
-
23
- result = {}
24
- for device in devices:
25
- device_a = utils.nb.dcim.devices.get(name=device)
26
- result[device] = device_a.custom_fields["device_state"]
27
-
28
- return result
29
-
30
-
31
- def set_maintenance(device, state):
32
- """Set the maintenance state for a device in the Netbox."""
33
-
34
- logger.info(f"Set maintenance state of device {device} = {state}")
35
-
36
- device_a = utils.nb.dcim.devices.get(name=device)
37
- device_a.custom_fields = {"maintenance": state}
38
- device_a.save()
39
-
40
-
41
- def set_ironic_state(device, state):
42
- """Set the ironic state (ironic_state) for a device in the Netbox."""
43
-
44
- logger.info(f"Set ironic state of device {device} = {state}")
45
-
46
- device_a = utils.nb.dcim.devices.get(name=device)
47
- device_a.custom_fields = {"ironic_state": state}
48
- device_a.save()
49
-
50
-
51
- def set_introspection_state(device, state):
52
- """Set the introspection state (introspection_state) for a device in the Netbox."""
53
-
54
- logger.info(f"Set introspection state of device {device} = {state}")
55
-
56
- device_a = utils.nb.dcim.devices.get(name=device)
57
- device_a.custom_fields = {"introspection_state": state}
58
- device_a.save()
59
-
60
-
61
- def set_deployment_state(device, state):
62
- """Set the deployment state (deployment_state) for a device in the Netbox."""
63
-
64
- logger.info(f"Set deployment state of device {device} = {state}")
65
-
66
- device_a = utils.nb.dcim.devices.get(name=device)
67
- device_a.custom_fields = {"deployment_state": state}
68
- device_a.save()
69
-
70
-
71
- def set_device_state(device, state):
72
- """Set the state (device_state) for a device in the Netbox."""
73
-
74
- logger.info(f"Set state of device {device} = {state}")
75
-
76
- device_a = utils.nb.dcim.devices.get(name=device)
77
- device_a.custom_fields = {"device_state": state}
78
- device_a.save()
79
-
80
-
81
- def set_state(device, state, state_type):
82
- """Set the state for a device in the Netbox."""
83
-
84
- lock = Redlock(key=f"lock_state_{device}", masters={utils.redis})
85
- lock.acquire()
86
-
87
- if state_type == "power":
88
- set_power_state(device, state)
89
- elif state_type == "provision":
90
- set_provision_state(device, state)
91
- elif state_type == "introspection":
92
- set_introspection_state(device, state)
93
- elif state_type == "ironic":
94
- set_ironic_state(device, state)
95
- elif state_type == "deployment":
96
- set_deployment_state(device, state)
97
- else:
98
- set_device_state(device, state)
99
-
100
- lock.release()
101
-
102
-
103
- def set_provision_state(device, state):
104
- """Set the provision state (provision_state) for a device in the Netbox."""
105
-
106
- logger.info(f"Set provision state of device {device} = {state}")
107
-
108
- device_a = utils.nb.dcim.devices.get(name=device)
109
- device_a.custom_fields = {"provision_state": state}
110
- device_a.save()
111
-
112
-
113
- def set_power_state(device, state):
114
- """Set the power state (power_state) for a device in the Netbox."""
115
-
116
- logger.info(f"Set power state of device {device} = {state}")
117
-
118
- device_a = utils.nb.dcim.devices.get(name=device)
119
- device_a.custom_fields = {"power_state": state}
120
- device_a.save()
@@ -1,13 +0,0 @@
1
- # SPDX-License-Identifier: CC-BY-NC-4.0
2
- # Copyright OSISM GmbH, 2022-2023
3
-
4
- from osism import utils
5
-
6
-
7
- def update_network_interface_name(mac_address, network_interface_name):
8
- """Sets the network interface name from a performed
9
- introspection for an interface with a given MAC address."""
10
-
11
- interface_a = utils.nb.dcim.interfaces.get(mac_address=mac_address)
12
- interface_a.custom_fields = {"network_interface_name": network_interface_name}
13
- interface_a.save()
@@ -1 +0,0 @@
1
- {"git_version": "8324e98", "is_release": false}