Пример #1
0
    def add(self, source, destination, port):
        """
        Make the service or cidr block described by "destination" accessible from the service or
        cidr block described by "source" on the given port.

        Either "source" or "destination" must be a service object.
        """
        logger.info('Adding path from %s to %s on port %s', source, destination, port)
        return self.paths.add(source, destination, port)
Пример #2
0
    def remove(self, source, destination, port):
        """
        Ensure the service or cidr block described by "destination" is not accessible from the
        service or cidr block described by "source" on the given port.

        Either "source" or "destination" must be a service object.
        """
        logger.info('Removing path from %s to %s on port %s', source, destination, port)
        return self.paths.remove(source, destination, port)
Пример #3
0
 def destroy(self, service):
     """
     Destroy a service described by the "service" object.
     """
     logger.info('Destroying service %s', service)
     if not isinstance(service, Service):
         raise DisallowedOperationException(
             "Service argument to destroy must be of type butter.types.common.Service"
         )
     return self.service.destroy(service)
Пример #4
0
    def list(self):
        """
        List all networks.

        Example:

            client.network.list()

        """
        logger.info('Listing networks')
        return self.network.list()
Пример #5
0
    def get(self, name):
        """
        Get a network named "name" and return some data about it.

        Example:

            client.network.get("mynetwork")

        """
        logger.info('Getting network %s', name)
        return self.network.get(name)
Пример #6
0
    def create(self, name, blueprint=None):
        """
        Create new network named "name" with blueprint file at "blueprint".

        Example:

            client.network.create("mynetwork", "network-blueprint.yml")

        """
        logger.info('Creating network %s with blueprint %s', name, blueprint)
        return self.network.create(name, blueprint)
Пример #7
0
 def get(self, network, service_name):
     """
     Get a service in "network" named "service_name".
     """
     logger.info('Discovering service %s in network %s', service_name,
                 network)
     if not isinstance(network, Network):
         raise DisallowedOperationException(
             "Network argument to get must be of type butter.types.common.Network"
         )
     return self.service.get(network, service_name)
Пример #8
0
    def destroy(self, network):
        """
        Destroy the given network.

        Example:

            client.network.destroy(client.network.get("mynetwork"))

        """
        logger.info('Destroying network %s', network)
        if not isinstance(network, Network):
            raise DisallowedOperationException(
                "Argument to destroy must be of type butter.types.common.Network"
            )
        return self.network.destroy(network)
Пример #9
0
    def create(self,
               network,
               service_name,
               blueprint,
               template_vars=None,
               count=None):
        """
        Create a service in "network" named "service_name" with blueprint file at "blueprint".

        "template_vars" are passed to the initialization scripts as jinja2
        variables.
        """
        logger.info(
            'Creating service %s in network %s with blueprint %s, template_vars %s, '
            'and count %s', service_name, network, blueprint, template_vars,
            count)
        if not isinstance(network, Network):
            raise DisallowedOperationException(
                "Network argument to create must be of type butter.types.common.Network"
            )
        return self.service.create(network, service_name, blueprint,
                                   template_vars, count)
Пример #10
0
 def node_types(self):
     """
     Get mapping of node types to the resources.
     """
     logger.info('Listing node types')
     return self.service.node_types()
Пример #11
0
 def list(self):
     """
     List all services.
     """
     logger.info('Listing services')
     return self.service.list()