def testQuickCreate(self): quick_create_event(1, event_server = server(SERVERID = "TEST"), event_schedule=schedule(SCHEDID = "SCHED1"), event_job=job(JOBID = 15), event_action=action(ACTIONID="ACT1"), event_user=user(USERID="Dan")) self.assert_(getsession().query(event).filter(event.EVENTNUM == 1).count()) e = getsession().query(event).filter(event.EVENTNUM == 1).one() self.assert_(e.SERVERID == "TEST") self.assert_(e.SCHEDID == "SCHED1") self.assert_(e.JOBID == 15) self.assert_(e.ACTIONID == "ACT1") self.assert_(e.USERID == "Dan")
def add_server(self): self.server_ip = self.dialogUi.ip_line.text() self.username = self.dialogUi.username_line.text() self.password = self.dialogUi.password_line.text() self.port = self.dialogUi.port_line.text() added_server = servers.server(self.server_ip, self.username, self.password, self.port) servers.add_server(added_server) self.update_lists_signal.emit("") self.close()
def __init__(self): print("started at "+str(datetime.today())) self.server = server('127.0.0.1', 6000, 8000) self.json = jsonserver(self.server) self.json.tcp_client+= self.got_flash self.json.got_packet+= self.flash_data self.server.start()
def testDescription(self): u = user(USERID = "DAN", EMAIL="*****@*****.**") edef = eventdef() desc = edef.event_text("%USER% has email %EMAIL%", event_user = u) self.assert_(u.USERID in desc) self.assert_(u.EMAIL in desc) s = server(SERVERID = "testserver", IP = "192.168.1.1", PORT = 2200, OS = 1, TYPE = 1) desc = edef.event_text("%SERVER% has ip %IP% port %PORT% os %SERVEROS% ", event_server = s, event_user = u) self.assert_(s.SERVERID in desc) self.assert_(s.IP in desc) self.assert_(str(s.PORT) in desc) self.assert_(s.os_to_string() in desc) q = job(JOBID = 14, SCHDATE = datetime.now(), BATCH = "batch1", IGNOREDEP = False, REMAININGRUNS = 15, MAXRUNS = 10) desc = edef.event_text("%JOB% %SCHDATE% %BATCH% %IGNOREDEPS% %REMAININGRUNS% %MAXRUNS%", event_job = q) self.assert_(str(q.JOBID) in desc) self.assert_(str(q.SCHDATE) in desc) self.assert_(q.BATCH in desc) self.assert_(str(q.IGNOREDEP) in desc) self.assert_(str(q.REMAININGRUNS) in desc) self.assert_(str(q.MAXRUNS) in desc) a = action(ACTIONID = "Action12", CMDLINE = "dir", STDIN = True, STARTINDIR = "/etc", STDOUT = False, OS = 1, USERID = "JOHN") desc = edef.event_text(" %ACTION% %CMDLINE% %STDIN% %STARTINDIR% %CAPTURESTDOUT% %ACTIONOS% %ACTIONUSER%", event_action = a) self.assert_(a.CMDLINE in desc) self.assert_(a.ACTIONID in desc) self.assert_(str(a.STDIN) in desc) self.assert_(a.STARTINDIR in desc) self.assert_(str(a.STDOUT) in desc) self.assert_(a.os_to_string() in desc) self.assert_(a.USERID in desc) s = schedule(SCHEDID = "sched1", INTERVAL = 1, METHOD = 2, AFTER = 0, DELTA = 3, CALID = "cal3", CALTYPE = 2) desc = edef.event_text("%SCHEDID% %INTERVAL% %METHOD% %RESCHEDULEON% %DELTA% %CALENDAR% %CALTYPE% %ASCHEDULEMAXRUNS% %ABSRESCHEDULE%", event_schedule = s) self.assert_(s.SCHEDID in desc) self.assert_(str(s.INTERVAL) in desc) self.assert_(s.method_str() in desc) self.assert_(s.resch_str() in desc) self.assert_(s.type_str() in desc) self.assert_(s.CALID in desc) self.assert_(s.caltype_str() in desc) self.assert_(str(s.MAXRUNS) in desc) self.assert_(str(s.WHEN) in desc) desc = edef.event_text("%CONTROLLER% for %MESSAGE%", event_message="A generic message") self.assert_(myname in desc) self.assert_("A generic message" in desc)
def getVms(creds): servers = {} try: url = creds['service_endpoints']['nova']+"/servers/detail?all_tenants=1" req = urllib2.Request(url) req.add_header('Content-Type','application/json') req.add_header('X-Auth-Token',creds["id"]) response=urllib2.urlopen(req) code = response.code data = json.loads(response.read()) for ops_svr in data["servers"]: ops_svr[ 'addrLabels'] = srv.getAddr() srv = server(ops_svr) if ops_svr["status"] == "ACTIVE": srv.addDgn(getVmStats(ops_svr["id"],creds)) else: srv.addDgn({}) return data except urllib2.HTTPError, e: logger.warning('Error: '+str(e))
def getVms(creds): print("getVms") servers = {} try: url = creds['service_endpoints']['nova'] + "/servers/detail" req = urllib2.Request(url) req.add_header('Content-Type', 'application/json') req.add_header('X-Auth-Token', creds["id"]) response = urllib2.urlopen(req) code = response.code data = json.loads(response.read()) for ops_svr in data["servers"]: srv = server(ops_svr) ops_svr['addrLabels'] = srv.getAddr() if ops_svr["status"] == "ACTIVE": srv.addDgn(getVmStats(ops_svr["id"], creds)) else: srv.addDgn({}) return data except urllib2.HTTPError, e: logger.warning('Error: ' + str(e))