summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Server/Plugins')
-rw-r--r--src/lib/Server/Plugins/Account.py2
-rw-r--r--src/lib/Server/Plugins/BB.py20
-rw-r--r--src/lib/Server/Plugins/Bundler.py2
-rw-r--r--src/lib/Server/Plugins/Deps.py6
-rw-r--r--src/lib/Server/Plugins/Hostbase.py2
-rw-r--r--src/lib/Server/Plugins/Metadata.py34
-rw-r--r--src/lib/Server/Plugins/SSHbase.py6
7 files changed, 36 insertions, 36 deletions
diff --git a/src/lib/Server/Plugins/Account.py b/src/lib/Server/Plugins/Account.py
index 8cab47b01..dd44390e1 100644
--- a/src/lib/Server/Plugins/Account.py
+++ b/src/lib/Server/Plugins/Account.py
@@ -62,7 +62,7 @@ class Account(Bcfg2.Server.Plugin.GeneratorPlugin):
rdata = self.repository.entries
entry.text = "".join([rdata["%s.key" % user].data for user \
in superusers if \
- rdata.has_key("%s.key" % user)])
+ ("%s.key" % user) in rdata])
perms = {'owner':'root', 'group':'root', 'perms':'0600'}
[entry.attrib.__setitem__(key, value) for (key, value) \
in perms.iteritems()]
diff --git a/src/lib/Server/Plugins/BB.py b/src/lib/Server/Plugins/BB.py
index 858ab8102..70b90016b 100644
--- a/src/lib/Server/Plugins/BB.py
+++ b/src/lib/Server/Plugins/BB.py
@@ -55,7 +55,7 @@ class BB(Bcfg2.Server.Plugin.GeneratorPlugin,
viz_str = ""
egroups = groups.findall("Group") + groups.findall('.//Groups/Group')
for group in egroups:
- if not categories.has_key(group.get('category')):
+ if not group.get('category') in categories:
categories[group.get('category')] = colors.pop()
group.set('color', categories[group.get('category')])
if None in categories:
@@ -63,7 +63,7 @@ class BB(Bcfg2.Server.Plugin.GeneratorPlugin,
if hosts:
clients = self.clients
for client, profile in clients.iteritems():
- if instances.has_key(profile):
+ if profile in instances:
instances[profile].append(client)
else:
instances[profile] = [client]
@@ -160,7 +160,7 @@ class BB(Bcfg2.Server.Plugin.GeneratorPlugin,
entry.text = self.entries["static.dhcpd.conf"].data
for host, data in self.nodes.iteritems():
entry.text += "host %s {\n" % (host + DOMAIN_SUFFIX)
- if data.has_key('mac') and data.has_key('ip'):
+ if 'mac' in data and 'ip' in data:
entry.text += " hardware ethernet %s;\n" % (data['mac'])
entry.text += " fixed-address %s;\n" % (data['ip'])
entry.text += " filename \"%s\";\n}\n" % (PXE_CONFIG)
@@ -175,7 +175,7 @@ class BB(Bcfg2.Server.Plugin.GeneratorPlugin,
entry = self.entries["static.dhcpd.conf"].data
for host, data in self.nodes.iteritems():
entry += "host %s {\n" % (host + DOMAIN_SUFFIX)
- if data.has_key('mac') and data.has_key('ip'):
+ if 'mac' in data and 'ip' in data:
entry += " hardware ethernet %s;\n" % (data['mac'])
entry += " fixed-address %s;\n" % (data['ip'])
entry += " filename \"%s\";\n}\n" % (PXE_CONFIG)
@@ -190,7 +190,7 @@ class BB(Bcfg2.Server.Plugin.GeneratorPlugin,
users = self.get_users(metadata)
rdata = self.entries
entry.text = "".join([rdata["%s.key" % user].data for user
- in users if rdata.has_key("%s.key" % user)])
+ in users if ("%s.key" % user) in rdata])
perms = {'owner':'root', 'group':'root', 'perms':'0600'}
[entry.attrib.__setitem__(key, value) for (key, value)
in perms.iteritems()]
@@ -220,7 +220,7 @@ class BB(Bcfg2.Server.Plugin.GeneratorPlugin,
users = []
for host, host_dict in self.nodes.iteritems():
if host == metadata.hostname.split('.')[0]:
- if host_dict.has_key('user'):
+ if 'user' in host_dict:
if host_dict['user'] != "none":
users.append(host_dict['user'])
return users
@@ -266,7 +266,7 @@ class BB(Bcfg2.Server.Plugin.GeneratorPlugin,
'''Handle events'''
Bcfg2.Server.Plugin.DirectoryBacked.HandleEvent(self, event)
# static.dhcpd.conf hack
- if self.entries.has_key('static.dhcpd.conf'):
+ if 'static.dhcpd.conf' in self.entries:
self.dhcpd_loaded = True
if self.need_update and self.dhcpd_loaded:
self.update_dhcpd()
@@ -285,7 +285,7 @@ class BB(Bcfg2.Server.Plugin.GeneratorPlugin,
if node.findall("Interface"):
iface = node.findall("Interface")[0]
node_dict['mac'] = iface.attrib['mac']
- if iface.attrib.has_key('ip'):
+ if 'ip' in iface.attrib:
node_dict['ip'] = iface.attrib['ip']
# populate self.clients dict
full_hostname = host + DOMAIN_SUFFIX
@@ -308,7 +308,7 @@ class BB(Bcfg2.Server.Plugin.GeneratorPlugin,
profile = "basic"
self.clients[full_hostname] = profile
# get ip address from bb.mxl, if available
- if node_dict.has_key('ip'):
+ if 'ip' in node_dict:
ip = node_dict['ip']
self.addresses[ip] = [host]
else:
@@ -319,7 +319,7 @@ class BB(Bcfg2.Server.Plugin.GeneratorPlugin,
self.nodes[host] = node_dict
# update symlinks and /etc/dhcp3/dhcpd.conf
if self.write_to_disk:
- if not node_dict.has_key('mac'):
+ if not 'mac' in node_dict:
self.logger.error("no mac address for %s" % host)
continue
mac = node_dict['mac'].replace(':','-').lower()
diff --git a/src/lib/Server/Plugins/Bundler.py b/src/lib/Server/Plugins/Bundler.py
index f771d4016..5cc881167 100644
--- a/src/lib/Server/Plugins/Bundler.py
+++ b/src/lib/Server/Plugins/Bundler.py
@@ -23,7 +23,7 @@ class Bundler(Bcfg2.Server.Plugin.StructurePlugin,
'''Build all structures for client (metadata)'''
bundleset = []
for bundlename in metadata.bundles:
- if not self.entries.has_key("%s.xml"%(bundlename)):
+ if not ("%s.xml" % bundlename) in self.entries:
self.logger.error("Client %s requested nonexistent bundle %s" % \
(metadata.hostname, bundlename))
continue
diff --git a/src/lib/Server/Plugins/Deps.py b/src/lib/Server/Plugins/Deps.py
index 21ff302fe..8749f2a31 100644
--- a/src/lib/Server/Plugins/Deps.py
+++ b/src/lib/Server/Plugins/Deps.py
@@ -61,7 +61,7 @@ class Deps(Bcfg2.Server.Plugin.PrioDir):
gdata = metadata.groups[:]
gdata.sort()
gdata = tuple(gdata)
- if self.cache.has_key((entries, gdata)):
+ if (entries, gdata) in self.cache:
prereqs = self.cache[(entries, gdata)]
else:
[src.Cache(metadata) for src in self.entries.values()]
@@ -70,8 +70,8 @@ class Deps(Bcfg2.Server.Plugin.PrioDir):
while toexamine:
entry = toexamine.pop()
matching = [src for src in self.entries.values()
- if src.cache and src.cache[1].has_key(entry[0])
- and src.cache[1][entry[0]].has_key(entry[1])]
+ if src.cache and entry[0] in src.cache[1]
+ and entry[1] in src.cache[1][entry[0]]]
if len(matching) > 1:
prio = [int(src.priority) for src in matching]
if prio.count(max(prio)) > 1:
diff --git a/src/lib/Server/Plugins/Hostbase.py b/src/lib/Server/Plugins/Hostbase.py
index 08a521545..b08e847da 100644
--- a/src/lib/Server/Plugins/Hostbase.py
+++ b/src/lib/Server/Plugins/Hostbase.py
@@ -78,7 +78,7 @@ class Hostbase(StructurePlugin,GeneratorPlugin):
def FetchFile(self, entry, metadata):
'''Return prebuilt file data'''
fname = entry.get('name').split('/')[-1]
- if not self.filedata.has_key(fname):
+ if not fname in self.filedata:
raise PluginExecutionError
perms = {'owner':'root', 'group':'root', 'perms':'644'}
[entry.attrib.__setitem__(key, value) for (key, value) in perms.iteritems()]
diff --git a/src/lib/Server/Plugins/Metadata.py b/src/lib/Server/Plugins/Metadata.py
index f17f52ed4..5ab1a9252 100644
--- a/src/lib/Server/Plugins/Metadata.py
+++ b/src/lib/Server/Plugins/Metadata.py
@@ -250,7 +250,7 @@ class Metadata(Bcfg2.Server.Plugin.MetadataPlugin,
clname = client.get('name').lower()
if 'address' in client.attrib:
caddr = client.get('address')
- if self.addresses.has_key(caddr):
+ if caddr in self.addresses:
self.addresses[caddr].append(clname)
else:
self.addresses[caddr] = [clname]
@@ -264,7 +264,7 @@ class Metadata(Bcfg2.Server.Plugin.MetadataPlugin,
self.passwords[clname] = client.get('password')
for alias in [alias for alias in client.findall('Alias')\
if 'address' in alias.attrib]:
- if self.addresses.has_key(alias.get('address')):
+ if alias.get('address') in self.addresses:
self.addresses[alias.get('address')].append(clname)
else:
self.addresses[alias.get('address')] = [clname]
@@ -289,7 +289,7 @@ class Metadata(Bcfg2.Server.Plugin.MetadataPlugin,
self.profiles.append(group.get('name'))
if group.get('public', 'false') == 'true':
self.public.append(group.get('name'))
- if group.attrib.has_key('category'):
+ if 'category' in group.attrib:
self.categories[group.get('name')] = group.get('category')
for group in grouptmp:
# self.groups[group] => (bundles, groups, categories)
@@ -300,14 +300,14 @@ class Metadata(Bcfg2.Server.Plugin.MetadataPlugin,
now = tocheck.pop()
if now not in self.groups[group][1]:
self.groups[group][1].append(now)
- if grouptmp.has_key(now):
+ if now in grouptmp:
(bundles, groups) = grouptmp[now]
for ggg in [ggg for ggg in groups if ggg not in self.groups[group][1]]:
if ggg not in self.categories or \
self.categories[ggg] not in self.groups[group][2]:
self.groups[group][1].append(ggg)
tocheck.append(ggg)
- if self.categories.has_key(ggg):
+ if ggg in self.categories:
group_cat[self.categories[ggg]] = ggg
elif ggg in self.categories:
self.logger.info("Group %s: %s cat-suppressed %s" % \
@@ -341,14 +341,14 @@ class Metadata(Bcfg2.Server.Plugin.MetadataPlugin,
if profile not in self.public:
self.logger.error("Failed to set client %s to private group %s" % (client, profile))
raise MetadataConsistencyError
- if self.clients.has_key(client):
+ if client in self.clients:
self.logger.info("Changing %s group from %s to %s" % (client, self.clients[client], profile))
cli = self.clientdata_original.xpath('.//Client[@name="%s"]' % (client))
cli[0].set('profile', profile)
else:
self.logger.info("Creating new client: %s, profile %s" % \
(client, profile))
- if self.session_cache.has_key(addresspair):
+ if addresspair in self.session_cache:
# we are working with a uuid'd client
lxml.etree.SubElement(self.clientdata_original.getroot(),
'Client', name=client,
@@ -424,12 +424,12 @@ class Metadata(Bcfg2.Server.Plugin.MetadataPlugin,
def resolve_client(self, addresspair):
'''Lookup address locally or in DNS to get a hostname'''
#print self.session_cache
- if self.session_cache.has_key(addresspair):
+ if addresspair in self.session_cache:
(stamp, uuid) = self.session_cache[addresspair]
if time.time() - stamp < 60:
return self.uuid[uuid]
address = addresspair[0]
- if self.addresses.has_key(address):
+ if address in self.addresses:
if len(self.addresses[address]) != 1:
self.logger.error("Address %s has multiple reverse assignments; a uuid must be used" % (address))
raise MetadataConsistencyError
@@ -447,9 +447,9 @@ class Metadata(Bcfg2.Server.Plugin.MetadataPlugin,
def get_metadata(self, client):
'''Return the metadata for a given client'''
client = client.lower()
- if self.aliases.has_key(client):
+ if client in self.aliases:
client = self.aliases[client]
- if self.clients.has_key(client):
+ if client in self.clients:
(bundles, groups, categories) = self.groups[self.clients[client]]
else:
if self.default == None:
@@ -462,7 +462,7 @@ class Metadata(Bcfg2.Server.Plugin.MetadataPlugin,
newbundles = bundles[:]
newcategories = {}
newcategories.update(categories)
- if self.passwords.has_key(client):
+ if client in self.passwords:
password = self.passwords[client]
else:
password = None
@@ -472,7 +472,7 @@ class Metadata(Bcfg2.Server.Plugin.MetadataPlugin,
else:
uuid = None
for group in self.cgroups.get(client, []):
- if self.groups.has_key(group):
+ if group in self.groups:
nbundles, ngroups, ncategories = self.groups[group]
else:
nbundles, ngroups, ncategories = ([], [group], {})
@@ -500,7 +500,7 @@ class Metadata(Bcfg2.Server.Plugin.MetadataPlugin,
def ReceiveDataItem(self, client, data):
'''Receive probe results pertaining to client'''
- if not self.cgroups.has_key(client.hostname):
+ if not client.hostname in self.cgroups:
self.cgroups[client.hostname] = []
if data.text == None:
self.logger.error("Got null response to probe %s from %s" % \
@@ -561,7 +561,7 @@ class Metadata(Bcfg2.Server.Plugin.MetadataPlugin,
self.logger.error("Client %s used incorrect global password" % (address[0]))
return False
if client not in self.secure:
- if self.passwords.has_key(client):
+ if client in self.passwords:
plist = [self.password, self.passwords[client]]
else:
plist = [self.password]
@@ -599,7 +599,7 @@ class Metadata(Bcfg2.Server.Plugin.MetadataPlugin,
viz_str = ""
egroups = groups.findall("Group") + groups.findall('.//Groups/Group')
for group in egroups:
- if not categories.has_key(group.get('category')):
+ if not group.get('category') in categories:
categories[group.get('category')] = colors.pop()
group.set('color', categories[group.get('category')])
if None in categories:
@@ -607,7 +607,7 @@ class Metadata(Bcfg2.Server.Plugin.MetadataPlugin,
if hosts:
clients = self.clients
for client, profile in clients.iteritems():
- if instances.has_key(profile):
+ if profile in instances:
instances[profile].append(client)
else:
instances[profile] = [client]
diff --git a/src/lib/Server/Plugins/SSHbase.py b/src/lib/Server/Plugins/SSHbase.py
index e1d80b0bc..4910cb6f4 100644
--- a/src/lib/Server/Plugins/SSHbase.py
+++ b/src/lib/Server/Plugins/SSHbase.py
@@ -108,7 +108,7 @@ class SSHbase(Bcfg2.Server.Plugin.GeneratorPlugin, Bcfg2.Server.Plugin.Director
def get_ipcache_entry(self, client):
'''build a cache of dns results'''
- if self.ipcache.has_key(client):
+ if client in self.ipcache:
if self.ipcache[client]:
return self.ipcache[client]
else:
@@ -133,7 +133,7 @@ class SSHbase(Bcfg2.Server.Plugin.GeneratorPlugin, Bcfg2.Server.Plugin.Director
client = metadata.hostname
entry.text = self.skn
hostkeys = [keytmpl % client for keytmpl in self.pubkeys \
- if self.entries.has_key(keytmpl % client)]
+ if (keytmpl % client) in self.entries]
hostkeys.sort()
for hostkey in hostkeys:
entry.text += "localhost,localhost.localdomain,127.0.0.1 %s" % (
@@ -147,7 +147,7 @@ class SSHbase(Bcfg2.Server.Plugin.GeneratorPlugin, Bcfg2.Server.Plugin.Director
filename = "%s.H_%s" % (entry.get('name').split('/')[-1], client)
if filename not in self.entries.keys():
self.GenerateHostKeys(client)
- if not self.entries.has_key(filename):
+ if not filename in self.entries:
self.logger.error("%s still not registered" % filename)
raise Bcfg2.Server.Plugin.PluginExecutionError
keydata = self.entries[filename].data