Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
705ec802a3 | |||
47d7b23763 | |||
0bae729a18 | |||
b968110e9f | |||
4898ae5082 | |||
249e1568a1 |
@ -1,5 +1,9 @@
|
|||||||
## PVC Changelog
|
## PVC Changelog
|
||||||
|
|
||||||
|
###### [v0.9.67](https://github.com/parallelvirtualcluster/pvc/releases/tag/v0.9.67)
|
||||||
|
|
||||||
|
* [CLI] Fixes several more bugs in the refactored CLI
|
||||||
|
|
||||||
###### [v0.9.66](https://github.com/parallelvirtualcluster/pvc/releases/tag/v0.9.66)
|
###### [v0.9.66](https://github.com/parallelvirtualcluster/pvc/releases/tag/v0.9.66)
|
||||||
|
|
||||||
* [CLI] Fixes a missing YAML import in CLI
|
* [CLI] Fixes a missing YAML import in CLI
|
||||||
|
@ -27,7 +27,7 @@ from ssl import SSLContext, TLSVersion
|
|||||||
from distutils.util import strtobool as dustrtobool
|
from distutils.util import strtobool as dustrtobool
|
||||||
|
|
||||||
# Daemon version
|
# Daemon version
|
||||||
version = "0.9.66"
|
version = "0.9.67"
|
||||||
|
|
||||||
# API version
|
# API version
|
||||||
API_VERSION = 1.0
|
API_VERSION = 1.0
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
from colorama import Fore
|
||||||
|
from difflib import unified_diff
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from json import dump as jdump
|
from json import dump as jdump
|
||||||
from json import dumps as jdumps
|
from json import dumps as jdumps
|
||||||
@ -26,7 +28,7 @@ from json import loads as jloads
|
|||||||
from os import environ, makedirs, path
|
from os import environ, makedirs, path
|
||||||
from pkg_resources import get_distribution
|
from pkg_resources import get_distribution
|
||||||
from lxml.etree import fromstring, tostring
|
from lxml.etree import fromstring, tostring
|
||||||
from re import sub
|
from re import sub, match
|
||||||
from yaml import load as yload
|
from yaml import load as yload
|
||||||
from yaml import SafeLoader as SafeYAMLLoader
|
from yaml import SafeLoader as SafeYAMLLoader
|
||||||
|
|
||||||
@ -1196,7 +1198,7 @@ def cli_vm_modify(
|
|||||||
text=current_vm_cfgfile, require_save=True, extension=".xml"
|
text=current_vm_cfgfile, require_save=True, extension=".xml"
|
||||||
)
|
)
|
||||||
if new_vm_cfgfile is None:
|
if new_vm_cfgfile is None:
|
||||||
echo("Aborting with no modifications.")
|
echo(CLI_CONFIG, "Aborting with no modifications.")
|
||||||
exit(0)
|
exit(0)
|
||||||
else:
|
else:
|
||||||
new_vm_cfgfile = new_vm_cfgfile.strip()
|
new_vm_cfgfile = new_vm_cfgfile.strip()
|
||||||
@ -1208,16 +1210,14 @@ def cli_vm_modify(
|
|||||||
cfgfile.close()
|
cfgfile.close()
|
||||||
|
|
||||||
echo(
|
echo(
|
||||||
|
CLI_CONFIG,
|
||||||
'Replacing configuration of VM "{}" with file "{}".'.format(
|
'Replacing configuration of VM "{}" with file "{}".'.format(
|
||||||
dom_name, cfgfile.name
|
dom_name, cfgfile.name
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Show a diff and confirm
|
|
||||||
echo("Pending modifications:")
|
|
||||||
echo("")
|
|
||||||
diff = list(
|
diff = list(
|
||||||
difflib.unified_diff(
|
unified_diff(
|
||||||
current_vm_cfgfile.split("\n"),
|
current_vm_cfgfile.split("\n"),
|
||||||
new_vm_cfgfile.split("\n"),
|
new_vm_cfgfile.split("\n"),
|
||||||
fromfile="current",
|
fromfile="current",
|
||||||
@ -1228,16 +1228,23 @@ def cli_vm_modify(
|
|||||||
lineterm="",
|
lineterm="",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
if len(diff) < 1:
|
||||||
|
echo(CLI_CONFIG, "Aborting with no modifications.")
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
# Show a diff and confirm
|
||||||
|
echo(CLI_CONFIG, "Pending modifications:")
|
||||||
|
echo(CLI_CONFIG, "")
|
||||||
for line in diff:
|
for line in diff:
|
||||||
if re.match(r"^\+", line) is not None:
|
if match(r"^\+", line) is not None:
|
||||||
echo(colorama.Fore.GREEN + line + colorama.Fore.RESET)
|
echo(CLI_CONFIG, Fore.GREEN + line + Fore.RESET)
|
||||||
elif re.match(r"^\-", line) is not None:
|
elif match(r"^\-", line) is not None:
|
||||||
echo(colorama.Fore.RED + line + colorama.Fore.RESET)
|
echo(CLI_CONFIG, Fore.RED + line + Fore.RESET)
|
||||||
elif re.match(r"^\^", line) is not None:
|
elif match(r"^\^", line) is not None:
|
||||||
echo(colorama.Fore.BLUE + line + colorama.Fore.RESET)
|
echo(CLI_CONFIG, Fore.BLUE + line + Fore.RESET)
|
||||||
else:
|
else:
|
||||||
echo(line)
|
echo(CLI_CONFIG, line)
|
||||||
echo("")
|
echo(CLI_CONFIG, "")
|
||||||
|
|
||||||
# Verify our XML is sensible
|
# Verify our XML is sensible
|
||||||
try:
|
try:
|
||||||
@ -3594,7 +3601,7 @@ def cli_storage_volume_upload(pool, name, image_format, image_file):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if not os.path.exists(image_file):
|
if not os.path.exists(image_file):
|
||||||
echo("ERROR: File '{}' does not exist!".format(image_file))
|
echo(CLI_CONFIG, "ERROR: File '{}' does not exist!".format(image_file))
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
retcode, retmsg = pvc.lib.storage.ceph_volume_upload(
|
retcode, retmsg = pvc.lib.storage.ceph_volume_upload(
|
||||||
@ -4432,7 +4439,8 @@ def cli_provisioner_template_storage_disk_add(
|
|||||||
|
|
||||||
if source_volume and (size or filesystem or mountpoint):
|
if source_volume and (size or filesystem or mountpoint):
|
||||||
echo(
|
echo(
|
||||||
'The "--source-volume" option is not compatible with the "--size", "--filesystem", or "--mountpoint" options.'
|
CLI_CONFIG,
|
||||||
|
'The "--source-volume" option is not compatible with the "--size", "--filesystem", or "--mountpoint" options.',
|
||||||
)
|
)
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
@ -4514,7 +4522,7 @@ def cli_provisioner_userdata_add(name, filename):
|
|||||||
try:
|
try:
|
||||||
yload(userdata, Loader=SafeYAMLLoader)
|
yload(userdata, Loader=SafeYAMLLoader)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
echo("Error: Userdata document is malformed")
|
echo(CLI_CONFIG, "Error: Userdata document is malformed")
|
||||||
cleanup(False, e)
|
cleanup(False, e)
|
||||||
|
|
||||||
params = dict()
|
params = dict()
|
||||||
@ -4551,7 +4559,7 @@ def cli_provisioner_userdata_modify(name, filename, editor):
|
|||||||
# Grab the current config
|
# Grab the current config
|
||||||
retcode, retdata = pvc.lib.provisioner.userdata_info(CLI_CONFIG, name)
|
retcode, retdata = pvc.lib.provisioner.userdata_info(CLI_CONFIG, name)
|
||||||
if not retcode:
|
if not retcode:
|
||||||
echo(retdata)
|
echo(CLI_CONFIG, retdata)
|
||||||
exit(1)
|
exit(1)
|
||||||
current_userdata = retdata["userdata"].strip()
|
current_userdata = retdata["userdata"].strip()
|
||||||
|
|
||||||
@ -4559,16 +4567,14 @@ def cli_provisioner_userdata_modify(name, filename, editor):
|
|||||||
text=current_userdata, require_save=True, extension=".yaml"
|
text=current_userdata, require_save=True, extension=".yaml"
|
||||||
)
|
)
|
||||||
if new_userdata is None:
|
if new_userdata is None:
|
||||||
echo("Aborting with no modifications.")
|
echo(CLI_CONFIG, "Aborting with no modifications.")
|
||||||
exit(0)
|
exit(0)
|
||||||
else:
|
else:
|
||||||
new_userdata = new_userdata.strip()
|
new_userdata = new_userdata.strip()
|
||||||
|
|
||||||
# Show a diff and confirm
|
# Show a diff and confirm
|
||||||
echo("Pending modifications:")
|
|
||||||
echo("")
|
|
||||||
diff = list(
|
diff = list(
|
||||||
difflib.unified_diff(
|
unified_diff(
|
||||||
current_userdata.split("\n"),
|
current_userdata.split("\n"),
|
||||||
new_userdata.split("\n"),
|
new_userdata.split("\n"),
|
||||||
fromfile="current",
|
fromfile="current",
|
||||||
@ -4579,16 +4585,22 @@ def cli_provisioner_userdata_modify(name, filename, editor):
|
|||||||
lineterm="",
|
lineterm="",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
if len(diff) < 1:
|
||||||
|
echo(CLI_CONFIG, "Aborting with no modifications.")
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
echo(CLI_CONFIG, "Pending modifications:")
|
||||||
|
echo(CLI_CONFIG, "")
|
||||||
for line in diff:
|
for line in diff:
|
||||||
if re.match(r"^\+", line) is not None:
|
if match(r"^\+", line) is not None:
|
||||||
echo(colorama.Fore.GREEN + line + colorama.Fore.RESET)
|
echo(CLI_CONFIG, Fore.GREEN + line + Fore.RESET)
|
||||||
elif re.match(r"^\-", line) is not None:
|
elif match(r"^\-", line) is not None:
|
||||||
echo(colorama.Fore.RED + line + colorama.Fore.RESET)
|
echo(CLI_CONFIG, Fore.RED + line + Fore.RESET)
|
||||||
elif re.match(r"^\^", line) is not None:
|
elif match(r"^\^", line) is not None:
|
||||||
echo(colorama.Fore.BLUE + line + colorama.Fore.RESET)
|
echo(CLI_CONFIG, Fore.BLUE + line + Fore.RESET)
|
||||||
else:
|
else:
|
||||||
echo(line)
|
echo(CLI_CONFIG, line)
|
||||||
echo("")
|
echo(CLI_CONFIG, "")
|
||||||
|
|
||||||
click.confirm("Write modifications to cluster?", abort=True)
|
click.confirm("Write modifications to cluster?", abort=True)
|
||||||
|
|
||||||
@ -4603,7 +4615,7 @@ def cli_provisioner_userdata_modify(name, filename, editor):
|
|||||||
try:
|
try:
|
||||||
yload(userdata, Loader=SafeYAMLLoader)
|
yload(userdata, Loader=SafeYAMLLoader)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
echo("Error: Userdata document is malformed")
|
echo(CLI_CONFIG, "Error: Userdata document is malformed")
|
||||||
cleanup(False, e)
|
cleanup(False, e)
|
||||||
|
|
||||||
params = dict()
|
params = dict()
|
||||||
@ -4741,22 +4753,20 @@ def cli_provisioner_script_modify(name, filename, editor):
|
|||||||
# Grab the current config
|
# Grab the current config
|
||||||
retcode, retdata = pvc.lib.provisioner.script_info(CLI_CONFIG, name)
|
retcode, retdata = pvc.lib.provisioner.script_info(CLI_CONFIG, name)
|
||||||
if not retcode:
|
if not retcode:
|
||||||
echo(retdata)
|
echo(CLI_CONFIG, retdata)
|
||||||
exit(1)
|
exit(1)
|
||||||
current_script = retdata["script"].strip()
|
current_script = retdata["script"].strip()
|
||||||
|
|
||||||
new_script = click.edit(text=current_script, require_save=True, extension=".py")
|
new_script = click.edit(text=current_script, require_save=True, extension=".py")
|
||||||
if new_script is None:
|
if new_script is None:
|
||||||
echo("Aborting with no modifications.")
|
echo(CLI_CONFIG, "Aborting with no modifications.")
|
||||||
exit(0)
|
exit(0)
|
||||||
else:
|
else:
|
||||||
new_script = new_script.strip()
|
new_script = new_script.strip()
|
||||||
|
|
||||||
# Show a diff and confirm
|
# Show a diff and confirm
|
||||||
echo("Pending modifications:")
|
|
||||||
echo("")
|
|
||||||
diff = list(
|
diff = list(
|
||||||
difflib.unified_diff(
|
unified_diff(
|
||||||
current_script.split("\n"),
|
current_script.split("\n"),
|
||||||
new_script.split("\n"),
|
new_script.split("\n"),
|
||||||
fromfile="current",
|
fromfile="current",
|
||||||
@ -4767,16 +4777,22 @@ def cli_provisioner_script_modify(name, filename, editor):
|
|||||||
lineterm="",
|
lineterm="",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
if len(diff) < 1:
|
||||||
|
echo(CLI_CONFIG, "Aborting with no modifications.")
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
echo(CLI_CONFIG, "Pending modifications:")
|
||||||
|
echo(CLI_CONFIG, "")
|
||||||
for line in diff:
|
for line in diff:
|
||||||
if re.match(r"^\+", line) is not None:
|
if match(r"^\+", line) is not None:
|
||||||
echo(colorama.Fore.GREEN + line + colorama.Fore.RESET)
|
echo(CLI_CONFIG, Fore.GREEN + line + Fore.RESET)
|
||||||
elif re.match(r"^\-", line) is not None:
|
elif match(r"^\-", line) is not None:
|
||||||
echo(colorama.Fore.RED + line + colorama.Fore.RESET)
|
echo(CLI_CONFIG, Fore.RED + line + Fore.RESET)
|
||||||
elif re.match(r"^\^", line) is not None:
|
elif match(r"^\^", line) is not None:
|
||||||
echo(colorama.Fore.BLUE + line + colorama.Fore.RESET)
|
echo(CLI_CONFIG, Fore.BLUE + line + Fore.RESET)
|
||||||
else:
|
else:
|
||||||
echo(line)
|
echo(CLI_CONFIG, line)
|
||||||
echo("")
|
echo(CLI_CONFIG, "")
|
||||||
|
|
||||||
click.confirm("Write modifications to cluster?", abort=True)
|
click.confirm("Write modifications to cluster?", abort=True)
|
||||||
|
|
||||||
@ -4897,7 +4913,7 @@ def cli_provisioner_ova_upload(name, filename, pool):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if not os.path.exists(filename):
|
if not os.path.exists(filename):
|
||||||
echo("ERROR: File '{}' does not exist!".format(filename))
|
echo(CLI_CONFIG, "ERROR: File '{}' does not exist!".format(filename))
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
params = dict()
|
params = dict()
|
||||||
|
@ -2,7 +2,7 @@ from setuptools import setup
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="pvc",
|
name="pvc",
|
||||||
version="0.9.66",
|
version="0.9.67",
|
||||||
packages=["pvc.cli", "pvc.lib"],
|
packages=["pvc.cli", "pvc.lib"],
|
||||||
install_requires=[
|
install_requires=[
|
||||||
"Click",
|
"Click",
|
||||||
|
6
debian/changelog
vendored
6
debian/changelog
vendored
@ -1,3 +1,9 @@
|
|||||||
|
pvc (0.9.67-0) unstable; urgency=high
|
||||||
|
|
||||||
|
* [CLI] Fixes several more bugs in the refactored CLI
|
||||||
|
|
||||||
|
-- Joshua M. Boniface <joshua@boniface.me> Sun, 27 Aug 2023 14:47:20 -0400
|
||||||
|
|
||||||
pvc (0.9.66-0) unstable; urgency=high
|
pvc (0.9.66-0) unstable; urgency=high
|
||||||
|
|
||||||
* [CLI] Fixes a missing YAML import in CLI
|
* [CLI] Fixes a missing YAML import in CLI
|
||||||
|
@ -49,7 +49,7 @@ import re
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
# Daemon version
|
# Daemon version
|
||||||
version = "0.9.66"
|
version = "0.9.67"
|
||||||
|
|
||||||
|
|
||||||
##########################################################
|
##########################################################
|
||||||
|
Reference in New Issue
Block a user