Move libvirt_schema and fix other imports

This commit is contained in:
2023-12-09 12:20:29 -05:00
parent 7976e1d2d0
commit 0bda095571
6 changed files with 17 additions and 17 deletions

View File

@ -174,7 +174,7 @@ class VMBuilderScript(VMBuilder):
"""
# Run any imports first
import pvcapid.libvirt_schema as libvirt_schema
import daemon_lib.libvirt_schema as libvirt_schema
import datetime
import random

View File

@ -177,7 +177,7 @@ class VMBuilderScript(VMBuilder):
"""
# Run any imports first
import pvcapid.libvirt_schema as libvirt_schema
import daemon_lib.libvirt_schema as libvirt_schema
import datetime
import random
@ -289,7 +289,7 @@ class VMBuilderScript(VMBuilder):
"""
# Run any imports first
from pvcapid.vmbuilder import open_zk
from daemon_lib.vmbuilder import open_zk
from pvcapid.Daemon import config
import daemon_lib.common as pvc_common
import daemon_lib.ceph as pvc_ceph
@ -383,7 +383,7 @@ class VMBuilderScript(VMBuilder):
"""
# Run any imports first
from pvcapid.vmbuilder import open_zk
from daemon_lib.vmbuilder import open_zk
from pvcapid.Daemon import config
import daemon_lib.ceph as pvc_ceph

View File

@ -186,7 +186,7 @@ class VMBuilderScript(VMBuilder):
"""
# Run any imports first
import pvcapid.libvirt_schema as libvirt_schema
import daemon_lib.libvirt_schema as libvirt_schema
import datetime
import random
@ -301,7 +301,7 @@ class VMBuilderScript(VMBuilder):
This function should use the various exposed PVC commands as indicated to create
RBD block devices and map them to the host as required.
open_zk is exposed from pvcapid.vmbuilder to provide a context manager for opening
open_zk is exposed from daemon_lib.vmbuilder to provide a context manager for opening
connections to the PVC Zookeeper cluster; ensure you also import (and pass it)
the config object from pvcapid.Daemon as well. This context manager then allows
the use of various common daemon library functions, without going through the API.
@ -309,7 +309,7 @@ class VMBuilderScript(VMBuilder):
# Run any imports first
import os
from pvcapid.vmbuilder import open_zk
from daemon_lib.vmbuilder import open_zk
from pvcapid.Daemon import config
import daemon_lib.common as pvc_common
import daemon_lib.ceph as pvc_ceph
@ -446,7 +446,7 @@ class VMBuilderScript(VMBuilder):
# Run any imports first
import os
from pvcapid.vmbuilder import chroot
from daemon_lib.vmbuilder import chroot
# The directory we mounted things on earlier during prepare(); this could very well
# be exposed as a module-level variable if you so choose
@ -718,7 +718,7 @@ GRUB_DISABLE_LINUX_UUID=false
# Run any imports first
import os
from pvcapid.vmbuilder import open_zk
from daemon_lib.vmbuilder import open_zk
from pvcapid.Daemon import config
import daemon_lib.common as pvc_common
import daemon_lib.ceph as pvc_ceph

View File

@ -186,7 +186,7 @@ class VMBuilderScript(VMBuilder):
"""
# Run any imports first
import pvcapid.libvirt_schema as libvirt_schema
import daemon_lib.libvirt_schema as libvirt_schema
import datetime
import random
@ -301,7 +301,7 @@ class VMBuilderScript(VMBuilder):
This function should use the various exposed PVC commands as indicated to create
RBD block devices and map them to the host as required.
open_zk is exposed from pvcapid.vmbuilder to provide a context manager for opening
open_zk is exposed from daemon_lib.vmbuilder to provide a context manager for opening
connections to the PVC Zookeeper cluster; ensure you also import (and pass it)
the config object from pvcapid.Daemon as well. This context manager then allows
the use of various common daemon library functions, without going through the API.
@ -309,7 +309,7 @@ class VMBuilderScript(VMBuilder):
# Run any imports first
import os
from pvcapid.vmbuilder import open_zk
from daemon_lib.vmbuilder import open_zk
from pvcapid.Daemon import config
import daemon_lib.common as pvc_common
import daemon_lib.ceph as pvc_ceph
@ -446,7 +446,7 @@ class VMBuilderScript(VMBuilder):
# Run any imports first
import os
from pvcapid.vmbuilder import chroot
from daemon_lib.vmbuilder import chroot
import daemon_lib.common as pvc_common
# The directory we mounted things on earlier during prepare(); this could very well
@ -692,7 +692,7 @@ GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=
# Run any imports first
import os
from pvcapid.vmbuilder import open_zk
from daemon_lib.vmbuilder import open_zk
from pvcapid.Daemon import config
import daemon_lib.common as pvc_common
import daemon_lib.ceph as pvc_ceph

View File

@ -243,7 +243,7 @@ class VMBuilderScript(VMBuilder):
"""
# Run any imports first
import pvcapid.libvirt_schema as libvirt_schema
import daemon_lib.libvirt_schema as libvirt_schema
import datetime
import random
@ -358,7 +358,7 @@ class VMBuilderScript(VMBuilder):
# Run any imports first; as shown here, you can import anything from the PVC
# namespace, as well as (of course) the main Python namespaces
from pvcapid.vmbuilder import open_zk
from daemon_lib.vmbuilder import open_zk
from pvcapid.Daemon import config
import daemon_lib.common as pvc_common
import daemon_lib.ceph as pvc_ceph
@ -902,7 +902,7 @@ class VMBuilderScript(VMBuilder):
"""
# Run any imports first
from pvcapid.vmbuilder import open_zk
from daemon_lib.vmbuilder import open_zk
from pvcapid.Daemon import config
import daemon_lib.ceph as pvc_ceph

View File

@ -1,141 +0,0 @@
#!/usr/bin/env python3
# libvirt_schema.py - Libvirt schema elements
# Part of the Parallel Virtual Cluster (PVC) system
#
# Copyright (C) 2018-2022 Joshua M. Boniface <joshua@boniface.me>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
###############################################################################
# File header, containing default values for various non-device components
# Variables:
# * vm_name
# * vm_uuid
# * vm_description
# * vm_memory
# * vm_vcpus
# * vm_architecture
libvirt_header = """<domain type='kvm'>
<name>{vm_name}</name>
<uuid>{vm_uuid}</uuid>
<description>{vm_description}</description>
<memory unit='MiB'>{vm_memory}</memory>
<vcpu>{vm_vcpus}</vcpu>
<cpu mode='host-model'>
<topology sockets='1' cores='{vm_vcpus}' threads='1'/>
</cpu>
<os>
<type arch='{vm_architecture}' machine='pc-i440fx-2.7'>hvm</type>
<bootmenu enable='yes'/>
<boot dev='cdrom'/>
<boot dev='hd'/>
<bios useserial='yes' rebootTimeout='5'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<console type='pty'/>
"""
# File footer, closing devices and domain elements
libvirt_footer = """ </devices>
</domain>"""
# Default devices for all VMs
devices_default = """ <emulator>/usr/bin/kvm</emulator>
<controller type='usb' index='0'/>
<controller type='pci' index='0' model='pci-root'/>
<rng model='virtio'>
<rate period="1000" bytes="2048"/>
<backend model='random'>/dev/random</backend>
</rng>
<channel type='unix'>
<target type='virtio' name='org.qemu.guest_agent.0'/>
</channel>
"""
# Serial device
# Variables:
# * vm_name
devices_serial = """ <serial type='pty'>
<log file='/var/log/libvirt/{vm_name}.log' append='on'/>
</serial>
"""
# VNC device
# Variables:
# * vm_vncport
# * vm_vnc_autoport
# * vm_vnc_bind
devices_vnc = """ <graphics type='vnc' port='{vm_vncport}' autoport='{vm_vnc_autoport}' listen='{vm_vnc_bind}'/>
"""
# VirtIO SCSI device
devices_scsi_controller = """ <controller type='scsi' index='0' model='virtio-scsi'/>
"""
# Disk device header
# Variables:
# * ceph_storage_secret
# * disk_pool
# * vm_name
# * disk_id
devices_disk_header = """ <disk type='network' device='disk'>
<driver name='qemu' discard='unmap' cache='none'/>
<target dev='{disk_id}' bus='scsi'/>
<auth username='libvirt'>
<secret type='ceph' uuid='{ceph_storage_secret}'/>
</auth>
<source protocol='rbd' name='{disk_pool}/{vm_name}_{disk_id}'>
"""
# Disk device coordinator element
# Variables:
# * coordinator_name
# * coordinator_ceph_mon_port
devices_disk_coordinator = """ <host name='{coordinator_name}' port='{coordinator_ceph_mon_port}'/>
"""
# Disk device footer
devices_disk_footer = """ </source>
</disk>
"""
# vhostmd virtualization passthrough device
devices_vhostmd = """ <disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/dev/shm/vhostmd0'/>
<target dev='sdz' bus='usb'/>
<readonly/>
</disk>
"""
# Network interface device
# Variables:
# * eth_macaddr
# * eth_bridge
devices_net_interface = """ <interface type='bridge'>
<mac address='{eth_macaddr}'/>
<source bridge='{eth_bridge}'/>
<model type='virtio'/>
</interface>
"""