-
Notifications
You must be signed in to change notification settings - Fork 0
/
FedController.py
69 lines (56 loc) · 2.21 KB
/
FedController.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import threading
import CupConfig
import logging
import ApplicationCore
import ssh
import uploadCerts
PORT = 5269
class WorkerThread():
def __init__(self,ip1,tlsoption,mode,hn1,dn1,dnsip, creds,advancedTab):
self.ip = ip1
self.tlsoption = tlsoption
self.mode=mode
self.hn=hn1
self.dn=dn1
self.dnsip=dnsip
self.creds=creds
self.advancedTab=advancedTab
self.core = ApplicationCore.Federation()
if self.creds:
logging.info('Credential given. Creating driver for cup config. ')
thread = threading.Thread(target=self.run,args=())
thread.start()
else:
logging.info('No credential given. Not doing cup config')
if dnsip:
logging.info("DNS ip given. Updating DNS")
self.updateDns()
#if tlsoption == 1 or tlsoption ==2:
# if self.downloadCerts() == 1:
# pass
# self.uploadCerts()
def updateDns(self):
logging.info('Contacting DNS. Updating A record')
self.core.UpdateDnsA(self.hn, self.ip, self.dn, 'A', self.dnsip)
logging.info('Contacting DNS. Updating SRV record')
self.core.UpdateDnsSrv(PORT, self.hn, self.dn, self.dnsip)
def downloadCerts(self):
# if tlsoption == 1 or tlsoption == 2:
logging.info('Downloading certs from '+self.ip)
myssh = ssh.Ssh(self.ip)
try:
self.downloaddir = myssh.download('/usr/local/sip/.security/xmpp-s2s/certs/cup-xmpp-s2s.der')
logging.info('Downloaded certs to '+self.downloaddir)
myssh.download('/usr/local/sip/.security/xmpp-s2s-ECDSA/certs/cup-xmpp-s2s-ECDSA.der')
except:
logging.info('Certificate download failed')
return 0
logging.info('Downloaded certificates')
return 1
def uploadCerts(self):
logging.info("Starting upload certs")
plat_tuple = self.creds._platid, self.creds._platpw
uploadCerts.UploadCerts(self.ip,'xmpp',plat_tuple,self.downloaddir)
def run(self):
logging.debug('Running driver thread')
CupConfig.Driver(self.ip, self.hn, self.tlsoption, self.mode, self.creds, self.advancedTab)