示例#1
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.

        Example:

            example_network = client.network.create("example")
            example_service = client.service.create(network=example_network,
                                                    name="example_service",
                                                    blueprint="example-blueprint.yml")

        """
        logger.debug(
            '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 cloudless.types.common.Network"
            )
        return self.service.create(network, service_name, blueprint,
                                   template_vars, count)
示例#2
0
    def list(self):
        """
        List all images.

        Example:

            client.image.list()

        """
        logger.debug('Listing images')
        return self.image.list()
示例#3
0
    def get(self, name):
        """
        Get a image named "name" and return some data about it.

        Example:

            client.image.get("myimage")

        """
        logger.debug('Getting image %s', name)
        return self.image.get(name)
示例#4
0
    def list(self):
        """
        List all services.

        Example:

            client.service.list()

        """
        logger.debug('Listing services')
        return self.service.list()
示例#5
0
    def node_types(self):
        """
        Get mapping of node types to the resources.

        Example:

            client.service.node_types()

        """
        logger.debug('Listing node types')
        return self.service.node_types()
示例#6
0
    def list(self):
        """
        List all networks.

        Example:

            client.network.list()

        """
        logger.debug('Listing networks')
        return self.network.list()
示例#7
0
    def get(self, name):
        """
        Get a network named "name" and return some data about it.

        Example:

            client.network.get("mynetwork")

        """
        logger.debug('Getting network %s', name)
        return self.network.get(name)
示例#8
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.debug('Creating network %s with blueprint %s', name, blueprint)
        return self.network.create(name, blueprint)
示例#9
0
    def destroy(self, image):
        """
        Destroy the given image.

        Example:

            client.image.destroy(client.image.get("myimage"))

        """
        logger.debug('Destroying image %s', image)
        if not isinstance(image, Image):
            raise DisallowedOperationException(
                "Argument to destroy must be of type cloudless.types.common.Image"
            )
        return self.image.destroy(image)
示例#10
0
    def create(self, name, service):
        """
        Create new image named "name" from "service".

        Example:

            client.image.create("myimage", service)

        """
        logger.debug('Creating image %s from service %s', name, service)
        if not isinstance(service, Service):
            raise DisallowedOperationException(
                "Service argument to create must be of type cloudless.types.common.Service"
            )
        return self.image.create(name, service)
示例#11
0
    def destroy(self, network):
        """
        Destroy the given network.

        Example:

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

        """
        logger.debug('Destroying network %s', network)
        if not isinstance(network, Network):
            raise DisallowedOperationException(
                "Argument to destroy must be of type cloudless.types.common.Network"
            )
        return self.network.destroy(network)
示例#12
0
    def get(self, network, service_name):
        """
        Get a service in "network" named "service_name".

        Example:

            example_service = client.service.get(network=client.network.get("example"),
                                                 name="example_service")

        """
        logger.debug('Discovering service %s in network %s', service_name,
                     network)
        if not isinstance(network, Network):
            raise DisallowedOperationException(
                "Network argument to get must be of type cloudless.types.common.Network"
            )
        return self.service.get(network, service_name)
示例#13
0
    def destroy(self, service):
        """
        Destroy a service described by the "service" object.

        Example:

            example_service = client.service.get(network=client.network.get("example"),
                                                 name="example_service")
            client.service.destroy(example_service)

        """
        logger.debug('Destroying service %s', service)
        if not isinstance(service, Service):
            raise DisallowedOperationException(
                "Service argument to destroy must be of type cloudless.types.common.Service"
            )
        return self.service.destroy(service)
示例#14
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.

        Example:

            service1 = client.service.get(network=client.network.get("example"), name="service1")
            service2 = client.service.get(network=client.network.get("example"), name="service2")
            internet = cloudless.types.networking.CidrBlock("0.0.0.0/0")
            client.paths.remove(service1, service2, 443)
            client.paths.remove(internet, service1, 80)

        """
        logger.debug('Removing path from %s to %s on port %s', source,
                     destination, port)
        return self.paths.remove(source, destination, int(port))