Beispiel #1
0
    def from_dict(cls, dct, domain):
        """Load this Host from a dict"""
        if isinstance(dct, basestring):
            dct = {'name': dct}
        try:
            role = dct.pop('role').lower()
        except KeyError:
            role = domain.static_roles[0]

        hostname = dct.pop('name')
        if '.' not in hostname:
            hostname = '.'.join((hostname, domain.name))

        ip = dct.pop('ip', None)
        external_hostname = dct.pop('external_hostname', None)

        username = dct.pop('username', None)
        password = dct.pop('password', None)
        host_type = dct.pop('host_type', 'default')

        check_config_dict_empty(dct, 'host %s' % hostname)

        return cls(domain, hostname, role,
                   ip=ip,
                   external_hostname=external_hostname,
                   username=username,
                   password=password,
                   host_type=host_type)
Beispiel #2
0
    def from_dict(cls, dct, config):
        """Load this Domain from a dict
        """
        domain_type = dct.pop('type', 'default')
        domain_name = dct.pop('name')
        self = cls(config, domain_name, domain_type)

        for host_dict in dct.pop('hosts'):
            host_class = self.get_host_class(host_dict)
            host = host_class.from_dict(dict(host_dict), self)
            self.hosts.append(host)

        check_config_dict_empty(dct, 'domain %s' % domain_name)

        return self
Beispiel #3
0
    def from_dict(cls, dct, config):
        """Load this Domain from a dict
        """
        domain_type = dct.pop('type', 'default')
        domain_name = dct.pop('name')
        self = cls(config, domain_name, domain_type)

        for host_dict in dct.pop('hosts'):
            host_class = self.get_host_class(host_dict)
            host = host_class.from_dict(dict(host_dict), self)
            self.hosts.append(host)

        check_config_dict_empty(dct, 'domain %s' % domain_name)

        return self
Beispiel #4
0
    def from_dict(cls, dct, domain):
        """Load this Host from a dict"""
        if isinstance(dct, basestring):
            dct = {'name': dct}
        try:
            role = dct.pop('role').lower()
        except KeyError:
            role = domain.static_roles[0]

        hostname = dct.pop('name')
        if '.' not in hostname:
            hostname = '.'.join((hostname, domain.name))

        ip = dct.pop('ip', None)
        external_hostname = dct.pop('external_hostname', None)

        check_config_dict_empty(dct, 'host %s' % hostname)

        return cls(domain, hostname, role, ip, external_hostname)