Lint: E305 expected 2 blank lines after class or function definition, found X

This commit is contained in:
Joshua Boniface 2020-11-07 13:17:49 -05:00
parent e553c5d42a
commit 961ebb4c01
7 changed files with 146 additions and 1 deletions

View File

@ -81,6 +81,7 @@ def run_migrations_online():
finally: finally:
connection.close() connection.close()
if context.is_offline_mode(): if context.is_offline_mode():
run_migrations_offline() run_migrations_offline()
else: else:

View File

@ -48,6 +48,7 @@ def strtobool(stringv):
except Exception: 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']
@ -225,6 +226,8 @@ class API_Root(Resource):
example: "PVC API version 1.0" example: "PVC API version 1.0"
""" """
return {"message": "PVC API version {}".format(API_VERSION)} return {"message": "PVC API version {}".format(API_VERSION)}
api.add_resource(API_Root, '/') api.add_resource(API_Root, '/')
# /doc - NOTE: Until flask_swagger is packaged for Debian this must be disabled # /doc - NOTE: Until flask_swagger is packaged for Debian this must be disabled
@ -244,7 +247,9 @@ api.add_resource(API_Root, '/')
# swagger_data['info']['title'] = "PVC Client and Provisioner API" # swagger_data['info']['title'] = "PVC Client and Provisioner API"
# swagger_data['host'] = "{}:{}".format(config['listen_address'], config['listen_port']) # swagger_data['host'] = "{}:{}".format(config['listen_address'], config['listen_port'])
# return swagger_data # return swagger_data
# api.add_resource(API_Doc, '/doc') #
api.add_resource(API_Doc, '/doc')
# /login # /login
class API_Login(Resource): class API_Login(Resource):
@ -285,6 +290,8 @@ class API_Login(Resource):
return {"message": "Authentication successful"}, 200 return {"message": "Authentication successful"}, 200
else: else:
{"message": "Authentication failed"}, 401 {"message": "Authentication failed"}, 401
api.add_resource(API_Login, '/login') api.add_resource(API_Login, '/login')
# /logout # /logout
@ -309,6 +316,8 @@ class API_Logout(Resource):
flask.session.pop('token', None) flask.session.pop('token', None)
return {"message": "Deauthentication successful"}, 200 return {"message": "Deauthentication successful"}, 200
api.add_resource(API_Logout, '/logout') api.add_resource(API_Logout, '/logout')
# /initialize # /initialize
@ -338,6 +347,8 @@ class API_Initialize(Resource):
return {"message": "Successfully initialized a new PVC cluster"}, 200 return {"message": "Successfully initialized a new PVC cluster"}, 200
else: else:
return {"message": "PVC cluster already initialized"}, 400 return {"message": "PVC cluster already initialized"}, 400
api.add_resource(API_Initialize, '/initialize') api.add_resource(API_Initialize, '/initialize')
# /status # /status
@ -449,6 +460,8 @@ class API_Status(Resource):
""" """
return api_helper.cluster_maintenance(reqargs.get('state', 'false')) return api_helper.cluster_maintenance(reqargs.get('state', 'false'))
api.add_resource(API_Status, '/status') api.add_resource(API_Status, '/status')
@ -572,6 +585,8 @@ class API_Node_Root(Resource):
coordinator_state=reqargs.get('coordinator_state', None), coordinator_state=reqargs.get('coordinator_state', None),
domain_state=reqargs.get('domain_state', None) domain_state=reqargs.get('domain_state', None)
) )
api.add_resource(API_Node_Root, '/node') api.add_resource(API_Node_Root, '/node')
# /node/<node> # /node/<node>
@ -595,6 +610,8 @@ class API_Node_Element(Resource):
id: Message id: Message
""" """
return api_helper.node_list(node, is_fuzzy=False) return api_helper.node_list(node, is_fuzzy=False)
api.add_resource(API_Node_Element, '/node/<node>') api.add_resource(API_Node_Element, '/node/<node>')
# /node/<node>/daemon-state # /node/<node>/daemon-state
@ -626,6 +643,8 @@ class API_Node_DaemonState(Resource):
id: Message id: Message
""" """
return api_helper.node_daemon_state(node) return api_helper.node_daemon_state(node)
api.add_resource(API_Node_DaemonState, '/node/<node>/daemon-state') api.add_resource(API_Node_DaemonState, '/node/<node>/daemon-state')
# /node/<node>/coordinator-state # /node/<node>/coordinator-state
@ -694,6 +713,8 @@ class API_Node_CoordinatorState(Resource):
if reqargs['state'] == 'secondary': if reqargs['state'] == 'secondary':
return api_helper.node_secondary(node) return api_helper.node_secondary(node)
abort(400) abort(400)
api.add_resource(API_Node_CoordinatorState, '/node/<node>/coordinator-state') api.add_resource(API_Node_CoordinatorState, '/node/<node>/coordinator-state')
# /node/<node>/domain-state # /node/<node>/domain-state
@ -767,6 +788,8 @@ class API_Node_DomainState(Resource):
if reqargs['state'] == 'ready': if reqargs['state'] == 'ready':
return api_helper.node_ready(node, bool(strtobool(reqargs.get('wait', 'false')))) return api_helper.node_ready(node, bool(strtobool(reqargs.get('wait', 'false'))))
abort(400) abort(400)
api.add_resource(API_Node_DomainState, '/node/<node>/domain-state') api.add_resource(API_Node_DomainState, '/node/<node>/domain-state')
@ -1102,6 +1125,8 @@ class API_VM_Root(Resource):
bool(strtobool(reqargs.get('autostart', 'false'))), bool(strtobool(reqargs.get('autostart', 'false'))),
reqargs.get('migration_method', 'none') reqargs.get('migration_method', 'none')
) )
api.add_resource(API_VM_Root, '/vm') api.add_resource(API_VM_Root, '/vm')
# /vm/<vm> # /vm/<vm>
@ -1282,6 +1307,8 @@ class API_VM_Element(Resource):
return api_helper.vm_remove(vm) return api_helper.vm_remove(vm)
else: else:
return api_helper.vm_undefine(vm) return api_helper.vm_undefine(vm)
api.add_resource(API_VM_Element, '/vm/<vm>') api.add_resource(API_VM_Element, '/vm/<vm>')
# /vm/<vm>/meta # /vm/<vm>/meta
@ -1395,6 +1422,8 @@ class API_VM_Metadata(Resource):
reqargs.get('profile', None), reqargs.get('profile', None),
reqargs.get('migration_method', None) reqargs.get('migration_method', None)
) )
api.add_resource(API_VM_Metadata, '/vm/<vm>/meta') api.add_resource(API_VM_Metadata, '/vm/<vm>/meta')
# /vm/<vm</state # /vm/<vm</state
@ -1480,6 +1509,8 @@ class API_VM_State(Resource):
if state == 'disable': if state == 'disable':
return api_helper.vm_disable(vm) return api_helper.vm_disable(vm)
abort(400) abort(400)
api.add_resource(API_VM_State, '/vm/<vm>/state') api.add_resource(API_VM_State, '/vm/<vm>/state')
# /vm/<vm>/node # /vm/<vm>/node
@ -1580,6 +1611,8 @@ class API_VM_Node(Resource):
if action == 'unmigrate': if action == 'unmigrate':
return api_helper.vm_unmigrate(vm, wait, force_live) return api_helper.vm_unmigrate(vm, wait, force_live)
abort(400) abort(400)
api.add_resource(API_VM_Node, '/vm/<vm>/node') api.add_resource(API_VM_Node, '/vm/<vm>/node')
# /vm/<vm>/locks # /vm/<vm>/locks
@ -1604,6 +1637,8 @@ class API_VM_Locks(Resource):
id: Message id: Message
""" """
return api_helper.vm_flush_locks(vm) return api_helper.vm_flush_locks(vm)
api.add_resource(API_VM_Locks, '/vm/<vm>/locks') api.add_resource(API_VM_Locks, '/vm/<vm>/locks')
# /vm/<vm</console # /vm/<vm</console
@ -1647,6 +1682,8 @@ class API_VM_Console(Resource):
vm, vm,
reqargs.get('lines', None) reqargs.get('lines', None)
) )
api.add_resource(API_VM_Console, '/vm/<vm>/console') api.add_resource(API_VM_Console, '/vm/<vm>/console')
@ -1845,6 +1882,8 @@ class API_Network_Root(Resource):
reqargs.get('dhcp4_start', None), reqargs.get('dhcp4_start', None),
reqargs.get('dhcp4_end', None), reqargs.get('dhcp4_end', None),
) )
api.add_resource(API_Network_Root, '/network') api.add_resource(API_Network_Root, '/network')
# /network/<vni> # /network/<vni>
@ -2091,6 +2130,8 @@ class API_Network_Element(Resource):
id: Message id: Message
""" """
return api_helper.net_remove(vni) return api_helper.net_remove(vni)
api.add_resource(API_Network_Element, '/network/<vni>') api.add_resource(API_Network_Element, '/network/<vni>')
# /network/<vni>/lease # /network/<vni>/lease
@ -2210,6 +2251,8 @@ class API_Network_Lease_Root(Resource):
reqargs.get('macaddress', None), reqargs.get('macaddress', None),
reqargs.get('hostname', None) reqargs.get('hostname', None)
) )
api.add_resource(API_Network_Lease_Root, '/network/<vni>/lease') api.add_resource(API_Network_Lease_Root, '/network/<vni>/lease')
# /network/<vni>/lease/{mac} # /network/<vni>/lease/{mac}
@ -2336,6 +2379,8 @@ class API_Network_Lease_Element(Resource):
vni, vni,
mac mac
) )
api.add_resource(API_Network_Lease_Element, '/network/<vni>/lease/<mac>') api.add_resource(API_Network_Lease_Element, '/network/<vni>/lease/<mac>')
# /network/<vni>/acl # /network/<vni>/acl
@ -2458,6 +2503,8 @@ class API_Network_ACL_Root(Resource):
reqargs.get('rule', None), reqargs.get('rule', None),
reqargs.get('order', None) reqargs.get('order', None)
) )
api.add_resource(API_Network_ACL_Root, '/network/<vni>/acl') api.add_resource(API_Network_ACL_Root, '/network/<vni>/acl')
# /network/<vni>/acl/<description> # /network/<vni>/acl/<description>
@ -2565,6 +2612,8 @@ class API_Network_ACL_Element(Resource):
vni, vni,
description description
) )
api.add_resource(API_Network_ACL_Element, '/network/<vni>/acl/<description>') api.add_resource(API_Network_ACL_Element, '/network/<vni>/acl/<description>')
@ -2581,6 +2630,8 @@ class API_Storage_Root(Resource):
@Authenticator @Authenticator
def get(self): def get(self):
pass pass
api.add_resource(API_Storage_Root, '/storage') api.add_resource(API_Storage_Root, '/storage')
# /storage/ceph # /storage/ceph
@ -2588,6 +2639,8 @@ class API_Storage_Ceph_Root(Resource):
@Authenticator @Authenticator
def get(self): def get(self):
pass pass
api.add_resource(API_Storage_Ceph_Root, '/storage/ceph') api.add_resource(API_Storage_Ceph_Root, '/storage/ceph')
# /storage/ceph/status # /storage/ceph/status
@ -2616,6 +2669,8 @@ class API_Storage_Ceph_Status(Resource):
description: The raw output data description: The raw output data
""" """
return api_helper.ceph_status() return api_helper.ceph_status()
api.add_resource(API_Storage_Ceph_Status, '/storage/ceph/status') api.add_resource(API_Storage_Ceph_Status, '/storage/ceph/status')
# /storage/ceph/utilization # /storage/ceph/utilization
@ -2644,6 +2699,8 @@ class API_Storage_Ceph_Utilization(Resource):
description: The raw output data description: The raw output data
""" """
return api_helper.ceph_util() return api_helper.ceph_util()
api.add_resource(API_Storage_Ceph_Utilization, '/storage/ceph/utilization') api.add_resource(API_Storage_Ceph_Utilization, '/storage/ceph/utilization')
# /storage/ceph/benchmark # /storage/ceph/benchmark
@ -2802,6 +2859,8 @@ class API_Storage_Ceph_Benchmark(Resource):
reqargs.get('pool', None) reqargs.get('pool', None)
) )
return {"task_id": task.id}, 202, {'Location': Api.url_for(api, API_Storage_Ceph_Benchmark, task_id=task.id)} return {"task_id": task.id}, 202, {'Location': Api.url_for(api, API_Storage_Ceph_Benchmark, task_id=task.id)}
api.add_resource(API_Storage_Ceph_Benchmark, '/storage/ceph/benchmark') api.add_resource(API_Storage_Ceph_Benchmark, '/storage/ceph/benchmark')
# /storage/ceph/option # /storage/ceph/option
@ -2848,6 +2907,8 @@ class API_Storage_Ceph_Option(Resource):
if reqargs.get('action') == 'unset': if reqargs.get('action') == 'unset':
return api_helper.ceph_osd_unset(reqargs.get('option')) return api_helper.ceph_osd_unset(reqargs.get('option'))
abort(400) abort(400)
api.add_resource(API_Storage_Ceph_Option, '/storage/ceph/option') api.add_resource(API_Storage_Ceph_Option, '/storage/ceph/option')
# /storage/ceph/osd # /storage/ceph/osd
@ -2991,6 +3052,8 @@ class API_Storage_Ceph_OSD_Root(Resource):
reqargs.get('device', None), reqargs.get('device', None),
reqargs.get('weight', None) reqargs.get('weight', None)
) )
api.add_resource(API_Storage_Ceph_OSD_Root, '/storage/ceph/osd') api.add_resource(API_Storage_Ceph_OSD_Root, '/storage/ceph/osd')
# /storage/ceph/osd/<osdid> # /storage/ceph/osd/<osdid>
@ -3050,6 +3113,8 @@ class API_Storage_Ceph_OSD_Element(Resource):
return api_helper.ceph_osd_remove( return api_helper.ceph_osd_remove(
osdid osdid
) )
api.add_resource(API_Storage_Ceph_OSD_Element, '/storage/ceph/osd/<osdid>') api.add_resource(API_Storage_Ceph_OSD_Element, '/storage/ceph/osd/<osdid>')
# /storage/ceph/osd/<osdid>/state # /storage/ceph/osd/<osdid>/state
@ -3107,6 +3172,8 @@ class API_Storage_Ceph_OSD_State(Resource):
osdid osdid
) )
abort(400) abort(400)
api.add_resource(API_Storage_Ceph_OSD_State, '/storage/ceph/osd/<osdid>/state') api.add_resource(API_Storage_Ceph_OSD_State, '/storage/ceph/osd/<osdid>/state')
# /storage/ceph/pool # /storage/ceph/pool
@ -3237,6 +3304,8 @@ class API_Storage_Ceph_Pool_Root(Resource):
reqargs.get('pgs', None), reqargs.get('pgs', None),
reqargs.get('replcfg', None) reqargs.get('replcfg', None)
) )
api.add_resource(API_Storage_Ceph_Pool_Root, '/storage/ceph/pool') api.add_resource(API_Storage_Ceph_Pool_Root, '/storage/ceph/pool')
# /storage/ceph/pool/<pool> # /storage/ceph/pool/<pool>
@ -3346,6 +3415,8 @@ class API_Storage_Ceph_Pool_Element(Resource):
return api_helper.ceph_pool_remove( return api_helper.ceph_pool_remove(
pool pool
) )
api.add_resource(API_Storage_Ceph_Pool_Element, '/storage/ceph/pool/<pool>') api.add_resource(API_Storage_Ceph_Pool_Element, '/storage/ceph/pool/<pool>')
# /storage/ceph/volume # /storage/ceph/volume
@ -3495,6 +3566,8 @@ class API_Storage_Ceph_Volume_Root(Resource):
reqargs.get('volume', None), reqargs.get('volume', None),
reqargs.get('size', None) reqargs.get('size', None)
) )
api.add_resource(API_Storage_Ceph_Volume_Root, '/storage/ceph/volume') api.add_resource(API_Storage_Ceph_Volume_Root, '/storage/ceph/volume')
# /storage/ceph/volume/<pool>/<volume> # /storage/ceph/volume/<pool>/<volume>
@ -3642,6 +3715,8 @@ class API_Storage_Ceph_Volume_Element(Resource):
pool, pool,
volume volume
) )
api.add_resource(API_Storage_Ceph_Volume_Element, '/storage/ceph/volume/<pool>/<volume>') api.add_resource(API_Storage_Ceph_Volume_Element, '/storage/ceph/volume/<pool>/<volume>')
# /storage/ceph/volume/<pool>/<volume>/clone # /storage/ceph/volume/<pool>/<volume>/clone
@ -3684,6 +3759,8 @@ class API_Storage_Ceph_Volume_Element_Clone(Resource):
reqargs.get('new_volume', None), reqargs.get('new_volume', None),
volume volume
) )
api.add_resource(API_Storage_Ceph_Volume_Element_Clone, '/storage/ceph/volume/<pool>/<volume>/clone') api.add_resource(API_Storage_Ceph_Volume_Element_Clone, '/storage/ceph/volume/<pool>/<volume>/clone')
# /storage/ceph/volume/<pool>/<volume>/upload # /storage/ceph/volume/<pool>/<volume>/upload
@ -3735,6 +3812,8 @@ class API_Storage_Ceph_Volume_Element_Upload(Resource):
volume, volume,
reqargs.get('image_format', None) reqargs.get('image_format', None)
) )
api.add_resource(API_Storage_Ceph_Volume_Element_Upload, '/storage/ceph/volume/<pool>/<volume>/upload') api.add_resource(API_Storage_Ceph_Volume_Element_Upload, '/storage/ceph/volume/<pool>/<volume>/upload')
# /storage/ceph/snapshot # /storage/ceph/snapshot
@ -3840,6 +3919,8 @@ class API_Storage_Ceph_Snapshot_Root(Resource):
reqargs.get('volume', None), reqargs.get('volume', None),
reqargs.get('snapshot', None) reqargs.get('snapshot', None)
) )
api.add_resource(API_Storage_Ceph_Snapshot_Root, '/storage/ceph/snapshot') api.add_resource(API_Storage_Ceph_Snapshot_Root, '/storage/ceph/snapshot')
# /storage/ceph/snapshot/<pool>/<volume>/<snapshot> # /storage/ceph/snapshot/<pool>/<volume>/<snapshot>
@ -3980,6 +4061,8 @@ class API_Storage_Ceph_Snapshot_Element(Resource):
volume, volume,
snapshot snapshot
) )
api.add_resource(API_Storage_Ceph_Snapshot_Element, '/storage/ceph/snapshot/<pool>/<volume>/<snapshot>') api.add_resource(API_Storage_Ceph_Snapshot_Element, '/storage/ceph/snapshot/<pool>/<volume>/<snapshot>')
@ -3995,6 +4078,8 @@ class API_Provisioner_Root(Resource):
Unused endpoint Unused endpoint
""" """
abort(404) abort(404)
api.add_resource(API_Provisioner_Root, '/provisioner') api.add_resource(API_Provisioner_Root, '/provisioner')
# /provisioner/template # /provisioner/template
@ -4041,6 +4126,8 @@ class API_Provisioner_Template_Root(Resource):
return api_provisioner.template_list( return api_provisioner.template_list(
reqargs.get('limit', None) reqargs.get('limit', None)
) )
api.add_resource(API_Provisioner_Template_Root, '/provisioner/template') api.add_resource(API_Provisioner_Template_Root, '/provisioner/template')
# /provisioner/template/system # /provisioner/template/system
@ -4230,6 +4317,8 @@ class API_Provisioner_Template_System_Root(Resource):
node_autostart, node_autostart,
reqargs.get('migration_method', None), reqargs.get('migration_method', None),
) )
api.add_resource(API_Provisioner_Template_System_Root, '/provisioner/template/system') api.add_resource(API_Provisioner_Template_System_Root, '/provisioner/template/system')
# /provisioner/template/system/<template> # /provisioner/template/system/<template>
@ -4473,6 +4562,8 @@ class API_Provisioner_Template_System_Element(Resource):
return api_provisioner.delete_template_system( return api_provisioner.delete_template_system(
template template
) )
api.add_resource(API_Provisioner_Template_System_Element, '/provisioner/template/system/<template>') api.add_resource(API_Provisioner_Template_System_Element, '/provisioner/template/system/<template>')
# /provisioner/template/network # /provisioner/template/network
@ -4574,6 +4665,8 @@ class API_Provisioner_Template_Network_Root(Resource):
reqargs.get('name', None), reqargs.get('name', None),
reqargs.get('mac_template', None) reqargs.get('mac_template', None)
) )
api.add_resource(API_Provisioner_Template_Network_Root, '/provisioner/template/network') api.add_resource(API_Provisioner_Template_Network_Root, '/provisioner/template/network')
# /provisioner/template/network/<template> # /provisioner/template/network/<template>
@ -4656,6 +4749,8 @@ class API_Provisioner_Template_Network_Element(Resource):
return api_provisioner.delete_template_network( return api_provisioner.delete_template_network(
template template
) )
api.add_resource(API_Provisioner_Template_Network_Element, '/provisioner/template/network/<template>') api.add_resource(API_Provisioner_Template_Network_Element, '/provisioner/template/network/<template>')
# /provisioner/template/network/<template>/net # /provisioner/template/network/<template>/net
@ -4721,6 +4816,8 @@ class API_Provisioner_Template_Network_Net_Root(Resource):
template, template,
reqargs.get('vni', None) reqargs.get('vni', None)
) )
api.add_resource(API_Provisioner_Template_Network_Net_Root, '/provisioner/template/network/<template>/net') api.add_resource(API_Provisioner_Template_Network_Net_Root, '/provisioner/template/network/<template>/net')
# /provisioner/template/network/<template>/net/<vni> # /provisioner/template/network/<template>/net/<vni>
@ -4799,6 +4896,8 @@ class API_Provisioner_Template_Network_Net_Element(Resource):
template, template,
vni vni
) )
api.add_resource(API_Provisioner_Template_Network_Net_Element, '/provisioner/template/network/<template>/net/<vni>') api.add_resource(API_Provisioner_Template_Network_Net_Element, '/provisioner/template/network/<template>/net/<vni>')
# /provisioner/template/storage # /provisioner/template/storage
@ -4907,6 +5006,8 @@ class API_Provisioner_Template_Storage_Root(Resource):
return api_provisioner.create_template_storage( return api_provisioner.create_template_storage(
reqargs.get('name', None) reqargs.get('name', None)
) )
api.add_resource(API_Provisioner_Template_Storage_Root, '/provisioner/template/storage') api.add_resource(API_Provisioner_Template_Storage_Root, '/provisioner/template/storage')
# /provisioner/template/storage/<template> # /provisioner/template/storage/<template>
@ -4979,6 +5080,8 @@ class API_Provisioner_Template_Storage_Element(Resource):
return api_provisioner.delete_template_storage( return api_provisioner.delete_template_storage(
template template
) )
api.add_resource(API_Provisioner_Template_Storage_Element, '/provisioner/template/storage/<template>') api.add_resource(API_Provisioner_Template_Storage_Element, '/provisioner/template/storage/<template>')
# /provisioner/template/storage/<template>/disk # /provisioner/template/storage/<template>/disk
@ -5089,6 +5192,8 @@ class API_Provisioner_Template_Storage_Disk_Root(Resource):
reqargs.get('filesystem_arg', []), reqargs.get('filesystem_arg', []),
reqargs.get('mountpoint', None) reqargs.get('mountpoint', None)
) )
api.add_resource(API_Provisioner_Template_Storage_Disk_Root, '/provisioner/template/storage/<template>/disk') api.add_resource(API_Provisioner_Template_Storage_Disk_Root, '/provisioner/template/storage/<template>/disk')
# /provisioner/template/storage/<template>/disk/<disk_id> # /provisioner/template/storage/<template>/disk/<disk_id>
@ -5213,6 +5318,8 @@ class API_Provisioner_Template_Storage_Disk_Element(Resource):
template, template,
disk_id disk_id
) )
api.add_resource(API_Provisioner_Template_Storage_Disk_Element, '/provisioner/template/storage/<template>/disk/<disk_id>') api.add_resource(API_Provisioner_Template_Storage_Disk_Element, '/provisioner/template/storage/<template>/disk/<disk_id>')
# /provisioner/userdata # /provisioner/userdata
@ -5297,6 +5404,8 @@ class API_Provisioner_Userdata_Root(Resource):
reqargs.get('name', None), reqargs.get('name', None),
reqargs.get('data', None) reqargs.get('data', None)
) )
api.add_resource(API_Provisioner_Userdata_Root, '/provisioner/userdata') api.add_resource(API_Provisioner_Userdata_Root, '/provisioner/userdata')
# /provisioner/userdata/<userdata> # /provisioner/userdata/<userdata>
@ -5412,6 +5521,8 @@ class API_Provisioner_Userdata_Element(Resource):
return api_provisioner.delete_userdata( return api_provisioner.delete_userdata(
userdata userdata
) )
api.add_resource(API_Provisioner_Userdata_Element, '/provisioner/userdata/<userdata>') api.add_resource(API_Provisioner_Userdata_Element, '/provisioner/userdata/<userdata>')
# /provisioner/script # /provisioner/script
@ -5496,6 +5607,8 @@ class API_Provisioner_Script_Root(Resource):
reqargs.get('name', None), reqargs.get('name', None),
reqargs.get('data', None) reqargs.get('data', None)
) )
api.add_resource(API_Provisioner_Script_Root, '/provisioner/script') api.add_resource(API_Provisioner_Script_Root, '/provisioner/script')
# /provisioner/script/<script> # /provisioner/script/<script>
@ -5611,6 +5724,8 @@ class API_Provisioner_Script_Element(Resource):
return api_provisioner.delete_script( return api_provisioner.delete_script(
script script
) )
api.add_resource(API_Provisioner_Script_Element, '/provisioner/script/<script>') api.add_resource(API_Provisioner_Script_Element, '/provisioner/script/<script>')
# /provisioner/profile # /provisioner/profile
@ -5722,6 +5837,8 @@ class API_Provisioner_OVA_Root(Resource):
reqargs.get('name', None), reqargs.get('name', None),
reqargs.get('ova_size', None), reqargs.get('ova_size', None),
) )
api.add_resource(API_Provisioner_OVA_Root, '/provisioner/ova') api.add_resource(API_Provisioner_OVA_Root, '/provisioner/ova')
# /provisioner/ova/<ova> # /provisioner/ova/<ova>
@ -5813,6 +5930,8 @@ class API_Provisioner_OVA_Element(Resource):
return api_ova.delete_ova( return api_ova.delete_ova(
ova ova
) )
api.add_resource(API_Provisioner_OVA_Element, '/provisioner/ova/<ova>') api.add_resource(API_Provisioner_OVA_Element, '/provisioner/ova/<ova>')
# /provisioner/profile # /provisioner/profile
@ -5965,6 +6084,8 @@ class API_Provisioner_Profile_Root(Resource):
reqargs.get('ova', None), reqargs.get('ova', None),
reqargs.get('arg', []) reqargs.get('arg', [])
) )
api.add_resource(API_Provisioner_Profile_Root, '/provisioner/profile') api.add_resource(API_Provisioner_Profile_Root, '/provisioner/profile')
# /provisioner/profile/<profile> # /provisioner/profile/<profile>
@ -6167,6 +6288,8 @@ class API_Provisioner_Profile_Element(Resource):
return api_provisioner.delete_profile( return api_provisioner.delete_profile(
profile profile
) )
api.add_resource(API_Provisioner_Profile_Element, '/provisioner/profile/<profile>') api.add_resource(API_Provisioner_Profile_Element, '/provisioner/profile/<profile>')
# /provisioner/create # /provisioner/create
@ -6249,6 +6372,8 @@ class API_Provisioner_Create_Root(Resource):
script_run_args=reqargs.get('arg', []), script_run_args=reqargs.get('arg', []),
) )
return {"task_id": task.id}, 202, {'Location': Api.url_for(api, API_Provisioner_Status_Element, task_id=task.id)} return {"task_id": task.id}, 202, {'Location': Api.url_for(api, API_Provisioner_Status_Element, task_id=task.id)}
api.add_resource(API_Provisioner_Create_Root, '/provisioner/create') api.add_resource(API_Provisioner_Create_Root, '/provisioner/create')
# /provisioner/status # /provisioner/status
@ -6283,6 +6408,8 @@ class API_Provisioner_Status_Root(Resource):
'reserved': queue.reserved() 'reserved': queue.reserved()
} }
return response return response
api.add_resource(API_Provisioner_Status_Root, '/provisioner/status') api.add_resource(API_Provisioner_Status_Root, '/provisioner/status')
# /provisioner/status/<task_id> # /provisioner/status/<task_id>
@ -6343,4 +6470,6 @@ class API_Provisioner_Status_Element(Resource):
'status': str(task.info) 'status': str(task.info)
} }
return response return response
api.add_resource(API_Provisioner_Status_Element, '/provisioner/status/<task_id>') api.add_resource(API_Provisioner_Status_Element, '/provisioner/status/<task_id>')

View File

@ -62,6 +62,7 @@ def format_bytes_fromhuman(datahuman):
databytes = datasize * byte_unit_matrix[dataunit] databytes = datasize * byte_unit_matrix[dataunit]
return '{}B'.format(databytes) return '{}B'.format(databytes)
# Format ops sizes to/from human-readable units # Format ops sizes to/from human-readable units
ops_unit_matrix = { ops_unit_matrix = {
'': 1, '': 1,

View File

@ -127,6 +127,7 @@ def update_store(store_path, store_data):
with open(store_file, 'w') as fh: with open(store_file, 'w') as fh:
fh.write(json.dumps(store_data, sort_keys=True, indent=4)) fh.write(json.dumps(store_data, sort_keys=True, indent=4))
pvc_client_dir = os.environ.get('PVC_CLIENT_DIR', None) pvc_client_dir = os.environ.get('PVC_CLIENT_DIR', None)
home_dir = os.environ.get('HOME', None) home_dir = os.environ.get('HOME', None)
if pvc_client_dir: if pvc_client_dir:
@ -3669,6 +3670,7 @@ def cli(_cluster, _debug, _quiet):
) )
click.echo('', err=True) click.echo('', err=True)
config = dict() config = dict()
# #
@ -3833,5 +3835,6 @@ cli.add_command(init_cluster)
def main(): def main():
return cli(obj={}) return cli(obj={})
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View File

@ -73,6 +73,7 @@ def verifyOSDBlock(zk_conn, node, device):
return osd return osd
return None return None
# Format byte sizes to/from human-readable units # Format byte sizes to/from human-readable units
byte_unit_matrix = { byte_unit_matrix = {
'B': 1, 'B': 1,
@ -106,6 +107,7 @@ def format_bytes_fromhuman(datahuman):
databytes = datasize * byte_unit_matrix[dataunit] databytes = datasize * byte_unit_matrix[dataunit]
return '{}B'.format(databytes) return '{}B'.format(databytes)
# Format ops sizes to/from human-readable units # Format ops sizes to/from human-readable units
ops_unit_matrix = { ops_unit_matrix = {
'': 1, '': 1,

View File

@ -93,6 +93,7 @@ def stopKeepaliveTimer():
except Exception: except Exception:
pass pass
############################################################################### ###############################################################################
# PHASE 1a - Configuration parsing # PHASE 1a - Configuration parsing
############################################################################### ###############################################################################
@ -272,6 +273,7 @@ def readConfig(pvcnoded_config_file, myhostname):
return config return config
# Get the config object from readConfig() # Get the config object from readConfig()
config = readConfig(pvcnoded_config_file, myhostname) config = readConfig(pvcnoded_config_file, myhostname)
debug = config['debug'] debug = config['debug']
@ -542,6 +544,7 @@ def zk_listener(state):
zk_conn.add_listener(zk_listener) zk_conn.add_listener(zk_listener)
break break
zk_conn.add_listener(zk_listener) zk_conn.add_listener(zk_listener)
############################################################################### ###############################################################################
@ -621,6 +624,7 @@ def hup(signum='', frame=''):
if config['file_logging']: if config['file_logging']:
logger.hup() logger.hup()
# Handle signals gracefully # Handle signals gracefully
signal.signal(signal.SIGTERM, term) signal.signal(signal.SIGTERM, term)
signal.signal(signal.SIGINT, term) signal.signal(signal.SIGINT, term)
@ -816,6 +820,7 @@ def update_nodes(new_node_list):
for node in d_node: for node in d_node:
d_node[node].update_node_list(d_node) d_node[node].update_node_list(d_node)
# Alias for our local node (passed to network and domain objects) # Alias for our local node (passed to network and domain objects)
this_node = d_node[myhostname] this_node = d_node[myhostname]
@ -873,6 +878,7 @@ def update_primary(new_primary, stat, event=''):
for node in d_node: for node in d_node:
d_node[node].primary_node = new_primary d_node[node].primary_node = new_primary
if enable_networking: if enable_networking:
# Network objects # Network objects
@zk_conn.ChildrenWatch('/networks') @zk_conn.ChildrenWatch('/networks')
@ -1292,6 +1298,7 @@ def collect_ceph_stats(queue):
if debug: if debug:
logger.out("Thread finished", state='d', prefix='ceph-thread') logger.out("Thread finished", state='d', prefix='ceph-thread')
# State table for pretty stats # State table for pretty stats
libvirt_vm_states = { libvirt_vm_states = {
0: "NOSTATE", 0: "NOSTATE",
@ -1641,6 +1648,7 @@ def node_keepalive():
if debug: if debug:
logger.out("Keepalive finished", state='d', prefix='main-thread') logger.out("Keepalive finished", state='d', prefix='main-thread')
# Start keepalive thread # Start keepalive thread
update_timer = startKeepaliveTimer() update_timer = startKeepaliveTimer()

View File

@ -122,6 +122,7 @@ def add_lease(zk_conn, zk_leases_key, expiry, macaddr, ipaddr, hostname, clienti
def del_lease(zk_conn, zk_leases_key, macaddr, expiry): def del_lease(zk_conn, zk_leases_key, macaddr, expiry):
zk_conn.delete('{}/{}'.format(zk_leases_key, macaddr), recursive=True) zk_conn.delete('{}/{}'.format(zk_leases_key, macaddr), recursive=True)
# #
# Instantiate the parser # Instantiate the parser
# #