|
@@ -217,16 +217,24 @@ class BindCmdInterpreter(Cmd):
|
|
|
for module_name in self.config_data.get_config_item_list():
|
|
|
self._prepare_module_commands(self.config_data.get_module_spec(module_name))
|
|
|
|
|
|
+ def _send_message(self, url, body):
|
|
|
+ headers = {"cookie" : self.session_id}
|
|
|
+ self.conn.request('GET', url, body, headers)
|
|
|
+ res = self.conn.getresponse()
|
|
|
+ return res.status, res.read()
|
|
|
+
|
|
|
def send_GET(self, url, body = None):
|
|
|
'''Send GET request to cmdctl, session id is send with the name
|
|
|
'cookie' in header.
|
|
|
'''
|
|
|
- headers = {"cookie" : self.session_id}
|
|
|
- self.conn.request('GET', url, body, headers)
|
|
|
- res = self.conn.getresponse()
|
|
|
- reply_msg = res.read()
|
|
|
+ status, reply_msg = self._send_message(url, body)
|
|
|
+ if status == http.client.UNAUTHORIZED:
|
|
|
+ if self.login_to_cmdctl():
|
|
|
+ # successful, so try send again
|
|
|
+ status, reply_msg = self._send_message(url, body)
|
|
|
+
|
|
|
if reply_msg:
|
|
|
- return json.loads(reply_msg.decode())
|
|
|
+ return json.loads(reply_msg.decode())
|
|
|
else:
|
|
|
return {}
|
|
|
|