Lint: E302 expected 2 blank lines, found X

This commit is contained in:
2020-11-07 14:45:24 -05:00
parent e9643651f7
commit 260b39ebf2
36 changed files with 694 additions and 19 deletions

View File

@ -22,24 +22,40 @@
import datetime
# ANSII colours for output
def red():
return '\033[91m'
def blue():
return '\033[94m'
def cyan():
return '\033[96m'
def green():
return '\033[92m'
def yellow():
return '\033[93m'
def purple():
return '\033[95m'
def bold():
return '\033[1m'
def end():
return '\033[0m'
# Print function
def echo(message, prefix, state):
# Get the date

View File

@ -32,7 +32,7 @@ from cli_lib.common import UploadProgressBar, call_api
# Supplemental functions
#
# Format byte sizes to/from human-readable units
# Matrix of human-to-byte values
byte_unit_matrix = {
'B': 1,
'K': 1024,
@ -41,6 +41,19 @@ byte_unit_matrix = {
'T': 1024*1024*1024*1024,
'P': 1024*1024*1024*1024*1024
}
# Matrix of human-to-metric values
ops_unit_matrix = {
'': 1,
'K': 1000,
'M': 1000*1000,
'G': 1000*1000*1000,
'T': 1000*1000*1000*1000,
'P': 1000*1000*1000*1000*1000
}
# Format byte sizes to/from human-readable units
def format_bytes_tohuman(databytes):
datahuman = ''
for unit in sorted(byte_unit_matrix, key=byte_unit_matrix.get, reverse=True):
@ -55,6 +68,7 @@ def format_bytes_tohuman(databytes):
return datahuman
def format_bytes_fromhuman(datahuman):
# Trim off human-readable character
dataunit = datahuman[-1]
@ -64,14 +78,6 @@ def format_bytes_fromhuman(datahuman):
# Format ops sizes to/from human-readable units
ops_unit_matrix = {
'': 1,
'K': 1000,
'M': 1000*1000,
'G': 1000*1000*1000,
'T': 1000*1000*1000*1000,
'P': 1000*1000*1000*1000*1000
}
def format_ops_tohuman(dataops):
datahuman = ''
for unit in sorted(ops_unit_matrix, key=ops_unit_matrix.get, reverse=True):
@ -86,6 +92,7 @@ def format_ops_tohuman(dataops):
return datahuman
def format_ops_fromhuman(datahuman):
# Trim off human-readable character
dataunit = datahuman[-1]
@ -93,10 +100,12 @@ def format_ops_fromhuman(datahuman):
dataops = datasize * ops_unit_matrix[dataunit]
return '{}'.format(dataops)
def format_pct_tohuman(datapct):
datahuman = "{0:.1f}".format(float(datapct * 100.0))
return datahuman
#
# Status functions
#
@ -115,6 +124,7 @@ def ceph_status(config):
else:
return False, response.json().get('message', '')
def ceph_util(config):
"""
Get utilization of the Ceph cluster
@ -130,6 +140,7 @@ def ceph_util(config):
else:
return False, response.json().get('message', '')
def format_raw_output(status_data):
ainformation = list()
ainformation.append('{bold}Ceph cluster {stype} (primary node {end}{blue}{primary}{end}{bold}){end}\n'.format(bold=ansiprint.bold(), end=ansiprint.end(), blue=ansiprint.blue(), stype=status_data['type'], primary=status_data['primary_node']))
@ -138,6 +149,7 @@ def format_raw_output(status_data):
return '\n'.join(ainformation)
#
# OSD functions
#
@ -156,6 +168,7 @@ def ceph_osd_info(config, osd):
else:
return False, response.json().get('message', '')
def ceph_osd_list(config, limit):
"""
Get list information about Ceph OSDs (limited by {limit})
@ -175,6 +188,7 @@ def ceph_osd_list(config, limit):
else:
return False, response.json().get('message', '')
def ceph_osd_add(config, node, device, weight):
"""
Add new Ceph OSD
@ -197,6 +211,7 @@ def ceph_osd_add(config, node, device, weight):
return retstatus, response.json().get('message', '')
def ceph_osd_remove(config, osdid):
"""
Remove Ceph OSD
@ -217,6 +232,7 @@ def ceph_osd_remove(config, osdid):
return retstatus, response.json().get('message', '')
def ceph_osd_state(config, osdid, state):
"""
Set state of Ceph OSD
@ -237,6 +253,7 @@ def ceph_osd_state(config, osdid, state):
return retstatus, response.json().get('message', '')
def ceph_osd_option(config, option, action):
"""
Set cluster option of Ceph OSDs
@ -258,6 +275,7 @@ def ceph_osd_option(config, option, action):
return retstatus, response.json().get('message', '')
def getOutputColoursOSD(osd_information):
# Set the UP status
if osd_information['stats']['up'] == 1:
@ -277,6 +295,7 @@ def getOutputColoursOSD(osd_information):
return osd_up_flag, osd_up_colour, osd_in_flag, osd_in_colour
def format_list_osd(osd_list):
# Handle empty list
if not osd_list:
@ -542,6 +561,7 @@ def ceph_pool_info(config, pool):
else:
return False, response.json().get('message', '')
def ceph_pool_list(config, limit):
"""
Get list information about Ceph OSDs (limited by {limit})
@ -561,6 +581,7 @@ def ceph_pool_list(config, limit):
else:
return False, response.json().get('message', '')
def ceph_pool_add(config, pool, pgs, replcfg):
"""
Add new Ceph OSD
@ -583,6 +604,7 @@ def ceph_pool_add(config, pool, pgs, replcfg):
return retstatus, response.json().get('message', '')
def ceph_pool_remove(config, pool):
"""
Remove Ceph OSD
@ -603,6 +625,7 @@ def ceph_pool_remove(config, pool):
return retstatus, response.json().get('message', '')
def format_list_pool(pool_list):
# Handle empty list
if not pool_list:
@ -820,6 +843,7 @@ def ceph_volume_info(config, pool, volume):
else:
return False, response.json().get('message', '')
def ceph_volume_list(config, limit, pool):
"""
Get list information about Ceph volumes (limited by {limit} and by {pool})
@ -841,6 +865,7 @@ def ceph_volume_list(config, limit, pool):
else:
return False, response.json().get('message', '')
def ceph_volume_add(config, pool, volume, size):
"""
Add new Ceph volume
@ -863,6 +888,7 @@ def ceph_volume_add(config, pool, volume, size):
return retstatus, response.json().get('message', '')
def ceph_volume_upload(config, pool, volume, image_format, image_file):
"""
Upload a disk image to a Ceph volume
@ -898,6 +924,7 @@ def ceph_volume_upload(config, pool, volume, image_format, image_file):
return retstatus, response.json().get('message', '')
def ceph_volume_remove(config, pool, volume):
"""
Remove Ceph volume
@ -915,6 +942,7 @@ def ceph_volume_remove(config, pool, volume):
return retstatus, response.json().get('message', '')
def ceph_volume_modify(config, pool, volume, new_name=None, new_size=None):
"""
Modify Ceph volume
@ -939,6 +967,7 @@ def ceph_volume_modify(config, pool, volume, new_name=None, new_size=None):
return retstatus, response.json().get('message', '')
def ceph_volume_clone(config, pool, volume, new_volume):
"""
Clone Ceph volume
@ -959,6 +988,7 @@ def ceph_volume_clone(config, pool, volume, new_volume):
return retstatus, response.json().get('message', '')
def format_list_volume(volume_list):
# Handle empty list
if not volume_list:
@ -1092,6 +1122,7 @@ def ceph_snapshot_info(config, pool, volume, snapshot):
else:
return False, response.json().get('message', '')
def ceph_snapshot_list(config, limit, volume, pool):
"""
Get list information about Ceph snapshots (limited by {limit}, by {pool}, or by {volume})
@ -1115,6 +1146,7 @@ def ceph_snapshot_list(config, limit, volume, pool):
else:
return False, response.json().get('message', '')
def ceph_snapshot_add(config, pool, volume, snapshot):
"""
Add new Ceph snapshot
@ -1137,6 +1169,7 @@ def ceph_snapshot_add(config, pool, volume, snapshot):
return retstatus, response.json().get('message', '')
def ceph_snapshot_remove(config, pool, volume, snapshot):
"""
Remove Ceph snapshot
@ -1154,6 +1187,7 @@ def ceph_snapshot_remove(config, pool, volume, snapshot):
return retstatus, response.json().get('message', '')
def ceph_snapshot_modify(config, pool, volume, snapshot, new_name=None):
"""
Modify Ceph snapshot
@ -1176,6 +1210,7 @@ def ceph_snapshot_modify(config, pool, volume, snapshot, new_name=None):
return retstatus, response.json().get('message', '')
def format_list_snapshot(snapshot_list):
# Handle empty list
if not snapshot_list:
@ -1249,6 +1284,7 @@ def format_list_snapshot(snapshot_list):
return '\n'.join(sorted(snapshot_list_output))
#
# Benchmark functions
#
@ -1274,6 +1310,7 @@ def ceph_benchmark_run(config, pool):
return retvalue, retdata
def ceph_benchmark_list(config, job):
"""
View results of one or more previous benchmark runs
@ -1300,6 +1337,7 @@ def ceph_benchmark_list(config, job):
return retvalue, retdata
def format_list_benchmark(config, benchmark_information):
benchmark_list_output = []
@ -1420,6 +1458,7 @@ def format_list_benchmark(config, benchmark_information):
return '\n'.join(benchmark_list_output)
def format_info_benchmark(config, benchmark_information):
if benchmark_information[0]['benchmark_result'] == "Running":
return "Benchmark test is still running."

View File

@ -25,6 +25,7 @@ import json
import cli_lib.ansiprint as ansiprint
from cli_lib.common import call_api
def initialize(config):
"""
Initialize the PVC cluster
@ -42,6 +43,7 @@ def initialize(config):
return retstatus, response.json().get('message', '')
def maintenance_mode(config, state):
"""
Enable or disable PVC cluster maintenance mode
@ -62,6 +64,7 @@ def maintenance_mode(config, state):
return retstatus, response.json().get('message', '')
def get_info(config):
"""
Get status of the PVC cluster
@ -77,6 +80,7 @@ def get_info(config):
else:
return False, response.json().get('message', '')
def format_info(cluster_information, oformat):
if oformat == 'json':
return json.dumps(cluster_information)

View File

@ -27,6 +27,7 @@ import requests
import click
from urllib3 import disable_warnings
def format_bytes(size_bytes):
byte_unit_matrix = {
'B': 1,
@ -44,6 +45,7 @@ def format_bytes(size_bytes):
break
return human_bytes
def format_metric(integer):
integer_unit_matrix = {
'': 1,
@ -61,6 +63,7 @@ def format_metric(integer):
break
return human_integer
class UploadProgressBar(object):
def __init__(self, filename, end_message='', end_nl=True):
file_size = os.path.getsize(filename)
@ -103,6 +106,7 @@ class UploadProgressBar(object):
if self.end_message:
click.echo(self.end_message + self.end_suffix, nl=self.end_nl)
class ErrorResponse(requests.Response):
def __init__(self, json_data, status_code):
self.json_data = json_data
@ -111,6 +115,7 @@ class ErrorResponse(requests.Response):
def json(self):
return self.json_data
def call_api(config, operation, request_uri, headers={}, params=None, data=None, files=None):
# Craft the URI
uri = '{}://{}{}{}'.format(

View File

@ -24,6 +24,7 @@ import re
import cli_lib.ansiprint as ansiprint
from cli_lib.common import call_api
def isValidMAC(macaddr):
allowed = re.compile(r"""
(
@ -37,6 +38,7 @@ def isValidMAC(macaddr):
else:
return False
def isValidIP(ipaddr):
ip4_blocks = str(ipaddr).split(".")
if len(ip4_blocks) == 4:
@ -50,6 +52,7 @@ def isValidIP(ipaddr):
return True
return False
#
# Primary functions
#
@ -68,6 +71,7 @@ def net_info(config, net):
else:
return False, response.json().get('message', '')
def net_list(config, limit):
"""
Get list information about networks (limited by {limit})
@ -87,6 +91,7 @@ def net_list(config, limit):
else:
return False, response.json().get('message', '')
def net_add(config, vni, description, nettype, domain, name_servers, ip4_network, ip4_gateway, ip6_network, ip6_gateway, dhcp4_flag, dhcp4_start, dhcp4_end):
"""
Add new network
@ -118,6 +123,7 @@ def net_add(config, vni, description, nettype, domain, name_servers, ip4_network
return retstatus, response.json().get('message', '')
def net_modify(config, net, description, domain, name_servers, ip4_network, ip4_gateway, ip6_network, ip6_gateway, dhcp4_flag, dhcp4_start, dhcp4_end):
"""
Modify a network
@ -157,6 +163,7 @@ def net_modify(config, net, description, domain, name_servers, ip4_network, ip4_
return retstatus, response.json().get('message', '')
def net_remove(config, net):
"""
Remove a network
@ -174,6 +181,7 @@ def net_remove(config, net):
return retstatus, response.json().get('message', '')
#
# DHCP lease functions
#
@ -192,6 +200,7 @@ def net_dhcp_info(config, net, mac):
else:
return False, response.json().get('message', '')
def net_dhcp_list(config, net, limit, only_static=False):
"""
Get list information about leases (limited by {limit})
@ -216,6 +225,7 @@ def net_dhcp_list(config, net, limit, only_static=False):
else:
return False, response.json().get('message', '')
def net_dhcp_add(config, net, ipaddr, macaddr, hostname):
"""
Add new network DHCP lease
@ -238,6 +248,7 @@ def net_dhcp_add(config, net, ipaddr, macaddr, hostname):
return retstatus, response.json().get('message', '')
def net_dhcp_remove(config, net, mac):
"""
Remove a network DHCP lease
@ -255,6 +266,7 @@ def net_dhcp_remove(config, net, mac):
return retstatus, response.json().get('message', '')
#
# ACL functions
#
@ -273,6 +285,7 @@ def net_acl_info(config, net, description):
else:
return False, response.json().get('message', '')
def net_acl_list(config, net, limit, direction):
"""
Get list information about ACLs (limited by {limit})
@ -294,6 +307,7 @@ def net_acl_list(config, net, limit, direction):
else:
return False, response.json().get('message', '')
def net_acl_add(config, net, direction, description, rule, order):
"""
Add new network acl
@ -318,7 +332,9 @@ def net_acl_add(config, net, direction, description, rule, order):
return retstatus, response.json().get('message', '')
def net_acl_remove(config, net, description):
"""
Remove a network ACL
@ -360,6 +376,7 @@ def getOutputColours(network_information):
return v6_flag_colour, v4_flag_colour, dhcp6_flag_colour, dhcp4_flag_colour
def format_info(config, network_information, long_output):
if not network_information:
return "No network found"
@ -418,6 +435,7 @@ def format_info(config, network_information, long_output):
# Join it all together
return '\n'.join(ainformation)
def format_list(config, network_list):
if not network_list:
return "No network found"
@ -534,6 +552,7 @@ def format_list(config, network_list):
return '\n'.join(sorted(network_list_output))
def format_list_dhcp(dhcp_lease_list):
dhcp_lease_list_output = []
@ -598,6 +617,7 @@ def format_list_dhcp(dhcp_lease_list):
return '\n'.join(sorted(dhcp_lease_list_output))
def format_list_acl(acl_list):
# Handle when we get an empty entry
if not acl_list:

View File

@ -23,6 +23,7 @@
import cli_lib.ansiprint as ansiprint
from cli_lib.common import call_api
#
# Primary functions
#
@ -46,6 +47,7 @@ def node_coordinator_state(config, node, action):
return retstatus, response.json().get('message', '')
def node_domain_state(config, node, action, wait):
"""
Set node domain state state (flush/ready)
@ -67,6 +69,7 @@ def node_domain_state(config, node, action, wait):
return retstatus, response.json().get('message', '')
def node_info(config, node):
"""
Get information about node
@ -82,6 +85,7 @@ def node_info(config, node):
else:
return False, response.json().get('message', '')
def node_list(config, limit, target_daemon_state, target_coordinator_state, target_domain_state):
"""
Get list information about nodes (limited by {limit})
@ -107,6 +111,7 @@ def node_list(config, limit, target_daemon_state, target_coordinator_state, targ
else:
return False, response.json().get('message', '')
#
# Output display functions
#
@ -148,6 +153,7 @@ def getOutputColours(node_information):
return daemon_state_colour, coordinator_state_colour, domain_state_colour, mem_allocated_colour, mem_provisioned_colour
def format_info(node_information, long_output):
daemon_state_colour, coordinator_state_colour, domain_state_colour, mem_allocated_colour, mem_provisioned_colour = getOutputColours(node_information)
@ -178,6 +184,7 @@ def format_info(node_information, long_output):
ainformation.append('')
return '\n'.join(ainformation)
def format_list(node_list, raw):
# Handle single-element lists
if not isinstance(node_list, list):

View File

@ -27,6 +27,7 @@ from requests_toolbelt.multipart.encoder import MultipartEncoder, MultipartEncod
import cli_lib.ansiprint as ansiprint
from cli_lib.common import UploadProgressBar, call_api
#
# Primary functions
#
@ -45,6 +46,7 @@ def template_info(config, template, template_type):
else:
return False, response.json().get('message', '')
def template_list(config, limit, template_type=None):
"""
Get list information about templates (limited by {limit})
@ -67,6 +69,7 @@ def template_list(config, limit, template_type=None):
else:
return False, response.json().get('message', '')
def template_add(config, params, template_type=None):
"""
Add a new template of {template_type} with {params}
@ -84,6 +87,7 @@ def template_add(config, params, template_type=None):
return retvalue, response.json().get('message', '')
def template_modify(config, params, name, template_type):
"""
Modify an existing template of {template_type} with {params}
@ -101,6 +105,7 @@ def template_modify(config, params, name, template_type):
return retvalue, response.json().get('message', '')
def template_remove(config, name, template_type):
"""
Remove template {name} of {template_type}
@ -118,6 +123,7 @@ def template_remove(config, name, template_type):
return retvalue, response.json().get('message', '')
def template_element_add(config, name, element_id, params, element_type=None, template_type=None):
"""
Add a new template element of {element_type} with {params} to template {name} of {template_type}
@ -135,6 +141,7 @@ def template_element_add(config, name, element_id, params, element_type=None, te
return retvalue, response.json().get('message', '')
def template_element_remove(config, name, element_id, element_type=None, template_type=None):
"""
Remove template element {element_id} of {element_type} from template {name} of {template_type}
@ -152,6 +159,7 @@ def template_element_remove(config, name, element_id, element_type=None, templat
return retvalue, response.json().get('message', '')
def userdata_info(config, userdata):
"""
Get information about userdata
@ -167,6 +175,7 @@ def userdata_info(config, userdata):
else:
return False, response.json().get('message', '')
def userdata_list(config, limit):
"""
Get list information about userdatas (limited by {limit})
@ -186,6 +195,7 @@ def userdata_list(config, limit):
else:
return False, response.json().get('message', '')
def userdata_show(config, name):
"""
Get information about userdata name
@ -201,6 +211,7 @@ def userdata_show(config, name):
else:
return False, response.json().get('message', '')
def userdata_add(config, params):
"""
Add a new userdata with {params}
@ -227,6 +238,7 @@ def userdata_add(config, params):
return retvalue, response.json().get('message', '')
def userdata_modify(config, name, params):
"""
Modify userdata {name} with {params}
@ -252,6 +264,7 @@ def userdata_modify(config, name, params):
return retvalue, response.json().get('message', '')
def userdata_remove(config, name):
"""
Remove userdata {name}
@ -269,6 +282,7 @@ def userdata_remove(config, name):
return retvalue, response.json().get('message', '')
def script_info(config, script):
"""
Get information about script
@ -284,6 +298,7 @@ def script_info(config, script):
else:
return False, response.json().get('message', '')
def script_list(config, limit):
"""
Get list information about scripts (limited by {limit})
@ -303,6 +318,7 @@ def script_list(config, limit):
else:
return False, response.json().get('message', '')
def script_show(config, name):
"""
Get information about script name
@ -318,6 +334,7 @@ def script_show(config, name):
else:
return False, response.json().get('message', '')
def script_add(config, params):
"""
Add a new script with {params}
@ -344,6 +361,7 @@ def script_add(config, params):
return retvalue, response.json().get('message', '')
def script_modify(config, name, params):
"""
Modify script {name} with {params}
@ -369,6 +387,7 @@ def script_modify(config, name, params):
return retvalue, response.json().get('message', '')
def script_remove(config, name):
"""
Remove script {name}
@ -386,6 +405,7 @@ def script_remove(config, name):
return retvalue, response.json().get('message', '')
def ova_info(config, name):
"""
Get information about OVA image {name}
@ -401,6 +421,7 @@ def ova_info(config, name):
else:
return False, response.json().get('message', '')
def ova_list(config, limit):
"""
Get list information about OVA images (limited by {limit})
@ -420,6 +441,7 @@ def ova_list(config, limit):
else:
return False, response.json().get('message', '')
def ova_upload(config, name, ova_file, params):
"""
Upload an OVA image to the cluster
@ -452,6 +474,7 @@ def ova_upload(config, name, ova_file, params):
return retstatus, response.json().get('message', '')
def ova_remove(config, name):
"""
Remove OVA image {name}
@ -469,6 +492,7 @@ def ova_remove(config, name):
return retvalue, response.json().get('message', '')
def profile_info(config, profile):
"""
Get information about profile
@ -484,6 +508,7 @@ def profile_info(config, profile):
else:
return False, response.json().get('message', '')
def profile_list(config, limit):
"""
Get list information about profiles (limited by {limit})
@ -503,6 +528,7 @@ def profile_list(config, limit):
else:
return False, response.json().get('message', '')
def profile_add(config, params):
"""
Add a new profile with {params}
@ -520,6 +546,7 @@ def profile_add(config, params):
return retvalue, response.json().get('message', '')
def profile_modify(config, name, params):
"""
Modify profile {name} with {params}
@ -537,6 +564,7 @@ def profile_modify(config, name, params):
return retvalue, response.json().get('message', '')
def profile_remove(config, name):
"""
Remove profile {name}
@ -554,6 +582,7 @@ def profile_remove(config, name):
return retvalue, response.json().get('message', '')
def vm_create(config, name, profile, wait_flag, define_flag, start_flag, script_args):
"""
Create a new VM named {name} with profile {profile}
@ -584,6 +613,7 @@ def vm_create(config, name, profile, wait_flag, define_flag, start_flag, script_
return retvalue, retdata
def task_status(config, task_id=None, is_watching=False):
"""
Get information about provisioner job {task_id} or all tasks if None
@ -658,6 +688,7 @@ def task_status(config, task_id=None, is_watching=False):
return retvalue, retdata
#
# Format functions
#
@ -700,6 +731,7 @@ def format_list_template(template_data, template_type=None):
return '\n'.join(ainformation)
def format_list_template_system(template_data):
if isinstance(template_data, dict):
template_data = [template_data]
@ -848,6 +880,7 @@ Meta: {template_node_limit: <{template_node_limit_length}} \
return True, ''
def format_list_template_network(template_template):
if isinstance(template_template, dict):
template_template = [template_template]
@ -922,6 +955,7 @@ def format_list_template_network(template_template):
return '\n'.join([template_list_output_header] + template_list_output)
def format_list_template_storage(template_template):
if isinstance(template_template, dict):
template_template = [template_template]
@ -1057,6 +1091,7 @@ def format_list_template_storage(template_template):
return '\n'.join([template_list_output_header] + template_list_output)
def format_list_userdata(userdata_data, lines=None):
if isinstance(userdata_data, dict):
userdata_data = [userdata_data]
@ -1131,6 +1166,7 @@ def format_list_userdata(userdata_data, lines=None):
return '\n'.join([userdata_list_output_header] + userdata_list_output)
def format_list_script(script_data, lines=None):
if isinstance(script_data, dict):
script_data = [script_data]
@ -1205,6 +1241,7 @@ def format_list_script(script_data, lines=None):
return '\n'.join([script_list_output_header] + script_list_output)
def format_list_ova(ova_data):
if isinstance(ova_data, dict):
ova_data = [ova_data]
@ -1318,6 +1355,7 @@ def format_list_ova(ova_data):
return '\n'.join([ova_list_output_header] + ova_list_output)
def format_list_profile(profile_data):
if isinstance(profile_data, dict):
profile_data = [profile_data]
@ -1442,6 +1480,7 @@ Data: {profile_userdata: <{profile_userdata_length}} \
return '\n'.join([profile_list_output_header] + profile_list_output)
def format_list_task(task_data):
task_list_output = []

View File

@ -26,6 +26,7 @@ import re
import cli_lib.ansiprint as ansiprint
from cli_lib.common import call_api, format_bytes, format_metric
#
# Primary functions
#
@ -53,6 +54,7 @@ def vm_info(config, vm):
else:
return False, response.json().get('message', '')
def vm_list(config, limit, target_node, target_state):
"""
Get list information about VMs (limited by {limit}, {target_node}, or {target_state})
@ -76,6 +78,7 @@ def vm_list(config, limit, target_node, target_state):
else:
return False, response.json().get('message', '')
def vm_define(config, xml, node, node_limit, node_selector, node_autostart, migration_method):
"""
Define a new VM on the cluster
@ -103,6 +106,7 @@ def vm_define(config, xml, node, node_limit, node_selector, node_autostart, migr
return retstatus, response.json().get('message', '')
def vm_modify(config, vm, xml, restart):
"""
Modify the configuration of VM
@ -126,6 +130,7 @@ def vm_modify(config, vm, xml, restart):
return retstatus, response.json().get('message', '')
def vm_metadata(config, vm, node_limit, node_selector, node_autostart, migration_method, provisioner_profile):
"""
Modify PVC metadata of a VM
@ -162,6 +167,7 @@ def vm_metadata(config, vm, node_limit, node_selector, node_autostart, migration
return retstatus, response.json().get('message', '')
def vm_remove(config, vm, delete_disks=False):
"""
Remove a VM
@ -182,6 +188,7 @@ def vm_remove(config, vm, delete_disks=False):
return retstatus, response.json().get('message', '')
def vm_state(config, vm, target_state, wait=False):
"""
Modify the current state of VM
@ -203,6 +210,7 @@ def vm_state(config, vm, target_state, wait=False):
return retstatus, response.json().get('message', '')
def vm_node(config, vm, target_node, action, force=False, wait=False, force_live=False):
"""
Modify the current node of VM via {action}
@ -227,6 +235,7 @@ def vm_node(config, vm, target_node, action, force=False, wait=False, force_live
return retstatus, response.json().get('message', '')
def vm_locks(config, vm):
"""
Flush RBD locks of (stopped) VM
@ -244,6 +253,7 @@ def vm_locks(config, vm):
return retstatus, response.json().get('message', '')
def view_console_log(config, vm, lines=100):
"""
Return console log lines from the API (and display them in a pager in the main CLI)
@ -268,6 +278,7 @@ def view_console_log(config, vm, lines=100):
return True, loglines
def follow_console_log(config, vm, lines=10):
"""
Return and follow console log lines from the API
@ -323,6 +334,7 @@ def follow_console_log(config, vm, lines=10):
return True, ''
#
# Output display functions
#
@ -478,6 +490,7 @@ def format_info(config, domain_information, long_output):
ainformation.append('')
return '\n'.join(ainformation)
def format_list(config, vm_list, raw):
# Handle single-element lists
if not isinstance(vm_list, list):

View File

@ -22,6 +22,7 @@
import uuid
# Exists function
def exists(zk_conn, key):
stat = zk_conn.exists(key)
@ -30,21 +31,25 @@ def exists(zk_conn, key):
else:
return False
# Child list function
def listchildren(zk_conn, key):
children = zk_conn.get_children(key)
return children
# Delete key function
def deletekey(zk_conn, key, recursive=True):
zk_conn.delete(key, recursive=recursive)
# Data read function
def readdata(zk_conn, key):
data_raw = zk_conn.get(key)
data = data_raw[0].decode('utf8')
return data
# Data write function
def writedata(zk_conn, kv):
# Start up a transaction
@ -83,12 +88,14 @@ def writedata(zk_conn, kv):
except Exception:
return False
# Write lock function
def writelock(zk_conn, key):
lock_id = str(uuid.uuid1())
lock = zk_conn.WriteLock('{}'.format(key), lock_id)
return lock
# Read lock function
def readlock(zk_conn, key):
lock_id = str(uuid.uuid1())

View File

@ -50,6 +50,7 @@ default_store_data = {
'cfgfile': '/etc/pvc/pvcapid.yaml' # pvc/api/listen_address, pvc/api/listen_port
}
#
# Data store handling functions
#
@ -69,6 +70,7 @@ def read_from_yaml(cfgfile):
api_key = 'N/A'
return host, port, scheme, api_key
def get_config(store_data, cluster=None):
# This is generally static
prefix = '/api/v1'
@ -110,12 +112,14 @@ def get_config(store_data, cluster=None):
return config
def get_store(store_path):
store_file = '{}/pvc-cli.json'.format(store_path)
with open(store_file, 'r') as fh:
store_data = json.loads(fh.read())
return store_data
def update_store(store_path, store_data):
store_file = '{}/pvc-cli.json'.format(store_path)
if not os.path.exists(store_file):
@ -145,6 +149,7 @@ if not os.path.isfile(store_path + '/pvc-cli.json'):
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'], max_content_width=120)
def cleanup(retcode, retmsg):
if retcode is True:
if retmsg != '':
@ -155,6 +160,7 @@ def cleanup(retcode, retmsg):
click.echo(retmsg)
exit(1)
###############################################################################
# pvc cluster
###############################################################################
@ -165,6 +171,7 @@ def cli_cluster():
"""
pass
###############################################################################
# pvc cluster add
###############################################################################
@ -210,6 +217,7 @@ def cluster_add(address, port, ssl, name, api_key):
update_store(store_path, existing_config)
click.echo('Added new cluster "{}" at host "{}" to local database'.format(name, address))
###############################################################################
# pvc cluster remove
###############################################################################
@ -232,6 +240,7 @@ def cluster_remove(name):
update_store(store_path, existing_config)
click.echo('Removed cluster "{}" from local database'.format(name))
###############################################################################
# pvc cluster list
###############################################################################
@ -338,6 +347,7 @@ def cluster_list():
)
)
# Validate that the cluster is set for a given command
def cluster_req(function):
@wraps(function)
@ -357,6 +367,8 @@ def cli_node():
"""
Manage the state of a node in the PVC cluster.
"""
pass
###############################################################################
# pvc node secondary
@ -402,6 +414,7 @@ def node_secondary(node, wait):
time.sleep(0.5)
cleanup(retcode, retmsg)
###############################################################################
# pvc node primary
###############################################################################
@ -446,6 +459,7 @@ def node_primary(node, wait):
time.sleep(0.5)
cleanup(retcode, retmsg)
###############################################################################
# pvc node flush
###############################################################################
@ -466,6 +480,7 @@ def node_flush(node, wait):
retcode, retmsg = pvc_node.node_domain_state(config, node, 'flush', wait)
cleanup(retcode, retmsg)
###############################################################################
# pvc node ready/unflush
###############################################################################
@ -486,6 +501,7 @@ def node_ready(node, wait):
retcode, retmsg = pvc_node.node_domain_state(config, node, 'ready', wait)
cleanup(retcode, retmsg)
@click.command(name='unflush', short_help='Restore node to service.')
@click.argument(
'node', default=myhostname
@ -502,6 +518,7 @@ def node_unflush(node, wait):
retcode, retmsg = pvc_node.node_domain_state(config, node, 'ready', wait)
cleanup(retcode, retmsg)
###############################################################################
# pvc node info
###############################################################################
@ -524,6 +541,7 @@ def node_info(node, long_output):
retdata = pvc_node.format_info(retdata, long_output)
cleanup(retcode, retdata)
###############################################################################
# pvc node list
###############################################################################
@ -561,6 +579,7 @@ def node_list(limit, target_daemon_state, target_coordinator_state, target_domai
retdata = ""
cleanup(retcode, retdata)
###############################################################################
# pvc vm
###############################################################################
@ -569,6 +588,8 @@ def cli_vm():
"""
Manage the state of a virtual machine in the PVC cluster.
"""
pass
###############################################################################
# pvc vm define
@ -619,6 +640,7 @@ def vm_define(vmconfig, target_node, node_limit, node_selector, node_autostart,
retcode, retmsg = pvc_vm.vm_define(config, new_cfg, target_node, node_limit, node_selector, node_autostart, migration_method)
cleanup(retcode, retmsg)
###############################################################################
# pvc vm meta
###############################################################################
@ -660,6 +682,7 @@ def vm_meta(domain, node_limit, node_selector, node_autostart, migration_method,
retcode, retmsg = pvc_vm.vm_metadata(config, domain, node_limit, node_selector, node_autostart, migration_method, provisioner_profile)
cleanup(retcode, retmsg)
###############################################################################
# pvc vm modify
###############################################################################
@ -748,6 +771,7 @@ def vm_modify(domain, cfgfile, editor, restart):
retcode, retmsg = pvc_vm.vm_modify(config, domain, new_cfg, restart)
cleanup(retcode, retmsg)
###############################################################################
# pvc vm undefine
###############################################################################
@ -774,6 +798,7 @@ def vm_undefine(domain, confirm_flag):
retcode, retmsg = pvc_vm.vm_remove(config, domain, delete_disks=False)
cleanup(retcode, retmsg)
###############################################################################
# pvc vm remove
###############################################################################
@ -800,6 +825,7 @@ def vm_remove(domain, confirm_flag):
retcode, retmsg = pvc_vm.vm_remove(config, domain, delete_disks=True)
cleanup(retcode, retmsg)
###############################################################################
# pvc vm start
###############################################################################
@ -816,6 +842,7 @@ def vm_start(domain):
retcode, retmsg = pvc_vm.vm_state(config, domain, 'start')
cleanup(retcode, retmsg)
###############################################################################
# pvc vm restart
###############################################################################
@ -836,6 +863,7 @@ def vm_restart(domain, wait):
retcode, retmsg = pvc_vm.vm_state(config, domain, 'restart', wait=wait)
cleanup(retcode, retmsg)
###############################################################################
# pvc vm shutdown
###############################################################################
@ -856,6 +884,7 @@ def vm_shutdown(domain, wait):
retcode, retmsg = pvc_vm.vm_state(config, domain, 'shutdown', wait=wait)
cleanup(retcode, retmsg)
###############################################################################
# pvc vm stop
###############################################################################
@ -872,6 +901,7 @@ def vm_stop(domain):
retcode, retmsg = pvc_vm.vm_state(config, domain, 'stop')
cleanup(retcode, retmsg)
###############################################################################
# pvc vm disable
###############################################################################
@ -890,6 +920,7 @@ def vm_disable(domain):
retcode, retmsg = pvc_vm.vm_state(config, domain, 'disable')
cleanup(retcode, retmsg)
###############################################################################
# pvc vm move
###############################################################################
@ -918,6 +949,7 @@ def vm_move(domain, target_node, wait, force_live):
retcode, retmsg = pvc_vm.vm_node(config, domain, target_node, 'move', force=False, wait=wait, force_live=force_live)
cleanup(retcode, retmsg)
###############################################################################
# pvc vm migrate
###############################################################################
@ -950,6 +982,7 @@ def vm_migrate(domain, target_node, force_migrate, wait, force_live):
retcode, retmsg = pvc_vm.vm_node(config, domain, target_node, 'migrate', force=force_migrate, wait=wait, force_live=force_live)
cleanup(retcode, retmsg)
###############################################################################
# pvc vm unmigrate
###############################################################################
@ -974,6 +1007,7 @@ def vm_unmigrate(domain, wait, force_live):
retcode, retmsg = pvc_vm.vm_node(config, domain, None, 'unmigrate', force=False, wait=wait, force_live=force_live)
cleanup(retcode, retmsg)
###############################################################################
# pvc vm flush-locks
###############################################################################
@ -990,6 +1024,7 @@ def vm_flush_locks(domain):
retcode, retmsg = pvc_vm.vm_locks(config, domain)
cleanup(retcode, retmsg)
###############################################################################
# pvc vm log
###############################################################################
@ -1026,6 +1061,7 @@ def vm_log(domain, lines, follow):
retmsg = ''
cleanup(retcode, retmsg)
###############################################################################
# pvc vm info
###############################################################################
@ -1048,6 +1084,7 @@ def vm_info(domain, long_output):
retdata = pvc_vm.format_info(config, retdata, long_output)
cleanup(retcode, retdata)
###############################################################################
# pvc vm dump
###############################################################################
@ -1071,6 +1108,7 @@ def vm_dump(domain):
current_vm_cfgfile = etree.tostring(xml_data, pretty_print=True).decode('utf8')
click.echo(current_vm_cfgfile.strip())
###############################################################################
# pvc vm list
###############################################################################
@ -1106,6 +1144,7 @@ def vm_list(target_node, target_state, limit, raw):
retdata = ""
cleanup(retcode, retdata)
###############################################################################
# pvc network
###############################################################################
@ -1114,6 +1153,8 @@ def cli_network():
"""
Manage the state of a VXLAN network in the PVC cluster.
"""
pass
###############################################################################
# pvc network add
@ -1200,6 +1241,7 @@ def net_add(vni, description, nettype, domain, ip_network, ip_gateway, ip6_netwo
retcode, retmsg = pvc_network.net_add(config, vni, description, nettype, domain, name_servers, ip_network, ip_gateway, ip6_network, ip6_gateway, dhcp_flag, dhcp_start, dhcp_end)
cleanup(retcode, retmsg)
###############################################################################
# pvc network modify
###############################################################################
@ -1270,6 +1312,7 @@ def net_modify(vni, description, domain, name_servers, ip6_network, ip6_gateway,
retcode, retmsg = pvc_network.net_modify(config, vni, description, domain, name_servers, ip4_network, ip4_gateway, ip6_network, ip6_gateway, dhcp_flag, dhcp_start, dhcp_end)
cleanup(retcode, retmsg)
###############################################################################
# pvc network remove
###############################################################################
@ -1299,6 +1342,7 @@ def net_remove(net, confirm_flag):
retcode, retmsg = pvc_network.net_remove(config, net)
cleanup(retcode, retmsg)
###############################################################################
# pvc network info
###############################################################################
@ -1321,6 +1365,7 @@ def net_info(vni, long_output):
retdata = pvc_network.format_info(config, retdata, long_output)
cleanup(retcode, retdata)
###############################################################################
# pvc network list
###############################################################################
@ -1339,6 +1384,7 @@ def net_list(limit):
retdata = pvc_network.format_list(config, retdata)
cleanup(retcode, retdata)
###############################################################################
# pvc network dhcp
###############################################################################
@ -1347,6 +1393,8 @@ def net_dhcp():
"""
Manage host IPv4 DHCP leases of a VXLAN network in the PVC cluster.
"""
pass
###############################################################################
# pvc network dhcp add
@ -1373,6 +1421,7 @@ def net_dhcp_add(net, ipaddr, macaddr, hostname):
retcode, retmsg = pvc_network.net_dhcp_add(config, net, ipaddr, macaddr, hostname)
cleanup(retcode, retmsg)
###############################################################################
# pvc network dhcp remove
###############################################################################
@ -1402,6 +1451,7 @@ def net_dhcp_remove(net, macaddr, confirm_flag):
retcode, retmsg = pvc_network.net_dhcp_remove(config, net, macaddr)
cleanup(retcode, retmsg)
###############################################################################
# pvc network dhcp list
###############################################################################
@ -1427,6 +1477,7 @@ def net_dhcp_list(net, limit, only_static):
retdata = pvc_network.format_list_dhcp(retdata)
cleanup(retcode, retdata)
###############################################################################
# pvc network acl
###############################################################################
@ -1435,6 +1486,8 @@ def net_acl():
"""
Manage firewall ACLs of a VXLAN network in the PVC cluster.
"""
pass
###############################################################################
# pvc network acl add
@ -1487,6 +1540,7 @@ def net_acl_add(net, direction, description, rule, order):
retcode, retmsg = pvc_network.net_acl_add(config, net, direction, description, rule, order)
cleanup(retcode, retmsg)
###############################################################################
# pvc network acl remove
###############################################################################
@ -1550,6 +1604,7 @@ def net_acl_list(net, limit, direction):
retdata = pvc_network.format_list_acl(retdata)
cleanup(retcode, retdata)
###############################################################################
# pvc storage
###############################################################################
@ -1563,6 +1618,8 @@ def cli_storage():
"""
Manage the storage of the PVC cluster.
"""
pass
###############################################################################
# pvc storage status
@ -1579,6 +1636,7 @@ def ceph_status():
retdata = pvc_ceph.format_raw_output(retdata)
cleanup(retcode, retdata)
###############################################################################
# pvc storage util
###############################################################################
@ -1594,6 +1652,7 @@ def ceph_util():
retdata = pvc_ceph.format_raw_output(retdata)
cleanup(retcode, retdata)
###############################################################################
# pvc storage benchmark
###############################################################################
@ -1603,6 +1662,8 @@ def ceph_benchmark():
"""
Run or view benchmarks of the storage cluster.
"""
pass
###############################################################################
# pvc storage benchmark run
@ -1624,6 +1685,7 @@ def ceph_benchmark_run(pool):
retcode, retmsg = pvc_ceph.ceph_benchmark_run(config, pool)
cleanup(retcode, retmsg)
###############################################################################
# pvc storage benchmark info
###############################################################################
@ -1642,6 +1704,7 @@ def ceph_benchmark_info(job):
retdata = pvc_ceph.format_info_benchmark(config, retdata)
cleanup(retcode, retdata)
###############################################################################
# pvc storage benchmark list
###############################################################################
@ -1660,6 +1723,7 @@ def ceph_benchmark_list(job):
retdata = pvc_ceph.format_list_benchmark(config, retdata)
cleanup(retcode, retdata)
###############################################################################
# pvc storage osd
###############################################################################
@ -1668,6 +1732,8 @@ def ceph_osd():
"""
Manage the Ceph OSDs of the PVC cluster.
"""
pass
###############################################################################
# pvc storage osd add
@ -1703,6 +1769,7 @@ def ceph_osd_add(node, device, weight, confirm_flag):
retcode, retmsg = pvc_ceph.ceph_osd_add(config, node, device, weight)
cleanup(retcode, retmsg)
###############################################################################
# pvc storage osd remove
###############################################################################
@ -1731,6 +1798,7 @@ def ceph_osd_remove(osdid, confirm_flag):
retcode, retmsg = pvc_ceph.ceph_osd_remove(config, osdid)
cleanup(retcode, retmsg)
###############################################################################
# pvc storage osd in
###############################################################################
@ -1747,6 +1815,7 @@ def ceph_osd_in(osdid):
retcode, retmsg = pvc_ceph.ceph_osd_state(config, osdid, 'in')
cleanup(retcode, retmsg)
###############################################################################
# pvc storage osd out
###############################################################################
@ -1763,6 +1832,7 @@ def ceph_osd_out(osdid):
retcode, retmsg = pvc_ceph.ceph_osd_state(config, osdid, 'out')
cleanup(retcode, retmsg)
###############################################################################
# pvc storage osd set
###############################################################################
@ -1783,6 +1853,7 @@ def ceph_osd_set(osd_property):
retcode, retmsg = pvc_ceph.ceph_osd_option(config, osd_property, 'set')
cleanup(retcode, retmsg)
###############################################################################
# pvc storage osd unset
###############################################################################
@ -1803,6 +1874,7 @@ def ceph_osd_unset(osd_property):
retcode, retmsg = pvc_ceph.ceph_osd_option(config, osd_property, 'unset')
cleanup(retcode, retmsg)
###############################################################################
# pvc storage osd list
###############################################################################
@ -1821,6 +1893,7 @@ def ceph_osd_list(limit):
retdata = pvc_ceph.format_list_osd(retdata)
cleanup(retcode, retdata)
###############################################################################
# pvc storage pool
###############################################################################
@ -1829,6 +1902,8 @@ def ceph_pool():
"""
Manage the Ceph RBD pools of the PVC cluster.
"""
pass
###############################################################################
# pvc storage pool add
@ -1858,6 +1933,7 @@ def ceph_pool_add(name, pgs, replcfg):
retcode, retmsg = pvc_ceph.ceph_pool_add(config, name, pgs, replcfg)
cleanup(retcode, retmsg)
###############################################################################
# pvc storage pool remove
###############################################################################
@ -1886,6 +1962,7 @@ def ceph_pool_remove(name, confirm_flag):
retcode, retmsg = pvc_ceph.ceph_pool_remove(config, name)
cleanup(retcode, retmsg)
###############################################################################
# pvc storage pool list
###############################################################################
@ -1904,6 +1981,7 @@ def ceph_pool_list(limit):
retdata = pvc_ceph.format_list_pool(retdata)
cleanup(retcode, retdata)
###############################################################################
# pvc storage volume
###############################################################################
@ -1912,6 +1990,8 @@ def ceph_volume():
"""
Manage the Ceph RBD volumes of the PVC cluster.
"""
pass
###############################################################################
# pvc storage volume add
@ -1935,6 +2015,7 @@ def ceph_volume_add(pool, name, size):
retcode, retmsg = pvc_ceph.ceph_volume_add(config, pool, name, size)
cleanup(retcode, retmsg)
###############################################################################
# pvc storage volume upload
###############################################################################
@ -1970,6 +2051,7 @@ def ceph_volume_upload(pool, name, image_format, image_file):
retcode, retmsg = pvc_ceph.ceph_volume_upload(config, pool, name, image_format, image_file)
cleanup(retcode, retmsg)
###############################################################################
# pvc storage volume remove
###############################################################################
@ -2001,6 +2083,7 @@ def ceph_volume_remove(pool, name, confirm_flag):
retcode, retmsg = pvc_ceph.ceph_volume_remove(config, pool, name)
cleanup(retcode, retmsg)
###############################################################################
# pvc storage volume resize
###############################################################################
@ -2022,6 +2105,7 @@ def ceph_volume_resize(pool, name, size):
retcode, retmsg = pvc_ceph.ceph_volume_modify(config, pool, name, new_size=size)
cleanup(retcode, retmsg)
###############################################################################
# pvc storage volume rename
###############################################################################
@ -2043,6 +2127,7 @@ def ceph_volume_rename(pool, name, new_name):
retcode, retmsg = pvc_ceph.ceph_volume_modify(config, pool, name, new_name=new_name)
cleanup(retcode, retmsg)
###############################################################################
# pvc storage volume clone
###############################################################################
@ -2064,6 +2149,7 @@ def ceph_volume_clone(pool, name, new_name):
retcode, retmsg = pvc_ceph.ceph_volume_clone(config, pool, name, new_name)
cleanup(retcode, retmsg)
###############################################################################
# pvc storage volume list
###############################################################################
@ -2087,6 +2173,7 @@ def ceph_volume_list(limit, pool):
retdata = pvc_ceph.format_list_volume(retdata)
cleanup(retcode, retdata)
###############################################################################
# pvc storage volume snapshot
###############################################################################
@ -2095,6 +2182,8 @@ def ceph_volume_snapshot():
"""
Manage the Ceph RBD volume snapshots of the PVC cluster.
"""
pass
###############################################################################
# pvc storage volume snapshot add
@ -2118,6 +2207,7 @@ def ceph_volume_snapshot_add(pool, volume, name):
retcode, retmsg = pvc_ceph.ceph_snapshot_add(config, pool, volume, name)
cleanup(retcode, retmsg)
###############################################################################
# pvc storage volume snapshot rename
###############################################################################
@ -2142,6 +2232,7 @@ def ceph_volume_snapshot_rename(pool, volume, name, new_name):
retcode, retmsg = pvc_ceph.ceph_snapshot_modify(config, pool, volume, name, new_name=new_name)
cleanup(retcode, retmsg)
###############################################################################
# pvc storage volume snapshot remove
###############################################################################
@ -2176,6 +2267,7 @@ def ceph_volume_snapshot_remove(pool, volume, name, confirm_flag):
retcode, retmsg = pvc_ceph.ceph_snapshot_remove(config, pool, volume, name)
cleanup(retcode, retmsg)
###############################################################################
# pvc storage volume snapshot list
###############################################################################
@ -2213,6 +2305,8 @@ def cli_provisioner():
"""
Manage the PVC provisioner.
"""
pass
###############################################################################
# pvc provisioner template
@ -2222,6 +2316,7 @@ def provisioner_template():
"""
Manage the PVC provisioner template system.
"""
pass
###############################################################################
@ -2241,6 +2336,7 @@ def provisioner_template_list(limit):
retdata = pvc_provisioner.format_list_template(retdata)
cleanup(retcode, retdata)
###############################################################################
# pvc provisioner template system
###############################################################################
@ -2249,6 +2345,8 @@ def provisioner_template_system():
"""
Manage the PVC provisioner system templates.
"""
pass
###############################################################################
# pvc provisioner template system list
@ -2267,6 +2365,7 @@ def provisioner_template_system_list(limit):
retdata = pvc_provisioner.format_list_template(retdata, template_type='system')
cleanup(retcode, retdata)
###############################################################################
# pvc provisioner template system add
###############################################################################
@ -2346,6 +2445,7 @@ def provisioner_template_system_add(name, vcpus, vram, serial, vnc, vnc_bind, no
retcode, retdata = pvc_provisioner.template_add(config, params, template_type='system')
cleanup(retcode, retdata)
###############################################################################
# pvc provisioner template system modify
###############################################################################
@ -2416,6 +2516,7 @@ def provisioner_template_system_modify(name, vcpus, vram, serial, vnc, vnc_bind,
retcode, retdata = pvc_provisioner.template_modify(config, params, name, template_type='system')
cleanup(retcode, retdata)
###############################################################################
# pvc provisioner template system remove
###############################################################################
@ -2451,6 +2552,8 @@ def provisioner_template_network():
"""
Manage the PVC provisioner network templates.
"""
pass
###############################################################################
# pvc provisioner template network list
@ -2469,6 +2572,7 @@ def provisioner_template_network_list(limit):
retdata = pvc_provisioner.format_list_template(retdata, template_type='network')
cleanup(retcode, retdata)
###############################################################################
# pvc provisioner template network add
###############################################################################
@ -2519,6 +2623,7 @@ def provisioner_template_network_add(name, mac_template):
retcode, retdata = pvc_provisioner.template_add(config, params, template_type='network')
cleanup(retcode, retdata)
###############################################################################
# pvc provisioner template network remove
###############################################################################
@ -2545,6 +2650,7 @@ def provisioner_template_network_remove(name, confirm_flag):
retcode, retdata = pvc_provisioner.template_remove(config, name, template_type='network')
cleanup(retcode, retdata)
###############################################################################
# pvc provisioner template network vni
###############################################################################
@ -2553,6 +2659,8 @@ def provisioner_template_network_vni():
"""
Manage the network VNIs in PVC provisioner network templates.
"""
pass
###############################################################################
# pvc provisioner template network vni add
@ -2576,6 +2684,7 @@ def provisioner_template_network_vni_add(name, vni):
retcode, retdata = pvc_provisioner.template_element_add(config, name, vni, params, element_type='net', template_type='network')
cleanup(retcode, retdata)
###############################################################################
# pvc provisioner template network vni remove
###############################################################################
@ -2614,6 +2723,8 @@ def provisioner_template_storage():
"""
Manage the PVC provisioner storage templates.
"""
pass
###############################################################################
# pvc provisioner template storage list
@ -2632,6 +2743,7 @@ def provisioner_template_storage_list(limit):
retdata = pvc_provisioner.format_list_template(retdata, template_type='storage')
cleanup(retcode, retdata)
###############################################################################
# pvc provisioner template storage add
###############################################################################
@ -2650,6 +2762,7 @@ def provisioner_template_storage_add(name):
retcode, retdata = pvc_provisioner.template_add(config, params, template_type='storage')
cleanup(retcode, retdata)
###############################################################################
# pvc provisioner template storage remove
###############################################################################
@ -2676,6 +2789,7 @@ def provisioner_template_storage_remove(name, confirm_flag):
retcode, retdata = pvc_provisioner.template_remove(config, name, template_type='storage')
cleanup(retcode, retdata)
###############################################################################
# pvc provisioner template storage disk
###############################################################################
@ -2684,6 +2798,8 @@ def provisioner_template_storage_disk():
"""
Manage the disks in PVC provisioner storage templates.
"""
pass
###############################################################################
# pvc provisioner template storage disk add
@ -2760,6 +2876,7 @@ def provisioner_template_storage_disk_add(name, disk, pool, source_volume, size,
retcode, retdata = pvc_provisioner.template_element_add(config, name, disk, params, element_type='disk', template_type='storage')
cleanup(retcode, retdata)
###############################################################################
# pvc provisioner template storage disk remove
###############################################################################
@ -2800,6 +2917,8 @@ def provisioner_userdata():
"""
Manage userdata documents in the PVC provisioner.
"""
pass
###############################################################################
# pvc provisioner userdata list
@ -2827,6 +2946,7 @@ def provisioner_userdata_list(limit, full):
retdata = pvc_provisioner.format_list_userdata(retdata, lines)
cleanup(retcode, retdata)
###############################################################################
# pvc provisioner userdata show
###############################################################################
@ -2842,6 +2962,7 @@ def provisioner_userdata_show(name):
retcode, retdata = pvc_provisioner.userdata_show(config, name)
cleanup(retcode, retdata)
###############################################################################
# pvc provisioner userdata add
###############################################################################
@ -2874,6 +2995,7 @@ def provisioner_userdata_add(name, filename):
retcode, retmsg = pvc_provisioner.userdata_add(config, params)
cleanup(retcode, retmsg)
###############################################################################
# pvc provisioner userdata modify
###############################################################################
@ -2949,6 +3071,7 @@ def provisioner_userdata_modify(name, filename, editor):
retcode, retmsg = pvc_provisioner.userdata_modify(config, name, params)
cleanup(retcode, retmsg)
###############################################################################
# pvc provisioner userdata remove
###############################################################################
@ -2984,6 +3107,8 @@ def provisioner_script():
"""
Manage scripts in the PVC provisioner.
"""
pass
###############################################################################
# pvc provisioner script list
@ -3011,6 +3136,7 @@ def provisioner_script_list(limit, full):
retdata = pvc_provisioner.format_list_script(retdata, lines)
cleanup(retcode, retdata)
###############################################################################
# pvc provisioner script show
###############################################################################
@ -3026,6 +3152,7 @@ def provisioner_script_show(name):
retcode, retdata = pvc_provisioner.script_show(config, name)
cleanup(retcode, retdata)
###############################################################################
# pvc provisioner script add
###############################################################################
@ -3053,6 +3180,7 @@ def provisioner_script_add(name, filename):
retcode, retmsg = pvc_provisioner.script_add(config, params)
cleanup(retcode, retmsg)
###############################################################################
# pvc provisioner script modify
###############################################################################
@ -3122,6 +3250,7 @@ def provisioner_script_modify(name, filename, editor):
retcode, retmsg = pvc_provisioner.script_modify(config, name, params)
cleanup(retcode, retmsg)
###############################################################################
# pvc provisioner script remove
###############################################################################
@ -3157,6 +3286,8 @@ def provisioner_ova():
"""
Manage ovas in the PVC provisioner.
"""
pass
###############################################################################
# pvc provisioner ova list
@ -3175,6 +3306,7 @@ def provisioner_ova_list(limit):
retdata = pvc_provisioner.format_list_ova(retdata)
cleanup(retcode, retdata)
###############################################################################
# pvc provisioner ova upload
###############################################################################
@ -3214,6 +3346,7 @@ def provisioner_ova_upload(name, filename, pool):
retcode, retdata = pvc_provisioner.ova_upload(config, name, filename, params)
cleanup(retcode, retdata)
###############################################################################
# pvc provisioner ova remove
###############################################################################
@ -3249,6 +3382,8 @@ def provisioner_profile():
"""
Manage profiles in the PVC provisioner.
"""
pass
###############################################################################
# pvc provisioner profile list
@ -3267,6 +3402,7 @@ def provisioner_profile_list(limit):
retdata = pvc_provisioner.format_list_profile(retdata)
cleanup(retcode, retdata)
###############################################################################
# pvc provisioner profile add
###############################################################################
@ -3328,6 +3464,7 @@ def provisioner_profile_add(name, profile_type, system_template, network_templat
retcode, retdata = pvc_provisioner.profile_add(config, params)
cleanup(retcode, retdata)
###############################################################################
# pvc provisioner profile modify
###############################################################################
@ -3394,6 +3531,7 @@ def provisioner_profile_modify(name, system_template, network_template, storage_
retcode, retdata = pvc_provisioner.profile_modify(config, name, params)
cleanup(retcode, retdata)
###############################################################################
# pvc provisioner profile remove
###############################################################################
@ -3520,6 +3658,7 @@ def provisioner_create(name, profile, wait_flag, define_flag, start_flag, script
cleanup(retcode, retdata)
###############################################################################
# pvc provisioner status
###############################################################################
@ -3546,6 +3685,8 @@ def cli_maintenance():
"""
Manage the maintenance mode of the PVC cluster.
"""
pass
###############################################################################
# pvc maintenance on
@ -3559,6 +3700,7 @@ def maintenance_on():
retcode, retdata = pvc_cluster.maintenance_mode(config, 'true')
cleanup(retcode, retdata)
###############################################################################
# pvc maintenance off
###############################################################################
@ -3592,6 +3734,7 @@ def status_cluster(oformat):
retdata = pvc_cluster.format_info(retdata, oformat)
cleanup(retcode, retdata)
###############################################################################
# pvc init
###############################################################################
@ -3619,6 +3762,7 @@ def init_cluster(confirm_flag):
retcode, retmsg = pvc_cluster.initialize(config)
cleanup(retcode, retmsg)
###############################################################################
# pvc
###############################################################################