netbox-memory-input 0.1__tar.gz → 0.3__tar.gz
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.
- netbox_memory_input-0.3/PKG-INFO +11 -0
- {netbox_memory_input-0.1 → netbox_memory_input-0.3}/netbox_memory_input/forms.py +28 -8
- netbox_memory_input-0.3/netbox_memory_input.egg-info/PKG-INFO +11 -0
- {netbox_memory_input-0.1 → netbox_memory_input-0.3}/setup.py +2 -2
- netbox_memory_input-0.1/PKG-INFO +0 -7
- netbox_memory_input-0.1/netbox_memory_input.egg-info/PKG-INFO +0 -7
- {netbox_memory_input-0.1 → netbox_memory_input-0.3}/README.md +0 -0
- {netbox_memory_input-0.1 → netbox_memory_input-0.3}/netbox_memory_input/__init__.py +0 -0
- {netbox_memory_input-0.1 → netbox_memory_input-0.3}/netbox_memory_input.egg-info/SOURCES.txt +0 -0
- {netbox_memory_input-0.1 → netbox_memory_input-0.3}/netbox_memory_input.egg-info/dependency_links.txt +0 -0
- {netbox_memory_input-0.1 → netbox_memory_input-0.3}/netbox_memory_input.egg-info/not-zip-safe +0 -0
- {netbox_memory_input-0.1 → netbox_memory_input-0.3}/netbox_memory_input.egg-info/top_level.txt +0 -0
- {netbox_memory_input-0.1 → netbox_memory_input-0.3}/setup.cfg +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: netbox_memory_input
|
|
3
|
+
Version: 0.3
|
|
4
|
+
Summary: Input VM memory in GB instead of MB in NetBox.
|
|
5
|
+
Home-page: https://eww.at
|
|
6
|
+
Author: jannis
|
|
7
|
+
License: AGPLv3
|
|
8
|
+
Dynamic: author
|
|
9
|
+
Dynamic: home-page
|
|
10
|
+
Dynamic: license
|
|
11
|
+
Dynamic: summary
|
|
@@ -35,18 +35,38 @@ class MemoryGBVirtualMachineForm(VirtualMachineForm):
|
|
|
35
35
|
logger.debug("MemoryGBVirtualMachineForm initialization started")
|
|
36
36
|
super().__init__(*args, **kwargs)
|
|
37
37
|
|
|
38
|
-
# Handle memory conversion
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
# Handle memory conversion. The value may come from a saved instance
|
|
39
|
+
# (edit) or from initial data supplied via the URL query string (clone),
|
|
40
|
+
# in which case self.instance is a new, unsaved object.
|
|
41
|
+
memory_mb = self._get_initial_mb('memory')
|
|
42
|
+
if memory_mb:
|
|
43
|
+
gb_value = round(memory_mb / 1000, 2) # Round to 2 decimal places
|
|
44
|
+
logger.debug(f"Setting initial memory value: {memory_mb}MB -> {gb_value}GB")
|
|
42
45
|
self.initial['memory'] = gb_value
|
|
43
|
-
|
|
46
|
+
|
|
44
47
|
# Handle disk conversion
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
disk_mb = self._get_initial_mb('disk')
|
|
49
|
+
if disk_mb:
|
|
50
|
+
gb_value = round(disk_mb / 1000, 2) # Round to 2 decimal places
|
|
51
|
+
logger.debug(f"Setting initial disk value: {disk_mb}MB -> {gb_value}GB")
|
|
48
52
|
self.initial['disk'] = gb_value
|
|
49
53
|
|
|
54
|
+
def _get_initial_mb(self, field):
|
|
55
|
+
"""Return the source value in MB from the instance (edit) or the initial
|
|
56
|
+
clone data, or None if there is nothing to convert."""
|
|
57
|
+
instance_value = getattr(self.instance, field, None)
|
|
58
|
+
if instance_value:
|
|
59
|
+
return instance_value
|
|
60
|
+
# Clone: value arrives as a string in initial data from the query string.
|
|
61
|
+
initial_value = self.initial.get(field)
|
|
62
|
+
if initial_value in (None, ''):
|
|
63
|
+
return None
|
|
64
|
+
try:
|
|
65
|
+
return float(initial_value)
|
|
66
|
+
except (TypeError, ValueError):
|
|
67
|
+
logger.debug(f"Could not parse initial {field} value: {initial_value!r}")
|
|
68
|
+
return None
|
|
69
|
+
|
|
50
70
|
def clean_memory(self):
|
|
51
71
|
memory = self.cleaned_data.get('memory')
|
|
52
72
|
if memory is not None:
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: netbox_memory_input
|
|
3
|
+
Version: 0.3
|
|
4
|
+
Summary: Input VM memory in GB instead of MB in NetBox.
|
|
5
|
+
Home-page: https://eww.at
|
|
6
|
+
Author: jannis
|
|
7
|
+
License: AGPLv3
|
|
8
|
+
Dynamic: author
|
|
9
|
+
Dynamic: home-page
|
|
10
|
+
Dynamic: license
|
|
11
|
+
Dynamic: summary
|
|
@@ -2,9 +2,9 @@ from setuptools import find_packages, setup
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name='netbox_memory_input',
|
|
5
|
-
version='0.
|
|
5
|
+
version='0.3',
|
|
6
6
|
description='Input VM memory in GB instead of MB in NetBox.',
|
|
7
|
-
url='https://
|
|
7
|
+
url='https://eww.at',
|
|
8
8
|
author='jannis',
|
|
9
9
|
license='AGPLv3',
|
|
10
10
|
install_requires=[],
|
netbox_memory_input-0.1/PKG-INFO
DELETED
|
File without changes
|
|
File without changes
|
{netbox_memory_input-0.1 → netbox_memory_input-0.3}/netbox_memory_input.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{netbox_memory_input-0.1 → netbox_memory_input-0.3}/netbox_memory_input.egg-info/not-zip-safe
RENAMED
|
File without changes
|
{netbox_memory_input-0.1 → netbox_memory_input-0.3}/netbox_memory_input.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|