예제 #1
0
    def build(self, *_args, **_opts):
        "Build function"
        tgen = get_topogen(self)

        # This function only purpose is to create topology
        # as defined in input json file.
        #
        # Create topology (setup module)
        # Creating 2 routers topology, r1, r2in IBGP
        # Bring up topology

        # Building topology from json file
        build_topo_from_json(tgen, topo)
예제 #2
0
def build_topo(tgen):
    "Build function"

    # This function only purpose is to create topology
    # as defined in input json file.
    #
    # Example
    #
    # Creating 2 routers having single links in between,
    # which is used to establised BGP neighborship

    # Building topology from json file
    build_topo_from_json(tgen, topo)
    def build(self, *_args, **_opts):
        "Build function"
        tgen = get_topogen(self)

        # This function only purpose is to create topology
        # as defined in input json file.
        #
        # Example
        #
        # Creating 2 routers having 2 links in between,
        # one is used to establised BGP neighborship

        # Building topology from json file
        build_topo_from_json(tgen, topo)
예제 #4
0
    def build(self, *_args, **_opts):
        """Build function."""
        tgen = get_topogen(self)

        # Building topology from json file
        build_topo_from_json(tgen, topo)
예제 #5
0
    def _init_topo(self, topodef):
        """
        Initialize the topogily provided by the user. The user topology class
        must call get_topogen() during build() to get the topogen object.
        """
        # Set the global variable so the test cases can access it anywhere
        set_topogen(self)

        # Increase host based limits
        topotest.fix_host_limits()

        # Test for MPLS Kernel modules available
        self.hasmpls = False
        if not topotest.module_present("mpls-router"):
            logger.info(
                "MPLS tests will not run (missing mpls-router kernel module)")
        elif not topotest.module_present("mpls-iptunnel"):
            logger.info(
                "MPLS tests will not run (missing mpls-iptunnel kernel module)"
            )
        else:
            self.hasmpls = True

        # Load the default topology configurations
        self._load_config()

        # Create new log directory
        self.logdir = topotest.get_logs_path(g_extra_config["rundir"])
        subprocess.check_call("mkdir -p {0} && chmod 1777 {0}".format(
            self.logdir),
                              shell=True)
        try:
            routertype = self.config.get(self.CONFIG_SECTION, "routertype")
            # Only allow group, if it exist.
            gid = grp.getgrnam(routertype)[2]
            os.chown(self.logdir, 0, gid)
            os.chmod(self.logdir, 0o775)
        except KeyError:
            # Allow anyone, but set the sticky bit to avoid file deletions
            os.chmod(self.logdir, 0o1777)

        # Remove old twisty way of creating sub-classed topology object which has it's
        # build method invoked which calls Topogen methods which then call Topo methods
        # to create a topology within the Topo object, which is then used by
        # Mininet(Micronet) to build the actual topology.
        assert not inspect.isclass(topodef)

        self.net = Mininet(controller=None)

        # New direct way: Either a dictionary defines the topology or a build function
        # is supplied, or a json filename all of which build the topology by calling
        # Topogen methods which call Mininet(Micronet) methods to create the actual
        # topology.
        if not inspect.isclass(topodef):
            if callable(topodef):
                topodef(self)
                self.net.configure_hosts()
            elif is_string(topodef):
                # topojson imports topogen in one function too,
                # switch away from this use here to the topojson
                # fixutre and remove this case
                from lib.topojson import build_topo_from_json

                with open(topodef, "r") as topof:
                    self.json_topo = json.load(topof)
                build_topo_from_json(self, self.json_topo)
                self.net.configure_hosts()
            elif topodef:
                self.add_topology_from_dict(topodef)
예제 #6
0
    def build(self, *_args, **_opts):
        "Build function"
        tgen = get_topogen(self)

        # Building topology and configuration from json file
        build_topo_from_json(tgen, topo)
예제 #7
0
def build_topo(tgen):
    """Build function"""

    # Building topology from json file
    build_topo_from_json(tgen, topo)
예제 #8
0
 def build(self, *_args, **_opts):
     "Defines the allocation and relationship between routers and switches."
     tgen = get_topogen(self)
     build_topo_from_json(tgen, topo)