From 3394588602508bcde6e3c58b018b901f027363fd Mon Sep 17 00:00:00 2001 From: m0duspwnens Date: Tue, 29 Oct 2024 10:56:18 -0400 Subject: [PATCH] sync hypervisor state remote to local --- salt/hypervisor/defaults.brainstorm.yaml | 0 salt/hypervisor/defaults.sls | 79 ------------------- salt/hypervisor/defaults.yaml | 62 +++++++++++++++ salt/hypervisor/soc_hypervisor.yaml | 46 +++-------- .../tools/sbin/so-kvm-modify-hardware | 16 ++-- .../tools/sbin/so-qcow2-modify-network | 18 ++--- 6 files changed, 92 insertions(+), 129 deletions(-) create mode 100644 salt/hypervisor/defaults.brainstorm.yaml delete mode 100644 salt/hypervisor/defaults.sls create mode 100644 salt/hypervisor/defaults.yaml diff --git a/salt/hypervisor/defaults.brainstorm.yaml b/salt/hypervisor/defaults.brainstorm.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/salt/hypervisor/defaults.sls b/salt/hypervisor/defaults.sls deleted file mode 100644 index 5157e4aed..000000000 --- a/salt/hypervisor/defaults.sls +++ /dev/null @@ -1,79 +0,0 @@ -hypervisor: - nodes: - jpphype1: - add_guest: [] - guests: - - sen1_sensor: - cpu: 2 - mem: 8192 - - jpphype1: - guests: - sen1_sensor: - hardware: - cpu: 2 - mem: 8192 - - - - models: - model1: - hardware: - cpu: - total: 128 - free: 128 - memory: - total: 128 - free: 128 - disks: - free: - 3: pci_0000_c7_00_0 - 4: pci_0000_c8_00_0 - claimed: - 1: pci_0000_c5_00_0 - 2: pci_0000_c6_00_0 - copper: - free: - 1: pci_0000_c4_00_0 - 2: pci_0000_c4_00_1 - 3: pci_0000_c4_00_2 - 4: pci_0000_c4_00_3 - claimed: {} - sfp: - free: - 5: pci_0000_41_00_0 - 6: pci_0000_41_00_1 - claimed: {} - model2: - hardware: - cpu: - total: 128 - free: 128 - memory: - total: 512 - free: 512 - disks: - free: - 3: pci_0000_c8_00_0 - 4: pci_0000_c9_00_0 - 5: pci_0000_c10_00_0 - 6: pci_0000_c11_00_0 - claimed: - 1: pci_0000_c6_00_0 - 2: pci_0000_c7_00_0 - copper: - free: - 1: pci_0000_c4_00_0 - 2: pci_0000_c4_00_1 - 3: pci_0000_c4_00_2 - 4: pci_0000_c4_00_3 - 5: pci_0000_c5_00_0 - 6: pci_0000_c5_00_1 - 7: pci_0000_c5_00_2 - 8: pci_0000_c5_00_3 - claimed: {} - sfp: - free: - 9: pci_0000_41_00_0 - 10: pci_0000_41_00_1 - claimed: {} diff --git a/salt/hypervisor/defaults.yaml b/salt/hypervisor/defaults.yaml new file mode 100644 index 000000000..4a762e677 --- /dev/null +++ b/salt/hypervisor/defaults.yaml @@ -0,0 +1,62 @@ +hypervisor: + nodes: [] + model1: + hardware: + cpu: + total: 128 + free: 128 + memory: + total: 128 + free: 128 + disks: + free: + 3: pci_0000_c7_00_0 + 4: pci_0000_c8_00_0 + claimed: + 1: pci_0000_c5_00_0 + 2: pci_0000_c6_00_0 + copper: + free: + 1: pci_0000_c4_00_0 + 2: pci_0000_c4_00_1 + 3: pci_0000_c4_00_2 + 4: pci_0000_c4_00_3 + claimed: {} + sfp: + free: + 5: pci_0000_41_00_0 + 6: pci_0000_41_00_1 + claimed: {} + model2: + hardware: + cpu: + total: 128 + free: 128 + memory: + total: 512 + free: 512 + disks: + free: + 3: pci_0000_c8_00_0 + 4: pci_0000_c9_00_0 + 5: pci_0000_c10_00_0 + 6: pci_0000_c11_00_0 + claimed: + 1: pci_0000_c6_00_0 + 2: pci_0000_c7_00_0 + copper: + free: + 1: pci_0000_c4_00_0 + 2: pci_0000_c4_00_1 + 3: pci_0000_c4_00_2 + 4: pci_0000_c4_00_3 + 5: pci_0000_c5_00_0 + 6: pci_0000_c5_00_1 + 7: pci_0000_c5_00_2 + 8: pci_0000_c5_00_3 + claimed: {} + sfp: + free: + 9: pci_0000_41_00_0 + 10: pci_0000_41_00_1 + claimed: {} diff --git a/salt/hypervisor/soc_hypervisor.yaml b/salt/hypervisor/soc_hypervisor.yaml index 8865b27ab..571b1661d 100644 --- a/salt/hypervisor/soc_hypervisor.yaml +++ b/salt/hypervisor/soc_hypervisor.yaml @@ -1,35 +1,15 @@ +# This is the start of an example of what this file will look like. It will be generated by Salt, so this yaml file is not used by Salt. hypervisor: hosts: - defaultHost: - add_guest: - description: List of hypervisor nodes. - forcedType: "[]string" - global: True - multiline: True - guests: - defaultGuest: - copper: - description: Copper nics - forcedType: "[]int" - global: True - multiline: True - sfp: - description: sfp nics - forcedType: "[]int" - global: True - multiline: True - disks: - description: disk - forcedType: "[]int" - global: True - multiline: True - cpu: - description: cpu - forcedType: int - global: True - multiline: True - memory: - description: mem - forcedType: int - global: True - multiline: True + jpphype1: + add_searchnode: + description: Add a new searchnode to the hypervisor. + file: true + global: true + multiline: true + add_sensor: + description: Add a new sensor to the hypervisor. + file: true + global: true + multiline: true + guests: {} diff --git a/salt/hypervisor/tools/sbin/so-kvm-modify-hardware b/salt/hypervisor/tools/sbin/so-kvm-modify-hardware index cf4c20c49..4191373c4 100644 --- a/salt/hypervisor/tools/sbin/so-kvm-modify-hardware +++ b/salt/hypervisor/tools/sbin/so-kvm-modify-hardware @@ -101,6 +101,14 @@ def redefine_vm(conn, new_xml_desc, logger): sys.exit(1) def main(): + # Set up logging using the so_logging_utils library + logger = setup_logging( + logger_name='so-kvm-modify-hardware', + log_file_path='/opt/so/log/hypervisor/so-kvm-modify-hardware.log', + log_level=logging.INFO, + format_str='%(asctime)s - %(levelname)s - %(message)s' + ) + try: args = parse_arguments() @@ -110,14 +118,6 @@ def main(): pci_id = args.pci start_vm_flag = args.start - # Set up logging using the so_logging_utils library - logger = setup_logging( - logger_name='so-kvm-modify-hardware', - log_file_path='/opt/so/log/hypervisor/so-kvm-modify-hardware.log', - log_level=logging.INFO, - format_str='%(asctime)s - %(levelname)s - %(message)s' - ) - # Connect to libvirt try: conn = libvirt.open(None) diff --git a/salt/hypervisor/tools/sbin/so-qcow2-modify-network b/salt/hypervisor/tools/sbin/so-qcow2-modify-network index 6ec83d3e3..8829d3223 100644 --- a/salt/hypervisor/tools/sbin/so-qcow2-modify-network +++ b/salt/hypervisor/tools/sbin/so-qcow2-modify-network @@ -12,9 +12,9 @@ Usage: python so-qcow2-modify-network.py -I -i (--dhcp4 | --static4 --ip4 --gw4 ) [--dns4 ] [--search4 ] Examples: - python so-qcow2-modify-network.py -I path_to_image -i eth0 --static4 --ip4 192.168.1.10/24 --gw4 192.168.1.1 --dns4 192.168.1.1,8.8.8.8 --search4 example.local + python so-qcow2-modify-network.py -I /var/lib/libvirt/images/coreol9/coreol9.qcow2 -i eth0 --static4 --ip4 192.168.1.10/24 --gw4 192.168.1.1 --dns4 192.168.1.1,8.8.8.8 --search4 example.local - python so-qcow2-modify-network.py -I path_to_image -i eth0 --dhcp4 + python so-qcow2-modify-network.py -I /var/lib/libvirt/images/coreol9/coreol9.qcow2 -i eth0 --dhcp4 """ import argparse @@ -161,14 +161,14 @@ def parse_arguments(): return args def main(): + # Set up logging using the so_logging_utils library + logger = setup_logging( + logger_name='so-qcow2-modify-network', + log_file_path='/opt/so/log/hypervisor/so-qcow2-modify-network.log', + log_level=logging.INFO, + format_str='%(asctime)s - %(levelname)s - %(message)s' + ) try: - # Set up logging using the so_logging_utils library - logger = setup_logging( - logger_name='so-qcow2-modify-network', - log_file_path='/opt/so/log/hypervisor/so-qcow2-modify-network.log', - log_level=logging.INFO, - format_str='%(asctime)s - %(levelname)s - %(message)s' - ) args = parse_arguments() validate_interface_name(args.interface)