Esempio n. 1
0
 def __init__(self, key=None, code=None):
     self._session = requests.Session()
     self._session.keep_alive = False
     self._headers = {}
     self.request_data = {
         "enterpriseLoginName": "awcloud",
         "userName": GetModel.account()[0],
         "password": GetModel.account()[1],
         "verificationCode": code,
         "verificationKey": key
     }
Esempio n. 2
0
 def get_token(self):
     panacube_ip = "http://" + GetModel.panacube_ip()
     url = '{}/v1/management/login/'.format(panacube_ip)
     username, password = GetModel.account()
     current_app.logger.info('panacube登录username={}, password={}'.format(
         username, password))
     if username and password:
         try:
             resp = requests.post(url,
                                  data={
                                      "username": username,
                                      "password": password
                                  },
                                  verify=False)
         except Exception as e:
             raise e
         current_app.logger.info(resp.json())
         return resp.json().get('data').get('token')
     current_app.logger.error('参数有误--->username={}, password={}'.format(
         username, password))
     return {
         'code':
         1,
         'message':
         '参数有误--->username={}, password={}'.format(username, password)
     }