コード例 #1
0
def check_csmcompat(csm):
	warn = 0

# first check nodes
	nodes = synctool_config.get_all_nodes()
	ifaces = {}

	for node in nodes:
		host = synctool_config.get_node_interface(node)
		ifaces[host] = node

		if not csm['host'].has_key(host) and not node in synctool_config.IGNORE_GROUPS:
			print 'synctool node %s is not defined in CSM' % host
			warn = warn + 1

	for host in csm['host'].keys():
		if not ifaces.has_key(host):
			print 'CSM host %s is not defined in synctool' % host
			warn = warn + 1

# check groups
	nodes = synctool_config.get_all_nodes()

	for node in nodes:
		host = synctool_config.get_node_interface(node)

		synctool_groups = synctool_config.get_groups(node)
		synctool_groups.sort()

		try:
			csm_groups = csm['host'][host]
		except KeyError:			# this is OK because we checked all nodes earlier
			continue

		csm_groups.sort()

		if synctool_groups == csm_groups:
			continue

		for group in synctool_groups:
			if group == node or group == host:		# filter default synctool groups
				continue

			if not group in csm_groups:
 				print 'CSM host %s is not a member of group %s' % (host, group)
				warn = warn + 1

		for group in csm_groups:
			if not group in synctool_groups:
				print 'synctool node %s is not a member of group %s' % (node, group)
				warn = warn + 1

	for group in csm['emptygroups']:
		if not group in synctool_config.IGNORE_GROUPS:
			print 'CSM defines empty group %s' % group
			warn = warn + 1

	if not warn:
		print 'synctool and CSM configs are in sync'
コード例 #2
0
ファイル: synctool_nodeset.py プロジェクト: gyepisam/synctool
	def interfaces(self):
		'''return list of interfaces of relevant nodes'''
		
		explicit_includes = self.nodelist[:]
		
		# by default, work on all nodes
		if not self.nodelist and not self.grouplist:
			self.nodelist = synctool_config.get_all_nodes()
		
		# check if the nodes exist at all; the user could have given bogus names
		all_nodes = synctool_config.get_all_nodes()
		for node in self.nodelist:
			if not node in all_nodes:
				stderr("no such node '%s'" % node)
				return None
		
		if self.grouplist:
			# check if the groups exist at all
			all_groups = synctool_config.make_all_groups()
			for group in self.grouplist:
				if not group in all_groups:
					stderr("no such group '%s'" % group)
					return None
			
			self.nodelist.extend(synctool_config.get_nodes_in_groups(self.grouplist))
		
		if self.exclude_groups:
			self.exclude_nodes.extend(synctool_config.get_nodes_in_groups(self.exclude_groups))
		
		for node in self.exclude_nodes:
			# remove excluded nodes, if not explicitly included
			if node in self.nodelist and not node in explicit_includes:
				self.nodelist.remove(node)
		
		if len(self.nodelist) <= 0:
			return []
		
		ifaces = []
		
		for node in self.nodelist:
			if node in synctool_param.IGNORE_GROUPS and not node in explicit_includes:
				verbose('node %s is ignored' % node)
				continue
			
			groups = synctool_config.get_groups(node)
			do_continue = False
			
			for group in groups:
				if group in synctool_param.IGNORE_GROUPS:
					verbose('group %s is ignored' % group)
					do_continue = True
					break
			
			if do_continue:
				continue
			
			iface = synctool_config.get_node_interface(node)
			self.namemap[iface] = node
			
			if not iface in ifaces:		# make sure we do not have duplicates
				ifaces.append(iface)
		
		return ifaces
コード例 #3
0
ファイル: synctool_nodeset.py プロジェクト: samuelet/synctool
	def interfaces(self):
		'''return list of interfaces of relevant nodes'''
		
		explicit_includes = self.nodelist[:]
		
		# by default, work on all nodes
		if not self.nodelist and not self.grouplist:
			self.nodelist = synctool_config.get_nodes_in_groups(["all"])
		
		# check if the nodes exist at all; the user could have given bogus names
		all_nodes = synctool_config.get_all_nodes()
		for node in self.nodelist:
			if not node in all_nodes:
				stderr("no such node '%s'" % node)
				return None
		
		if self.grouplist:
			# check if the groups exist at all
			all_groups = synctool_config.make_all_groups()
			for group in self.grouplist:
				if not group in all_groups:
					stderr("no such group '%s'" % group)
					return None
			
			self.nodelist.extend(synctool_config.get_nodes_in_groups(self.grouplist))
		
		if self.exclude_groups:
			self.exclude_nodes.extend(synctool_config.get_nodes_in_groups(self.exclude_groups))
		
		for node in self.exclude_nodes:
			# remove excluded nodes, if not explicitly included
			if node in self.nodelist and not node in explicit_includes:
				self.nodelist.remove(node)
		
		if len(self.nodelist) <= 0:
			return []
		
		ifaces = []
		ignored_nodes = ''
		
		for node in self.nodelist:
			if node in synctool_param.IGNORE_GROUPS and not node in explicit_includes:
				verbose('node %s is ignored' % node)
				
				if not ignored_nodes:
					ignored_nodes = node
				else:
					ignored_nodes = ignored_nodes + ',' + node
				continue
			
			groups = synctool_config.get_groups(node)
			do_continue = False
			
			for group in groups:
				if group in synctool_param.IGNORE_GROUPS:
					verbose('group %s is ignored' % group)
					
					if not ignored_nodes:
						ignored_nodes = node
					else:
						ignored_nodes = ignored_nodes + ',' + node
					
					do_continue = True
					break
			
			if do_continue:
				continue
			
			iface = synctool_config.get_node_interface(node)
			self.namemap[iface] = node
			
			if not iface in ifaces:		# make sure we do not have duplicates
				ifaces.append(iface)
		
		# print message about ignored nodes
		if ignored_nodes and not synctool_lib.QUIET and not synctool_lib.UNIX_CMD:
			if synctool_param.TERSE:
				synctool_lib.terse(synctool_lib.TERSE_WARNING, 'ignored nodes')
			else:
				ignored_nodes = 'warning: ignored nodes: ' + ignored_nodes
				if len(ignored_nodes) < 80:
					print ignored_nodes
				else:
					print 'warning: some nodes are ignored'
		
		return ifaces
コード例 #4
0
ファイル: synctool_csmcompat.py プロジェクト: zenny/synctool
def check_csmcompat(csm):
    warn = 0

    # first check nodes
    nodes = synctool_config.get_all_nodes()
    ifaces = {}

    for node in nodes:
        host = synctool_config.get_node_interface(node)
        ifaces[host] = node

        if not csm['host'].has_key(
                host) and not node in synctool_config.IGNORE_GROUPS:
            print 'synctool node %s is not defined in CSM' % host
            warn = warn + 1

    for host in csm['host'].keys():
        if not ifaces.has_key(host):
            print 'CSM host %s is not defined in synctool' % host
            warn = warn + 1


# check groups
    nodes = synctool_config.get_all_nodes()

    for node in nodes:
        host = synctool_config.get_node_interface(node)

        synctool_groups = synctool_config.get_groups(node)
        synctool_groups.sort()

        try:
            csm_groups = csm['host'][host]
        except KeyError:  # this is OK because we checked all nodes earlier
            continue

        csm_groups.sort()

        if synctool_groups == csm_groups:
            continue

        for group in synctool_groups:
            if group == node or group == host:  # filter default synctool groups
                continue

            if not group in csm_groups:
                print 'CSM host %s is not a member of group %s' % (host, group)
                warn = warn + 1

        for group in csm_groups:
            if not group in synctool_groups:
                print 'synctool node %s is not a member of group %s' % (node,
                                                                        group)
                warn = warn + 1

    for group in csm['emptygroups']:
        if not group in synctool_config.IGNORE_GROUPS:
            print 'CSM defines empty group %s' % group
            warn = warn + 1

    if not warn:
        print 'synctool and CSM configs are in sync'