Beispiel #1
0
    def render(self, session, name, type, **arguments):
        dblocation = Location.get_unique(session, name=name, location_type=type,
                                         compel=True)

        q = session.query(Network).filter_by(location=dblocation)
        if q.count():
            raise ArgumentError("Could not delete {0:l}, networks were found "
                                "using this location.".format(dblocation))

        q = session.query(NetworkEnvironment).filter_by(location=dblocation)
        if q.count():
            raise ArgumentError("Could not delete {0:l}, network environments "
                                "were found using this location."
                                .format(dblocation))

        q = session.query(Cluster).filter_by(location_constraint=dblocation)
        if q.count():
            raise ArgumentError("Could not delete {0:l}, clusters were found "
                                "using this location.".format(dblocation))

        q = session.query(HardwareEntity).filter_by(location=dblocation)
        if q.count():
            raise ArgumentError("Could not delete {0:l}, hardware objects were "
                                "found using this location.".format(dblocation))

        session.delete(dblocation)
        return
Beispiel #2
0
    def render(self, session, name, type, **arguments):
        dblocation = Location.get_unique(session,
                                         name=name,
                                         location_type=type,
                                         compel=True)

        q = session.query(Network).filter_by(location=dblocation)
        if q.count():
            raise ArgumentError("Could not delete {0:l}, networks were found "
                                "using this location.".format(dblocation))

        q = session.query(NetworkEnvironment).filter_by(location=dblocation)
        if q.count():
            raise ArgumentError(
                "Could not delete {0:l}, network environments "
                "were found using this location.".format(dblocation))

        q = session.query(Cluster).filter_by(location_constraint=dblocation)
        if q.count():
            raise ArgumentError("Could not delete {0:l}, clusters were found "
                                "using this location.".format(dblocation))

        q = session.query(HardwareEntity).filter_by(location=dblocation)
        if q.count():
            raise ArgumentError(
                "Could not delete {0:l}, hardware objects were "
                "found using this location.".format(dblocation))

        session.delete(dblocation)
        return
Beispiel #3
0
    def render(self, session, type, name, **arguments):
        cls = Location.polymorphic_subclass(type, "Unknown location type")
        query = session.query(cls)
        query = query.options(subqueryload('parents'),
                              subqueryload('default_dns_domain'))

        if name:
            query = query.filter_by(name=name)
            try:
                return query.one()
            except NoResultFound:
                raise NotFoundException("%s %s not found." %
                                        (cls._get_class_label(), name))

        return query.order_by(Location.location_type, Location.name).all()
Beispiel #4
0
    def render(self, session, type, name, **arguments):
        cls = Location.polymorphic_subclass(type, "Unknown location type")
        query = session.query(cls)
        query = query.options(subqueryload('parents'),
                              subqueryload('default_dns_domain'))

        if name:
            query = query.filter_by(name=name)
            try:
                return query.one()
            except NoResultFound:
                raise NotFoundException("%s %s not found." %
                                        (cls._get_class_label(), name))

        return LocationList(
            query.order_by(Location.location_type, Location.name).all())
Beispiel #5
0
    def render(self, session, logger, metacluster, archetype, personality,
               domain, sandbox, max_members, buildstatus, comments,
               **arguments):

        validate_nlist_key("metacluster", metacluster)

        # this should be reverted when virtbuild supports these options
        if not archetype:
            archetype = "metacluster"

        if not personality:
            personality = "metacluster"

        dbpersonality = Personality.get_unique(session, name=personality,
                                               archetype=archetype, compel=True)
        if not dbpersonality.is_cluster:
            raise ArgumentError("%s is not a cluster personality." %
                                personality)

        if not buildstatus:
            buildstatus = "build"
        dbstatus = ClusterLifecycle.get_instance(session, buildstatus)

        # this should be reverted when virtbuild supports these options
        if not domain and not sandbox:
            domain = self.config.get("archetype_metacluster", "host_domain")

        (dbbranch, dbauthor) = get_branch_and_author(session, logger,
                                                     domain=domain,
                                                     sandbox=sandbox,
                                                     compel=False)

        dbloc = get_location(session, **arguments)

        # this should be reverted when virtbuild supports this option
        if not dbloc:
            dbloc = Location.get_unique(session,
                                        name=self.config.get("archetype_metacluster",
                                                             "location_name"),
                                        location_type=self.config.get("archetype_metacluster",
                                                                      "location_type"))
        elif not dbloc.campus:
            raise ArgumentError("{0} is not within a campus.".format(dbloc))

        if max_members is None:
            max_members = self.config.getint("archetype_metacluster",
                                             "max_members_default")

        if metacluster.strip().lower() == 'global':
            raise ArgumentError("Metacluster name global is reserved.")

        MetaCluster.get_unique(session, metacluster, preclude=True)

        dbcluster = MetaCluster(name=metacluster, location_constraint=dbloc,
                                personality=dbpersonality,
                                max_clusters=max_members,
                                branch=dbbranch, sandbox_author=dbauthor,
                                status=dbstatus, comments=comments)

        session.add(dbcluster)
        session.flush()

        plenary = Plenary.get_plenary(dbcluster, logger=logger)
        plenary.write()

        return
Beispiel #6
0
    def render(self, session, logger,
               metacluster, archetype, personality,
               domain, sandbox,
               max_members,
               buildstatus, comments,
               **arguments):

        validate_basic("metacluster", metacluster)

        # this should be reverted when virtbuild supports these options
        if not archetype:
            archetype = "metacluster"

        if not personality:
            personality = "metacluster"

        dbpersonality = Personality.get_unique(session, name=personality,
                                               archetype=archetype, compel=True)
        if not dbpersonality.is_cluster:
            raise ArgumentError("%s is not a cluster personality." %
                                personality)

        ctype = "meta"  # dbpersonality.archetype.cluster_type

        if not buildstatus:
            buildstatus = "build"
        dbstatus = ClusterLifecycle.get_unique(session, buildstatus,
                                               compel=True)

        # this should be reverted when virtbuild supports these options
        if not domain and not sandbox:
            domain = self.config.get("archetype_metacluster", "host_domain")

        (dbbranch, dbauthor) = get_branch_and_author(session, logger,
                                                     domain=domain,
                                                     sandbox=sandbox,
                                                     compel=False)

        dbloc = get_location(session, **arguments)

        # this should be reverted when virtbuild supports this option
        if not dbloc:
            dbloc = Location.get_unique(session,
                                        name=self.config.get("archetype_metacluster",
                                                             "location_name"),
                                        location_type=self.config.get("archetype_metacluster",
                                                                      "location_type"))
        elif not dbloc.campus:
            raise ArgumentError("{0} is not within a campus.".format(dbloc))

        if max_members is None:
            max_members = self.config.getint("archetype_metacluster",
                                             "max_members_default")

        if metacluster.strip().lower() == 'global':
            raise ArgumentError("Metacluster name global is reserved.")

        MetaCluster.get_unique(session, metacluster, preclude=True)
        clus_type = MetaCluster  # Cluster.__mapper__.polymorphic_map[ctype].class_

        kw = {}

        dbcluster = MetaCluster(name=metacluster, location_constraint=dbloc,
                                personality=dbpersonality,
                                max_clusters=max_members,
                                branch=dbbranch, sandbox_author=dbauthor,
                                status=dbstatus, comments=comments)

        session.add(dbcluster)
        session.flush()

        plenary = PlenaryMetaCluster(dbcluster, logger=logger)
        plenary.write()

        return