def get_context(self): super_context = super(self.__class__,self).get_context() servers = utils.extract_user_servers(self.user) #Extracting puppet classes level serverslist=[] for server in servers: serverdict = {} serverdict["online"]=server.online serverdict["fqdn"]=server.fqdn serverdict["hostname"]=server.hostname for puppetclass in server.puppet_classes.values(): if puppetclass["level"]==0: serverdict["lvl1"]=puppetclass["name"] elif puppetclass["level"]==1: serverdict["lvl2"]=puppetclass["name"] elif puppetclass["level"]==2: serverdict["lvl3"]=puppetclass["name"] elif puppetclass["level"]==3: serverdict["lvl4"]=puppetclass["name"] elif puppetclass["level"]==4: if "lvl5" in serverdict: serverdict["lvl5"]=serverdict["lvl5"] + ', ' + puppetclass["name"] else: serverdict["lvl5"]=puppetclass["name"] serverslist.append(serverdict) widget_context = {"servers":serverslist} return dict(super_context.items() + widget_context.items())
def get_context(self): super_context = super(self.__class__, self).get_context() servers = utils.extract_user_servers(self.user) #Extracting puppet classes level serverslist = [] for server in servers: serverdict = {} serverdict["online"] = server.online serverdict["fqdn"] = server.fqdn serverdict["hostname"] = server.hostname for puppetclass in server.puppet_classes.values(): if puppetclass["level"] == 0: serverdict["lvl1"] = puppetclass["name"] elif puppetclass["level"] == 1: serverdict["lvl2"] = puppetclass["name"] elif puppetclass["level"] == 2: serverdict["lvl3"] = puppetclass["name"] elif puppetclass["level"] == 3: serverdict["lvl4"] = puppetclass["name"] elif puppetclass["level"] == 4: if "lvl5" in serverdict: serverdict["lvl5"] = serverdict[ "lvl5"] + ', ' + puppetclass["name"] else: serverdict["lvl5"] = puppetclass["name"] serverslist.append(serverdict) widget_context = {"servers": serverslist} return dict(super_context.items() + widget_context.items())
def get_context(self): super_context = super(self.__class__, self).get_context() operations = [{ 'id': 'script_ex', 'name': 'Execute Script' }, { 'id': 'deploy_bar', 'name': 'Deploy Bar' }, { 'id': 'deploy_ear', 'name': 'Deploy EAR' }, { 'id': 'restart_instance', 'name': 'Restart Instance' }] servers = utils.extract_user_servers(self.user) server_list = [] for server in servers: server_list.append({'id': server.fqdn, 'name': server.fqdn}) server_dict = {"results": server_list, "total": len(server_list)} widget_context = { 'operations': operations, 'server_list': json.dumps(server_dict, ensure_ascii=False) } return dict(super_context.items() + widget_context.items())
def generate_csv_server(user, response): """ Generates an CSV with servers list """ writer = csv.writer(response, delimiter=';') writer.writerow( ["UsedName", "Name", "BU", "Projet", "Status", "Zone", "Type"]) servers = utils.extract_user_servers(user) logger.info("Generating servers CSV") logger.debug("Found %s servers" % len(servers)) for server in servers: classes = [] for i in range(0, 5): values = server.puppet_classes.filter(level=i).values() if values: classes.append(values[0]['name']) else: classes.append('') writer.writerow([ server.fqdn, server.hostname, classes[0], classes[1], classes[2], classes[3], classes[4] ]) #def generate_xls_server(response): # wb = xlwt.Workbook() # ws = wb.add_sheet('Servers Farm') # # ws.write(0, 0, 'UsedName') # ws.write(0, 1, 'Name') # ws.write(0, 2, 'BU') # ws.write(0, 3, 'Projet') # ws.write(0, 4, 'Status') # ws.write(0, 5, 'Zone') # ws.write(0, 6, 'Type') # servers = Server.objects.all() # logger.info("Generating server XLS") # logger.debug("Found %s servers" % len(servers)) # counter = 1 # for server in servers: # classes = [] # for i in range(0,5): # values = server.puppet_classes.filter(level=i).values() # if values: # classes.append(values[0]['name']) # else: # classes.append('') # ws.write(counter, 0, server.fqdn) # ws.write(counter, 1, server.hostname) # ws.write(counter, 2, classes[0]) # ws.write(counter, 3, classes[1]) # ws.write(counter, 4, classes[2]) # ws.write(counter, 5, classes[3]) # ws.write(counter, 6, classes[4]) # counter = counter + 1 # # wb.save(response) # return response
def getAppliInfo(self, user, appname): servers = utils.extract_user_servers(user) #Retrieving applilist for any server controlled by kermit applications = [] if servers: for server in servers: environment = self.extract_environment_level(server) appli = extract_appli_details(server.hostname, environment, appname) if appli: applications.extend(appli) return applications
def generate_csv_server(user, response): """ Generates an CSV with servers list """ writer = csv.writer(response, delimiter=';') writer.writerow(["UsedName","Name","BU","Projet","Status","Zone","Type"]) servers = utils.extract_user_servers(user) logger.info("Generating servers CSV") logger.debug("Found %s servers" % len(servers)) for server in servers: classes = [] for i in range(0,5): values = server.puppet_classes.filter(level=i).values() if values: classes.append(values[0]['name']) else: classes.append('') writer.writerow([server.fqdn, server.hostname, classes[0], classes[1], classes[2], classes[3], classes[4]]) #def generate_xls_server(response): # wb = xlwt.Workbook() # ws = wb.add_sheet('Servers Farm') # # ws.write(0, 0, 'UsedName') # ws.write(0, 1, 'Name') # ws.write(0, 2, 'BU') # ws.write(0, 3, 'Projet') # ws.write(0, 4, 'Status') # ws.write(0, 5, 'Zone') # ws.write(0, 6, 'Type') # servers = Server.objects.all() # logger.info("Generating server XLS") # logger.debug("Found %s servers" % len(servers)) # counter = 1 # for server in servers: # classes = [] # for i in range(0,5): # values = server.puppet_classes.filter(level=i).values() # if values: # classes.append(values[0]['name']) # else: # classes.append('') # ws.write(counter, 0, server.fqdn) # ws.write(counter, 1, server.hostname) # ws.write(counter, 2, classes[0]) # ws.write(counter, 3, classes[1]) # ws.write(counter, 4, classes[2]) # ws.write(counter, 5, classes[3]) # ws.write(counter, 6, classes[4]) # counter = counter + 1 # # wb.save(response) # return response
def get_context(self): super_context = super(self.__class__,self).get_context() operations = [{'id': 'script_ex', 'name': 'Execute Script'}, {'id': 'deploy_bar', 'name': 'Deploy Bar'}, {'id': 'deploy_ear', 'name': 'Deploy EAR'}, {'id': 'restart_instance', 'name': 'Restart Instance'}] servers = utils.extract_user_servers(self.user) server_list = [] for server in servers: server_list.append({'id': server.fqdn, 'name': server.fqdn}) server_dict = {"results": server_list, "total": len(server_list)} widget_context = {'operations': operations, 'server_list':json.dumps(server_dict, ensure_ascii=False)} return dict(super_context.items() + widget_context.items())
def getApplications(self, user): servers = utils.extract_user_servers(user) #Retrieving applilist for any server controlled by kermit applications = [] if servers: for server in servers: environment = self.extract_environment_level(server) appli = extract_appli_info(server.hostname, environment) if appli: for app in appli: extracted = check_contains(applications, app) if extracted: extracted["deploy"] = extracted["deploy"] + 1 extracted["servers"].append(app["servers"]) else: applications.append(app) return applications
def get_context(self): super_context = super(self.__class__,self).get_context() servers = utils.extract_user_servers(self.user) widget_context = {"servers":servers} return dict(super_context.items() + widget_context.items())
def server_list(request): servers = utils.extract_user_servers(request.user) server_list = [] for server in servers: server_list.append({'id': server.fqdn, 'name': server.fqdn}) return HttpResponse(json.dumps({"results":server_list}))
def get_context(self): super_context = super(self.__class__, self).get_context() servers = utils.extract_user_servers(self.user) widget_context = {"servers": servers} return dict(super_context.items() + widget_context.items())