Convert pvc-client-cli into a proper Python module
Also fixes up the Debian packaging such that this works how I would want, with proper module installation while leaving everything else untouched. Finally implements automatic installation and removal of the BASH completion for the PVC command.
This commit is contained in:
parent
f0db631947
commit
f248d579df
|
@ -1,4 +1,8 @@
|
|||
*.pyc
|
||||
*.tmp
|
||||
*.swp
|
||||
venv/
|
||||
# Ignore build artifacts
|
||||
debian/pvc-*/
|
||||
debian/*.log
|
||||
debian/*.substvars
|
||||
debian/files
|
||||
|
|
|
@ -7,7 +7,7 @@ if [[ -z ${new_version} ]]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
current_version="$( grep '^version = ' node-daemon/pvcnoded/Daemon.py | awk -F "'" '{ print $2 }' )"
|
||||
current_version="$( cat .version )"
|
||||
echo "${current_version} -> ${new_version}"
|
||||
|
||||
changelog_file=$( mktemp )
|
||||
|
@ -18,6 +18,8 @@ changelog="$( cat ${changelog_file} | grep -v '^#' | sed 's/^*/ */' )"
|
|||
|
||||
sed -i "s,version = '${current_version}',version = '${new_version}'," node-daemon/pvcnoded/Daemon.py
|
||||
sed -i "s,version = '${current_version}',version = '${new_version}'," api-daemon/pvcapid/Daemon.py
|
||||
sed -i "s,version='${current_version}',version='${new_version}'," client-cli/setup.py
|
||||
echo ${new_version} > .version
|
||||
|
||||
readme_tmpdir=$( mktemp -d )
|
||||
cp README.md ${readme_tmpdir}/
|
||||
|
|
|
@ -24,8 +24,8 @@ import math
|
|||
|
||||
from requests_toolbelt.multipart.encoder import MultipartEncoder, MultipartEncoderMonitor
|
||||
|
||||
import cli_lib.ansiprint as ansiprint
|
||||
from cli_lib.common import UploadProgressBar, call_api
|
||||
import pvc.cli_lib.ansiprint as ansiprint
|
||||
from pvc.cli_lib.common import UploadProgressBar, call_api
|
||||
|
||||
#
|
||||
# Supplemental functions
|
|
@ -21,8 +21,8 @@
|
|||
|
||||
import json
|
||||
|
||||
import cli_lib.ansiprint as ansiprint
|
||||
from cli_lib.common import call_api
|
||||
import pvc.cli_lib.ansiprint as ansiprint
|
||||
from pvc.cli_lib.common import call_api
|
||||
|
||||
|
||||
def initialize(config, overwrite=False):
|
|
@ -20,8 +20,8 @@
|
|||
###############################################################################
|
||||
|
||||
import re
|
||||
import cli_lib.ansiprint as ansiprint
|
||||
from cli_lib.common import call_api
|
||||
import pvc.cli_lib.ansiprint as ansiprint
|
||||
from pvc.cli_lib.common import call_api
|
||||
|
||||
|
||||
def isValidMAC(macaddr):
|
|
@ -19,8 +19,8 @@
|
|||
#
|
||||
###############################################################################
|
||||
|
||||
import cli_lib.ansiprint as ansiprint
|
||||
from cli_lib.common import call_api
|
||||
import pvc.cli_lib.ansiprint as ansiprint
|
||||
from pvc.cli_lib.common import call_api
|
||||
|
||||
|
||||
#
|
|
@ -21,8 +21,8 @@
|
|||
|
||||
from requests_toolbelt.multipart.encoder import MultipartEncoder, MultipartEncoderMonitor
|
||||
|
||||
import cli_lib.ansiprint as ansiprint
|
||||
from cli_lib.common import UploadProgressBar, call_api
|
||||
import pvc.cli_lib.ansiprint as ansiprint
|
||||
from pvc.cli_lib.common import UploadProgressBar, call_api
|
||||
|
||||
|
||||
#
|
|
@ -22,8 +22,8 @@
|
|||
import time
|
||||
import re
|
||||
|
||||
import cli_lib.ansiprint as ansiprint
|
||||
from cli_lib.common import call_api, format_bytes, format_metric
|
||||
import pvc.cli_lib.ansiprint as ansiprint
|
||||
from pvc.cli_lib.common import call_api, format_bytes, format_metric
|
||||
|
||||
|
||||
#
|
||||
|
@ -512,7 +512,7 @@ def vm_networks_add(config, vm, network, macaddr, model, sriov, sriov_mode, rest
|
|||
from lxml.objectify import fromstring
|
||||
from lxml.etree import tostring
|
||||
from random import randint
|
||||
import cli_lib.network as pvc_network
|
||||
import pvc.cli_lib.network as pvc_network
|
||||
|
||||
# Verify that the provided network is valid (not in SR-IOV mode)
|
||||
if not sriov:
|
||||
|
@ -800,7 +800,7 @@ def vm_volumes_add(config, vm, volume, disk_id, bus, disk_type, restart):
|
|||
from lxml.objectify import fromstring
|
||||
from lxml.etree import tostring
|
||||
from copy import deepcopy
|
||||
import cli_lib.ceph as pvc_ceph
|
||||
import pvc.cli_lib.ceph as pvc_ceph
|
||||
|
||||
if disk_type == 'rbd':
|
||||
# Verify that the provided volume is valid
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# pvc.py - PVC client command-line interface
|
||||
# Part of the Parallel Virtual Cluster (PVC) system
|
||||
#
|
||||
|
@ -34,13 +32,13 @@ from distutils.util import strtobool
|
|||
|
||||
from functools import wraps
|
||||
|
||||
import cli_lib.ansiprint as ansiprint
|
||||
import cli_lib.cluster as pvc_cluster
|
||||
import cli_lib.node as pvc_node
|
||||
import cli_lib.vm as pvc_vm
|
||||
import cli_lib.network as pvc_network
|
||||
import cli_lib.ceph as pvc_ceph
|
||||
import cli_lib.provisioner as pvc_provisioner
|
||||
import pvc.cli_lib.ansiprint as ansiprint
|
||||
import pvc.cli_lib.cluster as pvc_cluster
|
||||
import pvc.cli_lib.node as pvc_node
|
||||
import pvc.cli_lib.vm as pvc_vm
|
||||
import pvc.cli_lib.network as pvc_network
|
||||
import pvc.cli_lib.ceph as pvc_ceph
|
||||
import pvc.cli_lib.provisioner as pvc_provisioner
|
||||
|
||||
myhostname = socket.gethostname().split('.')[0]
|
||||
zk_host = ''
|
|
@ -0,0 +1,20 @@
|
|||
from setuptools import setup
|
||||
|
||||
setup(
|
||||
name='pvc',
|
||||
version='0.9.20',
|
||||
packages=['pvc', 'pvc.cli_lib'],
|
||||
install_requires=[
|
||||
'Click',
|
||||
'PyYAML',
|
||||
'lxml',
|
||||
'colorama',
|
||||
'requests',
|
||||
'requests-toolbelt'
|
||||
],
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
'pvc = pvc.pvc:cli',
|
||||
],
|
||||
},
|
||||
)
|
|
@ -1,3 +0,0 @@
|
|||
client-cli/pvc.py usr/share/pvc
|
||||
client-cli/cli_lib usr/share/pvc
|
||||
client-cli/scripts usr/share/pvc
|
|
@ -1,4 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Install client binary to /usr/bin via symlink
|
||||
ln -s /usr/share/pvc/pvc.py /usr/bin/pvc
|
||||
# Generate the bash completion configuration
|
||||
if [ -d /etc/bash_completion.d ]; then
|
||||
_PVC_COMPLETE=source_bash pvc > /etc/bash_completion.d/pvc
|
||||
fi
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Remove client binary symlink
|
||||
rm -f /usr/bin/pvc
|
||||
# Remove the bash completion
|
||||
if [ -f /etc/bash_completion.d/pvc ]; then
|
||||
rm -f /etc/bash_completion.d/pvc
|
||||
fi
|
||||
|
|
|
@ -1,13 +1,19 @@
|
|||
#!/usr/bin/make -f
|
||||
# See debhelper(7) (uncomment to enable)
|
||||
# output every command that modifies files on the build system.
|
||||
#export DH_VERBOSE = 1
|
||||
export DH_VERBOSE = 1
|
||||
|
||||
%:
|
||||
dh $@
|
||||
dh $@ --with python3
|
||||
|
||||
override_dh_python3:
|
||||
cd $(CURDIR)/client-cli; pybuild --system=distutils --dest-dir=../debian/pvc-client-cli/
|
||||
mkdir -p debian/pvc-client-cli/usr/lib/python3
|
||||
mv debian/pvc-client-cli/usr/lib/python3*/* debian/pvc-client-cli/usr/lib/python3/
|
||||
rm -r $(CURDIR)/client-cli/.pybuild $(CURDIR)/client-cli/pvc.egg-info
|
||||
|
||||
override_dh_auto_clean:
|
||||
find . -name "__pycache__" -exec rm -r {} \; || true
|
||||
find . -name "__pycache__" -o -name ".pybuild" -exec rm -r {} \; || true
|
||||
|
||||
# If you need to rebuild the Sphinx documentation
|
||||
# Add spinxdoc to the dh --with line
|
||||
|
|
Loading…
Reference in New Issue