コード例 #1
0
ファイル: test_config_reader.py プロジェクト: dramich/f5-cccl
    def test_get_config(self):
        reader = ServiceConfigReader(self.partition)
        config = reader.read_ltm_config(self.ltm_service, 0)

        assert len(config.get('virtuals')) == 1
        assert len(config.get('pools')) == 1
        assert len(config.get('http_monitors')) == 1
        assert len(config.get('https_monitors')) == 1
        assert len(config.get('icmp_monitors')) == 1
        assert len(config.get('tcp_monitors')) == 1
        assert len(config.get('l7policies')) == 1
        assert len(config.get('iapps')) == 1

        config = reader.read_net_config(self.net_service, 0)
        assert len(config.get('arps')) == 1
        assert len(config.get('fdbTunnels')) == 1
        assert len(config.get('userFdbTunnels')) == 1
コード例 #2
0
    def setup(self):
        self.bigip = bigip_proxy()
        self.partition = "test"

        ltm_svcfile = 'f5_cccl/schemas/tests/ltm_service.json'
        with open(ltm_svcfile, 'r') as fp:
            self.ltm_service = json.loads(fp.read())

        net_svcfile = 'f5_cccl/schemas/tests/net_service.json'
        with open(net_svcfile, 'r') as fp:
            self.net_service = json.loads(fp.read())

        config_reader = ServiceConfigReader(self.partition)
        self.desired_ltm_config = config_reader.read_ltm_config(
            self.ltm_service)
        self.desired_net_config = config_reader.read_net_config(
            self.net_service)
コード例 #3
0
    def setup(self):
        self.bigip = bigip_proxy()
        self.partition = "test"

        ltm_svcfile = 'f5_cccl/schemas/tests/ltm_service.json'
        with open(ltm_svcfile, 'r') as fp:
            self.ltm_service = json.loads(fp.read())

        net_svcfile = 'f5_cccl/schemas/tests/net_service.json'
        with open(net_svcfile, 'r') as fp:
            self.net_service = json.loads(fp.read())

        config_reader = ServiceConfigReader(self.partition)
        self.default_route_domain = self.bigip.get_default_route_domain()
        self.desired_ltm_config = config_reader.read_ltm_config(
            self.ltm_service, self.default_route_domain, TEST_USER_AGENT)
        self.desired_net_config = config_reader.read_net_config(
            self.net_service, self.default_route_domain)
コード例 #4
0
ファイル: test_config_reader.py プロジェクト: russokj/f5-cccl
    def test_get_config(self):
        reader = ServiceConfigReader(self.partition)
        config = reader.read_ltm_config(self.ltm_service, 0,
                                        'marathon-bigip-ctlr-v1.2.1')

        assert len(config.get('virtuals')) == 2
        assert len(config.get('pools')) == 1
        assert len(config.get('http_monitors')) == 1
        assert len(config.get('https_monitors')) == 1
        assert len(config.get('icmp_monitors')) == 1
        assert len(config.get('tcp_monitors')) == 1
        assert len(config.get('l7policies')) == 2
        assert len(config.get('iapps')) == 1

        config = reader.read_net_config(self.net_service, 0)
        assert len(config.get('arps')) == 1
        assert len(config.get('fdbTunnels')) == 1
        assert len(config.get('userFdbTunnels')) == 1
コード例 #5
0
    def setup(self):
        self.bigip = bigip_proxy()
        self.partition = "test"

        ltm_svcfile = 'f5_cccl/schemas/tests/ltm_service.json'
        with open(ltm_svcfile, 'r') as fp:
            self.ltm_service = json.loads(fp.read())

        net_svcfile = 'f5_cccl/schemas/tests/net_service.json'
        with open(net_svcfile, 'r') as fp:
            self.net_service = json.loads(fp.read())

        config_reader = ServiceConfigReader(self.partition)
        self.default_route_domain = self.bigip.get_default_route_domain()
        self.desired_ltm_config = config_reader.read_ltm_config(
            self.ltm_service, self.default_route_domain, TEST_USER_AGENT)
        self.desired_net_config = config_reader.read_net_config(
            self.net_service, self.default_route_domain)
コード例 #6
0
class ServiceManager(object):
    """CCCL apply config implementation class."""

    def __init__(self, bigip_proxy, partition, schema):
        """Initialize the ServiceManager.

        Args:
            bigip_proxy:  BigIPProxy object, f5_cccl.bigip.BigIPProxy.
            partition: The managed partition.
            schema: Schema that defines the structure of a service
            configuration.

        Raises:
            F5CcclError: Error initializing the validator or reading the
            API schema.
        """
        self._partition = partition
        self._bigip = bigip_proxy
        self._config_validator = ServiceConfigValidator(schema)
        self._service_deployer = ServiceConfigDeployer(bigip_proxy)
        self._config_reader = ServiceConfigReader(self._partition)

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

    def apply_ltm_config(self, service_config, user_agent):
        """Apply the desired LTM service configuration.
        Args:
            service_config: The desired configuration state of the managed
            partition.

        Returns:
            The number of resources that were not successfully deployed.

        Raises:
            F5CcclValidationError: Indicates that the service_configuration
            does not conform to the API schema.
        """

        LOGGER.debug("apply_ltm_config start")
        start_time = time()

        # Validate the service configuration.
        self._config_validator.validate(service_config)

        # Determine the default route domain for the partition
        default_route_domain = self._bigip.get_default_route_domain()

        # Read in the configuration
        desired_config = self._config_reader.read_ltm_config(
            service_config, default_route_domain, user_agent)

        # Deploy the service desired configuration.
        retval = self._service_deployer.deploy_ltm(
            desired_config, default_route_domain)

        LOGGER.debug(
            "apply_ltm_config took %.5f seconds.", (time() - start_time))

        return retval

    def apply_net_config(self, service_config):
        """Apply the desired NET service configuration.
        Args:
            service_config: The desired configuration state of the managed
            partition.

        Returns:
            The number of resources that were not successfully deployed.

        Raises:
            F5CcclValidationError: Indicates that the service_configuration
            does not conform to the API schema.
        """

        LOGGER.debug("apply_net_config start")
        start_time = time()

        # Validate the service configuration.
        self._config_validator.validate(service_config)

        # Determine the default route domain for the partition
        default_route_domain = self._bigip.get_default_route_domain()

        # Read in the configuration
        desired_config = self._config_reader.read_net_config(
            service_config, default_route_domain)

        # Deploy the service desired configuration.
        retval = self._service_deployer.deploy_net(desired_config)

        LOGGER.debug(
            "apply_net_config took %.5f seconds.", (time() - start_time))

        return retval
コード例 #7
0
ファイル: manager.py プロジェクト: russokj/f5-cccl
class ServiceManager(object):
    """CCCL apply config implementation class."""

    def __init__(self, bigip_proxy, partition, schema):
        """Initialize the ServiceManager.

        Args:
            bigip_proxy:  BigIPProxy object, f5_cccl.bigip.BigIPProxy.
            partition: The managed partition.
            schema: Schema that defines the structure of a service
            configuration.

        Raises:
            F5CcclError: Error initializing the validator or reading the
            API schema.
        """
        self._partition = partition
        self._bigip = bigip_proxy
        self._config_validator = ServiceConfigValidator(schema)
        self._service_deployer = ServiceConfigDeployer(bigip_proxy)
        self._config_reader = ServiceConfigReader(self._partition)

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

    def apply_ltm_config(self, service_config, user_agent):
        """Apply the desired LTM service configuration.
        Args:
            service_config: The desired configuration state of the managed
            partition.

        Returns:
            The number of resources that were not successfully deployed.

        Raises:
            F5CcclValidationError: Indicates that the service_configuration
            does not conform to the API schema.
        """

        LOGGER.debug("apply_ltm_config start")
        start_time = time()

        # Validate the service configuration.
        self._config_validator.validate(service_config)

        # Determine the default route domain for the partition
        default_route_domain = self._bigip.get_default_route_domain()

        # Read in the configuration
        desired_config = self._config_reader.read_ltm_config(
            service_config, default_route_domain, user_agent)

        # Deploy the service desired configuration.
        retval = self._service_deployer.deploy_ltm(
            desired_config, default_route_domain)

        LOGGER.debug(
            "apply_ltm_config took %.5f seconds.", (time() - start_time))

        return retval

    def apply_net_config(self, service_config):
        """Apply the desired NET service configuration.
        Args:
            service_config: The desired configuration state of the managed
            partition.

        Returns:
            The number of resources that were not successfully deployed.

        Raises:
            F5CcclValidationError: Indicates that the service_configuration
            does not conform to the API schema.
        """

        LOGGER.debug("apply_net_config start")
        start_time = time()

        # Validate the service configuration.
        self._config_validator.validate(service_config)

        # Determine the default route domain for the partition
        default_route_domain = self._bigip.get_default_route_domain()

        # Read in the configuration
        desired_config = self._config_reader.read_net_config(
            service_config, default_route_domain)

        # Deploy the service desired configuration.
        retval = self._service_deployer.deploy_net(desired_config)

        LOGGER.debug(
            "apply_net_config took %.5f seconds.", (time() - start_time))

        return retval