Beispiel #1
0
 def rg_addresses(self):
     """Query list of addresses in local vlan+location from directory."""
     d = Directory()
     with exceptions_screened():
         for node in d.list_addresses(self.vlan, self.location):
             if node['rg'] == self.rg:
                 yield netaddr.IPNetwork(node['addr']).ip
Beispiel #2
0
 def _load(self):
     directory = Directory()
     with exceptions_screened():
         self.users = directory.list_users(self.resource_group)
         self.permissions = directory.list_permissions()
         self.admins_group = directory.lookup_resourcegroup('admins')
         self.admins_permission = {'description': 'Administrators',
                                   'id': self.admins_group['gid'],
                                   'name': self.admins_group['name']}
         self.rg_info = directory.lookup_resourcegroup(self.resource_group)
Beispiel #3
0
    def __call__(self):
        if not self.box_server:
            print('No box server. Not configuring.')
            return
        with exceptions_screened():
            self.users = self.d.list_users(os.environ.get('RESOURCE_GROUP'))
        self.users = [u for u in self.users if u['class'] == 'human']
        self.users.sort(key=lambda u: u['uid'])

        self.ensure_symlinks()
        changed = self.ensure_automap()
        if changed:
            subprocess.check_call(['/etc/init.d/autofs', 'restart'])
Beispiel #4
0
def update():
    a = argparse.ArgumentParser()
    a.add_argument('-c',
                   '--config',
                   default='/etc/local/configure-zones.cfg',
                   help='path to configuration file (default: %(default)s)')
    args = a.parse_args()
    config = configobj.ConfigObj(args.config)
    zones = Zones(config)
    directory = Directory()
    with exceptions_screened():
        for node_addr in walk(directory):
            node_addr.inject_records(zones)
    if zones.update() and config['settings'].get('reload'):
        sys.stdout.flush()
        subprocess.check_call([config['settings']['reload']], shell=True)
Beispiel #5
0
def main():
    """dhcpd.conf generator main script."""
    options, location = process_options()
    changed = False
    dhcpd = DHCPd(location, options.ipversion)
    with exceptions_screened():
        dhcpd.query_directory()
    if options.output:
        conffile = gocept.net.configfile.ConfigFile(options.output)
        conffile.write(dhcpd.render(options.include,
                                    options.local_include_dir))
        changed = conffile.commit()
    else:
        sys.stdout.write(dhcpd.render(options.include))
    if changed:
        sys.exit(2)
Beispiel #6
0
 def __call__(self):
     with exceptions_screened():
         self.users = self.d.list_users()
     self.users = [u for u in self.users if u['class'] == 'human']
     self.create_boxes()