コード例 #1
0
def create_or_update_project(client,
                             project_name,
                             service_name,
                             resource_group_name,
                             location,
                             source_platform,
                             target_platform,
                             tags=None):

    # Set inputs to lowercase
    source_platform = source_platform.lower()
    target_platform = target_platform.lower()
    scenario_handled_in_extension = extension_handles_scenario(
        source_platform, target_platform)

    # Validation: Test scenario eligibility
    if not scenario_handled_in_extension:
        # If the core also doesn't handle this scenario, this will return with a failure.
        return core_create_or_update_project(client, project_name,
                                             service_name, resource_group_name,
                                             location, source_platform,
                                             target_platform, tags)

    # Run extension scenario
    parameters = Project(location=location,
                         source_platform=source_platform,
                         target_platform=target_platform,
                         tags=tags)

    return client.create_or_update(parameters=parameters,
                                   group_name=resource_group_name,
                                   service_name=service_name,
                                   project_name=project_name)
コード例 #2
0
def create_or_update_project(
        client,
        project_name,
        service_name,
        resource_group_name,
        location,
        source_platform,
        target_platform,
        tags=None):

    # Set inputs to lowercase
    source_platform = source_platform.lower()
    target_platform = target_platform.lower()
    scenario_handled_in_extension = extension_handles_scenario(source_platform, target_platform)

    # Validation: Test scenario eligibility
    if not scenario_handled_in_extension:
        # If not an extension scenario, run CLI core method
        # TODO: We currently don't have any CLI core code to perform any validations
        # because of this we need to raise the error here.
        try:
            # TODO: Remove this check after validations are added to core
            if source_platform != "sql" or target_platform != "sqldb":
                raise CLIError("The provided source-platform, target-platform combination is not appropriate. \n\
Please refer to the help file 'az dms project create -h' for the supported scenarios.")

            core_res = core_create_or_update_project(
                client,
                project_name,
                service_name,
                resource_group_name,
                location,
                source_platform,
                target_platform,
                tags)
        except:
            # TODO: We currently don't have any CLI core code to perform any validations
            # because of this we need to raise the error here.
            raise
        else:
            return core_res

    # Run extension scenario
    parameters = Project(location=location,
                         source_platform=source_platform,
                         target_platform=target_platform,
                         tags=tags)

    return client.create_or_update(parameters=parameters,
                                   group_name=resource_group_name,
                                   service_name=service_name,
                                   project_name=project_name)
コード例 #3
0
def create_or_update_project(client,
                             project_name,
                             service_name,
                             resource_group_name,
                             location,
                             source_platform,
                             target_platform,
                             tags=None):

    # Set inputs to lowercase
    source_platform = source_platform.lower()
    target_platform = target_platform.lower()
    scenario_handled_in_extension = extension_handles_scenario(
        source_platform, target_platform)

    # Validation: Test scenario eligibility
    if not scenario_handled_in_extension:
        # If not an extension scenario, run CLI core method
        # TODO: We currently don't have any CLI core code to perform any validations
        # because of this we need to raise the error here.
        try:
            # TODO: Remove this check after validations are added to core
            if source_platform != "sql" or target_platform != "sqldb":
                raise CLIError(
                    "The provided source-platform, target-platform combination is not appropriate. \n\
Please refer to the help file 'az dms project create -h' for the supported scenarios."
                )

            core_res = core_create_or_update_project(client, project_name,
                                                     service_name,
                                                     resource_group_name,
                                                     location, source_platform,
                                                     target_platform, tags)
        except:
            # TODO: We currently don't have any CLI core code to perform any validations
            # because of this we need to raise the error here.
            raise
        else:
            return core_res

    # Run extension scenario
    parameters = Project(location=location,
                         source_platform=source_platform,
                         target_platform=target_platform,
                         tags=tags)

    return client.create_or_update(parameters=parameters,
                                   group_name=resource_group_name,
                                   service_name=service_name,
                                   project_name=project_name)