def _create_virtual_interface(self, project, lb_id, subnet_id, ip_address):
        network_id = utils.get_subnet_network_id(self._api, subnet_id)
        try:
            vnet = self._api.virtual_network_read(id=network_id)
        except NoIdError:
            raise n_exc.NetworkNotFound(net_id=network_id)

        vmi = VirtualMachineInterface(lb_id, project)
        vmi.set_virtual_network(vnet)
        vmi.set_virtual_machine_interface_device_owner(
            n_constants.DEVICE_OWNER_LOADBALANCER)

        sg_obj = SecurityGroup("default", project)
        vmi.add_security_group(sg_obj)
        self._api.virtual_machine_interface_create(vmi)

        iip_obj = InstanceIp(name=lb_id)
        iip_obj.set_virtual_network(vnet)
        iip_obj.set_virtual_machine_interface(vmi)
        if ip_address and ip_address != attributes.ATTR_NOT_SPECIFIED:
            iip_obj.set_instance_ip_address(ip_address)
        self._api.instance_ip_create(iip_obj)
        iip = self._api.instance_ip_read(id=iip_obj.uuid)
        vip_address = iip.get_instance_ip_address()

        return vmi, vip_address
    def _create_virtual_interface(self, project, vip_id, subnet_id,
                                  ip_address):
        network_id = utils.get_subnet_network_id(self._api, subnet_id)
        try:
            vnet = self._api.virtual_network_read(id=network_id)
        except NoIdError:
            raise n_exc.NetworkNotFound(net_id=network_id)

        vmi = VirtualMachineInterface(vip_id, project)
        vmi.set_virtual_network(vnet)

        sg_obj = SecurityGroup("default", project)
        vmi.add_security_group(sg_obj)
        self._api.virtual_machine_interface_create(vmi)

        fq_name = list(project.get_fq_name())
        fq_name.append(vip_id)

        iip_obj = InstanceIp(fq_name=fq_name)
        iip_obj.set_virtual_network(vnet)
        iip_obj.set_virtual_machine_interface(vmi)
        if ip_address and ip_address != attributes.ATTR_NOT_SPECIFIED:
            iip_obj.set_instance_ip_address(ip_address)
        self._api.instance_ip_create(fq_name)

        return vmi
Ejemplo n.º 3
0
    def _create_virtual_interface(self, project, vip_id, subnet_id,
                                  ip_address):
        network_id = utils.get_subnet_network_id(self._api, subnet_id)
        try:
            vnet = self._api.virtual_network_read(id=network_id)
        except NoIdError:
            raise n_exc.NetworkNotFound(net_id=network_id)

        vmi = VirtualMachineInterface(vip_id, project)
        vmi.set_virtual_network(vnet)
        vmi.set_virtual_machine_interface_device_owner(n_constants.DEVICE_OWNER_LOADBALANCER)

        sg_obj = SecurityGroup("default", project)
        vmi.add_security_group(sg_obj)
        self._api.virtual_machine_interface_create(vmi)

        iip_obj = InstanceIp(name=vip_id)
        iip_obj.set_virtual_network(vnet)
        iip_obj.set_virtual_machine_interface(vmi)
        if ip_address and ip_address != attributes.ATTR_NOT_SPECIFIED:
            iip_obj.set_instance_ip_address(ip_address)
        self._api.instance_ip_create(iip_obj)
        iip = self._api.instance_ip_read(id=iip_obj.uuid)
        vip_address = iip.get_instance_ip_address()

        return vmi, vip_address
Ejemplo n.º 4
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()

        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
        props.right_virtual_network = ':'.join(vnet_refs[0]['to'])

        props.right_ip_address = self._get_interface_address(vmi)
        if props.right_ip_address is None:
            return None

        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
            props.left_virtual_network = ':'.join(vnet.get_fq_name())

        # set flag to create policy automatically
        props.set_auto_policy(True)

        return props
    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()

        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
        props.right_virtual_network = ':'.join(vnet_refs[0]['to'])

        props.right_ip_address = self._get_interface_address(vmi)
        if props.right_ip_address is None:
            return None

        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
            props.left_virtual_network = vnet.get_fq_name().join(':')

        return props
Ejemplo n.º 6
0
    def _create_virtual_interface(self, project, vip_id, subnet_id,
                                  ip_address):
        network_id = utils.get_subnet_network_id(self._api, subnet_id)
        try:
            vnet = self._api.virtual_network_read(id=network_id)
        except NoIdError:
            raise n_exc.NetworkNotFound(net_id=network_id)

        vmi = VirtualMachineInterface(vip_id, project)
        vmi.set_virtual_network(vnet)

        sg_obj = SecurityGroup("default", project)
        vmi.add_security_group(sg_obj)
        self._api.virtual_machine_interface_create(vmi)

        fq_name = list(project.get_fq_name())
        fq_name.append(vip_id)

        iip_obj = InstanceIp(fq_name=fq_name)
        iip_obj.set_virtual_network(vnet)
        iip_obj.set_virtual_machine_interface(vmi)
        if ip_address and ip_address != attributes.ATTR_NOT_SPECIFIED:
            iip_obj.set_instance_ip_address(ip_address)
        self._api.instance_ip_create(fq_name)

        return vmi
    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