Пример #1
0
    def _create_active_standby_topology(
            self, lf_name=constants.CREATE_LOADBALANCER_FLOW):
        # When we boot up amphora for an active/standby topology,
        # we should leverage the Nova anti-affinity capabilities
        # to place the amphora on different hosts, also we need to check
        # if anti-affinity-flag is enabled or not:
        anti_affinity = CONF.nova.enable_anti_affinity
        flows = []
        if anti_affinity:
            # we need to create a server group first
            flows.append(
                compute_tasks.NovaServerGroupCreate(
                    name=lf_name + '-' + constants.CREATE_SERVER_GROUP_FLOW,
                    requires=(constants.LOADBALANCER_ID),
                    provides=constants.SERVER_GROUP_ID))

            # update server group id in lb table
            flows.append(
                database_tasks.UpdateLBServerGroupInDB(
                    name=lf_name + '-' +
                    constants.UPDATE_LB_SERVERGROUPID_FLOW,
                    requires=(constants.LOADBALANCER_ID,
                              constants.SERVER_GROUP_ID)))

        f_name = constants.CREATE_LOADBALANCER_FLOW
        amps_flow = unordered_flow.Flow(f_name)
        master_amp_sf = self.amp_flows.get_amphora_for_lb_subflow(
            prefix=constants.ROLE_MASTER, role=constants.ROLE_MASTER)

        backup_amp_sf = self.amp_flows.get_amphora_for_lb_subflow(
            prefix=constants.ROLE_BACKUP, role=constants.ROLE_BACKUP)
        amps_flow.add(master_amp_sf, backup_amp_sf)

        return flows + [amps_flow]
    def _create_active_standby_topology(
            self, lf_name=constants.CREATE_LOADBALANCER_FLOW):
        anti_affinity = CONF.a10_nova.enable_anti_affinity
        flows = []
        if anti_affinity:
            flows.append(
                a10_compute_tasks.NovaServerGroupCreate(
                    name=lf_name + '-' + constants.CREATE_SERVER_GROUP_FLOW,
                    requires=(constants.LOADBALANCER_ID),
                    provides=constants.SERVER_GROUP_ID))

            flows.append(
                database_tasks.UpdateLBServerGroupInDB(
                    name=lf_name + '-' +
                    constants.UPDATE_LB_SERVERGROUPID_FLOW,
                    requires=(constants.LOADBALANCER_ID,
                              constants.SERVER_GROUP_ID)))

        f_name = constants.CREATE_LOADBALANCER_FLOW
        amps_flow = unordered_flow.Flow(f_name)
        master_amp_sf = self.vthunder_flows.get_vthunder_for_lb_subflow(
            prefix=constants.ROLE_MASTER, role=constants.ROLE_MASTER)

        backup_amp_sf = self.vthunder_flows.get_vthunder_for_lb_subflow(
            prefix=constants.ROLE_BACKUP, role=constants.ROLE_BACKUP)
        amps_flow.add(master_amp_sf, backup_amp_sf)

        return flows + [amps_flow]
Пример #3
0
    def get_create_load_balancer_flow(self, topology):
        """Creates a conditional graph flow that allocates a loadbalancer to

        two spare amphorae.
        :raises InvalidTopology: Invalid topology specified
        :return: The graph flow for creating a loadbalancer.
        """
        # create a linear flow as a wrapper
        lf_name = constants.PRE_CREATE_LOADBALANCER_FLOW
        create_lb_flow_wrapper = linear_flow.Flow(lf_name)

        f_name = constants.CREATE_LOADBALANCER_FLOW
        lb_create_flow = unordered_flow.Flow(f_name)

        if topology == constants.TOPOLOGY_ACTIVE_STANDBY:
            # When we boot up amphora for an active/standby topology,
            # we should leverage the Nova anti-affinity capabilities
            # to place the amphora on different hosts, also we need to check
            # if anti-affinity-flag is enabled or not:
            anti_affinity = CONF.nova.enable_anti_affinity
            if anti_affinity:
                # we need to create a server group first
                create_lb_flow_wrapper.add(
                    compute_tasks.NovaServerGroupCreate(
                        name=lf_name + '-' +
                        constants.CREATE_SERVER_GROUP_FLOW,
                        requires=(constants.LOADBALANCER_ID),
                        provides=constants.SERVER_GROUP_ID))

                # update server group id in lb table
                create_lb_flow_wrapper.add(
                    database_tasks.UpdateLBServerGroupInDB(
                        name=lf_name + '-' +
                        constants.UPDATE_LB_SERVERGROUPID_FLOW,
                        requires=(constants.LOADBALANCER_ID,
                                  constants.SERVER_GROUP_ID)))

            master_amp_sf = self.amp_flows.get_amphora_for_lb_subflow(
                prefix=constants.ROLE_MASTER, role=constants.ROLE_MASTER)

            backup_amp_sf = self.amp_flows.get_amphora_for_lb_subflow(
                prefix=constants.ROLE_BACKUP, role=constants.ROLE_BACKUP)

            lb_create_flow.add(master_amp_sf, backup_amp_sf)

        elif topology == constants.TOPOLOGY_SINGLE:
            amphora_sf = self.amp_flows.get_amphora_for_lb_subflow(
                prefix=constants.ROLE_STANDALONE,
                role=constants.ROLE_STANDALONE)
            lb_create_flow.add(amphora_sf)
        else:
            LOG.error(
                _LE("Unknown topology: %s.  Unable to build load "
                    "balancer."), topology)
            raise exceptions.InvalidTopology(topology=topology)

        create_lb_flow_wrapper.add(lb_create_flow)
        return create_lb_flow_wrapper