From 961ebb4c018c728b9cd847d51e6aa6206b75ea3a Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Sat, 7 Nov 2020 13:17:49 -0500 Subject: [PATCH] Lint: E305 expected 2 blank lines after class or function definition, found X --- api-daemon/migrations/env.py | 1 + api-daemon/pvcapid/flaskapi.py | 131 +++++++++++++++++- client-cli/cli_lib/ceph.py | 1 + client-cli/pvc.py | 3 + daemon-common/ceph.py | 2 + node-daemon/pvcnoded/Daemon.py | 8 ++ .../pvcnoded/dnsmasq-zookeeper-leases.py | 1 + 7 files changed, 146 insertions(+), 1 deletion(-) diff --git a/api-daemon/migrations/env.py b/api-daemon/migrations/env.py index 0ecfdf8f..8f39ee5c 100644 --- a/api-daemon/migrations/env.py +++ b/api-daemon/migrations/env.py @@ -81,6 +81,7 @@ def run_migrations_online(): finally: connection.close() + if context.is_offline_mode(): run_migrations_offline() else: diff --git a/api-daemon/pvcapid/flaskapi.py b/api-daemon/pvcapid/flaskapi.py index a2c0ccd8..17729a65 100755 --- a/api-daemon/pvcapid/flaskapi.py +++ b/api-daemon/pvcapid/flaskapi.py @@ -48,6 +48,7 @@ def strtobool(stringv): except Exception: return False + # Parse the configuration file try: pvc_config_file = os.environ['PVC_CONFIG_FILE'] @@ -225,6 +226,8 @@ class API_Root(Resource): example: "PVC API version 1.0" """ return {"message": "PVC API version {}".format(API_VERSION)} + + api.add_resource(API_Root, '/') # /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['host'] = "{}:{}".format(config['listen_address'], config['listen_port']) # return swagger_data -# api.add_resource(API_Doc, '/doc') +# + +api.add_resource(API_Doc, '/doc') # /login class API_Login(Resource): @@ -285,6 +290,8 @@ class API_Login(Resource): return {"message": "Authentication successful"}, 200 else: {"message": "Authentication failed"}, 401 + + api.add_resource(API_Login, '/login') # /logout @@ -309,6 +316,8 @@ class API_Logout(Resource): flask.session.pop('token', None) return {"message": "Deauthentication successful"}, 200 + + api.add_resource(API_Logout, '/logout') # /initialize @@ -338,6 +347,8 @@ class API_Initialize(Resource): return {"message": "Successfully initialized a new PVC cluster"}, 200 else: return {"message": "PVC cluster already initialized"}, 400 + + api.add_resource(API_Initialize, '/initialize') # /status @@ -449,6 +460,8 @@ class API_Status(Resource): """ return api_helper.cluster_maintenance(reqargs.get('state', 'false')) + + api.add_resource(API_Status, '/status') @@ -572,6 +585,8 @@ class API_Node_Root(Resource): coordinator_state=reqargs.get('coordinator_state', None), domain_state=reqargs.get('domain_state', None) ) + + api.add_resource(API_Node_Root, '/node') # /node/ @@ -595,6 +610,8 @@ class API_Node_Element(Resource): id: Message """ return api_helper.node_list(node, is_fuzzy=False) + + api.add_resource(API_Node_Element, '/node/') # /node//daemon-state @@ -626,6 +643,8 @@ class API_Node_DaemonState(Resource): id: Message """ return api_helper.node_daemon_state(node) + + api.add_resource(API_Node_DaemonState, '/node//daemon-state') # /node//coordinator-state @@ -694,6 +713,8 @@ class API_Node_CoordinatorState(Resource): if reqargs['state'] == 'secondary': return api_helper.node_secondary(node) abort(400) + + api.add_resource(API_Node_CoordinatorState, '/node//coordinator-state') # /node//domain-state @@ -767,6 +788,8 @@ class API_Node_DomainState(Resource): if reqargs['state'] == 'ready': return api_helper.node_ready(node, bool(strtobool(reqargs.get('wait', 'false')))) abort(400) + + api.add_resource(API_Node_DomainState, '/node//domain-state') @@ -1102,6 +1125,8 @@ class API_VM_Root(Resource): bool(strtobool(reqargs.get('autostart', 'false'))), reqargs.get('migration_method', 'none') ) + + api.add_resource(API_VM_Root, '/vm') # /vm/ @@ -1282,6 +1307,8 @@ class API_VM_Element(Resource): return api_helper.vm_remove(vm) else: return api_helper.vm_undefine(vm) + + api.add_resource(API_VM_Element, '/vm/') # /vm//meta @@ -1395,6 +1422,8 @@ class API_VM_Metadata(Resource): reqargs.get('profile', None), reqargs.get('migration_method', None) ) + + api.add_resource(API_VM_Metadata, '/vm//meta') # /vm//state') # /vm//node @@ -1580,6 +1611,8 @@ class API_VM_Node(Resource): if action == 'unmigrate': return api_helper.vm_unmigrate(vm, wait, force_live) abort(400) + + api.add_resource(API_VM_Node, '/vm//node') # /vm//locks @@ -1604,6 +1637,8 @@ class API_VM_Locks(Resource): id: Message """ return api_helper.vm_flush_locks(vm) + + api.add_resource(API_VM_Locks, '/vm//locks') # /vm//console') @@ -1845,6 +1882,8 @@ class API_Network_Root(Resource): reqargs.get('dhcp4_start', None), reqargs.get('dhcp4_end', None), ) + + api.add_resource(API_Network_Root, '/network') # /network/ @@ -2091,6 +2130,8 @@ class API_Network_Element(Resource): id: Message """ return api_helper.net_remove(vni) + + api.add_resource(API_Network_Element, '/network/') # /network//lease @@ -2210,6 +2251,8 @@ class API_Network_Lease_Root(Resource): reqargs.get('macaddress', None), reqargs.get('hostname', None) ) + + api.add_resource(API_Network_Lease_Root, '/network//lease') # /network//lease/{mac} @@ -2336,6 +2379,8 @@ class API_Network_Lease_Element(Resource): vni, mac ) + + api.add_resource(API_Network_Lease_Element, '/network//lease/') # /network//acl @@ -2458,6 +2503,8 @@ class API_Network_ACL_Root(Resource): reqargs.get('rule', None), reqargs.get('order', None) ) + + api.add_resource(API_Network_ACL_Root, '/network//acl') # /network//acl/ @@ -2565,6 +2612,8 @@ class API_Network_ACL_Element(Resource): vni, description ) + + api.add_resource(API_Network_ACL_Element, '/network//acl/') @@ -2581,6 +2630,8 @@ class API_Storage_Root(Resource): @Authenticator def get(self): pass + + api.add_resource(API_Storage_Root, '/storage') # /storage/ceph @@ -2588,6 +2639,8 @@ class API_Storage_Ceph_Root(Resource): @Authenticator def get(self): pass + + api.add_resource(API_Storage_Ceph_Root, '/storage/ceph') # /storage/ceph/status @@ -2616,6 +2669,8 @@ class API_Storage_Ceph_Status(Resource): description: The raw output data """ return api_helper.ceph_status() + + api.add_resource(API_Storage_Ceph_Status, '/storage/ceph/status') # /storage/ceph/utilization @@ -2644,6 +2699,8 @@ class API_Storage_Ceph_Utilization(Resource): description: The raw output data """ return api_helper.ceph_util() + + api.add_resource(API_Storage_Ceph_Utilization, '/storage/ceph/utilization') # /storage/ceph/benchmark @@ -2802,6 +2859,8 @@ class API_Storage_Ceph_Benchmark(Resource): reqargs.get('pool', None) ) 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') # /storage/ceph/option @@ -2848,6 +2907,8 @@ class API_Storage_Ceph_Option(Resource): if reqargs.get('action') == 'unset': return api_helper.ceph_osd_unset(reqargs.get('option')) abort(400) + + api.add_resource(API_Storage_Ceph_Option, '/storage/ceph/option') # /storage/ceph/osd @@ -2991,6 +3052,8 @@ class API_Storage_Ceph_OSD_Root(Resource): reqargs.get('device', None), reqargs.get('weight', None) ) + + api.add_resource(API_Storage_Ceph_OSD_Root, '/storage/ceph/osd') # /storage/ceph/osd/ @@ -3050,6 +3113,8 @@ class API_Storage_Ceph_OSD_Element(Resource): return api_helper.ceph_osd_remove( osdid ) + + api.add_resource(API_Storage_Ceph_OSD_Element, '/storage/ceph/osd/') # /storage/ceph/osd//state @@ -3107,6 +3172,8 @@ class API_Storage_Ceph_OSD_State(Resource): osdid ) abort(400) + + api.add_resource(API_Storage_Ceph_OSD_State, '/storage/ceph/osd//state') # /storage/ceph/pool @@ -3237,6 +3304,8 @@ class API_Storage_Ceph_Pool_Root(Resource): reqargs.get('pgs', None), reqargs.get('replcfg', None) ) + + api.add_resource(API_Storage_Ceph_Pool_Root, '/storage/ceph/pool') # /storage/ceph/pool/ @@ -3346,6 +3415,8 @@ class API_Storage_Ceph_Pool_Element(Resource): return api_helper.ceph_pool_remove( pool ) + + api.add_resource(API_Storage_Ceph_Pool_Element, '/storage/ceph/pool/') # /storage/ceph/volume @@ -3495,6 +3566,8 @@ class API_Storage_Ceph_Volume_Root(Resource): reqargs.get('volume', None), reqargs.get('size', None) ) + + api.add_resource(API_Storage_Ceph_Volume_Root, '/storage/ceph/volume') # /storage/ceph/volume// @@ -3642,6 +3715,8 @@ class API_Storage_Ceph_Volume_Element(Resource): pool, volume ) + + api.add_resource(API_Storage_Ceph_Volume_Element, '/storage/ceph/volume//') # /storage/ceph/volume///clone @@ -3684,6 +3759,8 @@ class API_Storage_Ceph_Volume_Element_Clone(Resource): reqargs.get('new_volume', None), volume ) + + api.add_resource(API_Storage_Ceph_Volume_Element_Clone, '/storage/ceph/volume///clone') # /storage/ceph/volume///upload @@ -3735,6 +3812,8 @@ class API_Storage_Ceph_Volume_Element_Upload(Resource): volume, reqargs.get('image_format', None) ) + + api.add_resource(API_Storage_Ceph_Volume_Element_Upload, '/storage/ceph/volume///upload') # /storage/ceph/snapshot @@ -3840,6 +3919,8 @@ class API_Storage_Ceph_Snapshot_Root(Resource): reqargs.get('volume', None), reqargs.get('snapshot', None) ) + + api.add_resource(API_Storage_Ceph_Snapshot_Root, '/storage/ceph/snapshot') # /storage/ceph/snapshot/// @@ -3980,6 +4061,8 @@ class API_Storage_Ceph_Snapshot_Element(Resource): volume, snapshot ) + + api.add_resource(API_Storage_Ceph_Snapshot_Element, '/storage/ceph/snapshot///') @@ -3995,6 +4078,8 @@ class API_Provisioner_Root(Resource): Unused endpoint """ abort(404) + + api.add_resource(API_Provisioner_Root, '/provisioner') # /provisioner/template @@ -4041,6 +4126,8 @@ class API_Provisioner_Template_Root(Resource): return api_provisioner.template_list( reqargs.get('limit', None) ) + + api.add_resource(API_Provisioner_Template_Root, '/provisioner/template') # /provisioner/template/system @@ -4230,6 +4317,8 @@ class API_Provisioner_Template_System_Root(Resource): node_autostart, reqargs.get('migration_method', None), ) + + api.add_resource(API_Provisioner_Template_System_Root, '/provisioner/template/system') # /provisioner/template/system/