示例#1
0
文件: api.py 项目: swapmat-f5/f5-cccl
class F5CloudServiceManager(object):
    """F5 Common Controller Cloud Service Management.

    The F5 Common Controller Core Library (CCCL) is an orchestration package
    that provides a declarative API for defining BIG-IP LTM services in
    diverse environments (e.g. Marathon, Kubernetes, OpenStack).  The
    API will allow a user to create proxy services by specifying the:
    virtual servers, pools, L7 policy and rules, and monitors  as a service
    description object.  Each instance of the CCCL is initialized with
    namespace qualifiers to allow it to uniquely identify the resources
    under its control.
    """

    def __init__(self, hostname, username, password, partition, prefix=None,
                 port=443, token=None, schema_path=API_SCHEMA):
        """Initialize an instance of the F5 CCCL service manager.

        :param hostname: BIG-IP hostname or ip address.
        :param username: Access BIG-IP as user
        :param password: User password
        :param partition: Name of BIG-IP partition to manage.
        :param prefix: Optional string to prepend to resource names
        (default: None).
        :param port: Port to use for connection (default: 443)
        :param token: Use for token authentication (default None)
        """
        self._bigip = CommonBigIP(hostname,
                                  username,
                                  password,
                                  partition,
                                  prefix=prefix,
                                  port=port,
                                  token=token)

        self._service_manager = ServiceManager(self._bigip, partition,
                                               schema_path, prefix)

    def apply_config(self, services):
        """Apply service configurations to the BIG-IP partition.

        :param services: A serializable object that defines one or more
        services. Its schema is defined by cccl-api-schema.json.

        :return: True if successful, otherwise an exception is thrown.
        """
        return self._service_manager.apply_config(services)

    def get_partition(self):
        """Get the name of the managed partition.

        :return: The managed partition name.
        """
        return self._service_manager.get_partition()

    def get_status(self):
        """Get status for each service in the managed partition.

        :return: A serializable object of the statuses of each managed
        resource.

        Its structure is defined by:
            cccl-status-schema.json
        """
        status = {}

        return status

    def get_statistics(self):
        """Get statistics for each service in the managed partition.

        :return: A serializable object of the virtual server statistics
        for each service.

        Its structure is defined by:
            cccl-statistics-schema.json
        """
        statistics = {}

        return statistics
示例#2
0
class F5CloudServiceManager(object):
    """F5 Common Controller Cloud Service Management.

    The F5 Common Controller Core Library (CCCL) is an orchestration package
    that provides a declarative API for defining BIG-IP LTM services in
    diverse environments (e.g. Marathon, Kubernetes, OpenStack).  The
    API will allow a user to create proxy services by specifying the:
    virtual servers, pools, L7 policy and rules, and monitors  as a service
    description object.  Each instance of the CCCL is initialized with
    namespace qualifiers to allow it to uniquely identify the resources
    under its control.
    """
    def __init__(self, bigip, partition, prefix=None, schema_path=None):
        """Initialize an instance of the F5 CCCL service manager.

        :param bigip: BIG-IP management root.
        :param partition: Name of BIG-IP partition to manage.
        :param prefix:  The prefix assigned to resources that should be
        managed by this CCCL instance.  This is prepended to the
        resource name (default: None)
        :param schema_path: User defined schema (default: from package)
        """
        LOGGER.debug("F5CloudServiceManager initialize")
        self._bigip_proxy = BigIPProxy(bigip, partition, prefix=prefix)

        if schema_path is None:
            schema_path = pkg_resources.resource_filename(
                resource_package, api_schema)
        self._service_manager = ServiceManager(self._bigip_proxy, partition,
                                               schema_path)

    def apply_config(self, services):
        """Apply service configurations to the BIG-IP partition.

        :param services: A serializable object that defines one or more
        services. Its schema is defined by cccl-api-schema.json.

        :return: True if successful, otherwise an exception is thrown.
        """
        return self._service_manager.apply_config(services)

    def get_partition(self):
        """Get the name of the managed partition.

        :return: The managed partition name.
        """
        return self._service_manager.get_partition()

    def get_status(self):
        """Get status for each service in the managed partition.

        :return: A serializable object of the statuses of each managed
        resource.

        Its structure is defined by:
            cccl-status-schema.json
        """
        status = {}

        return status

    def get_statistics(self):
        """Get statistics for each service in the managed partition.

        :return: A serializable object of the virtual server statistics
        for each service.

        Its structure is defined by:
            cccl-statistics-schema.json
        """
        statistics = {}

        return statistics