Beispiel #1
0
    def _calculate_instance_properties(self, pool, vip):
        """ ServiceInstance settings
        - right network: public side, determined by the vip
        - left network: backend, determined by the pool subnet
        """
        props = ServiceInstanceType()
        if_list = []

        vmi = self._get_virtual_ip_interface(vip)
        if not vmi:
            return None

        vnet_refs = vmi.get_virtual_network_refs()
        if vnet_refs is None:
            return None
        right_virtual_network = ':'.join(vnet_refs[0]['to'])

        right_ip_address = self._get_interface_address(vmi)
        if right_ip_address is None:
            return None
        right_if = ServiceInstanceInterfaceType(
            virtual_network=right_virtual_network,
            ip_address=right_ip_address)
        if_list.append(right_if)

        pool_attrs = pool.get_loadbalancer_pool_properties()
        backnet_id = utils.get_subnet_network_id(
            self._api, pool_attrs.subnet_id)
        if backnet_id != vnet_refs[0]['uuid']:
            try:
                vnet = self._api.virtual_network_read(id=backnet_id)
            except NoIdError as ex:
                LOG.error(ex)
                return None
            left_virtual_network = ':'.join(vnet.get_fq_name())
            left_if = ServiceInstanceInterfaceType(
                virtual_network=left_virtual_network)
            if_list.append(left_if)

        # set interfaces and ha
        props.set_interface_list(if_list)
        props.set_ha_mode('active-standby')
        scale_out = ServiceScaleOutType(max_instances=2, auto_scale=False)
        props.set_scale_out(scale_out)

        return props
Beispiel #2
0
    def _calculate_instance_properties(self, pool, vip):
        """ ServiceInstance settings
        - right network: public side, determined by the vip
        - left network: backend, determined by the pool subnet
        """
        props = ServiceInstanceType()
        if_list = []

        # Calculate the Right Interface from virtual ip property
        vmi = VirtualMachineInterfaceSM.get(vip.virtual_machine_interface)
        if not vmi:
            return None
        right_ip_address = self._get_interface_address(vmi)
        if right_ip_address is None:
            return None

        vip_vn = VirtualNetworkSM.get(vmi.virtual_network)
        if vip_vn is None:
            return None
        right_virtual_network = ':'.join(vip_vn.fq_name)

        right_if = ServiceInstanceInterfaceType(
            virtual_network=right_virtual_network, ip_address=right_ip_address)
        if_list.append(right_if)

        # Calculate the Left Interface from Pool property
        pool_attrs = pool.params
        pool_vn_id = self._api.kv_retrieve(pool_attrs['subnet_id']).split()[0]
        if pool_vn_id != vip_vn.uuid:
            pool_vn = VirtualNetworkSM.get(pool_vn_id)
            left_virtual_network = ':'.join(pool_vn.fq_name)
            left_if = ServiceInstanceInterfaceType(
                virtual_network=left_virtual_network)
            if_list.append(left_if)

        # set interfaces and ha
        props.set_interface_list(if_list)
        props.set_ha_mode('active-standby')
        scale_out = ServiceScaleOutType(max_instances=2, auto_scale=False)
        props.set_scale_out(scale_out)

        return props