Example #1
0
    def render(self, session, dns_domain, position, comments, **kw):
        dbdns_domain = DnsDomain.get_unique(session, name=dns_domain,
                                            compel=True)

        dblocation = get_location(session,
                                  query_options=[subqueryload('dns_maps')],
                                  **kw)
        if not dblocation:
            raise ArgumentError("Please specify a location.")

        DnsMap.get_unique(session, dns_domain=dbdns_domain, location=dblocation,
                          preclude=True)

        dbmap = DnsMap(dns_domain=dbdns_domain, comments=comments)
        if position is not None:
            dblocation.dns_maps.insert(position, dbmap)
        else:
            dblocation.dns_maps.append(dbmap)

        session.flush()
        return
Example #2
0
def main():
    q = session.query(Campus)
    for campus in q.all():
        print "Processing {0:l}".format(campus)

        name = campus.fullname.lower().strip().replace(" ", "-") + ".ms.com"
        dbdns_domain = DnsDomain.get_unique(session, name)
        if not dbdns_domain:
            print "    - DNS Domain %s does not exist, skipping" % name
            continue

        map = DnsMap.get_unique(session,
                                location=campus,
                                dns_domain=dbdns_domain)
        if map:
            print "    - {0} is already mapped, skipping".format(dbdns_domain)
            continue

        campus.dns_maps.append(DnsMap(dns_domain=dbdns_domain))
        print "    * Mapping {0:l} to {1:l}".format(dbdns_domain, campus)

    session.commit()
Example #3
0
    def render(self, session, dns_domain, position, comments, **kw):
        dbdns_domain = DnsDomain.get_unique(session,
                                            name=dns_domain,
                                            compel=True)

        dblocation = get_location(session,
                                  query_options=[subqueryload('dns_maps')],
                                  **kw)
        if not dblocation:
            raise ArgumentError("Please specify a location.")

        DnsMap.get_unique(session,
                          dns_domain=dbdns_domain,
                          location=dblocation,
                          preclude=True)

        dbmap = DnsMap(dns_domain=dbdns_domain, comments=comments)
        if position is not None:
            dblocation.dns_maps.insert(position, dbmap)
        else:
            dblocation.dns_maps.append(dbmap)

        session.flush()
        return
Example #4
0
def main():
    q = session.query(Campus)
    for campus in q.all():
        print "Processing {0:l}".format(campus)

        name = campus.fullname.lower().strip().replace(" ", "-") + ".ms.com"
        dbdns_domain = DnsDomain.get_unique(session, name)
        if not dbdns_domain:
            print "    - DNS Domain %s does not exist, skipping" % name
            continue

        map = DnsMap.get_unique(session, location=campus,
                                dns_domain=dbdns_domain)
        if map:
            print "    - {0} is already mapped, skipping".format(dbdns_domain)
            continue

        campus.dns_maps.append(DnsMap(dns_domain=dbdns_domain))
        print "    * Mapping {0:l} to {1:l}".format(dbdns_domain, campus)

    session.commit()