示例#1
0
	def autoWilds(self,string,testNode=False,testDomain=False):
		if not string: return string
		if testNode and model.getNodes(nodefilter=string,countOnly=True): return string
		if testDomain and model.getDomains(domainfilter=string,countOnly=True)>0: return string
		for wildchar in '%*?':
			if wildchar in string: return string
		return '*' + string + '*'
示例#2
0
	def createContent(self):
		user = self.getSessionValue('user')
		nodelist=model.getStatmonACL(user,'node_name')
		emptyMessage='''No active viewable nodes selected for user `%s' found matching: %s<br/>
			Please contact the site administrator for assistance with full details of the task you are trying to carry out.''' % (user,', '.join(nodelist))
		if not nodelist:
			emptyMessage='''No viewable nodes selected for user `%s'.<br/>
			Please contact the site administrator for assistance with full details of the task you are trying to carry out.''' % user

		self.nodeTable = nodeTable = TableController(self.req,'nodes','Nodes',emptyMessage=emptyMessage)
		nodeTable.addHeader(TH('node_name', 'Node Name',TH.TEXT,self.linkNode,sorted=True))
		nodeTable.addHeader(TH('domain_name', 'Domain Name',TH.TEXT,self.linkDomain))
		nodeTable.addHeader(TH('platform_name', 'Platform',TH.TEXT,sortDesc=False))
		nodeTable.addHeader(TH('node_version', 'Version',TH.NUMBER,sum=False))
		nodeTable.addHeader(TH('fs_min_backup_end', 'Last Time Every Filespace on Node was Successfully Backed up',TH.DATETIME,abbr='Last Complete Backup'))
		#nodeTable.addHeader(TH('fs_max_backup_end', 'Most Recent Time any Single Filespace on Node was Successfully Backed up',TH.DATETIME,abbr='Most Recent Backup'))
		#nodeTable.addHeader(TH('logical_bytes_bkup', 'Total Backup',TH.BYTES))
		#nodeTable.addHeader(TH('logical_bytes_arch', 'Total Archive',TH.BYTES))
		nodeTable.addHeader(TH('logical_total', 'Total Backup + Total Archive',TH.BYTES,dbOrder=False,abbr='Total Storage'))


		nodes = model.getNodes(
			nodelist=nodelist,
			orderby=nodeTable.getOrderBy()
		)
		for i in nodes:
			if not i.platform_name: i['platform_name'] = 'Unknown'
			i['logical_total'] = i.logical_bytes_arch+i.logical_bytes_bkup
			nodeTable.addRow(**i)
示例#3
0
	def createContent(self):
		self.days = [] # List container for all days recorded
		self.hosts = [] # List of all hosts recorded

		start, end = self.getStartEnd('historystart','endyesterday')

		schedules = model.getBackupHistory(start)
		schedules.sort(key=lambda x: x['nodename'])
		hosts = core.utils.DefaultDict( [] )

		# We need to reformat start to a datetime object.
		self.day = day = datetime.timedelta(days=1)

		user = self.getSessionValue('user')
		nodelist=model.getStatmonACL(user,'node_name')

		nodes = model.getNodes(
			nodelist=nodelist
		)

		self.nodeMap = {}
		for i in nodes:
			self.nodeMap[i.node_name] = i
		i = start
		last_success = {}
		while i <= end:
			self.days.append(i)
			i = i + day
		for i in schedules:
			if not self.nodeMap.has_key(i.nodename): continue
			hosts[i.nodename].append( i )
		for host, records in hosts.iteritems():
			self.hosts.append(host)
			log = core.utils.DefaultDict( 'U' )
			for i in records:
				if i['msgno'] == 2507:
					ls = max( self.parseDate(i['date_time']), last_success.get(host,None))
					last_success[host] = ls
					if log[ self.parseDate( i['date_time'] ) ] == 'N':
						i['successful'] = 'N'
					else:
						i['successful'] = 'Y'
				elif i['msgno'] == 2579:
					i['successful'] = 'N'
				elif i['msgno'] == 2578:
					i['successful'] = 'M'
				else:
					i['successful'] = 'U'
				log[ self.parseDate( i['date_time'] ) ] = i['successful']
			i = start
			while i < end:
				log[ self.parseDate(i)] = log[ self.parseDate(i)]
				i = i + day
			hosts[host] = log
		self.hostMap = hosts
		self.hosts.sort(key=lambda x: last_success.get(x,None) )
		self.last_success = last_success
		self.days.sort()
示例#4
0
	def createContent(self):
		domainfilter = self.processInput(self.standardInputs['domain'])
		nodefilter = self.processInput(self.standardInputs['node'])

		contacts = map( lambda x: (x['activity'],x['activity']), model.getAnzaContacts() )

		contactfilter = self.processInput(II('contact','Contact',II.DROPDOWN,options=contacts,allowBlank=True,blankVal=''))

		#stgpool = self.processInput(self.standardInputs['stgpool'])
		
		showDuplicatePools = self.processInput(II('dups','Include _DUP_',II.DROPDOWN,options=[('yes','Yes'),('','No')],allowBlank=True))

		# Create node list table
		self.nodeTable = nodeTable = TableController(self.req,'nodes','Nodes')
		if not contactfilter:
			nodeTable.addHeader(TH('contact', 'Contact',TH.TEXT,sorted=True))
			nodeTable.addHeader(TH('node_name', 'Node Name',TH.TEXT,self.linkNode))
		else:
			nodeTable.addHeader(TH('node_name', 'Node Name',TH.TEXT,self.linkNode,sorted=True))
		nodeTable.addHeader(TH('num_files', 'Number of Files',TH.NUMBER,dbOrder=False))
		nodeTable.addHeader(TH('logical_total', 'Total Storage',TH.BYTES,dbOrder=False))
		
		nodes = model.getNodes(
			nodefilter=nodefilter,
			domainfilter=domainfilter,
			contactfilter=contactfilter,
			orderby=nodeTable.getOrderBy()
		)
		
		for i in nodes:
			i['logical_total'] = i.logical_bytes_arch+i.logical_bytes_bkup
			i['num_files'] = i.num_files_bkup + i.num_files_arch
			if showDuplicatePools == True:
				i['logical_total'] += i.dup_logical_bytes_arch+i.dup_logical_bytes_bkup
				i['num_files'] += i.dup_num_files_bkup + i.dup_num_files_arch
			nodeTable.addRow(**i)
示例#5
0
	def createContent(self):
		domainfilter = self.processInput(self.standardInputs['domain'])
		nodefilter = self.processInput(self.standardInputs['node'])

		contacts = map( lambda x: (x['contact'],'%s (%d)' % (x['contact'],x['count'])), model.getAnzaContacts() )
		contactfilter = self.processInput(II('contact','Contact',II.DROPDOWN,options=contacts,allowBlank=True,blankVal=''))

		start = self.processInput(self.standardInputs['startyesterday'])
		end = self.processInput(self.standardInputs['endtoday'])

		nodes = model.getNodes(
			nodefilter=nodefilter,
			domainfilter=domainfilter,
			contactfilter=contactfilter
		)

		self.filespaces = {}
		self.clientopts = {}
		self.nodeList = []
		self.domainList = {}
		
		for i in nodes:
			self.nodeList.append( i.node_name )
			self.domainList[i.domain_name] = None
			# Filespace and filespace graphs
			self.filespaces[i.node_name] = filespaceTable = TableController(self.req,'filespaces_%s'%i.node_name,'Filespaces')
			filespaceTable.addHeader(TH('filespace_name','Filespace Name',TH.TEXT))
			filespaceTable.addHeader(TH('filespace_type', 'FS Type',TH.TEXT))
			filespaceTable.addHeader(TH('backup_end', 'Last Backup',TH.DATE))
			filespaceTable.addHeader(TH('capacity_bytes', 'Capacity',TH.BYTES,self.linkGraph))
			filespaceTable.addHeader(TH('used_bytes', 'Used',TH.BYTES,self.linkGraph))
			filespaceTable.addHeader(TH('logical_total', 'In Storage',TH.BYTES,dbOrder=False,sorted=True))
	
			filespaces = model.getFilespaces(i.node_name,orderby=filespaceTable.getOrderBy())
			for j in filespaces:
				j['logical_total'] = j.logical_bytes_bkup+j.logical_bytes_arch
				filespaceTable.addRow(**j)

			# Optionsets
			self.clientopts[i.node_name] = clientoptsTable = TableController(self.req,'clientopts_%s'%i.node_name,'Client Options Set',dbOrder=False)
			clientoptsTable.addHeader(TH('seqnumber','Sequence', TH.NUMBER,sorted=True,sortDesc=False))
			clientoptsTable.addHeader(TH('option_name','Option Name', TH.TEXT))
			clientoptsTable.addHeader(TH('option_value','Value', TH.NUMBER))
			
			clientopts = model.getClientopts(i.node_name)
			for j in clientopts: clientoptsTable.addRow(**j)
		
		copygroups = []
		for i in self.domainList.keys():
			copygroups += model.getCopygroups(domain_name=i)
		
		# Lets construct a copygroup table
		self.copygroups = copygroupTable = TableController(self.req,'copygroup','Copygroups',dbOrder=False)
		copygroupTable.addHeader(TH('domain_name', 'Domain Name', TH.TEXT ))
		copygroupTable.addHeader(TH('set_name', 'Set Name', TH.TEXT ))
		copygroupTable.addHeader(TH('copygroup_name', 'Group Name', TH.TEXT ))
		copygroupTable.addHeader(TH('destination', 'Destination', TH.TEXT ))
		copygroupTable.addHeader(TH('verexists', 'Versions Data Exists', TH.TEXT ))
		copygroupTable.addHeader(TH('verdeleted', 'Versions Data Deleted', TH.TEXT ))
		copygroupTable.addHeader(TH('retextra', 'Retain Extra Versions', TH.TEXT ))
		copygroupTable.addHeader(TH('retonly', 'Retain Only Version', TH.TEXT ))
		
		for j in copygroups: copygroupTable.addRow(**j)
		self.nodeList.sort()
示例#6
0
	def createContent(self):
		update, user = self.processInputs(allowBlankUser=False)

		updateNodes = StringToBool(self.getField('updateNodes'))

		# checked="checked"
		jsScript = '''<input class="checkbox" type="checkbox" name="_ALL_" onchange="SetAllCheckBoxes(this,this.checked);"/>'''
		extraFooter = '''<input class="submit commit" value="Add/Update User" type="submit">'''

		self.nodeTable = nodeTable = TableController(self.req,'nodes','Nodes',emptyMessage='No Matching Nodes Found',extraFooter=extraFooter,extraFooterClass='button')
		nodeTable.addHeader(TH('show_hide', jsScript,TH.HTML,sortable=False,escapeName=False))
		#nodeTable.addHeader(TH('view', 'View',TH.TEXT))
		nodeTable.addHeader(TH('node_name', 'Node Name',TH.TEXT,self.linkNode,sorted=True))
		nodeTable.addHeader(TH('domain_name', 'Domain Name',TH.TEXT,self.linkDomain))
		nodeTable.addHeader(TH('platform_name', 'Platform',TH.TEXT,sortDesc=False))
		nodeTable.addHeader(TH('node_version', 'Version',TH.NUMBER,sum=False))
		nodeTable.addHeader(TH('contact', 'Contact',TH.TEXT))

		self.addHiddenValue('user',user)
		domainfilter = self.processInput(self.standardInputs['domain'])
		nodefilter = self.processInput(self.standardInputs['node'])

		# TODO: ehrm.. something
		contacts = map( lambda x: (x['contact'],'%s (%d)' % (x['contact'],x['count'])), model.getAnzaContacts() )
		contactfilter = self.processInput(II('contact','Contact',II.DROPDOWN,options=contacts,allowBlank=True,blankVal=''))

		currentOpts = [('','-'),('1','Currently Seen'),('2','Currently Not Seen')]
		current = self.processInput(II('current','User Nodes',II.DROPDOWN,options=currentOpts,allowBlank=True,blankVal=''))

		invertOpts = [('','No'),('1','Yes')]
		invert = self.processInput(II('invert','Invert Result',II.DROPDOWN,options=invertOpts,allowBlank=True,blankVal=''))

		aclNodes = {}
		nodelist = []
		if user:
			for node in model.getStatmonACL(user,'node_name'):
				aclNodes[node] = True
				if current: nodelist.append(node)
		if not current: nodelist = None

		nodes = model.getNodes(
			nodefilter=nodefilter,
			nodelist=nodelist,
			domainfilter=domainfilter,
			contactfilter=contactfilter,
			orderby=nodeTable.getOrderBy(),
			invert=invert,
			invertNodelist=(current=='2'),
		)

		protected = model.getNodes(
			nodefilter=nodefilter,
			nodelist=nodelist,
			domainfilter=domainfilter,
			contactfilter=contactfilter,
			invert=not invert,
			invertNodelist=(current=='2'),
		)
		newAcl = {}
		if protected:
			self.inputHidden = False
			for node in protected:
				if aclNodes.has_key(node.node_name):
					newAcl[node.node_name] = True


		for node in nodes:
			checkname = '_%s_' % node.node_name

			old = checked = aclNodes.get(node.node_name,False)
			if updateNodes:
				checked = bool(self.getField(checkname,False))
			if checked:
				newAcl[node.node_name] = True
				node['oddevenclass'] = 'Checked'
			if not update and (old != checked):
				node['oddevenclass'] = 'Pending'

			check = ''
			if checked: check = 'checked="checked"'
			node['show_hide'] = '''<input class="checkbox" name="%s" type="checkbox" %s/>''' % (checkname, check)

			nodeTable.addRow(**node)

		if updateNodes:
			if update:
				intersect = {}
				deleted = {}
				added = {}
				union = {}
				for node in newAcl.keys():
					union[node] = True
					if aclNodes.has_key(node): intersect[node] = True
					else: added[node] = True
				for node in aclNodes.keys():
					union[node] = True
					if newAcl.has_key(node): intersect[node] = True
					else: deleted[node] = True
				self.addMessage('Node list updated: <span class="varible">%d</span> nodes affected, <span class="varible">%d</span> unchanged, <span class="varible">%d</span> added and <span class="varible">%d</span> deleted.' % (len(union),len(intersect),len(added),len(deleted)))
				model.updateStatmonACL(user,'node_name',newAcl)
			else:
				self.addMessage('Node list changes in red not applied, see above error.')