Example #1
0
    def test_create_config_item_exception(self):

        with patch.object(ApiVirtualServer,
                          '__init__',
                          side_effect=ValueError("test exception")):
            reader = ServiceConfigReader(self.partition)
            with pytest.raises(F5CcclConfigurationReadError) as e:
                reader.read_config(self.service)
Example #2
0
class ServiceManager(object):
    """CCCL apply config implementation class."""
    def __init__(self, bigip, partition, schema, prefix=None):
        """Initialize the ServiceManager."""
        self._bigip = bigip
        self._partition = partition
        self._prefix = prefix
        self._config_validator = ServiceConfigValidator(schema)
        self._service_deployer = ServiceConfigDeployer(self._bigip)
        self._config_reader = ServiceConfigReader(self._partition)

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

    def apply_config(self, service_config):
        """Apply the desired service configuration."""
        # Validate the service configuration.
        self._config_validator.validate(service_config)

        # Read in the configuration
        desired_config = self._config_reader.read_config(service_config)

        # Refresh the BigIP state.
        self._bigip.refresh()

        # Deploy the service desired configuratio.
        return self._service_deployer.deploy(desired_config)
    def setup(self):
        self.bigip = bigip_proxy()
        self.partition = "test"

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

        config_reader = ServiceConfigReader(self.partition)
        self.desired_config = config_reader.read_config(self.service)
Example #4
0
    def test_get_config(self):
        reader = ServiceConfigReader(self.partition)
        config = reader.read_config(self.service)

        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
Example #5
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._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_config(self, service_config):
        """Apply the desired service configuration.
        Args:
            service_config: The desired configuration state of the mananged
            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_config start")
        start_time = time()

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

        # Read in the configuration
        desired_config = self._config_reader.read_config(service_config)

        # Deploy the service desired configuratio.
        retval = self._service_deployer.deploy(desired_config)

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

        return retval