Exemple #1
0
def svr_init():
  global myDes3Key, myDes3Iv, myDes3
  myDes3Key = shell.config['des3-key']
  myDes3Iv = shell.config['des3-iv']
  myDes3 = encrypt.myDes3Cipher(myDes3Key, myDes3Iv, DES3.MODE_CBC)

  payload = {'EpochTime':common.get_epochtime(),'NodeName':common.get_hostname(),'Version':common.get_version(),"SvrType":15}
  #payload = {'EpochTime':common.get_epochtime(),'NodeName':'CSDX-TintanCDN.15-143','Version':common.get_version(),"SvrType":15}
  payload = json.dumps(payload, encoding='UTF-8')
  logging.info('Sent:     '+payload)
  payload = myDes3.myEncrypt(payload)
  r = requests.post(shell.config['dbagent']+'/DBAgentSvr/SvrInit', data=payload)

  r.raise_for_status()

  content = myDes3.myDecrypt(r.text)
  logging.info('Received: '+content)
  decodejson = json.loads(content, encoding='UTF-8')

  if decodejson['Status'] == 0:
    logging.error('Failure status returned')
    sys.exit(1)
  elif decodejson['Status'] == 1:
    shell.config['nodeid'] = decodejson['NodeId']
  else:
    logging.error('Unknown status returned')
    sys.exit(1)

  return
Exemple #2
0
def start():
  global myDes3Key, myDes3Iv, myDes3
  myDes3Key = shell.config['des3-key']
  myDes3Iv = shell.config['des3-iv']
  myDes3 = encrypt.myDes3Cipher(myDes3Key, myDes3Iv, DES3.MODE_CBC)

  global beat
  heartbeat = Heartbeat(beat)
  heartbeat.start()

  run(host=shell.config['local_address'], port=shell.config['local_port'], debug=True)