Beispiel #1
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)
Beispiel #2
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()
Beispiel #3
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.')