コード例 #1
0
    def create_network(self,
                       name,
                       driver="calico",
                       ipam_driver="calico-ipam",
                       subnet=None):
        """
        Create a Docker network using this host.  If the DockerHost is used
        as a context manager, exit processing will attempt deletion of *all*
        networks created across *all* Docker hosts - if you do not want the
        tidy up of networks to occur automatically, don't use the DockerHost as
        a context manager and perform tidy explicitly.

        :param name: The name of the network.  This must be unique per cluster
        and it is the user-facing identifier for the network.
        :param driver: The name of the network driver to use.  (The Calico
        driver is the default.)
        :param ipam_driver:  The name of the IPAM driver to use.  (The Calico
        driver is the default.)
        :param subnet: The subnet IP pool to assign IPs from.
        :return: A DockerNetwork object.
        """

        nw = DummyNetwork(name)

        if self.networking == NETWORKING_LIBNETWORK:
            nw = DockerNetwork(self,
                               name,
                               driver=driver,
                               ipam_driver=ipam_driver,
                               subnet=subnet)

        # Store the network so that we can attempt to remove it when this host
        # or another host exits.
        self.docker_networks.append(nw)
        return nw
コード例 #2
0
 def create_network(name):
     return DummyNetwork(name)