sync hypervisor state remote to local

This commit is contained in:
m0duspwnens
2024-10-29 10:56:18 -04:00
parent c64a05f2ff
commit 3394588602
6 changed files with 92 additions and 129 deletions

View File

View File

@@ -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: {}

View File

@@ -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: {}

View File

@@ -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: {}

View File

@@ -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)

View File

@@ -12,9 +12,9 @@ Usage:
python so-qcow2-modify-network.py -I <qcow2_image_path> -i <interface> (--dhcp4 | --static4 --ip4 <ip_address> --gw4 <gateway>) [--dns4 <dns_servers>] [--search4 <search_domain>]
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,7 +161,6 @@ def parse_arguments():
return args
def main():
try:
# Set up logging using the so_logging_utils library
logger = setup_logging(
logger_name='so-qcow2-modify-network',
@@ -169,6 +168,7 @@ def main():
log_level=logging.INFO,
format_str='%(asctime)s - %(levelname)s - %(message)s'
)
try:
args = parse_arguments()
validate_interface_name(args.interface)