コード例 #1
0
ファイル: amphora_flows.py プロジェクト: xurufei092/octavia
    def get_create_amphora_flow(self):
        """Creates a flow to create an amphora.

        :returns: The flow for creating the amphora
        """
        create_amphora_flow = linear_flow.Flow(constants.CREATE_AMPHORA_FLOW)
        create_amphora_flow.add(
            database_tasks.CreateAmphoraInDB(provides=constants.AMPHORA_ID))
        create_amphora_flow.add(
            lifecycle_tasks.AmphoraIDToErrorOnRevertTask(
                requires=constants.AMPHORA_ID))
        if self.REST_AMPHORA_DRIVER:
            create_amphora_flow.add(
                cert_task.GenerateServerPEMTask(provides=constants.SERVER_PEM))

            create_amphora_flow.add(
                database_tasks.UpdateAmphoraDBCertExpiration(
                    requires=(constants.AMPHORA_ID, constants.SERVER_PEM)))

            create_amphora_flow.add(
                compute_tasks.CertComputeCreate(
                    requires=(constants.AMPHORA_ID, constants.SERVER_PEM,
                              constants.BUILD_TYPE_PRIORITY),
                    provides=constants.COMPUTE_ID))
        else:
            create_amphora_flow.add(
                compute_tasks.ComputeCreate(
                    requires=(constants.AMPHORA_ID,
                              constants.BUILD_TYPE_PRIORITY),
                    provides=constants.COMPUTE_ID))
        create_amphora_flow.add(
            database_tasks.MarkAmphoraBootingInDB(
                requires=(constants.AMPHORA_ID, constants.COMPUTE_ID)))
        create_amphora_flow.add(
            compute_tasks.ComputeActiveWait(requires=(constants.COMPUTE_ID,
                                                      constants.AMPHORA_ID),
                                            provides=constants.COMPUTE_OBJ))
        create_amphora_flow.add(
            database_tasks.UpdateAmphoraInfo(requires=(constants.AMPHORA_ID,
                                                       constants.COMPUTE_OBJ),
                                             provides=constants.AMPHORA))
        create_amphora_flow.add(
            amphora_driver_tasks.AmphoraComputeConnectivityWait(
                requires=constants.AMPHORA))
        create_amphora_flow.add(
            database_tasks.ReloadAmphora(requires=constants.AMPHORA_ID,
                                         provides=constants.AMPHORA))
        create_amphora_flow.add(
            amphora_driver_tasks.AmphoraFinalize(requires=constants.AMPHORA))
        create_amphora_flow.add(
            database_tasks.MarkAmphoraReadyInDB(requires=constants.AMPHORA))

        return create_amphora_flow
コード例 #2
0
    def test_compute_wait_skipped(self, mock_time_sleep, mock_driver,
                                  mock_remove_from_build_queue):
        _amphora_mock.compute_id = COMPUTE_ID
        _amphora_mock.status = constants.ACTIVE
        _amphora_mock.lb_network_ip = LB_NET_IP

        mock_driver.get_amphora.return_value = _amphora_mock, None

        computewait = compute_tasks.ComputeActiveWait()
        computewait.execute(COMPUTE_ID, AMPHORA_ID)

        mock_driver.get_amphora.assert_called_once_with(COMPUTE_ID)
        mock_remove_from_build_queue.assert_not_called()
コード例 #3
0
    def test_compute_wait_error_status(self, mock_time_sleep, mock_driver,
                                       mock_remove_from_build_queue):

        self.conf.config(group='haproxy_amphora', build_rate_limit=5)
        _amphora_mock.compute_id = COMPUTE_ID
        _amphora_mock.status = constants.ACTIVE
        _amphora_mock.lb_network_ip = LB_NET_IP

        mock_driver.get_amphora.return_value = _amphora_mock, None

        computewait = compute_tasks.ComputeActiveWait()
        computewait.execute(COMPUTE_ID, AMPHORA_ID)

        mock_driver.get_amphora.assert_called_once_with(COMPUTE_ID)

        _amphora_mock.status = constants.ERROR

        self.assertRaises(exceptions.ComputeBuildException,
                          computewait.execute, _amphora_mock, AMPHORA_ID)
コード例 #4
0
ファイル: amphora_flows.py プロジェクト: xurufei092/octavia
    def _get_create_amp_for_lb_subflow(self, prefix, role):
        """Create a new amphora for lb."""

        sf_name = prefix + '-' + constants.CREATE_AMP_FOR_LB_SUBFLOW
        create_amp_for_lb_subflow = linear_flow.Flow(sf_name)
        create_amp_for_lb_subflow.add(
            database_tasks.CreateAmphoraInDB(name=sf_name + '-' +
                                             constants.CREATE_AMPHORA_INDB,
                                             provides=constants.AMPHORA_ID))

        require_server_group_id_condition = (
            role in (constants.ROLE_BACKUP, constants.ROLE_MASTER)
            and CONF.nova.enable_anti_affinity)

        if self.REST_AMPHORA_DRIVER:
            create_amp_for_lb_subflow.add(
                cert_task.GenerateServerPEMTask(name=sf_name + '-' +
                                                constants.GENERATE_SERVER_PEM,
                                                provides=constants.SERVER_PEM))

            create_amp_for_lb_subflow.add(
                database_tasks.UpdateAmphoraDBCertExpiration(
                    name=sf_name + '-' + constants.UPDATE_CERT_EXPIRATION,
                    requires=(constants.AMPHORA_ID, constants.SERVER_PEM)))

            if require_server_group_id_condition:
                create_amp_for_lb_subflow.add(
                    compute_tasks.CertComputeCreate(
                        name=sf_name + '-' + constants.CERT_COMPUTE_CREATE,
                        requires=(
                            constants.AMPHORA_ID,
                            constants.SERVER_PEM,
                            constants.BUILD_TYPE_PRIORITY,
                            constants.SERVER_GROUP_ID,
                        ),
                        provides=constants.COMPUTE_ID))
            else:
                create_amp_for_lb_subflow.add(
                    compute_tasks.CertComputeCreate(
                        name=sf_name + '-' + constants.CERT_COMPUTE_CREATE,
                        requires=(
                            constants.AMPHORA_ID,
                            constants.SERVER_PEM,
                            constants.BUILD_TYPE_PRIORITY,
                        ),
                        provides=constants.COMPUTE_ID))
        else:
            if require_server_group_id_condition:
                create_amp_for_lb_subflow.add(
                    compute_tasks.ComputeCreate(
                        name=sf_name + '-' + constants.COMPUTE_CREATE,
                        requires=(
                            constants.AMPHORA_ID,
                            constants.BUILD_TYPE_PRIORITY,
                            constants.SERVER_GROUP_ID,
                        ),
                        provides=constants.COMPUTE_ID))
            else:
                create_amp_for_lb_subflow.add(
                    compute_tasks.ComputeCreate(
                        name=sf_name + '-' + constants.COMPUTE_CREATE,
                        requires=(
                            constants.AMPHORA_ID,
                            constants.BUILD_TYPE_PRIORITY,
                        ),
                        provides=constants.COMPUTE_ID))

        create_amp_for_lb_subflow.add(
            database_tasks.UpdateAmphoraComputeId(
                name=sf_name + '-' + constants.UPDATE_AMPHORA_COMPUTEID,
                requires=(constants.AMPHORA_ID, constants.COMPUTE_ID)))
        create_amp_for_lb_subflow.add(
            database_tasks.MarkAmphoraBootingInDB(
                name=sf_name + '-' + constants.MARK_AMPHORA_BOOTING_INDB,
                requires=(constants.AMPHORA_ID, constants.COMPUTE_ID)))
        create_amp_for_lb_subflow.add(
            compute_tasks.ComputeActiveWait(
                name=sf_name + '-' + constants.COMPUTE_WAIT,
                requires=(constants.COMPUTE_ID, constants.AMPHORA_ID),
                provides=constants.COMPUTE_OBJ))
        create_amp_for_lb_subflow.add(
            database_tasks.UpdateAmphoraInfo(
                name=sf_name + '-' + constants.UPDATE_AMPHORA_INFO,
                requires=(constants.AMPHORA_ID, constants.COMPUTE_OBJ),
                provides=constants.AMPHORA))
        create_amp_for_lb_subflow.add(
            amphora_driver_tasks.AmphoraComputeConnectivityWait(
                name=sf_name + '-' + constants.AMP_COMPUTE_CONNECTIVITY_WAIT,
                requires=constants.AMPHORA))
        create_amp_for_lb_subflow.add(
            amphora_driver_tasks.AmphoraFinalize(name=sf_name + '-' +
                                                 constants.AMPHORA_FINALIZE,
                                                 requires=constants.AMPHORA))
        create_amp_for_lb_subflow.add(
            database_tasks.MarkAmphoraAllocatedInDB(
                name=sf_name + '-' + constants.MARK_AMPHORA_ALLOCATED_INDB,
                requires=(constants.AMPHORA, constants.LOADBALANCER_ID)))
        create_amp_for_lb_subflow.add(
            database_tasks.ReloadAmphora(name=sf_name + '-' +
                                         constants.RELOAD_AMPHORA,
                                         requires=constants.AMPHORA_ID,
                                         provides=constants.AMPHORA))

        if role == constants.ROLE_MASTER:
            create_amp_for_lb_subflow.add(
                database_tasks.MarkAmphoraMasterInDB(
                    name=sf_name + '-' + constants.MARK_AMP_MASTER_INDB,
                    requires=constants.AMPHORA))
        elif role == constants.ROLE_BACKUP:
            create_amp_for_lb_subflow.add(
                database_tasks.MarkAmphoraBackupInDB(
                    name=sf_name + '-' + constants.MARK_AMP_BACKUP_INDB,
                    requires=constants.AMPHORA))
        elif role == constants.ROLE_STANDALONE:
            create_amp_for_lb_subflow.add(
                database_tasks.MarkAmphoraStandAloneInDB(
                    name=sf_name + '-' + constants.MARK_AMP_STANDALONE_INDB,
                    requires=constants.AMPHORA))

        return create_amp_for_lb_subflow