Ejemplo n.º 1
0
    def get_new_LB_networking_subflow(self):
        """Create a sub-flow to setup networking.

        :returns: The flow to setup networking for a new amphora
        """

        new_LB_net_subflow = linear_flow.Flow(constants.
                                              LOADBALANCER_NETWORKING_SUBFLOW)
        new_LB_net_subflow.add(network_tasks.AllocateVIP(
            requires=constants.LOADBALANCER,
            provides=constants.VIP))
        new_LB_net_subflow.add(database_tasks.UpdateVIPAfterAllocation(
            requires=(constants.LOADBALANCER_ID, constants.VIP),
            provides=constants.LOADBALANCER))
        new_LB_net_subflow.add(network_tasks.PlugVIP(
            requires=constants.LOADBALANCER,
            provides=constants.AMPS_DATA))
        new_LB_net_subflow.add(database_tasks.UpdateAmphoraVIPData(
            requires=constants.AMPS_DATA))
        new_LB_net_subflow.add(database_tasks.ReloadLoadBalancer(
            name=constants.RELOAD_LB_AFTER_PLUG_VIP,
            requires=constants.LOADBALANCER_ID,
            provides=constants.LOADBALANCER))
        new_LB_net_subflow.add(network_tasks.GetAmphoraeNetworkConfigs(
            requires=constants.LOADBALANCER,
            provides=constants.AMPHORAE_NETWORK_CONFIG))
        new_LB_net_subflow.add(amphora_driver_tasks.AmphoraPostVIPPlug(
            requires=(constants.LOADBALANCER,
                      constants.AMPHORAE_NETWORK_CONFIG)))

        return new_LB_net_subflow
Ejemplo n.º 2
0
    def _get_amp_net_subflow(self, sf_name):
        flows = []
        flows.append(
            network_tasks.PlugVIPAmpphora(
                name=sf_name + '-' + constants.PLUG_VIP_AMPHORA,
                requires=(constants.LOADBALANCER, constants.AMPHORA,
                          constants.SUBNET),
                provides=constants.AMP_DATA))

        flows.append(
            network_tasks.ApplyQosAmphora(
                name=sf_name + '-' + constants.APPLY_QOS_AMP,
                requires=(constants.LOADBALANCER, constants.AMP_DATA,
                          constants.UPDATE_DICT)))
        flows.append(
            database_tasks.UpdateAmphoraVIPData(
                name=sf_name + '-' + constants.UPDATE_AMPHORA_VIP_DATA,
                requires=constants.AMP_DATA))
        flows.append(
            database_tasks.ReloadAmphora(name=sf_name + '-' +
                                         constants.RELOAD_AMP_AFTER_PLUG_VIP,
                                         requires=constants.AMPHORA_ID,
                                         provides=constants.AMPHORA))
        flows.append(
            database_tasks.ReloadLoadBalancer(
                name=sf_name + '-' + constants.RELOAD_LB_AFTER_PLUG_VIP,
                requires=constants.LOADBALANCER_ID,
                provides=constants.LOADBALANCER))
        flows.append(
            network_tasks.GetAmphoraNetworkConfigs(
                name=sf_name + '-' + constants.GET_AMP_NETWORK_CONFIG,
                requires=(constants.LOADBALANCER, constants.AMPHORA),
                provides=constants.AMPHORA_NETWORK_CONFIG))
        flows.append(
            amphora_driver_tasks.AmphoraPostVIPPlug(
                name=sf_name + '-' + constants.AMP_POST_VIP_PLUG,
                rebind={
                    constants.AMPHORAE_NETWORK_CONFIG:
                    constants.AMPHORA_NETWORK_CONFIG
                },
                requires=(constants.LOADBALANCER,
                          constants.AMPHORAE_NETWORK_CONFIG)))
        return flows
Ejemplo n.º 3
0
    def get_extension_flow(self, distributor):
        """Extend a amphora for load balancer.

        :returns: The flow for loadbalancer extension
        """

        extension_flow = linear_flow.Flow(
            constants.EXTENSION_LOADBALANCER_FLOW)

        get_amp_subflow = self.get_amphora_for_lb_subflow(
            prefix=constants.EXTENSION_LOADBALANCER_FLOW,
            role=constants.ROLE_ACTIVE)
        extension_flow.add(get_amp_subflow)

        # Update the data stored in the flow from the database
        extension_flow.add(
            database_tasks.ReloadLoadBalancer(
                name='first',
                requires=constants.LOADBALANCER_ID,
                provides=constants.LOADBALANCER))

        extension_flow.add(
            network_tasks.PlugAmphoraVIP(requires=(constants.AMPHORA,
                                                   constants.LOADBALANCER),
                                         provides=constants.AMPS_DATA))
        extension_flow.add(
            database_tasks.UpdateAmphoraVIPData(requires=constants.AMPS_DATA))

        # Update the data stored in the flow from the database
        extension_flow.add(
            database_tasks.ReloadLoadBalancer(
                name='second',
                requires=constants.LOADBALANCER_ID,
                provides=constants.LOADBALANCER))

        extension_flow.add(
            database_tasks.ReloadAmphora(requires=constants.AMPHORA_ID,
                                         provides=constants.AMPHORA))

        # Prepare to reconnect the network interface(s)
        extension_flow.add(
            network_tasks.GetAmphoraeNetworkConfigs(
                requires=constants.LOADBALANCER,
                provides=constants.AMPHORAE_NETWORK_CONFIG))
        extension_flow.add(
            database_tasks.GetListenersFromLoadbalancer(
                requires=constants.LOADBALANCER, provides=constants.LISTENERS))
        extension_flow.add(
            database_tasks.GetAmphoraeFromLoadbalancer(
                requires=constants.LOADBALANCER, provides=constants.AMPHORAE))
        extension_flow.add(
            amphora_driver_tasks.AmphoraPostVIPPlug(
                requires=(constants.AMPHORA, constants.LOADBALANCER,
                          constants.AMPHORAE_NETWORK_CONFIG)))

        timeout_dict = {
            constants.CONN_MAX_RETRIES:
            CONF.haproxy_amphora.active_connection_max_retries,
            constants.CONN_RETRY_INTERVAL:
            CONF.haproxy_amphora.active_connection_rety_interval
        }

        extension_flow.add(
            amphora_driver_tasks.AmpsListenersUpdate(
                name=constants.AMP_LISTENER_UPDATE,
                requires=(constants.LISTENERS, constants.LOADBALANCER),
                inject=({
                    constants.TIMEOUT_DICT: timeout_dict
                })))

        # Plug the member networks into the new amphora
        extension_flow.add(
            network_tasks.CalculateAmphoraDelta(
                requires=(constants.LOADBALANCER, constants.AMPHORA),
                provides=constants.DELTA))

        extension_flow.add(
            network_tasks.HandleNetworkDelta(requires=(constants.AMPHORA,
                                                       constants.DELTA),
                                             provides=constants.ADDED_PORTS))

        extension_flow.add(
            amphora_driver_tasks.AmphoraePostNetworkPlug(
                requires=(constants.LOADBALANCER, constants.ADDED_PORTS)))

        extension_flow.add(
            database_tasks.ReloadLoadBalancer(
                name='octavia-extension-LB-reload-2',
                requires=constants.LOADBALANCER_ID,
                provides=constants.LOADBALANCER))

        extension_flow.add(
            self.get_distributor_flows('octavia-extension-distributor-flow',
                                       distributor))

        extension_flow.add(
            amphora_driver_tasks.ListenersStart(
                requires=(constants.LOADBALANCER, constants.LISTENERS,
                          constants.AMPHORA)))
        return extension_flow
Ejemplo n.º 4
0
    def get_failover_flow(self):
        """Creates a flow to failover a stale amphora

        :returns: The flow for amphora failover
        """

        failover_amphora_flow = linear_flow.Flow(
            constants.FAILOVER_AMPHORA_FLOW)
        failover_amphora_flow.add(
            network_tasks.RetrievePortIDsOnAmphoraExceptLBNetwork(
                requires=constants.AMPHORA, provides=constants.PORTS))
        failover_amphora_flow.add(
            network_tasks.FailoverPreparationForAmphora(
                requires=constants.AMPHORA))
        failover_amphora_flow.add(
            compute_tasks.ComputeDelete(requires=constants.AMPHORA))
        failover_amphora_flow.add(
            database_tasks.MarkAmphoraDeletedInDB(requires=constants.AMPHORA))
        failover_amphora_flow.add(
            database_tasks.CreateAmphoraInDB(provides=constants.AMPHORA_ID))
        failover_amphora_flow.add(
            database_tasks.GetUpdatedFailoverAmpNetworkDetailsAsList(
                requires=(constants.AMPHORA_ID, constants.AMPHORA),
                provides=constants.AMPS_DATA))
        if self.REST_AMPHORA_DRIVER:
            failover_amphora_flow.add(
                cert_task.GenerateServerPEMTask(provides=constants.SERVER_PEM))
            failover_amphora_flow.add(
                compute_tasks.CertComputeCreate(
                    requires=(constants.AMPHORA_ID, constants.SERVER_PEM),
                    provides=constants.COMPUTE_ID))
        else:
            failover_amphora_flow.add(
                compute_tasks.ComputeCreate(requires=constants.AMPHORA_ID,
                                            provides=constants.COMPUTE_ID))
        failover_amphora_flow.add(
            database_tasks.UpdateAmphoraComputeId(
                requires=(constants.AMPHORA_ID, constants.COMPUTE_ID)))
        failover_amphora_flow.add(
            database_tasks.AssociateFailoverAmphoraWithLBID(
                requires=(constants.AMPHORA_ID, constants.LOADBALANCER_ID)))
        failover_amphora_flow.add(
            database_tasks.MarkAmphoraBootingInDB(
                requires=(constants.AMPHORA_ID, constants.COMPUTE_ID)))
        wait_flow = linear_flow.Flow(
            constants.WAIT_FOR_AMPHORA,
            retry=retry.Times(CONF.controller_worker.amp_active_retries))
        wait_flow.add(
            compute_tasks.ComputeWait(requires=constants.COMPUTE_ID,
                                      provides=constants.COMPUTE_OBJ))
        wait_flow.add(
            database_tasks.UpdateAmphoraInfo(requires=(constants.AMPHORA_ID,
                                                       constants.COMPUTE_OBJ),
                                             provides=constants.AMPHORA))
        failover_amphora_flow.add(wait_flow)
        failover_amphora_flow.add(
            database_tasks.ReloadAmphora(requires=constants.AMPHORA_ID,
                                         provides=constants.FAILOVER_AMPHORA))
        failover_amphora_flow.add(
            amphora_driver_tasks.AmphoraFinalize(
                rebind={constants.AMPHORA: constants.FAILOVER_AMPHORA},
                requires=constants.AMPHORA))
        failover_amphora_flow.add(
            database_tasks.UpdateAmphoraVIPData(requires=constants.AMPS_DATA))
        failover_amphora_flow.add(
            database_tasks.ReloadLoadBalancer(
                requires=constants.LOADBALANCER_ID,
                provides=constants.LOADBALANCER))
        failover_amphora_flow.add(
            network_tasks.GetAmphoraeNetworkConfigs(
                requires=constants.LOADBALANCER,
                provides=constants.AMPHORAE_NETWORK_CONFIG))
        failover_amphora_flow.add(
            database_tasks.GetListenersFromLoadbalancer(
                requires=constants.LOADBALANCER, provides=constants.LISTENERS))
        failover_amphora_flow.add(
            database_tasks.GetVipFromLoadbalancer(
                requires=constants.LOADBALANCER, provides=constants.VIP))
        failover_amphora_flow.add(
            amphora_driver_tasks.ListenersUpdate(requires=(constants.LISTENERS,
                                                           constants.VIP)))
        failover_amphora_flow.add(
            amphora_driver_tasks.AmphoraPostVIPPlug(
                requires=(constants.LOADBALANCER,
                          constants.AMPHORAE_NETWORK_CONFIG)))
        failover_amphora_flow.add(
            network_tasks.GetMemberPorts(
                rebind={constants.AMPHORA: constants.FAILOVER_AMPHORA},
                requires=(constants.LOADBALANCER, constants.AMPHORA),
                provides=constants.MEMBER_PORTS))
        failover_amphora_flow.add(
            amphora_driver_tasks.AmphoraPostNetworkPlug(
                rebind={
                    constants.AMPHORA: constants.FAILOVER_AMPHORA,
                    constants.PORTS: constants.MEMBER_PORTS
                },
                requires=(constants.AMPHORA, constants.PORTS)))
        failover_amphora_flow.add(
            amphora_driver_tasks.ListenersStart(requires=(constants.LISTENERS,
                                                          constants.VIP)))
        failover_amphora_flow.add(
            database_tasks.MarkAmphoraAllocatedInDB(
                rebind={constants.AMPHORA: constants.FAILOVER_AMPHORA},
                requires=(constants.AMPHORA, constants.LOADBALANCER_ID)))

        return failover_amphora_flow