cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
cfsp_debug.py
Go to the documentation of this file.
1 # *****************************************************************************
2 # * cloudFPGA
3 # * Copyright 2016 -- 2022 IBM Corporation
4 # * Licensed under the Apache License, Version 2.0 (the "License");
5 # * you may not use this file except in compliance with the License.
6 # * You may obtain a copy of the License at
7 # *
8 # * http://www.apache.org/licenses/LICENSE-2.0
9 # *
10 # * Unless required by applicable law or agreed to in writing, software
11 # * distributed under the License is distributed on an "AS IS" BASIS,
12 # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # * See the License for the specific language governing permissions and
14 # * limitations under the License.
15 # *----------------------------------------------------------------------------
16 
17 """
18 Usage:
19  cfsp debug (get)
20 Commands:
21  get flight_recorder_data <cluster/instance> Requests and returns the status information of the
22  Network Routing Core of this cluster/instance
23  Attention: There may be a delay of a few seconds until
24  the counters are updated after the packets were
25  processed.
26 """
27 from __future__ import absolute_import
28 
29 import sys,os
30 python_api_client_path = os.getcwd()+"/cFSPlib/python_api_client/"
31 sys.path.append(python_api_client_path)
32 
33 import cfsp_globals
34 import swagger_client
35 from swagger_client.rest import ApiException
36 from swagger_client.api_client import ApiClient
37 from swagger_client.configuration import Configuration
38 from tqdm import tqdm
39 
40 def main(args):
41  conf = Configuration()
42  conf.host = cfsp_globals.__cf_manager_url__
43  api_client = ApiClient(conf)
44  api_instance = swagger_client.DebugApi(api_client=api_client)
45 
46  if (len(args['<args>']) != 4):
47  print("ERROR: invalid arguments provided in 'cfsp debug' command. Aborting...")
48  exit(print(__doc__))
49 
50  username = cfsp_globals.__cfsp_username__
51  password = cfsp_globals.__cfsp_password__
52  project_name = cfsp_globals.__cfsp_project__
53 
54  if args['<args>'][0] == 'get':
55  if (args['<args>'][1] == "flight_recorder_data"):
56  if args['<args>'][2] == 'cluster':
57  try:
58  api_response = api_instance.cf_manager_rest_api_get_flight_recorder_cluster(username, password, args['<args>'][3])
59  except ApiException as e:
60  print("Exception when calling DebugApi->cf_manager_rest_api_get_flight_recorder_cluster: %s\n" % e)
61  exit(-1)
62  elif args['<args>'][2] == 'instance':
63  try:
64  api_response = api_instance.cf_manager_rest_api_get_flight_recorder_instance(username, password, args['<args>'][3])
65  except ApiException as e:
66  print("Exception when calling DebugApi->cf_manager_rest_api_get_flight_recorder_instance: %s\n" % e)
67  exit(-1)
68  else:
69  exit(print("ERROR: invalid arguments provided in cfsp debug get flight_recorder_data. Choose between 'cluster' or 'instance'. Aborting..."))
70  else:
71  exit(print("ERROR: invalid arguments provided in cfsp debug get. Aborting..."))
72  return(api_response)
73  else:
74  exit(print("ERROR: invalid command provided in cfsp debug. Type 'cfsp help debug' to get a list of supported commands. Aborting..."))
75 if __name__ == '__main__':
76  main(args)
def main(args)
Definition: cfsp_debug.py:40