Refactor pvcnoded to reduce Daemon.py size
This branch commit refactors the pvcnoded component to better adhere to good programming practices. The previous Daemon.py was a massive file which contained almost 2000 lines of direct, root-level code which was directly imported. Not only was this poor practice, but this resulted in a nigh-unmaintainable file which was hard even for me to understand. This refactoring splits a large section of the code from Daemon.py into separate small modules and functions in the `util/` directory. This will hopefully make most of the functionality easy to find and modify without having to dig through a single large file. Further the existing subcomponents have been moved to the `objects/` directory which clearly separates them. Finally, the Daemon.py code has mostly been moved into a function, `entrypoint()`, which is then called from the `pvcnoded.py` stub. An additional item is that most format strings have been replaced by f-strings to make use of the Python 3.6 features in Daemon.py and the utility files.
This commit is contained in:
@ -26,44 +26,44 @@ rm ${backup_tmp} || true
|
||||
|
||||
# Provisioner tests
|
||||
_pvc provisioner profile list test
|
||||
_pvc provisioner create --wait testX test
|
||||
_pvc provisioner create --wait testx test
|
||||
sleep 30
|
||||
|
||||
# VM tests
|
||||
vm_tmp=$(mktemp)
|
||||
_pvc vm dump testX --file ${vm_tmp}
|
||||
_pvc vm shutdown --yes --wait testX
|
||||
_pvc vm start testX
|
||||
_pvc vm dump testx --file ${vm_tmp}
|
||||
_pvc vm shutdown --yes --wait testx
|
||||
_pvc vm start testx
|
||||
sleep 30
|
||||
_pvc vm stop --yes testX
|
||||
_pvc vm disable testX
|
||||
_pvc vm undefine --yes testX
|
||||
_pvc vm stop --yes testx
|
||||
_pvc vm disable testx
|
||||
_pvc vm undefine --yes testx
|
||||
_pvc vm define --target hv3 --tag pvc-test ${vm_tmp}
|
||||
_pvc vm start testX
|
||||
_pvc vm start testx
|
||||
sleep 30
|
||||
_pvc vm restart --yes --wait testX
|
||||
_pvc vm restart --yes --wait testx
|
||||
sleep 30
|
||||
_pvc vm migrate --wait testX
|
||||
_pvc vm migrate --wait testx
|
||||
sleep 5
|
||||
_pvc vm unmigrate --wait testX
|
||||
_pvc vm unmigrate --wait testx
|
||||
sleep 5
|
||||
_pvc vm move --wait --target hv1 testX
|
||||
_pvc vm move --wait --target hv1 testx
|
||||
sleep 5
|
||||
_pvc vm meta testX --limit hv1 --selector vms --method live --profile test --no-autostart
|
||||
_pvc vm tag add testX mytag
|
||||
_pvc vm tag get testX
|
||||
_pvc vm meta testx --limit hv1 --selector vms --method live --profile test --no-autostart
|
||||
_pvc vm tag add testx mytag
|
||||
_pvc vm tag get testx
|
||||
_pvc vm list --tag mytag
|
||||
_pvc vm tag remove testX mytag
|
||||
_pvc vm network get testX
|
||||
_pvc vm vcpu set testX 4
|
||||
_pvc vm vcpu get testX
|
||||
_pvc vm memory set testX 4096
|
||||
_pvc vm memory get testX
|
||||
_pvc vm vcpu set testX 2
|
||||
_pvc vm memory set testX 2048 --restart --yes
|
||||
_pvc vm tag remove testx mytag
|
||||
_pvc vm network get testx
|
||||
_pvc vm vcpu set testx 4
|
||||
_pvc vm vcpu get testx
|
||||
_pvc vm memory set testx 4096
|
||||
_pvc vm memory get testx
|
||||
_pvc vm vcpu set testx 2
|
||||
_pvc vm memory set testx 2048 --restart --yes
|
||||
sleep 5
|
||||
_pvc vm list testX
|
||||
_pvc vm info --long testX
|
||||
_pvc vm list testx
|
||||
_pvc vm info --long testx
|
||||
rm ${vm_tmp} || true
|
||||
|
||||
# Node tests
|
||||
@ -81,9 +81,9 @@ _pvc node info hv1
|
||||
# Network tests
|
||||
_pvc network add 10001 --description testing --type managed --domain testing.local --ipnet 10.100.100.0/24 --gateway 10.100.100.1 --dhcp --dhcp-start 10.100.100.100 --dhcp-end 10.100.100.199
|
||||
sleep 5
|
||||
_pvc vm network add --restart --yes testX 10001
|
||||
_pvc vm network add --restart --yes testx 10001
|
||||
sleep 30
|
||||
_pvc vm network remove --restart --yes testX 10001
|
||||
_pvc vm network remove --restart --yes testx 10001
|
||||
sleep 5
|
||||
|
||||
_pvc network acl add 10001 --in --description test-acl --order 0 --rule "'ip daddr 10.0.0.0/8 counter'"
|
||||
@ -98,10 +98,10 @@ _pvc network list
|
||||
_pvc network info --long 10001
|
||||
|
||||
# Network-VM interaction tests
|
||||
_pvc vm network add testX 10001 --model virtio --restart --yes
|
||||
_pvc vm network add testx 10001 --model virtio --restart --yes
|
||||
sleep 30
|
||||
_pvc vm network get testX
|
||||
_pvc vm network remove testX 10001 --restart --yes
|
||||
_pvc vm network get testx
|
||||
_pvc vm network remove testx 10001 --restart --yes
|
||||
sleep 5
|
||||
|
||||
_pvc network remove --yes 10001
|
||||
@ -117,9 +117,9 @@ _pvc storage osd list
|
||||
_pvc storage pool add testing 64 --replcfg "copies=3,mincopies=2"
|
||||
sleep 5
|
||||
_pvc storage pool list
|
||||
_pvc storage volume add testing testX 1G
|
||||
_pvc storage volume resize testing testX 2G
|
||||
_pvc storage volume rename testing testX testerX
|
||||
_pvc storage volume add testing testx 1G
|
||||
_pvc storage volume resize testing testx 2G
|
||||
_pvc storage volume rename testing testx testerX
|
||||
_pvc storage volume clone testing testerX testerY
|
||||
_pvc storage volume list --pool testing
|
||||
_pvc storage volume snapshot add testing testerX asnapshotX
|
||||
@ -128,10 +128,10 @@ _pvc storage volume snapshot list
|
||||
_pvc storage volume snapshot remove --yes testing testerX asnapshotY
|
||||
|
||||
# Storage-VM interaction tests
|
||||
_pvc vm volume add testX --type rbd --disk-id sdh --bus scsi testing/testerY --restart --yes
|
||||
_pvc vm volume add testx --type rbd --disk-id sdh --bus scsi testing/testerY --restart --yes
|
||||
sleep 30
|
||||
_pvc vm volume get testX
|
||||
_pvc vm volume remove testX testing/testerY --restart --yes
|
||||
_pvc vm volume get testx
|
||||
_pvc vm volume remove testx testing/testerY --restart --yes
|
||||
sleep 5
|
||||
|
||||
_pvc storage volume remove --yes testing testerY
|
||||
@ -139,8 +139,8 @@ _pvc storage volume remove --yes testing testerX
|
||||
_pvc storage pool remove --yes testing
|
||||
|
||||
# Remove the VM
|
||||
_pvc vm stop --yes testX
|
||||
_pvc vm remove --yes testX
|
||||
_pvc vm stop --yes testx
|
||||
_pvc vm remove --yes testx
|
||||
|
||||
time_end=$(date +%s)
|
||||
|
||||
|
Reference in New Issue
Block a user