示例#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_ltm_config(self.ltm_service, 0,
                                       'marathon-bigip-ctlr-v1.2.1')
示例#2
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_ltm_config(self.ltm_service, 0,
                                       'marathon-bigip-ctlr-v1.2.1')
示例#3
0
 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)
示例#4
0
    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)
示例#5
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
示例#6
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)
示例#7
0
    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)
示例#8
0
    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
示例#9
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)
示例#10
0
    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
示例#11
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)
示例#12
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
示例#13
0
    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)
示例#14
0
    def test_create_reader(self):
        reader = ServiceConfigReader(self.partition)

        assert reader
        assert reader._partition == self.partition
示例#15
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