Esempio n. 1
0
    def render(self, session, logger, prefix, dns_domain, hostname, machine,
               **args):
        if dns_domain:
            dbdns_domain = DnsDomain.get_unique(session, dns_domain,
                                                compel=True)
        else:
            dbmachine = Machine.get_unique(session, machine, compel=True)
            dbdns_domain = None
            loc = dbmachine.location
            while loc and not dbdns_domain:
                dbdns_domain = loc.default_dns_domain
                loc = loc.parent

            if not dbdns_domain:
                raise ArgumentError("There is no default DNS domain configured "
                                    "for the machine's location. Please "
                                    "specify --dns_domain.")

        # Lock the DNS domain to prevent the same name generated for
        # simultaneous requests
        dbdns_domain.lock_row()

        prefix = AqStr.normalize(prefix)
        result = search_next(session=session, cls=Fqdn, attr=Fqdn.name,
                             value=prefix, dns_domain=dbdns_domain,
                             start=None, pack=None)
        hostname = "%s%d.%s" % (prefix, result, dbdns_domain)

        CommandAddHost.render(self, session, logger, hostname=hostname,
                              machine=machine, **args)

        logger.info("Selected host name %s" % hostname)
        self.audit_result(session, 'hostname', hostname, **args)
        return hostname
Esempio n. 2
0
 def render(self, *args, **kwargs):
     kwargs["archetype"] = "windows"
     kwargs["osname"] = "windows"
     kwargs["domain"] = None
     kwargs["sandbox"] = None
     kwargs["zebra_interfaces"] = None
     # The superclass already contains the logic to handle this case.
     return CommandAddHost.render(self, *args, **kwargs)
Esempio n. 3
0
 def render(self, *args, **kwargs):
     kwargs['archetype'] = 'windows'
     kwargs['osname'] = 'windows'
     kwargs['domain'] = None
     kwargs['sandbox'] = None
     kwargs['zebra_interfaces'] = None
     # The superclass already contains the logic to handle this case.
     return CommandAddHost.render(self, *args, **kwargs)
Esempio n. 4
0
 def render(self, *args, **kwargs):
     # The superclass already contains the logic to handle this case.
     kwargs['archetype'] = 'aquilon'
     return CommandAddHost.render(self, *args, **kwargs)
Esempio n. 5
0
                dbnetwork = get_net_id_from_ip(session, IPv4Address(host_ip), dbnet_env)
                dblocation = dbnetwork.location.building

            dbmachine = create_machine(session, machine, dblocation, dbmodel)
            # create_machine already does a save and a flush
            if dbslot:
                dbslot.machine = dbmachine
                session.add(dbslot)
        # FIXME: Pull this from somewhere.
        buildstatus = 'ready'

        kwargs['skip_dsdb_check'] = True
        kwargs['session'] = session
        kwargs['logger'] = logger
        kwargs['hostname'] = fqdn
        kwargs['archetype'] = 'aurora'
        kwargs['osname'] = osname
        kwargs['osversion'] = osversion
        kwargs['personality'] = None
        kwargs['domain'] = None
        kwargs['sandbox'] = None
        kwargs['machine'] = dbmachine.label
        kwargs['buildstatus'] = buildstatus
        kwargs['ip'] = None
        kwargs['zebra_interfaces'] = None
        kwargs['grn'] = None
        kwargs['eon_id'] = None
        # The superclass already contains the rest of the logic to handle this.
        return CommandAddHost.render(self, **kwargs)
Esempio n. 6
0
                dbnetwork = get_net_id_from_ip(session, IPv4Address(host_ip), dbnet_env)
                dblocation = dbnetwork.location.building

            dbmachine = create_machine(session, machine, dblocation, dbmodel)
            # create_machine already does a save and a flush
            if dbslot:
                dbslot.machine = dbmachine
                session.add(dbslot)
        # FIXME: Pull this from somewhere.
        buildstatus = 'ready'

        kwargs['skip_dsdb_check'] = True
        kwargs['session'] = session
        kwargs['logger'] = logger
        kwargs['hostname'] = fqdn
        kwargs['archetype'] = 'aurora'
        kwargs['osname'] = osname
        kwargs['osversion'] = osversion
        kwargs['personality'] = None
        kwargs['domain'] = None
        kwargs['sandbox'] = None
        kwargs['machine'] = dbmachine.label
        kwargs['buildstatus'] = buildstatus
        kwargs['ip'] = None
        kwargs['zebra_interfaces'] = None
        kwargs['grn'] = None
        kwargs['eon_id'] = None
        # The superclass already contains the rest of the logic to handle this.
        return CommandAddHost.render(self, **kwargs)