def __init__(self):
     self._data = {}
     self._data['auth_type'] = ''
     self._data['auth_properties'] = ''
     self._data['auth_link'] = True
     self._ad_conf = ActiveDirectoryConf()
     self._ldap_conf = LdapConf()
class AuthConf():

    def __init__(self):
        self._data = {}
        self._data['auth_type'] = ''
        self._data['auth_properties'] = ''
        self._data['auth_link'] = True
        self._ad_conf = ActiveDirectoryConf()
        self._ldap_conf = LdapConf()

    def load_data(self, conf):
        msg = 'ServerConf: Key "%s" not found in the configuration file.'
        try:
            self.set_auth_type(conf['auth_type'].lower())
        except KeyError as e:
            print msg % ('auth_type',)
        try:
            if conf['auth_type'].lower() == 'ldap':
                self._ldap_conf.load_data(conf['auth_properties'])
            else:
                self._ad_conf.load_data(conf['auth_properties'])

        except KeyError as e:
            print msg % ('auth_properties',)

    def validate(self):
        valid = validation.is_auth_type(self._data['auth_type']) 
        valid_prop = False
        if self._data['auth_type'].lower() == 'ldap':
            valid_prop = self._ldap_conf.validate()
        else:
            valid_prop = self._ad_conf.validate()
        return valid and valid_prop

    def get_auth_type(self):
        return self._data['auth_type'].encode('utf-8')

    def set_auth_type(self, auth_type):
        self._data['auth_type'] = auth_type
        return self

    def set_auth_link(self, auth_link):
        self._data['auth_link'] = auth_link
        return self

    def get_auth_link(self):
        return self._data['auth_link']

    def get_auth_properties(self):
        if self._data['auth_type'] == 'ldap':
            return self._ldap_conf
        else:
            return self._ad_conf
class AuthConf():
    def __init__(self):
        self._data = {}
        self._data['auth_type'] = ''
        self._data['auth_properties'] = ''
        self._data['auth_link'] = True
        self._ad_conf = ActiveDirectoryConf()
        self._ldap_conf = LdapConf()

    def load_data(self, conf):
        msg = 'ServerConf: Key "%s" not found in the configuration file.'
        try:
            self.set_auth_type(conf['auth_type'].lower())
        except KeyError as e:
            print msg % ('auth_type', )
        try:
            if conf['auth_type'].lower() == 'ldap':
                self._ldap_conf.load_data(conf['auth_properties'])
            else:
                self._ad_conf.load_data(conf['auth_properties'])

        except KeyError as e:
            print msg % ('auth_properties', )

    def validate(self):
        valid = validation.is_auth_type(self._data['auth_type'])
        valid_prop = False
        if self._data['auth_type'].lower() == 'ldap':
            valid_prop = self._ldap_conf.validate()
        else:
            valid_prop = self._ad_conf.validate()
        return valid and valid_prop

    def get_auth_type(self):
        return self._data['auth_type'].encode('utf-8')

    def set_auth_type(self, auth_type):
        self._data['auth_type'] = auth_type
        return self

    def set_auth_link(self, auth_link):
        self._data['auth_link'] = auth_link
        return self

    def get_auth_link(self):
        return self._data['auth_link']

    def get_auth_properties(self):
        if self._data['auth_type'] == 'ldap':
            return self._ldap_conf
        else:
            return self._ad_conf
Example #4
0
class ServerConf():

    def __init__(self):
        self._data = {}
        self._data['version'] = firstboot.serverconf.__CONFIG_FILE_VERSION__
        self._data['organization'] = ''
        self._data['notes'] = ''
        self._ldap_conf = LdapConf()
        self._chef_conf = ChefConf()

    def load_data(self, conf):
        self.set_organization(conf['organization'])
        self.set_notes(conf['notes'])
        self._ldap_conf.load_data(conf['pamldap'])
        self._chef_conf.load_data(conf['chef'])

    def validate(self):
        valid = len(self._data['version']) > 0 \
            and self._ldap_conf.validate() \
            and self._chef_conf.validate()
        return valid;

    def get_version(self):
        return self._data['version'].encode('utf-8')

    def set_version(self, version):
        self._data['version'] = version
        return self

    def get_organization(self):
        return self._data['organization'].encode('utf-8')

    def set_organization(self, organization):
        self._data['organization'] = organization
        return self

    def get_notes(self):
        return self._data['notes'].encode('utf-8')

    def set_notes(self, notes):
        self._data['notes'] = notes
        return self

    def get_ldap_conf(self):
        return self._ldap_conf

    def get_chef_conf(self):
        return self._chef_conf
Example #5
0
 def __init__(self):
     self._data = {}
     self._data['version'] = firstboot.serverconf.__CONFIG_FILE_VERSION__
     self._data['organization'] = ''
     self._data['notes'] = ''
     self._ldap_conf = LdapConf()
     self._chef_conf = ChefConf()
 def __init__(self):
     self._data = {}
     self._data['auth_type'] = ''
     self._data['auth_properties'] = ''
     self._data['auth_link'] = True
     self._ad_conf = ActiveDirectoryConf()
     self._ldap_conf = LdapConf()
Example #7
0
 def __init__(self):
     self._data = {}
     self._data['version'] = ServerConf.VERSION
     self._data['organization'] = ''
     self._data['notes'] = ''
     self._ldap_conf = LdapConf()
     self._chef_conf = ChefConf()
     self._ad_conf = ActiveDirectoryConf()
     self._ntp_conf = DateSyncConf()
Example #8
0
class ServerConf():

    # Version of the configuration JSON file
    VERSION = '1.3'

    def __init__(self):
        self._data = {}
        self._data['version'] = ServerConf.VERSION
        self._data['organization'] = ''
        self._data['notes'] = ''
        self._ldap_conf = LdapConf()
        self._chef_conf = ChefConf()
        self._ad_conf = ActiveDirectoryConf()
        self._ntp_conf = DateSyncConf()

    def load_data(self, conf):
        msg = 'ServerConf: Key "%s" not found in the configuration file.'
        try:
            v = conf['version']
            if v != ServerConf.VERSION:
                print 'WARNING: ServerConf and AUTOCONFIG_JSON version mismatch!'
        except KeyError as e:
            print msg % ('version',)
        try:
            self.set_organization(conf['organization'])
        except KeyError as e:
            print msg % ('organization',)
        try:
            self.set_notes(conf['notes'])
        except KeyError as e:
            print msg % ('notes',)
        try:
            self._ldap_conf.load_data(conf['pamldap'])
        except KeyError as e:
            print msg % ('pamldap',)
        try:
            self._chef_conf.load_data(conf['chef'])
        except KeyError as e:
            print msg % ('chef',)
        try:
            self._ad_conf.load_data(conf['ad'])
        except KeyError as e:
            print msg % ('ad',)
        try:
            self._ntp_conf.load_data(conf['ntp'])
        except KeyError as e:
            print msg % ('ntp',)

    def validate(self):
        valid = len(self._data['version']) > 0 \
            and self._ldap_conf.validate() \
            and self._chef_conf.validate() \
            and self._ad_conf.validate() \
            and self._ntp_conf.validate()
        return valid

    def get_version(self):
        return self._data['version'].encode('utf-8')

    def set_version(self, version):
        self._data['version'] = version
        return self

    def get_organization(self):
        return self._data['organization'].encode('utf-8')

    def set_organization(self, organization):
        self._data['organization'] = organization
        return self

    def get_notes(self):
        return self._data['notes'].encode('utf-8')

    def set_notes(self, notes):
        self._data['notes'] = notes
        return self

    def get_ad_conf(self):
        return self._ad_conf

    def get_ldap_conf(self):
        return self._ldap_conf

    def get_chef_conf(self):
        return self._chef_conf

    def get_ntp_conf(self):
        return self._ntp_conf