Lint: E722 do not use bare 'except'
This commit is contained in:
parent
601ab1a181
commit
63f4f9aed7
|
@ -47,7 +47,7 @@ def strtobool(stringv):
|
||||||
return bool(stringv)
|
return bool(stringv)
|
||||||
try:
|
try:
|
||||||
return bool(dustrtobool(stringv))
|
return bool(dustrtobool(stringv))
|
||||||
except:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -134,13 +134,13 @@ def run_benchmark(self, pool):
|
||||||
# Phase 0 - connect to databases
|
# Phase 0 - connect to databases
|
||||||
try:
|
try:
|
||||||
db_conn, db_cur = open_database(config)
|
db_conn, db_cur = open_database(config)
|
||||||
except:
|
except Exception:
|
||||||
print('FATAL - failed to connect to Postgres')
|
print('FATAL - failed to connect to Postgres')
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
try:
|
try:
|
||||||
zk_conn = pvc_common.startZKConnection(config['coordinators'])
|
zk_conn = pvc_common.startZKConnection(config['coordinators'])
|
||||||
except:
|
except Exception:
|
||||||
print('FATAL - failed to connect to Zookeeper')
|
print('FATAL - failed to connect to Zookeeper')
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
|
|
|
@ -53,13 +53,13 @@ def strtobool(stringv):
|
||||||
return bool(stringv)
|
return bool(stringv)
|
||||||
try:
|
try:
|
||||||
return bool(dustrtobool(stringv))
|
return bool(dustrtobool(stringv))
|
||||||
except:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Parse the configuration file
|
# Parse the configuration file
|
||||||
try:
|
try:
|
||||||
pvc_config_file = os.environ['PVC_CONFIG_FILE']
|
pvc_config_file = os.environ['PVC_CONFIG_FILE']
|
||||||
except:
|
except Exception:
|
||||||
print('Error: The "PVC_CONFIG_FILE" environment variable must be set before starting pvcapid.')
|
print('Error: The "PVC_CONFIG_FILE" environment variable must be set before starting pvcapid.')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
@ -4205,11 +4205,11 @@ class API_Provisioner_Template_System_Root(Resource):
|
||||||
# Validate arguments
|
# Validate arguments
|
||||||
try:
|
try:
|
||||||
vcpus = int(reqargs.get('vcpus'))
|
vcpus = int(reqargs.get('vcpus'))
|
||||||
except:
|
except Exception:
|
||||||
return { "message": "A vcpus value must be an integer" }, 400
|
return { "message": "A vcpus value must be an integer" }, 400
|
||||||
try:
|
try:
|
||||||
vram = int(reqargs.get('vram'))
|
vram = int(reqargs.get('vram'))
|
||||||
except:
|
except Exception:
|
||||||
return { "message": "A vram value must be an integer" }, 400
|
return { "message": "A vram value must be an integer" }, 400
|
||||||
# Cast boolean arguments
|
# Cast boolean arguments
|
||||||
if bool(strtobool(reqargs.get('serial', 'false'))):
|
if bool(strtobool(reqargs.get('serial', 'false'))):
|
||||||
|
@ -4345,11 +4345,11 @@ class API_Provisioner_Template_System_Element(Resource):
|
||||||
# Validate arguments
|
# Validate arguments
|
||||||
try:
|
try:
|
||||||
vcpus = int(reqargs.get('vcpus'))
|
vcpus = int(reqargs.get('vcpus'))
|
||||||
except:
|
except Exception:
|
||||||
return { "message": "A vcpus value must be an integer" }, 400
|
return { "message": "A vcpus value must be an integer" }, 400
|
||||||
try:
|
try:
|
||||||
vram = int(reqargs.get('vram'))
|
vram = int(reqargs.get('vram'))
|
||||||
except:
|
except Exception:
|
||||||
return { "message": "A vram value must be an integer" }, 400
|
return { "message": "A vram value must be an integer" }, 400
|
||||||
# Cast boolean arguments
|
# Cast boolean arguments
|
||||||
if bool(strtobool(reqargs.get('serial', False))):
|
if bool(strtobool(reqargs.get('serial', False))):
|
||||||
|
|
|
@ -42,7 +42,7 @@ def strtobool(stringv):
|
||||||
return bool(stringv)
|
return bool(stringv)
|
||||||
try:
|
try:
|
||||||
return bool(dustrtobool(stringv))
|
return bool(dustrtobool(stringv))
|
||||||
except:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -499,7 +499,7 @@ def update_vm_meta(vm, limit, selector, autostart, provisioner_profile, migratio
|
||||||
if autostart is not None:
|
if autostart is not None:
|
||||||
try:
|
try:
|
||||||
autostart = bool(strtobool(autostart))
|
autostart = bool(strtobool(autostart))
|
||||||
except:
|
except Exception:
|
||||||
autostart = False
|
autostart = False
|
||||||
retflag, retdata = pvc_vm.modify_vm_metadata(zk_conn, vm, limit, selector, autostart, provisioner_profile, migration_method)
|
retflag, retdata = pvc_vm.modify_vm_metadata(zk_conn, vm, limit, selector, autostart, provisioner_profile, migration_method)
|
||||||
pvc_common.stopZKConnection(zk_conn)
|
pvc_common.stopZKConnection(zk_conn)
|
||||||
|
@ -1393,7 +1393,7 @@ def ceph_volume_upload(pool, volume, img_type):
|
||||||
# Save the data to the blockdev directly
|
# Save the data to the blockdev directly
|
||||||
try:
|
try:
|
||||||
data.save(dest_blockdev)
|
data.save(dest_blockdev)
|
||||||
except:
|
except Exception:
|
||||||
output = {
|
output = {
|
||||||
'message': "Failed to write image file to volume."
|
'message': "Failed to write image file to volume."
|
||||||
}
|
}
|
||||||
|
@ -1457,7 +1457,7 @@ def ceph_volume_upload(pool, volume, img_type):
|
||||||
def ova_stream_factory(total_content_length, filename, content_type, content_length=None):
|
def ova_stream_factory(total_content_length, filename, content_type, content_length=None):
|
||||||
return open(temp_blockdev, 'wb')
|
return open(temp_blockdev, 'wb')
|
||||||
parse_form_data(flask.request.environ, stream_factory=ova_stream_factory)
|
parse_form_data(flask.request.environ, stream_factory=ova_stream_factory)
|
||||||
except:
|
except Exception:
|
||||||
output = {
|
output = {
|
||||||
'message': "Failed to upload or write image file to temporary volume."
|
'message': "Failed to upload or write image file to temporary volume."
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,7 +233,7 @@ def upload_ova(pool, name, ova_size):
|
||||||
def ova_stream_factory(total_content_length, filename, content_type, content_length=None):
|
def ova_stream_factory(total_content_length, filename, content_type, content_length=None):
|
||||||
return open(ova_blockdev, 'wb')
|
return open(ova_blockdev, 'wb')
|
||||||
parse_form_data(flask.request.environ, stream_factory=ova_stream_factory)
|
parse_form_data(flask.request.environ, stream_factory=ova_stream_factory)
|
||||||
except:
|
except Exception:
|
||||||
output = {
|
output = {
|
||||||
'message': "Failed to upload or write OVA file to temporary volume."
|
'message': "Failed to upload or write OVA file to temporary volume."
|
||||||
}
|
}
|
||||||
|
@ -329,7 +329,7 @@ def upload_ova(pool, name, ova_size):
|
||||||
vmdk_file.close()
|
vmdk_file.close()
|
||||||
# Perform an OS-level sync
|
# Perform an OS-level sync
|
||||||
pvc_common.run_os_command('sync')
|
pvc_common.run_os_command('sync')
|
||||||
except:
|
except Exception:
|
||||||
output = {
|
output = {
|
||||||
'message': "Failed to write image file '{}' to temporary volume.".format(disk.get('src'))
|
'message': "Failed to write image file '{}' to temporary volume.".format(disk.get('src'))
|
||||||
}
|
}
|
||||||
|
@ -493,7 +493,7 @@ class OVFParser(object):
|
||||||
for item in hardware_list:
|
for item in hardware_list:
|
||||||
try:
|
try:
|
||||||
item_type = self.RASD_TYPE[item.find("{{{rasd}}}ResourceType".format(rasd=self.RASD_SCHEMA)).text]
|
item_type = self.RASD_TYPE[item.find("{{{rasd}}}ResourceType".format(rasd=self.RASD_SCHEMA)).text]
|
||||||
except:
|
except Exception:
|
||||||
continue
|
continue
|
||||||
quantity = item.find("{{{rasd}}}VirtualQuantity".format(rasd=self.RASD_SCHEMA))
|
quantity = item.find("{{{rasd}}}VirtualQuantity".format(rasd=self.RASD_SCHEMA))
|
||||||
if quantity is None:
|
if quantity is None:
|
||||||
|
|
|
@ -49,7 +49,7 @@ def strtobool(stringv):
|
||||||
return bool(stringv)
|
return bool(stringv)
|
||||||
try:
|
try:
|
||||||
return bool(dustrtobool(stringv))
|
return bool(dustrtobool(stringv))
|
||||||
except:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -370,7 +370,7 @@ def modify_template_system(name, vcpu_count=None, vram_mb=None, serial=None, vnc
|
||||||
if vcpu_count is not None:
|
if vcpu_count is not None:
|
||||||
try:
|
try:
|
||||||
vcpu_count = int(vcpu_count)
|
vcpu_count = int(vcpu_count)
|
||||||
except:
|
except Exception:
|
||||||
retmsg = { 'message': 'The vcpus value must be an integer.' }
|
retmsg = { 'message': 'The vcpus value must be an integer.' }
|
||||||
retcode = 400
|
retcode = 400
|
||||||
return retmsg, retcode
|
return retmsg, retcode
|
||||||
|
@ -379,7 +379,7 @@ def modify_template_system(name, vcpu_count=None, vram_mb=None, serial=None, vnc
|
||||||
if vram_mb is not None:
|
if vram_mb is not None:
|
||||||
try:
|
try:
|
||||||
vram_mb = int(vram_mb)
|
vram_mb = int(vram_mb)
|
||||||
except:
|
except Exception:
|
||||||
retmsg = { 'message': 'The vram value must be an integer.' }
|
retmsg = { 'message': 'The vram value must be an integer.' }
|
||||||
retcode = 400
|
retcode = 400
|
||||||
return retmsg, retcode
|
return retmsg, retcode
|
||||||
|
@ -388,7 +388,7 @@ def modify_template_system(name, vcpu_count=None, vram_mb=None, serial=None, vnc
|
||||||
if serial is not None:
|
if serial is not None:
|
||||||
try:
|
try:
|
||||||
serial = bool(strtobool(serial))
|
serial = bool(strtobool(serial))
|
||||||
except:
|
except Exception:
|
||||||
retmsg = { 'message': 'The serial value must be a boolean.' }
|
retmsg = { 'message': 'The serial value must be a boolean.' }
|
||||||
retcode = 400
|
retcode = 400
|
||||||
return retmsg, retcode
|
return retmsg, retcode
|
||||||
|
@ -397,7 +397,7 @@ def modify_template_system(name, vcpu_count=None, vram_mb=None, serial=None, vnc
|
||||||
if vnc is not None:
|
if vnc is not None:
|
||||||
try:
|
try:
|
||||||
vnc = bool(strtobool(vnc))
|
vnc = bool(strtobool(vnc))
|
||||||
except:
|
except Exception:
|
||||||
retmsg = { 'message': 'The vnc value must be a boolean.' }
|
retmsg = { 'message': 'The vnc value must be a boolean.' }
|
||||||
retcode = 400
|
retcode = 400
|
||||||
return retmsg, retcode
|
return retmsg, retcode
|
||||||
|
@ -415,7 +415,7 @@ def modify_template_system(name, vcpu_count=None, vram_mb=None, serial=None, vnc
|
||||||
if node_autostart is not None:
|
if node_autostart is not None:
|
||||||
try:
|
try:
|
||||||
node_autostart = bool(strtobool(node_autostart))
|
node_autostart = bool(strtobool(node_autostart))
|
||||||
except:
|
except Exception:
|
||||||
retmsg = { 'message': 'The node_autostart value must be a boolean.' }
|
retmsg = { 'message': 'The node_autostart value must be a boolean.' }
|
||||||
retcode = 400
|
retcode = 400
|
||||||
fields.append({'field': 'node_autostart', 'data': node_autostart})
|
fields.append({'field': 'node_autostart', 'data': node_autostart})
|
||||||
|
@ -1044,13 +1044,13 @@ def create_vm(self, vm_name, vm_profile, define_vm=True, start_vm=True, script_r
|
||||||
# Phase 0 - connect to databases
|
# Phase 0 - connect to databases
|
||||||
try:
|
try:
|
||||||
db_conn, db_cur = open_database(config)
|
db_conn, db_cur = open_database(config)
|
||||||
except:
|
except Exception:
|
||||||
print('FATAL - failed to connect to Postgres')
|
print('FATAL - failed to connect to Postgres')
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
try:
|
try:
|
||||||
zk_conn = pvc_common.startZKConnection(config['coordinators'])
|
zk_conn = pvc_common.startZKConnection(config['coordinators'])
|
||||||
except:
|
except Exception:
|
||||||
print('FATAL - failed to connect to Zookeeper')
|
print('FATAL - failed to connect to Zookeeper')
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
|
@ -1212,7 +1212,7 @@ def create_vm(self, vm_name, vm_profile, define_vm=True, start_vm=True, script_r
|
||||||
pool_information = pvc_ceph.getPoolInformation(zk_conn, pool)
|
pool_information = pvc_ceph.getPoolInformation(zk_conn, pool)
|
||||||
if not pool_information:
|
if not pool_information:
|
||||||
raise
|
raise
|
||||||
except:
|
except Exception:
|
||||||
raise ClusterError('Pool "{}" is not present on the cluster.'.format(pool))
|
raise ClusterError('Pool "{}" is not present on the cluster.'.format(pool))
|
||||||
pool_free_space_gb = int(pool_information['stats']['free_bytes'] / 1024 / 1024 / 1024)
|
pool_free_space_gb = int(pool_information['stats']['free_bytes'] / 1024 / 1024 / 1024)
|
||||||
pool_vm_usage_gb = int(pools[pool])
|
pool_vm_usage_gb = int(pools[pool])
|
||||||
|
|
|
@ -1471,7 +1471,7 @@ def format_info_benchmark(config, benchmark_information):
|
||||||
for element in benchmark_details[test]['bandwidth']:
|
for element in benchmark_details[test]['bandwidth']:
|
||||||
try:
|
try:
|
||||||
_element_length = len(format_bytes_tohuman(int(float(benchmark_details[test]['bandwidth'][element]))))
|
_element_length = len(format_bytes_tohuman(int(float(benchmark_details[test]['bandwidth'][element]))))
|
||||||
except:
|
except Exception:
|
||||||
_element_length = len(benchmark_details[test]['bandwidth'][element])
|
_element_length = len(benchmark_details[test]['bandwidth'][element])
|
||||||
if _element_length > bandwidth_column_length:
|
if _element_length > bandwidth_column_length:
|
||||||
bandwidth_column_length = _element_length
|
bandwidth_column_length = _element_length
|
||||||
|
@ -1479,7 +1479,7 @@ def format_info_benchmark(config, benchmark_information):
|
||||||
for element in benchmark_details[test]['iops']:
|
for element in benchmark_details[test]['iops']:
|
||||||
try:
|
try:
|
||||||
_element_length = len(format_ops_tohuman(int(float(benchmark_details[test]['iops'][element]))))
|
_element_length = len(format_ops_tohuman(int(float(benchmark_details[test]['iops'][element]))))
|
||||||
except:
|
except Exception:
|
||||||
_element_length = len(benchmark_details[test]['iops'][element])
|
_element_length = len(benchmark_details[test]['iops'][element])
|
||||||
if _element_length > iops_column_length:
|
if _element_length > iops_column_length:
|
||||||
iops_column_length = _element_length
|
iops_column_length = _element_length
|
||||||
|
|
|
@ -301,7 +301,7 @@ def follow_console_log(config, vm, lines=10):
|
||||||
try:
|
try:
|
||||||
response = call_api(config, 'get', '/vm/{vm}/console'.format(vm=vm), params=params)
|
response = call_api(config, 'get', '/vm/{vm}/console'.format(vm=vm), params=params)
|
||||||
new_console_log = response.json()['data']
|
new_console_log = response.json()['data']
|
||||||
except:
|
except Exception:
|
||||||
break
|
break
|
||||||
# Split the new and old log strings into constitutent lines
|
# Split the new and old log strings into constitutent lines
|
||||||
old_console_loglines = console_log.split('\n')
|
old_console_loglines = console_log.split('\n')
|
||||||
|
|
|
@ -400,7 +400,7 @@ def node_secondary(node, wait):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
except:
|
except Exception:
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
cleanup(retcode, retmsg)
|
cleanup(retcode, retmsg)
|
||||||
|
|
||||||
|
@ -444,7 +444,7 @@ def node_primary(node, wait):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
except:
|
except Exception:
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
cleanup(retcode, retmsg)
|
cleanup(retcode, retmsg)
|
||||||
|
|
||||||
|
@ -615,7 +615,7 @@ def vm_define(vmconfig, target_node, node_limit, node_selector, node_autostart,
|
||||||
try:
|
try:
|
||||||
xml_data = etree.fromstring(vmconfig_data)
|
xml_data = etree.fromstring(vmconfig_data)
|
||||||
new_cfg = etree.tostring(xml_data, pretty_print=True).decode('utf8')
|
new_cfg = etree.tostring(xml_data, pretty_print=True).decode('utf8')
|
||||||
except:
|
except Exception:
|
||||||
cleanup(False, 'Error: XML is malformed or invalid')
|
cleanup(False, 'Error: XML is malformed or invalid')
|
||||||
|
|
||||||
retcode, retmsg = pvc_vm.vm_define(config, new_cfg, target_node, node_limit, node_selector, node_autostart, migration_method)
|
retcode, retmsg = pvc_vm.vm_define(config, new_cfg, target_node, node_limit, node_selector, node_autostart, migration_method)
|
||||||
|
@ -771,7 +771,7 @@ def vm_undefine(domain, confirm_flag):
|
||||||
if not confirm_flag:
|
if not confirm_flag:
|
||||||
try:
|
try:
|
||||||
click.confirm('Undefine VM {}'.format(domain), prompt_suffix='? ', abort=True)
|
click.confirm('Undefine VM {}'.format(domain), prompt_suffix='? ', abort=True)
|
||||||
except:
|
except Exception:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
retcode, retmsg = pvc_vm.vm_remove(config, domain, delete_disks=False)
|
retcode, retmsg = pvc_vm.vm_remove(config, domain, delete_disks=False)
|
||||||
|
@ -797,7 +797,7 @@ def vm_remove(domain, confirm_flag):
|
||||||
if not confirm_flag:
|
if not confirm_flag:
|
||||||
try:
|
try:
|
||||||
click.confirm('Undefine VM {} and remove all disks'.format(domain), prompt_suffix='? ', abort=True)
|
click.confirm('Undefine VM {} and remove all disks'.format(domain), prompt_suffix='? ', abort=True)
|
||||||
except:
|
except Exception:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
retcode, retmsg = pvc_vm.vm_remove(config, domain, delete_disks=True)
|
retcode, retmsg = pvc_vm.vm_remove(config, domain, delete_disks=True)
|
||||||
|
@ -1296,7 +1296,7 @@ def net_remove(net, confirm_flag):
|
||||||
if not confirm_flag:
|
if not confirm_flag:
|
||||||
try:
|
try:
|
||||||
click.confirm('Remove network {}'.format(net), prompt_suffix='? ', abort=True)
|
click.confirm('Remove network {}'.format(net), prompt_suffix='? ', abort=True)
|
||||||
except:
|
except Exception:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
retcode, retmsg = pvc_network.net_remove(config, net)
|
retcode, retmsg = pvc_network.net_remove(config, net)
|
||||||
|
@ -1399,7 +1399,7 @@ def net_dhcp_remove(net, macaddr, confirm_flag):
|
||||||
if not confirm_flag:
|
if not confirm_flag:
|
||||||
try:
|
try:
|
||||||
click.confirm('Remove DHCP lease for {} in network {}'.format(macaddr, net), prompt_suffix='? ', abort=True)
|
click.confirm('Remove DHCP lease for {} in network {}'.format(macaddr, net), prompt_suffix='? ', abort=True)
|
||||||
except:
|
except Exception:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
retcode, retmsg = pvc_network.net_dhcp_remove(config, net, macaddr)
|
retcode, retmsg = pvc_network.net_dhcp_remove(config, net, macaddr)
|
||||||
|
@ -1513,7 +1513,7 @@ def net_acl_remove(net, rule, confirm_flag):
|
||||||
if not confirm_flag:
|
if not confirm_flag:
|
||||||
try:
|
try:
|
||||||
click.confirm('Remove ACL {} in network {}'.format(rule, net), prompt_suffix='? ', abort=True)
|
click.confirm('Remove ACL {} in network {}'.format(rule, net), prompt_suffix='? ', abort=True)
|
||||||
except:
|
except Exception:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
retcode, retmsg = pvc_network.net_acl_remove(config, net, rule)
|
retcode, retmsg = pvc_network.net_acl_remove(config, net, rule)
|
||||||
|
@ -1621,7 +1621,7 @@ def ceph_benchmark_run(pool):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
click.confirm('NOTE: Storage benchmarks generate significant load on the cluster and can take a very long time to complete on slow storage. They should be run sparingly. Continue', prompt_suffix='? ', abort=True)
|
click.confirm('NOTE: Storage benchmarks generate significant load on the cluster and can take a very long time to complete on slow storage. They should be run sparingly. Continue', prompt_suffix='? ', abort=True)
|
||||||
except:
|
except Exception:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
retcode, retmsg = pvc_ceph.ceph_benchmark_run(config, pool)
|
retcode, retmsg = pvc_ceph.ceph_benchmark_run(config, pool)
|
||||||
|
@ -1700,7 +1700,7 @@ def ceph_osd_add(node, device, weight, confirm_flag):
|
||||||
if not confirm_flag:
|
if not confirm_flag:
|
||||||
try:
|
try:
|
||||||
click.confirm('Destroy all data and create a new OSD on {}:{}'.format(node, device), prompt_suffix='? ', abort=True)
|
click.confirm('Destroy all data and create a new OSD on {}:{}'.format(node, device), prompt_suffix='? ', abort=True)
|
||||||
except:
|
except Exception:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
retcode, retmsg = pvc_ceph.ceph_osd_add(config, node, device, weight)
|
retcode, retmsg = pvc_ceph.ceph_osd_add(config, node, device, weight)
|
||||||
|
@ -1728,7 +1728,7 @@ def ceph_osd_remove(osdid, confirm_flag):
|
||||||
if not confirm_flag:
|
if not confirm_flag:
|
||||||
try:
|
try:
|
||||||
click.confirm('Remove OSD {}'.format(osdid), prompt_suffix='? ', abort=True)
|
click.confirm('Remove OSD {}'.format(osdid), prompt_suffix='? ', abort=True)
|
||||||
except:
|
except Exception:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
retcode, retmsg = pvc_ceph.ceph_osd_remove(config, osdid)
|
retcode, retmsg = pvc_ceph.ceph_osd_remove(config, osdid)
|
||||||
|
@ -1883,7 +1883,7 @@ def ceph_pool_remove(name, confirm_flag):
|
||||||
if not confirm_flag:
|
if not confirm_flag:
|
||||||
try:
|
try:
|
||||||
click.confirm('Remove RBD pool {}'.format(name), prompt_suffix='? ', abort=True)
|
click.confirm('Remove RBD pool {}'.format(name), prompt_suffix='? ', abort=True)
|
||||||
except:
|
except Exception:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
retcode, retmsg = pvc_ceph.ceph_pool_remove(config, name)
|
retcode, retmsg = pvc_ceph.ceph_pool_remove(config, name)
|
||||||
|
@ -1998,7 +1998,7 @@ def ceph_volume_remove(pool, name, confirm_flag):
|
||||||
if not confirm_flag:
|
if not confirm_flag:
|
||||||
try:
|
try:
|
||||||
click.confirm('Remove volume {}/{}'.format(pool, name), prompt_suffix='? ', abort=True)
|
click.confirm('Remove volume {}/{}'.format(pool, name), prompt_suffix='? ', abort=True)
|
||||||
except:
|
except Exception:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
retcode, retmsg = pvc_ceph.ceph_volume_remove(config, pool, name)
|
retcode, retmsg = pvc_ceph.ceph_volume_remove(config, pool, name)
|
||||||
|
@ -2173,7 +2173,7 @@ def ceph_volume_snapshot_remove(pool, volume, name, confirm_flag):
|
||||||
if not confirm_flag:
|
if not confirm_flag:
|
||||||
try:
|
try:
|
||||||
click.confirm('Remove snapshot {} for volume {}/{}'.format(name, pool, volume), prompt_suffix='? ', abort=True)
|
click.confirm('Remove snapshot {} for volume {}/{}'.format(name, pool, volume), prompt_suffix='? ', abort=True)
|
||||||
except:
|
except Exception:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
retcode, retmsg = pvc_ceph.ceph_snapshot_remove(config, pool, volume, name)
|
retcode, retmsg = pvc_ceph.ceph_snapshot_remove(config, pool, volume, name)
|
||||||
|
@ -2439,7 +2439,7 @@ def provisioner_template_system_remove(name, confirm_flag):
|
||||||
if not confirm_flag:
|
if not confirm_flag:
|
||||||
try:
|
try:
|
||||||
click.confirm('Remove system template {}'.format(name), prompt_suffix='? ', abort=True)
|
click.confirm('Remove system template {}'.format(name), prompt_suffix='? ', abort=True)
|
||||||
except:
|
except Exception:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
retcode, retdata = pvc_provisioner.template_remove(config, name, template_type='system')
|
retcode, retdata = pvc_provisioner.template_remove(config, name, template_type='system')
|
||||||
|
@ -2542,7 +2542,7 @@ def provisioner_template_network_remove(name, confirm_flag):
|
||||||
if not confirm_flag:
|
if not confirm_flag:
|
||||||
try:
|
try:
|
||||||
click.confirm('Remove network template {}'.format(name), prompt_suffix='? ', abort=True)
|
click.confirm('Remove network template {}'.format(name), prompt_suffix='? ', abort=True)
|
||||||
except:
|
except Exception:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
retcode, retdata = pvc_provisioner.template_remove(config, name, template_type='network')
|
retcode, retdata = pvc_provisioner.template_remove(config, name, template_type='network')
|
||||||
|
@ -2602,7 +2602,7 @@ def provisioner_template_network_vni_remove(name, vni, confirm_flag):
|
||||||
if not confirm_flag:
|
if not confirm_flag:
|
||||||
try:
|
try:
|
||||||
click.confirm('Remove VNI {} from network template {}'.format(vni, name), prompt_suffix='? ', abort=True)
|
click.confirm('Remove VNI {} from network template {}'.format(vni, name), prompt_suffix='? ', abort=True)
|
||||||
except:
|
except Exception:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
retcode, retdata = pvc_provisioner.template_element_remove(config, name, vni, element_type='net', template_type='network')
|
retcode, retdata = pvc_provisioner.template_element_remove(config, name, vni, element_type='net', template_type='network')
|
||||||
|
@ -2673,7 +2673,7 @@ def provisioner_template_storage_remove(name, confirm_flag):
|
||||||
if not confirm_flag:
|
if not confirm_flag:
|
||||||
try:
|
try:
|
||||||
click.confirm('Remove storage template {}'.format(name), prompt_suffix='? ', abort=True)
|
click.confirm('Remove storage template {}'.format(name), prompt_suffix='? ', abort=True)
|
||||||
except:
|
except Exception:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
retcode, retdata = pvc_provisioner.template_remove(config, name, template_type='storage')
|
retcode, retdata = pvc_provisioner.template_remove(config, name, template_type='storage')
|
||||||
|
@ -2788,7 +2788,7 @@ def provisioner_template_storage_disk_remove(name, disk, confirm_flag):
|
||||||
if not confirm_flag:
|
if not confirm_flag:
|
||||||
try:
|
try:
|
||||||
click.confirm('Remove disk {} from storage template {}'.format(disk, name), prompt_suffix='? ', abort=True)
|
click.confirm('Remove disk {} from storage template {}'.format(disk, name), prompt_suffix='? ', abort=True)
|
||||||
except:
|
except Exception:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
retcode, retdata = pvc_provisioner.template_element_remove(config, name, disk, element_type='disk', template_type='storage')
|
retcode, retdata = pvc_provisioner.template_element_remove(config, name, disk, element_type='disk', template_type='storage')
|
||||||
|
@ -2972,7 +2972,7 @@ def provisioner_userdata_remove(name, confirm_flag):
|
||||||
if not confirm_flag:
|
if not confirm_flag:
|
||||||
try:
|
try:
|
||||||
click.confirm('Remove userdata document {}'.format(name), prompt_suffix='? ', abort=True)
|
click.confirm('Remove userdata document {}'.format(name), prompt_suffix='? ', abort=True)
|
||||||
except:
|
except Exception:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
retcode, retdata = pvc_provisioner.userdata_remove(config, name)
|
retcode, retdata = pvc_provisioner.userdata_remove(config, name)
|
||||||
|
@ -3145,7 +3145,7 @@ def provisioner_script_remove(name, confirm_flag):
|
||||||
if not confirm_flag:
|
if not confirm_flag:
|
||||||
try:
|
try:
|
||||||
click.confirm('Remove provisioning script {}'.format(name), prompt_suffix='? ', abort=True)
|
click.confirm('Remove provisioning script {}'.format(name), prompt_suffix='? ', abort=True)
|
||||||
except:
|
except Exception:
|
||||||
exit(0)
|
exit(0)
|
||||||
params = dict()
|
params = dict()
|
||||||
|
|
||||||
|
@ -3238,7 +3238,7 @@ def provisioner_ova_remove(name, confirm_flag):
|
||||||
if not confirm_flag:
|
if not confirm_flag:
|
||||||
try:
|
try:
|
||||||
click.confirm('Remove OVA image {}'.format(name), prompt_suffix='? ', abort=True)
|
click.confirm('Remove OVA image {}'.format(name), prompt_suffix='? ', abort=True)
|
||||||
except:
|
except Exception:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
retcode, retdata = pvc_provisioner.ova_remove(config, name)
|
retcode, retdata = pvc_provisioner.ova_remove(config, name)
|
||||||
|
@ -3418,7 +3418,7 @@ def provisioner_profile_remove(name, confirm_flag):
|
||||||
if not confirm_flag:
|
if not confirm_flag:
|
||||||
try:
|
try:
|
||||||
click.confirm('Remove profile {}'.format(name), prompt_suffix='? ', abort=True)
|
click.confirm('Remove profile {}'.format(name), prompt_suffix='? ', abort=True)
|
||||||
except:
|
except Exception:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
retcode, retdata = pvc_provisioner.profile_remove(config, name)
|
retcode, retdata = pvc_provisioner.profile_remove(config, name)
|
||||||
|
@ -3614,7 +3614,7 @@ def init_cluster(confirm_flag):
|
||||||
if not confirm_flag:
|
if not confirm_flag:
|
||||||
try:
|
try:
|
||||||
click.confirm('Remove all existing cluster data from coordinators and initialize a new cluster'.format(name), prompt_suffix='? ', abort=True)
|
click.confirm('Remove all existing cluster data from coordinators and initialize a new cluster'.format(name), prompt_suffix='? ', abort=True)
|
||||||
except:
|
except Exception:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
# Easter-egg
|
# Easter-egg
|
||||||
|
|
|
@ -223,7 +223,7 @@ def remove_osd(zk_conn, logger, osd_id, osd_obj):
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
except:
|
except Exception:
|
||||||
break
|
break
|
||||||
|
|
||||||
# 3. Stop the OSD process and wait for it to be terminated
|
# 3. Stop the OSD process and wait for it to be terminated
|
||||||
|
|
|
@ -337,7 +337,7 @@ class AXFRDaemonInstance(object):
|
||||||
# Set up our SQL cursor
|
# Set up our SQL cursor
|
||||||
try:
|
try:
|
||||||
sql_curs = self.sql_conn.cursor()
|
sql_curs = self.sql_conn.cursor()
|
||||||
except:
|
except Exception:
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ def stopKeepaliveTimer():
|
||||||
try:
|
try:
|
||||||
update_timer.shutdown()
|
update_timer.shutdown()
|
||||||
logger.out('Stopping keepalive timer', state='s')
|
logger.out('Stopping keepalive timer', state='s')
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -100,7 +100,7 @@ def stopKeepaliveTimer():
|
||||||
# Get the config file variable from the environment
|
# Get the config file variable from the environment
|
||||||
try:
|
try:
|
||||||
pvcnoded_config_file = os.environ['PVCD_CONFIG_FILE']
|
pvcnoded_config_file = os.environ['PVCD_CONFIG_FILE']
|
||||||
except:
|
except Exception:
|
||||||
print('ERROR: The "PVCD_CONFIG_FILE" environment variable must be set before starting pvcnoded.')
|
print('ERROR: The "PVCD_CONFIG_FILE" environment variable must be set before starting pvcnoded.')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ def readConfig(pvcnoded_config_file, myhostname):
|
||||||
config_debug = {
|
config_debug = {
|
||||||
'debug': o_config['pvc']['debug']
|
'debug': o_config['pvc']['debug']
|
||||||
}
|
}
|
||||||
except:
|
except Exception:
|
||||||
config_debug = {
|
config_debug = {
|
||||||
'debug': False
|
'debug': False
|
||||||
}
|
}
|
||||||
|
@ -535,7 +535,7 @@ def zk_listener(state):
|
||||||
_zk_conn = kazoo.client.KazooClient(hosts=config['coordinators'])
|
_zk_conn = kazoo.client.KazooClient(hosts=config['coordinators'])
|
||||||
try:
|
try:
|
||||||
_zk_conn.start()
|
_zk_conn.start()
|
||||||
except:
|
except Exception:
|
||||||
del _zk_conn
|
del _zk_conn
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -586,7 +586,7 @@ def cleanup():
|
||||||
logger.out('Waiting for primary migration', state='s')
|
logger.out('Waiting for primary migration', state='s')
|
||||||
while this_node.router_state != 'secondary':
|
while this_node.router_state != 'secondary':
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Stop keepalive thread
|
# Stop keepalive thread
|
||||||
|
@ -610,7 +610,7 @@ def cleanup():
|
||||||
try:
|
try:
|
||||||
zk_conn.stop()
|
zk_conn.stop()
|
||||||
zk_conn.close()
|
zk_conn.close()
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
logger.out('Terminated pvc daemon', state='s')
|
logger.out('Terminated pvc daemon', state='s')
|
||||||
|
@ -829,7 +829,7 @@ def set_maintenance(_maintenance, stat, event=''):
|
||||||
global maintenance
|
global maintenance
|
||||||
try:
|
try:
|
||||||
maintenance = bool(strtobool(_maintenance.decode('ascii')))
|
maintenance = bool(strtobool(_maintenance.decode('ascii')))
|
||||||
except:
|
except Exception:
|
||||||
maintenance = False
|
maintenance = False
|
||||||
|
|
||||||
# Primary node
|
# Primary node
|
||||||
|
@ -1371,7 +1371,7 @@ def collect_vm_stats(queue):
|
||||||
if debug:
|
if debug:
|
||||||
try:
|
try:
|
||||||
logger.out("Failed getting VM information for {}: {}".format(domain.name(), e), state='d', prefix='vm-thread')
|
logger.out("Failed getting VM information for {}: {}".format(domain.name(), e), state='d', prefix='vm-thread')
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -1462,7 +1462,7 @@ def node_keepalive():
|
||||||
try:
|
try:
|
||||||
if zkhandler.readdata(zk_conn, '/upstream_ip') != config['upstream_floating_ip']:
|
if zkhandler.readdata(zk_conn, '/upstream_ip') != config['upstream_floating_ip']:
|
||||||
raise
|
raise
|
||||||
except:
|
except Exception:
|
||||||
zkhandler.writedata(zk_conn, {'/upstream_ip': config['upstream_floating_ip']})
|
zkhandler.writedata(zk_conn, {'/upstream_ip': config['upstream_floating_ip']})
|
||||||
|
|
||||||
# Get past state and update if needed
|
# Get past state and update if needed
|
||||||
|
@ -1517,7 +1517,7 @@ def node_keepalive():
|
||||||
this_node.memalloc = vm_thread_queue.get()
|
this_node.memalloc = vm_thread_queue.get()
|
||||||
this_node.memprov = vm_thread_queue.get()
|
this_node.memprov = vm_thread_queue.get()
|
||||||
this_node.vcpualloc = vm_thread_queue.get()
|
this_node.vcpualloc = vm_thread_queue.get()
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
this_node.domains_count = 0
|
this_node.domains_count = 0
|
||||||
|
@ -1530,7 +1530,7 @@ def node_keepalive():
|
||||||
ceph_health_colour = ceph_thread_queue.get()
|
ceph_health_colour = ceph_thread_queue.get()
|
||||||
ceph_health = ceph_thread_queue.get()
|
ceph_health = ceph_thread_queue.get()
|
||||||
osds_this_node = ceph_thread_queue.get()
|
osds_this_node = ceph_thread_queue.get()
|
||||||
except:
|
except Exception:
|
||||||
ceph_health_colour = fmt_cyan
|
ceph_health_colour = fmt_cyan
|
||||||
ceph_health = 'UNKNOWN'
|
ceph_health = 'UNKNOWN'
|
||||||
osds_this_node = '?'
|
osds_this_node = '?'
|
||||||
|
@ -1552,7 +1552,7 @@ def node_keepalive():
|
||||||
'/nodes/{}/runningdomains'.format(this_node.name): ' '.join(this_node.domain_list),
|
'/nodes/{}/runningdomains'.format(this_node.name): ' '.join(this_node.domain_list),
|
||||||
'/nodes/{}/keepalive'.format(this_node.name): str(keepalive_time)
|
'/nodes/{}/keepalive'.format(this_node.name): str(keepalive_time)
|
||||||
})
|
})
|
||||||
except:
|
except Exception:
|
||||||
logger.out('Failed to set keepalive data', state='e')
|
logger.out('Failed to set keepalive data', state='e')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -1623,7 +1623,7 @@ def node_keepalive():
|
||||||
node_daemon_state = zkhandler.readdata(zk_conn, '/nodes/{}/daemonstate'.format(node_name))
|
node_daemon_state = zkhandler.readdata(zk_conn, '/nodes/{}/daemonstate'.format(node_name))
|
||||||
node_domain_state = zkhandler.readdata(zk_conn, '/nodes/{}/domainstate'.format(node_name))
|
node_domain_state = zkhandler.readdata(zk_conn, '/nodes/{}/domainstate'.format(node_name))
|
||||||
node_keepalive = int(zkhandler.readdata(zk_conn, '/nodes/{}/keepalive'.format(node_name)))
|
node_keepalive = int(zkhandler.readdata(zk_conn, '/nodes/{}/keepalive'.format(node_name)))
|
||||||
except:
|
except Exception:
|
||||||
node_daemon_state = 'unknown'
|
node_daemon_state = 'unknown'
|
||||||
node_domain_state = 'unknown'
|
node_domain_state = 'unknown'
|
||||||
node_keepalive = 0
|
node_keepalive = 0
|
||||||
|
@ -1654,5 +1654,5 @@ update_timer = startKeepaliveTimer()
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
except:
|
except Exception:
|
||||||
break
|
break
|
||||||
|
|
|
@ -170,7 +170,7 @@ class MetadataAPIInstance(object):
|
||||||
try:
|
try:
|
||||||
if information.get('ip4_address', None) == source_address:
|
if information.get('ip4_address', None) == source_address:
|
||||||
host_information = information
|
host_information = information
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Get our real information on the host; now we can start querying about it
|
# Get our real information on the host; now we can start querying about it
|
||||||
|
@ -188,7 +188,7 @@ class MetadataAPIInstance(object):
|
||||||
if network.get('mac', None) == client_macaddr:
|
if network.get('mac', None) == client_macaddr:
|
||||||
vm_name = vm.get('name')
|
vm_name = vm.get('name')
|
||||||
vm_details = vm
|
vm_details = vm
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return vm_details
|
return vm_details
|
||||||
|
|
|
@ -608,7 +608,7 @@ class NodeInstance(object):
|
||||||
try:
|
try:
|
||||||
lock.acquire(timeout=60) # Don't wait forever and completely block us
|
lock.acquire(timeout=60) # Don't wait forever and completely block us
|
||||||
self.logger.out('Acquired read lock for synchronization phase G', state='o')
|
self.logger.out('Acquired read lock for synchronization phase G', state='o')
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
self.logger.out('Releasing read lock for synchronization phase G', state='i')
|
self.logger.out('Releasing read lock for synchronization phase G', state='i')
|
||||||
lock.release()
|
lock.release()
|
||||||
|
@ -698,7 +698,7 @@ class NodeInstance(object):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
last_node = zkhandler.readdata(self.zk_conn, '/domains/{}/lastnode'.format(dom_uuid))
|
last_node = zkhandler.readdata(self.zk_conn, '/domains/{}/lastnode'.format(dom_uuid))
|
||||||
except:
|
except Exception:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if last_node != self.name:
|
if last_node != self.name:
|
||||||
|
|
|
@ -112,11 +112,11 @@ class VMInstance(object):
|
||||||
self.last_lastnode = zkhandler.readdata(self.zk_conn, '/domains/{}/lastnode'.format(self.domuuid))
|
self.last_lastnode = zkhandler.readdata(self.zk_conn, '/domains/{}/lastnode'.format(self.domuuid))
|
||||||
try:
|
try:
|
||||||
self.pinpolicy = zkhandler.readdata(self.zk_conn, '/domains/{}/pinpolicy'.format(self.domuuid))
|
self.pinpolicy = zkhandler.readdata(self.zk_conn, '/domains/{}/pinpolicy'.format(self.domuuid))
|
||||||
except:
|
except Exception:
|
||||||
self.pinpolicy = "none"
|
self.pinpolicy = "none"
|
||||||
try:
|
try:
|
||||||
self.migration_method = zkhandler.readdata(self.zk_conn, '/domains/{}/migration_method'.format(self.domuuid))
|
self.migration_method = zkhandler.readdata(self.zk_conn, '/domains/{}/migration_method'.format(self.domuuid))
|
||||||
except:
|
except Exception:
|
||||||
self.migration_method = 'none'
|
self.migration_method = 'none'
|
||||||
|
|
||||||
# These will all be set later
|
# These will all be set later
|
||||||
|
@ -166,7 +166,7 @@ class VMInstance(object):
|
||||||
else:
|
else:
|
||||||
domain_information = daemon_common.getInformationFromXML(self.zk_conn, self.domuuid)
|
domain_information = daemon_common.getInformationFromXML(self.zk_conn, self.domuuid)
|
||||||
memory = int(domain_information['memory'])
|
memory = int(domain_information['memory'])
|
||||||
except:
|
except Exception:
|
||||||
memory = 0
|
memory = 0
|
||||||
|
|
||||||
return memory
|
return memory
|
||||||
|
@ -174,7 +174,7 @@ class VMInstance(object):
|
||||||
def getvcpus(self):
|
def getvcpus(self):
|
||||||
try:
|
try:
|
||||||
vcpus = int(self.dom.info()[3])
|
vcpus = int(self.dom.info()[3])
|
||||||
except:
|
except Exception:
|
||||||
vcpus = 0
|
vcpus = 0
|
||||||
|
|
||||||
return vcpus
|
return vcpus
|
||||||
|
@ -220,7 +220,7 @@ class VMInstance(object):
|
||||||
try:
|
try:
|
||||||
self.dom = self.lookupByUUID(self.domuuid)
|
self.dom = self.lookupByUUID(self.domuuid)
|
||||||
curstate = self.dom.state()[0]
|
curstate = self.dom.state()[0]
|
||||||
except:
|
except Exception:
|
||||||
curstate = 'notstart'
|
curstate = 'notstart'
|
||||||
|
|
||||||
if curstate == libvirt.VIR_DOMAIN_RUNNING:
|
if curstate == libvirt.VIR_DOMAIN_RUNNING:
|
||||||
|
@ -325,7 +325,7 @@ class VMInstance(object):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
lvdomstate = self.dom.state()[0]
|
lvdomstate = self.dom.state()[0]
|
||||||
except:
|
except Exception:
|
||||||
lvdomstate = None
|
lvdomstate = None
|
||||||
|
|
||||||
if lvdomstate != libvirt.VIR_DOMAIN_RUNNING:
|
if lvdomstate != libvirt.VIR_DOMAIN_RUNNING:
|
||||||
|
@ -435,7 +435,7 @@ class VMInstance(object):
|
||||||
dest_lv_conn = libvirt.open(dest_lv)
|
dest_lv_conn = libvirt.open(dest_lv)
|
||||||
if not dest_lv_conn:
|
if not dest_lv_conn:
|
||||||
raise
|
raise
|
||||||
except:
|
except Exception:
|
||||||
self.logger.out('Failed to open connection to {}; aborting live migration.'.format(dest_lv), state='e', prefix='Domain {}'.format(self.domuuid))
|
self.logger.out('Failed to open connection to {}; aborting live migration.'.format(dest_lv), state='e', prefix='Domain {}'.format(self.domuuid))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -643,7 +643,7 @@ class VMInstance(object):
|
||||||
running, reason = self.dom.state()
|
running, reason = self.dom.state()
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
except:
|
except Exception:
|
||||||
running = libvirt.VIR_DOMAIN_NOSTATE
|
running = libvirt.VIR_DOMAIN_NOSTATE
|
||||||
|
|
||||||
self.logger.out('VM state change for "{}": {} {}'.format(self.domuuid, self.state, self.node), state='i')
|
self.logger.out('VM state change for "{}": {} {}'.format(self.domuuid, self.state, self.node), state='i')
|
||||||
|
@ -761,7 +761,7 @@ class VMInstance(object):
|
||||||
dom = lv_conn.lookupByUUID(buuid)
|
dom = lv_conn.lookupByUUID(buuid)
|
||||||
|
|
||||||
# Fail
|
# Fail
|
||||||
except:
|
except Exception:
|
||||||
dom = None
|
dom = None
|
||||||
|
|
||||||
# After everything
|
# After everything
|
||||||
|
|
|
@ -409,7 +409,7 @@ add rule inet filter forward ip6 saddr {netaddr6} counter jump {vxlannic}-out
|
||||||
try:
|
try:
|
||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
self.dhcp_server_daemon.signal('hup')
|
self.dhcp_server_daemon.signal('hup')
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def updateFirewallRules(self):
|
def updateFirewallRules(self):
|
||||||
|
@ -802,7 +802,7 @@ add rule inet filter forward ip6 saddr {netaddr6} counter jump {vxlannic}-out
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.remove(self.nftables_netconf_filename)
|
os.remove(self.nftables_netconf_filename)
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Reload firewall rules
|
# Reload firewall rules
|
||||||
|
|
|
@ -94,11 +94,11 @@ def run_os_command(command_string, background=False, environment=None, timeout=N
|
||||||
|
|
||||||
try:
|
try:
|
||||||
stdout = command_output.stdout.decode('ascii')
|
stdout = command_output.stdout.decode('ascii')
|
||||||
except:
|
except Exception:
|
||||||
stdout = ''
|
stdout = ''
|
||||||
try:
|
try:
|
||||||
stderr = command_output.stderr.decode('ascii')
|
stderr = command_output.stderr.decode('ascii')
|
||||||
except:
|
except Exception:
|
||||||
stderr = ''
|
stderr = ''
|
||||||
return retcode, stdout, stderr
|
return retcode, stdout, stderr
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ def findTargetNode(zk_conn, config, logger, dom_uuid):
|
||||||
node_limit = zkhandler.readdata(zk_conn, '/domains/{}/node_limit'.format(dom_uuid)).split(',')
|
node_limit = zkhandler.readdata(zk_conn, '/domains/{}/node_limit'.format(dom_uuid)).split(',')
|
||||||
if not any(node_limit):
|
if not any(node_limit):
|
||||||
node_limit = ''
|
node_limit = ''
|
||||||
except:
|
except Exception:
|
||||||
node_limit = ''
|
node_limit = ''
|
||||||
zkhandler.writedata(zk_conn, { '/domains/{}/node_limit'.format(dom_uuid): '' })
|
zkhandler.writedata(zk_conn, { '/domains/{}/node_limit'.format(dom_uuid): '' })
|
||||||
|
|
||||||
|
|
|
@ -47,14 +47,14 @@ def get_zookeeper_key():
|
||||||
def get_lease_expiry():
|
def get_lease_expiry():
|
||||||
try:
|
try:
|
||||||
expiry = os.environ['DNSMASQ_LEASE_EXPIRES']
|
expiry = os.environ['DNSMASQ_LEASE_EXPIRES']
|
||||||
except:
|
except Exception:
|
||||||
expiry = '0'
|
expiry = '0'
|
||||||
return expiry
|
return expiry
|
||||||
|
|
||||||
def get_client_id():
|
def get_client_id():
|
||||||
try:
|
try:
|
||||||
client_id = os.environ['DNSMASQ_CLIENT_ID']
|
client_id = os.environ['DNSMASQ_CLIENT_ID']
|
||||||
except:
|
except Exception:
|
||||||
client_id = '*'
|
client_id = '*'
|
||||||
return client_id
|
return client_id
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ def connect_zookeeper():
|
||||||
# We expect the environ to contain the config file
|
# We expect the environ to contain the config file
|
||||||
try:
|
try:
|
||||||
pvcnoded_config_file = os.environ['PVCD_CONFIG_FILE']
|
pvcnoded_config_file = os.environ['PVCD_CONFIG_FILE']
|
||||||
except:
|
except Exception:
|
||||||
# Default place
|
# Default place
|
||||||
pvcnoded_config_file = '/etc/pvc/pvcnoded.yaml'
|
pvcnoded_config_file = '/etc/pvc/pvcnoded.yaml'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue