Fix name of "ansiiprint" since it's "ANSI"
This commit is contained in:
parent
a3f7419124
commit
05af23064f
|
@ -34,7 +34,7 @@ import lxml.objectify
|
|||
import configparser
|
||||
import kazoo.client
|
||||
|
||||
import client_lib.ansiiprint as ansiiprint
|
||||
import client_lib.ansiprint as ansiprint
|
||||
import client_lib.zkhandler as zkhandler
|
||||
import client_lib.common as common
|
||||
|
||||
|
@ -164,30 +164,30 @@ def formatNetworkInformation(zk_conn, vni, long_output):
|
|||
description, domain, ip_network, ip_gateway, dhcp_flag, dhcp_start, dhcp_end = getNetworkInformation(zk_conn, vni)
|
||||
|
||||
if dhcp_flag == "True":
|
||||
dhcp_flag_colour = ansiiprint.green()
|
||||
dhcp_flag_colour = ansiprint.green()
|
||||
else:
|
||||
dhcp_flag_colour = ansiiprint.blue()
|
||||
colour_off = ansiiprint.end()
|
||||
dhcp_flag_colour = ansiprint.blue()
|
||||
colour_off = ansiprint.end()
|
||||
|
||||
# Format a nice output: do this line-by-line then concat the elements at the end
|
||||
ainformation = []
|
||||
ainformation.append('{}Virtual network information:{}'.format(ansiiprint.bold(), ansiiprint.end()))
|
||||
ainformation.append('{}Virtual network information:{}'.format(ansiprint.bold(), ansiprint.end()))
|
||||
ainformation.append('')
|
||||
# Basic information
|
||||
ainformation.append('{}VNI:{} {}'.format(ansiiprint.purple(), ansiiprint.end(), vni))
|
||||
ainformation.append('{}Description:{} {}'.format(ansiiprint.purple(), ansiiprint.end(), description))
|
||||
ainformation.append('{}Domain:{} {}'.format(ansiiprint.purple(), ansiiprint.end(), domain))
|
||||
ainformation.append('{}IP network:{} {}'.format(ansiiprint.purple(), ansiiprint.end(), ip_network))
|
||||
ainformation.append('{}IP gateway:{} {}'.format(ansiiprint.purple(), ansiiprint.end(), ip_gateway))
|
||||
ainformation.append('{}DHCP enabled:{} {}{}{}'.format(ansiiprint.purple(), ansiiprint.end(), dhcp_flag_colour, dhcp_flag, colour_off))
|
||||
ainformation.append('{}VNI:{} {}'.format(ansiprint.purple(), ansiprint.end(), vni))
|
||||
ainformation.append('{}Description:{} {}'.format(ansiprint.purple(), ansiprint.end(), description))
|
||||
ainformation.append('{}Domain:{} {}'.format(ansiprint.purple(), ansiprint.end(), domain))
|
||||
ainformation.append('{}IP network:{} {}'.format(ansiprint.purple(), ansiprint.end(), ip_network))
|
||||
ainformation.append('{}IP gateway:{} {}'.format(ansiprint.purple(), ansiprint.end(), ip_gateway))
|
||||
ainformation.append('{}DHCP enabled:{} {}{}{}'.format(ansiprint.purple(), ansiprint.end(), dhcp_flag_colour, dhcp_flag, colour_off))
|
||||
if dhcp_flag == "True":
|
||||
ainformation.append('{}DHCP range:{} {} - {}'.format(ansiiprint.purple(), ansiiprint.end(), dhcp_start, dhcp_end))
|
||||
ainformation.append('{}DHCP range:{} {} - {}'.format(ansiprint.purple(), ansiprint.end(), dhcp_start, dhcp_end))
|
||||
|
||||
if long_output:
|
||||
dhcp_reservations_list = getNetworkDHCPReservations(zk_conn, vni)
|
||||
if dhcp_reservations_list:
|
||||
ainformation.append('')
|
||||
ainformation.append('{}Client DHCP reservations:{}'.format(ansiiprint.bold(), ansiiprint.end()))
|
||||
ainformation.append('{}Client DHCP reservations:{}'.format(ansiprint.bold(), ansiprint.end()))
|
||||
ainformation.append('')
|
||||
# Only show static reservations in the detailed information
|
||||
dhcp_reservations_string = formatDHCPLeaseList(zk_conn, vni, dhcp_reservations_list, reservations=True)
|
||||
|
@ -197,7 +197,7 @@ def formatNetworkInformation(zk_conn, vni, long_output):
|
|||
firewall_rules = zk_conn.get_children('/networks/{}/firewall_rules'.format(vni))
|
||||
if firewall_rules:
|
||||
ainformation.append('')
|
||||
ainformation.append('{}Network firewall rules:{}'.format(ansiiprint.bold(), ansiiprint.end()))
|
||||
ainformation.append('{}Network firewall rules:{}'.format(ansiprint.bold(), ansiprint.end()))
|
||||
ainformation.append('')
|
||||
formatted_firewall_rules = get_list_firewall_rules(zk_conn, vni)
|
||||
|
||||
|
@ -216,7 +216,7 @@ def formatNetworkList(zk_conn, net_list):
|
|||
dhcp_start = {}
|
||||
dhcp_end = {}
|
||||
dhcp_range = {}
|
||||
colour_off = ansiiprint.end()
|
||||
colour_off = ansiprint.end()
|
||||
|
||||
# Gather information for printing
|
||||
for net in net_list:
|
||||
|
@ -224,10 +224,10 @@ def formatNetworkList(zk_conn, net_list):
|
|||
description[net], domain[net], ip_network[net], ip_gateway[net], dhcp_flag[net], dhcp_start[net], dhcp_end[net] = getNetworkInformation(zk_conn, net)
|
||||
|
||||
if dhcp_flag[net] == "True":
|
||||
dhcp_flag_colour[net] = ansiiprint.green()
|
||||
dhcp_flag_colour[net] = ansiprint.green()
|
||||
dhcp_range[net] = '{} - {}'.format(dhcp_start[net], dhcp_end[net])
|
||||
else:
|
||||
dhcp_flag_colour[net] = ansiiprint.blue()
|
||||
dhcp_flag_colour[net] = ansiprint.blue()
|
||||
dhcp_range[net] = 'N/A'
|
||||
|
||||
# Determine optimal column widths
|
||||
|
@ -274,8 +274,8 @@ def formatNetworkList(zk_conn, net_list):
|
|||
{net_dhcp_flag: <6} \
|
||||
{net_dhcp_range: <{net_dhcp_range_length}} \
|
||||
{end_bold}'.format(
|
||||
bold=ansiiprint.bold(),
|
||||
end_bold=ansiiprint.end(),
|
||||
bold=ansiprint.bold(),
|
||||
end_bold=ansiprint.end(),
|
||||
net_vni_length=net_vni_length,
|
||||
net_description_length=net_description_length,
|
||||
net_domain_length=net_domain_length,
|
||||
|
@ -364,8 +364,8 @@ def formatDHCPLeaseList(zk_conn, vni, dhcp_leases_list, reservations=False):
|
|||
{lease_mac_address: <{lease_mac_address_length}} \
|
||||
{lease_timestamp: <{lease_timestamp_length}} \
|
||||
{end_bold}'.format(
|
||||
bold=ansiiprint.bold(),
|
||||
end_bold=ansiiprint.end(),
|
||||
bold=ansiprint.bold(),
|
||||
end_bold=ansiprint.end(),
|
||||
lease_hostname_length=lease_hostname_length,
|
||||
lease_ip_address_length=lease_ip_address_length,
|
||||
lease_mac_address_length=lease_mac_address_length,
|
||||
|
@ -443,8 +443,8 @@ def formatACLList(zk_conn, vni, _direction, acl_list):
|
|||
{acl_description: <{acl_description_length}} \
|
||||
{acl_rule: <{acl_rule_length}} \
|
||||
{end_bold}'.format(
|
||||
bold=ansiiprint.bold(),
|
||||
end_bold=ansiiprint.end(),
|
||||
bold=ansiprint.bold(),
|
||||
end_bold=ansiprint.end(),
|
||||
acl_order_length=acl_order_length,
|
||||
acl_description_length=acl_description_length,
|
||||
acl_rule_length=acl_rule_length,
|
||||
|
|
|
@ -34,7 +34,7 @@ import lxml.objectify
|
|||
import configparser
|
||||
import kazoo.client
|
||||
|
||||
import client_lib.ansiiprint as ansiiprint
|
||||
import client_lib.ansiprint as ansiprint
|
||||
import client_lib.zkhandler as zkhandler
|
||||
import client_lib.common as common
|
||||
import client_lib.vm as pvc_vm
|
||||
|
@ -57,50 +57,50 @@ def getInformationFromNode(zk_conn, node_name, long_output):
|
|||
node_running_domains = zkhandler.readdata(zk_conn, '/nodes/{}/runningdomains'.format(node_name)).split()
|
||||
|
||||
if node_daemon_state == 'run':
|
||||
daemon_state_colour = ansiiprint.green()
|
||||
daemon_state_colour = ansiprint.green()
|
||||
elif node_daemon_state == 'stop':
|
||||
daemon_state_colour = ansiiprint.red()
|
||||
daemon_state_colour = ansiprint.red()
|
||||
elif node_daemon_state == 'init':
|
||||
daemon_state_colour = ansiiprint.yellow()
|
||||
daemon_state_colour = ansiprint.yellow()
|
||||
elif node_daemon_state == 'dead':
|
||||
daemon_state_colour = ansiiprint.red() + ansiiprint.bold()
|
||||
daemon_state_colour = ansiprint.red() + ansiprint.bold()
|
||||
else:
|
||||
daemon_state_colour = ansiiprint.blue()
|
||||
daemon_state_colour = ansiprint.blue()
|
||||
|
||||
if node_router_state == 'primary':
|
||||
router_state_colour = ansiiprint.green()
|
||||
router_state_colour = ansiprint.green()
|
||||
elif node_router_state == 'secondary':
|
||||
router_state_colour = ansiiprint.blue()
|
||||
router_state_colour = ansiprint.blue()
|
||||
else:
|
||||
router_state_colour = ansiiprint.purple()
|
||||
router_state_colour = ansiprint.purple()
|
||||
|
||||
if node_domain_state == 'ready':
|
||||
domain_state_colour = ansiiprint.green()
|
||||
domain_state_colour = ansiprint.green()
|
||||
else:
|
||||
domain_state_colour = ansiiprint.blue()
|
||||
domain_state_colour = ansiprint.blue()
|
||||
|
||||
# Format a nice output; do this line-by-line then concat the elements at the end
|
||||
ainformation = []
|
||||
ainformation.append('{}Node information:{}'.format(ansiiprint.bold(), ansiiprint.end()))
|
||||
ainformation.append('{}Node information:{}'.format(ansiprint.bold(), ansiprint.end()))
|
||||
ainformation.append('')
|
||||
# Basic information
|
||||
ainformation.append('{}Name:{} {}'.format(ansiiprint.purple(), ansiiprint.end(), node_name))
|
||||
ainformation.append('{}Daemon State:{} {}{}{}'.format(ansiiprint.purple(), ansiiprint.end(), daemon_state_colour, node_daemon_state, ansiiprint.end()))
|
||||
ainformation.append('{}Router State:{} {}{}{}'.format(ansiiprint.purple(), ansiiprint.end(), router_state_colour, node_router_state, ansiiprint.end()))
|
||||
ainformation.append('{}Domain State:{} {}{}{}'.format(ansiiprint.purple(), ansiiprint.end(), domain_state_colour, node_domain_state, ansiiprint.end()))
|
||||
ainformation.append('{}Active VM Count:{} {}'.format(ansiiprint.purple(), ansiiprint.end(), node_domains_count))
|
||||
ainformation.append('{}Name:{} {}'.format(ansiprint.purple(), ansiprint.end(), node_name))
|
||||
ainformation.append('{}Daemon State:{} {}{}{}'.format(ansiprint.purple(), ansiprint.end(), daemon_state_colour, node_daemon_state, ansiprint.end()))
|
||||
ainformation.append('{}Router State:{} {}{}{}'.format(ansiprint.purple(), ansiprint.end(), router_state_colour, node_router_state, ansiprint.end()))
|
||||
ainformation.append('{}Domain State:{} {}{}{}'.format(ansiprint.purple(), ansiprint.end(), domain_state_colour, node_domain_state, ansiprint.end()))
|
||||
ainformation.append('{}Active VM Count:{} {}'.format(ansiprint.purple(), ansiprint.end(), node_domains_count))
|
||||
if long_output == True:
|
||||
ainformation.append('')
|
||||
ainformation.append('{}Architecture:{} {}'.format(ansiiprint.purple(), ansiiprint.end(), node_arch))
|
||||
ainformation.append('{}Operating System:{} {}'.format(ansiiprint.purple(), ansiiprint.end(), node_os))
|
||||
ainformation.append('{}Kernel Version:{} {}'.format(ansiiprint.purple(), ansiiprint.end(), node_kernel))
|
||||
ainformation.append('{}Architecture:{} {}'.format(ansiprint.purple(), ansiprint.end(), node_arch))
|
||||
ainformation.append('{}Operating System:{} {}'.format(ansiprint.purple(), ansiprint.end(), node_os))
|
||||
ainformation.append('{}Kernel Version:{} {}'.format(ansiprint.purple(), ansiprint.end(), node_kernel))
|
||||
ainformation.append('')
|
||||
ainformation.append('{}CPUs:{} {}'.format(ansiiprint.purple(), ansiiprint.end(), node_cpu_count))
|
||||
ainformation.append('{}Load:{} {}'.format(ansiiprint.purple(), ansiiprint.end(), node_load))
|
||||
ainformation.append('{}Total RAM (MiB):{} {}'.format(ansiiprint.purple(), ansiiprint.end(), node_mem_total))
|
||||
ainformation.append('{}Used RAM (MiB):{} {}'.format(ansiiprint.purple(), ansiiprint.end(), node_mem_used))
|
||||
ainformation.append('{}Free RAM (MiB):{} {}'.format(ansiiprint.purple(), ansiiprint.end(), node_mem_free))
|
||||
ainformation.append('{}Allocated RAM (MiB):{} {}'.format(ansiiprint.purple(), ansiiprint.end(), node_mem_allocated))
|
||||
ainformation.append('{}CPUs:{} {}'.format(ansiprint.purple(), ansiprint.end(), node_cpu_count))
|
||||
ainformation.append('{}Load:{} {}'.format(ansiprint.purple(), ansiprint.end(), node_load))
|
||||
ainformation.append('{}Total RAM (MiB):{} {}'.format(ansiprint.purple(), ansiprint.end(), node_mem_total))
|
||||
ainformation.append('{}Used RAM (MiB):{} {}'.format(ansiprint.purple(), ansiprint.end(), node_mem_used))
|
||||
ainformation.append('{}Free RAM (MiB):{} {}'.format(ansiprint.purple(), ansiprint.end(), node_mem_free))
|
||||
ainformation.append('{}Allocated RAM (MiB):{} {}'.format(ansiprint.purple(), ansiprint.end(), node_mem_allocated))
|
||||
|
||||
# Join it all together
|
||||
information = '\n'.join(ainformation)
|
||||
|
@ -203,7 +203,7 @@ def get_info(zk_conn, node, long_output):
|
|||
|
||||
if long_output == True:
|
||||
click.echo('')
|
||||
click.echo('{}Virtual machines on node:{}'.format(ansiiprint.bold(), ansiiprint.end()))
|
||||
click.echo('{}Virtual machines on node:{}'.format(ansiprint.bold(), ansiprint.end()))
|
||||
click.echo('')
|
||||
# List all VMs on this node
|
||||
pvc_vm.get_list(zk_conn, node, None)
|
||||
|
@ -293,8 +293,8 @@ RAM (MiB): {node_mem_total: <6} {node_mem_used: <6} {node_mem_free: <6} {node_me
|
|||
daemon_state_length=daemon_state_length,
|
||||
router_state_length=router_state_length,
|
||||
domain_state_length=domain_state_length,
|
||||
bold=ansiiprint.bold(),
|
||||
end_bold=ansiiprint.end(),
|
||||
bold=ansiprint.bold(),
|
||||
end_bold=ansiprint.end(),
|
||||
daemon_state_colour='',
|
||||
router_state_colour='',
|
||||
domain_state_colour='',
|
||||
|
@ -316,30 +316,30 @@ RAM (MiB): {node_mem_total: <6} {node_mem_used: <6} {node_mem_free: <6} {node_me
|
|||
# Format the string (elements)
|
||||
for node_name in node_list:
|
||||
if node_daemon_state[node_name] == 'run':
|
||||
daemon_state_colour = ansiiprint.green()
|
||||
daemon_state_colour = ansiprint.green()
|
||||
elif node_daemon_state[node_name] == 'stop':
|
||||
daemon_state_colour = ansiiprint.red()
|
||||
daemon_state_colour = ansiprint.red()
|
||||
elif node_daemon_state[node_name] == 'init':
|
||||
daemon_state_colour = ansiiprint.yellow()
|
||||
daemon_state_colour = ansiprint.yellow()
|
||||
elif node_daemon_state[node_name] == 'dead':
|
||||
daemon_state_colour = ansiiprint.red() + ansiiprint.bold()
|
||||
daemon_state_colour = ansiprint.red() + ansiprint.bold()
|
||||
else:
|
||||
daemon_state_colour = ansiiprint.blue()
|
||||
daemon_state_colour = ansiprint.blue()
|
||||
|
||||
if node_router_state[node_name] == 'primary':
|
||||
router_state_colour = ansiiprint.green()
|
||||
router_state_colour = ansiprint.green()
|
||||
elif node_router_state[node_name] == 'secondary':
|
||||
router_state_colour = ansiiprint.blue()
|
||||
router_state_colour = ansiprint.blue()
|
||||
else:
|
||||
router_state_colour = ansiiprint.purple()
|
||||
router_state_colour = ansiprint.purple()
|
||||
|
||||
if node_mem_allocated[node_name] != 0 and node_mem_allocated[node_name] >= node_mem_total[node_name]:
|
||||
node_domain_state[node_name] = 'overprov'
|
||||
domain_state_colour = ansiiprint.yellow()
|
||||
domain_state_colour = ansiprint.yellow()
|
||||
elif node_domain_state[node_name] == 'ready':
|
||||
domain_state_colour = ansiiprint.green()
|
||||
domain_state_colour = ansiprint.green()
|
||||
else:
|
||||
domain_state_colour = ansiiprint.blue()
|
||||
domain_state_colour = ansiprint.blue()
|
||||
|
||||
node_list_output.append(
|
||||
'{bold}{node_name: <{node_name_length}} \
|
||||
|
@ -355,7 +355,7 @@ RAM (MiB): {node_mem_total: <6} {node_mem_used: <6} {node_mem_free: <6} {node_me
|
|||
daemon_state_colour=daemon_state_colour,
|
||||
router_state_colour=router_state_colour,
|
||||
domain_state_colour=domain_state_colour,
|
||||
end_colour=ansiiprint.end(),
|
||||
end_colour=ansiprint.end(),
|
||||
node_name=node_name,
|
||||
node_daemon_state=node_daemon_state[node_name],
|
||||
node_router_state=node_router_state[node_name],
|
||||
|
|
|
@ -33,7 +33,7 @@ import lxml.objectify
|
|||
import configparser
|
||||
import kazoo.client
|
||||
|
||||
import client_lib.ansiiprint as ansiiprint
|
||||
import client_lib.ansiprint as ansiprint
|
||||
import client_lib.zkhandler as zkhandler
|
||||
import client_lib.common as common
|
||||
|
||||
|
@ -64,39 +64,39 @@ def getInformationFromXML(zk_conn, uuid, long_output):
|
|||
|
||||
# Format a nice output; do this line-by-line then concat the elements at the end
|
||||
ainformation = []
|
||||
ainformation.append('{}Virtual machine information:{}'.format(ansiiprint.bold(), ansiiprint.end()))
|
||||
ainformation.append('{}Virtual machine information:{}'.format(ansiprint.bold(), ansiprint.end()))
|
||||
ainformation.append('')
|
||||
# Basic information
|
||||
ainformation.append('{}UUID:{} {}'.format(ansiiprint.purple(), ansiiprint.end(), duuid))
|
||||
ainformation.append('{}Name:{} {}'.format(ansiiprint.purple(), ansiiprint.end(), dname))
|
||||
ainformation.append('{}Description:{} {}'.format(ansiiprint.purple(), ansiiprint.end(), ddescription))
|
||||
ainformation.append('{}Memory (MiB):{} {}'.format(ansiiprint.purple(), ansiiprint.end(), dmemory))
|
||||
ainformation.append('{}vCPUs:{} {}'.format(ansiiprint.purple(), ansiiprint.end(), dvcpu))
|
||||
ainformation.append('{}Topology (S/C/T):{} {}'.format(ansiiprint.purple(), ansiiprint.end(), dvcputopo))
|
||||
ainformation.append('{}UUID:{} {}'.format(ansiprint.purple(), ansiprint.end(), duuid))
|
||||
ainformation.append('{}Name:{} {}'.format(ansiprint.purple(), ansiprint.end(), dname))
|
||||
ainformation.append('{}Description:{} {}'.format(ansiprint.purple(), ansiprint.end(), ddescription))
|
||||
ainformation.append('{}Memory (MiB):{} {}'.format(ansiprint.purple(), ansiprint.end(), dmemory))
|
||||
ainformation.append('{}vCPUs:{} {}'.format(ansiprint.purple(), ansiprint.end(), dvcpu))
|
||||
ainformation.append('{}Topology (S/C/T):{} {}'.format(ansiprint.purple(), ansiprint.end(), dvcputopo))
|
||||
|
||||
if long_output == True:
|
||||
# Virtualization information
|
||||
ainformation.append('')
|
||||
ainformation.append('{}Emulator:{} {}'.format(ansiiprint.purple(), ansiiprint.end(), demulator))
|
||||
ainformation.append('{}Type:{} {}'.format(ansiiprint.purple(), ansiiprint.end(), dtype))
|
||||
ainformation.append('{}Arch:{} {}'.format(ansiiprint.purple(), ansiiprint.end(), darch))
|
||||
ainformation.append('{}Machine:{} {}'.format(ansiiprint.purple(), ansiiprint.end(), dmachine))
|
||||
ainformation.append('{}Features:{} {}'.format(ansiiprint.purple(), ansiiprint.end(), ' '.join(dfeatures)))
|
||||
ainformation.append('{}Emulator:{} {}'.format(ansiprint.purple(), ansiprint.end(), demulator))
|
||||
ainformation.append('{}Type:{} {}'.format(ansiprint.purple(), ansiprint.end(), dtype))
|
||||
ainformation.append('{}Arch:{} {}'.format(ansiprint.purple(), ansiprint.end(), darch))
|
||||
ainformation.append('{}Machine:{} {}'.format(ansiprint.purple(), ansiprint.end(), dmachine))
|
||||
ainformation.append('{}Features:{} {}'.format(ansiprint.purple(), ansiprint.end(), ' '.join(dfeatures)))
|
||||
|
||||
# PVC cluster information
|
||||
ainformation.append('')
|
||||
dstate_colour = {
|
||||
'start': ansiiprint.green(),
|
||||
'restart': ansiiprint.yellow(),
|
||||
'shutdown': ansiiprint.yellow(),
|
||||
'stop': ansiiprint.red(),
|
||||
'failed': ansiiprint.red(),
|
||||
'migrate': ansiiprint.blue(),
|
||||
'unmigrate': ansiiprint.blue()
|
||||
'start': ansiprint.green(),
|
||||
'restart': ansiprint.yellow(),
|
||||
'shutdown': ansiprint.yellow(),
|
||||
'stop': ansiprint.red(),
|
||||
'failed': ansiprint.red(),
|
||||
'migrate': ansiprint.blue(),
|
||||
'unmigrate': ansiprint.blue()
|
||||
}
|
||||
ainformation.append('{}State:{} {}{}{}'.format(ansiiprint.purple(), ansiiprint.end(), dstate_colour[dstate], dstate, ansiiprint.end()))
|
||||
ainformation.append('{}Current Node:{} {}'.format(ansiiprint.purple(), ansiiprint.end(), dnode))
|
||||
ainformation.append('{}Previous Node:{} {}'.format(ansiiprint.purple(), ansiiprint.end(), dlastnode))
|
||||
ainformation.append('{}State:{} {}{}{}'.format(ansiprint.purple(), ansiprint.end(), dstate_colour[dstate], dstate, ansiprint.end()))
|
||||
ainformation.append('{}Current Node:{} {}'.format(ansiprint.purple(), ansiprint.end(), dnode))
|
||||
ainformation.append('{}Previous Node:{} {}'.format(ansiprint.purple(), ansiprint.end(), dlastnode))
|
||||
|
||||
# Network list
|
||||
net_list = []
|
||||
|
@ -105,11 +105,11 @@ def getInformationFromXML(zk_conn, uuid, long_output):
|
|||
net_vni = re.findall(r'\d+', net['source'])[0]
|
||||
net_exists = zkhandler.exists(zk_conn, '/networks/{}'.format(net_vni))
|
||||
if not net_exists:
|
||||
net_list.append(ansiiprint.red() + net_vni + ansiiprint.end() + ' [invalid]')
|
||||
net_list.append(ansiprint.red() + net_vni + ansiprint.end() + ' [invalid]')
|
||||
else:
|
||||
net_list.append(net_vni)
|
||||
ainformation.append('')
|
||||
ainformation.append('{}Networks:{} {}'.format(ansiiprint.purple(), ansiiprint.end(), ', '.join(net_list)))
|
||||
ainformation.append('{}Networks:{} {}'.format(ansiprint.purple(), ansiprint.end(), ', '.join(net_list)))
|
||||
|
||||
if long_output == True:
|
||||
# Disk list
|
||||
|
@ -119,16 +119,16 @@ def getInformationFromXML(zk_conn, uuid, long_output):
|
|||
_name_length = len(disk['name']) + 1
|
||||
if _name_length > name_length:
|
||||
name_length = _name_length
|
||||
ainformation.append('{0}Disks:{1} {2}ID Type {3: <{width}} Dev Bus{4}'.format(ansiiprint.purple(), ansiiprint.end(), ansiiprint.bold(), 'Name', ansiiprint.end(), width=name_length))
|
||||
ainformation.append('{0}Disks:{1} {2}ID Type {3: <{width}} Dev Bus{4}'.format(ansiprint.purple(), ansiprint.end(), ansiprint.bold(), 'Name', ansiprint.end(), width=name_length))
|
||||
for disk in ddisks:
|
||||
ainformation.append(' {0: <3} {1: <5} {2: <{width}} {3: <4} {4: <5}'.format(ddisks.index(disk), disk['type'], disk['name'], disk['dev'], disk['bus'], width=name_length))
|
||||
ainformation.append('')
|
||||
ainformation.append('{}Interfaces:{} {}ID Type Source Model MAC{}'.format(ansiiprint.purple(), ansiiprint.end(), ansiiprint.bold(), ansiiprint.end()))
|
||||
ainformation.append('{}Interfaces:{} {}ID Type Source Model MAC{}'.format(ansiprint.purple(), ansiprint.end(), ansiprint.bold(), ansiprint.end()))
|
||||
for net in dnets:
|
||||
ainformation.append(' {0: <3} {1: <8} {2: <10} {3: <8} {4}'.format(dnets.index(net), net['type'], net['source'], net['model'], net['mac']))
|
||||
# Controller list
|
||||
ainformation.append('')
|
||||
ainformation.append('{}Controllers:{} {}ID Type Model{}'.format(ansiiprint.purple(), ansiiprint.end(), ansiiprint.bold(), ansiiprint.end()))
|
||||
ainformation.append('{}Controllers:{} {}ID Type Model{}'.format(ansiprint.purple(), ansiprint.end(), ansiprint.bold(), ansiprint.end()))
|
||||
for controller in dcontrollers:
|
||||
ainformation.append(' {0: <3} {1: <14} {2: <8}'.format(dcontrollers.index(controller), controller['type'], controller['model']))
|
||||
|
||||
|
@ -476,7 +476,7 @@ def get_info(zk_conn, domain, long_output):
|
|||
failedreason = zk_conn.get('/domains/{}/failedreason'.format(dom_uuid))[0].decode('ascii')
|
||||
if failedreason != '':
|
||||
click.echo('')
|
||||
click.echo('{}Failure reason:{} {}'.format(ansiiprint.purple(), ansiiprint.end(), failedreason))
|
||||
click.echo('{}Failure reason:{} {}'.format(ansiprint.purple(), ansiprint.end(), failedreason))
|
||||
|
||||
click.echo('')
|
||||
|
||||
|
@ -596,8 +596,8 @@ def get_list(zk_conn, node, limit):
|
|||
vm_node_length=vm_node_length,
|
||||
vm_nets_length=vm_nets_length,
|
||||
vm_migrated_length=vm_migrated_length,
|
||||
bold=ansiiprint.bold(),
|
||||
end_bold=ansiiprint.end(),
|
||||
bold=ansiprint.bold(),
|
||||
end_bold=ansiprint.end(),
|
||||
vm_state_colour='',
|
||||
end_colour='',
|
||||
vm_name='Name',
|
||||
|
@ -614,26 +614,26 @@ def get_list(zk_conn, node, limit):
|
|||
# Format the string (elements)
|
||||
for vm in vm_list:
|
||||
if vm_state[vm] == 'start':
|
||||
vm_state_colour = ansiiprint.green()
|
||||
vm_state_colour = ansiprint.green()
|
||||
elif vm_state[vm] == 'restart':
|
||||
vm_state_colour = ansiiprint.yellow()
|
||||
vm_state_colour = ansiprint.yellow()
|
||||
elif vm_state[vm] == 'shutdown':
|
||||
vm_state_colour = ansiiprint.yellow()
|
||||
vm_state_colour = ansiprint.yellow()
|
||||
elif vm_state[vm] == 'stop':
|
||||
vm_state_colour = ansiiprint.red()
|
||||
vm_state_colour = ansiprint.red()
|
||||
elif vm_state[vm] == 'failed':
|
||||
vm_state_colour = ansiiprint.red()
|
||||
vm_state_colour = ansiprint.red()
|
||||
else:
|
||||
vm_state_colour = ansiiprint.blue()
|
||||
vm_state_colour = ansiprint.blue()
|
||||
|
||||
# Handle colouring for an invalid network config
|
||||
net_list = []
|
||||
vm_nets_colour = ansiiprint.end()
|
||||
vm_nets_colour = ansiprint.end()
|
||||
for net in vm_nets[vm]:
|
||||
net_exists = zkhandler.exists(zk_conn, '/networks/{}'.format(net))
|
||||
net_list.append(net)
|
||||
if not net_exists:
|
||||
vm_nets_colour = ansiiprint.red()
|
||||
vm_nets_colour = ansiprint.red()
|
||||
vm_nets[vm] = ','.join(net_list)
|
||||
|
||||
vm_list_output.append(
|
||||
|
@ -651,7 +651,7 @@ def get_list(zk_conn, node, limit):
|
|||
end_bold='',
|
||||
vm_state_colour=vm_state_colour,
|
||||
vm_nets_colour=vm_nets_colour,
|
||||
end_colour=ansiiprint.end(),
|
||||
end_colour=ansiprint.end(),
|
||||
vm_name=vm_name[vm],
|
||||
vm_uuid=vm_uuid[vm],
|
||||
vm_state=vm_state[vm],
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
###############################################################################
|
||||
|
||||
import kazoo.client
|
||||
import client_lib.ansiiprint as ansiiprint
|
||||
import client_lib.ansiprint as ansiprint
|
||||
|
||||
# Exists function
|
||||
def exists(zk_conn, key):
|
||||
|
|
Loading…
Reference in New Issue