全部產品
Search
文件中心

CloudOps Orchestration Service:ACS-HBR-SAPHanaRestorationAutomation

更新時間:Sep 06, 2024

ACS-HBR-SAPHanaRestorationAutomation SAP HANA備份可用性驗證(恢複到建立執行個體)

模板描述

在已有的SAP HANA執行個體(源執行個體)同一VPC下,自動建立單節點SAP HANA目的執行個體,通過HBR服務將源執行個體備份資料恢複到目的執行個體,並檢查恢複後的目的執行個體狀態立即執行

模板類型

自動化

所有者

Alibaba Cloud

輸入參數

參數名稱

描述

類型

是否必填

預設值

約束

zoneId

期望部署的可用性區域

String

vpcId

源執行個體所在Virtual Private Cloud

String

vSwitchId

目的執行個體所在交換器

String

sourceClusterId

HBR源執行個體ID

String

vaultId

HBR備份庫ID

String

HANASID

目的執行個體SAP HANA SID

String

字串校正Regex : ^[A-Z][A-Z0-9][A-Z0-9]$

masterPass

源執行個體SAP HANA Master帳號密碼

String

字串校正Regex : ^(?=.[0-9].)(?=.[A-Z].)(?=.[a-z].)[a-zA-Z][0-9a-zA-Z_@#$]{7,}$

imageId

目的執行個體的作業系統版本

String

instanceType

目的執行個體的執行個體規格

String

privateIpAddress

目的執行個體私人IP地址

String

字串校正Regex : ^((192.168

loginPassword

目的執行個體root使用者密碼

String

字串校正Regex : ^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\W_]+$)(?![a-z0-9]+$)(?![a-z\W_]+$)(?![0-9\W_]+$)[a-zA-Z0-9\W_]{8,}$

dataSize

目的執行個體的/hana/data大小

String

字串校正Regex : (^[2-9]\d{1}$)

logSize

目的執行個體的/hana/log大小

String

字串校正Regex : (^[2-9]\d{1}$)

sharedSize

目的執行個體的/hana/shared大小

String

字串校正Regex : (^[2-9]\d{1}$)

mediaPath

SAP HANA軟體包OSS路徑

String

字串校正Regex : ^(oss

dingTalkWebhook

DingTalk機器人Webhook地址

String

databaseName

資料庫執行個體列表

List

['SYSTEMDB@:SYSTEMDB']

customizedImage

使用自訂鏡像

Boolean

False

customizedImageId

自訂鏡像Id

String

""

ECSHostname

目的執行個體主機名稱

String

hana001

字串校正Regex : ^([a-zA-Z0-9]

HANAInstanceNumber

目的執行個體SAP HANA執行個體編號

String

00

字串校正Regex : ^([0-8][0-9]

systemDiskCategory

目的執行個體系統硬碟類型

String

cloud_ssd

systemDiskSize

目的執行個體系統硬碟大小

String

100

字串校正Regex : (^2[0-9]$)

dataLogDiskCategory

/hana/data和/hana/log檔案系統所在磁碟類型

String

cloud_ssd

sharedDiskCategory

目的執行個體的/hana/shared檔案系統所在磁碟類型

String

cloud_ssd

usrsapDiskCategory

目的執行個體的/usr/sap檔案系統所在磁碟類型

String

cloud_ssd

usrsapSize

目的執行個體的/usr/sap大小

String

50

字串校正Regex : (^[2-9]\d{1}$)

systemUsage

目的執行個體的SAP HANA系統類別型

String

custom

HANASapSidAdmUid

目的執行個體的SAP HANA sidadm使用者Id

String

1001

字串校正Regex : (^[5-9]\d{2}$)

HANASapSysGid

目的執行個體的SAP HANA sapsys組Id

String

79

字串校正Regex : (^\d+$)

userName

目的執行個體的使用者名稱

String

SYSTEM

weatherDeleteResource

驗證成功後保留雲資源.

Boolean

False

timeout

雲資源保留時間長度(單位:分鐘)

Number

30

輸出參數

參數名稱

描述

類型

Result

String

執行此模板需要的權限原則

關於建立角色並授權,詳情,請參見建立RAM角色並授權

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:DescribeAvailableResource",
                "ecs:DescribeInvocationResults",
                "ecs:DescribeInvocations",
                "ecs:RunCommand"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "hbr:CreateClients",
                "hbr:CreateHanaInstance",
                "hbr:CreateHanaRestore",
                "hbr:DeleteHanaInstance",
                "hbr:DescribeClients",
                "hbr:DescribeHanaBackupSetting",
                "hbr:DescribeHanaBackupsAsync",
                "hbr:DescribeHanaInstances",
                "hbr:DescribeHanaRestores",
                "hbr:DescribeTask",
                "hbr:UpdateHanaBackupSetting"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "ros:CreateStack",
                "ros:DeleteStack",
                "ros:GetStack"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "oos:ListExecutions"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

詳情

ACS-HBR-SAPHanaRestorationAutomation詳情

模板內容

FormatVersion: OOS-2019-06-01
Description:
  en: 'This template uses an existing VPC and SAP HANA instance(source instance) to create a single-node SAP instance(destination instance), restore the source instance backup data to the destination instance through the HBR service, and check the restored destination instance status.'
  zh-cn: 在已有的SAP HANA執行個體(源執行個體)同一VPC下,自動建立單節點SAP HANA目的執行個體,通過HBR服務將源執行個體備份資料恢複到目的執行個體,並檢查恢複後的目的執行個體狀態。
  name-en: ACS-HBR-SAPHanaRestorationAutomation
  name-zh-cn: SAP HANA備份可用性驗證(恢複到建立執行個體)
Parameters:
  zoneId:
    Type: String
    AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
    Label:
      zh-cn: 期望部署的可用性區域
      en: Availability Zones
    Description:
      zh-cn: '可用性區域列表請參考, <a href=''https://help.aliyun.com/document_detail/40654.html'' target=''_blank''>地區和可用性區域資訊</a>。'
      en: The Availability Zone where SAP HANA instance will be deployed
  vpcId:
    Type: String
    AssociationProperty: 'ALIYUN::ECS::VPC::VPCId'
    Label:
      zh-cn: 源執行個體所在Virtual Private Cloud
      en: Source VPC ID
    Description:
      zh-cn: 源執行個體所在Virtual Private Cloud
      en: VPC ID of source instance
  vSwitchId:
    Type: String
    AssociationProperty: 'ALIYUN::VPC::VSwitch::VSwitchId'
    Label:
      zh-cn: 目的執行個體所在交換器
      en: Target VSwitch ID
    Description:
      zh-cn: 目的執行個體所在交換器
      en: VSwitch ID of destination instance
  sourceClusterId:
    Label:
      zh-cn: HBR源執行個體Id
      en: Source SAP HANA instance ID
    Description:
      zh-cn: '源執行個體Id, 需要恢複的SAP HANA備份執行個體的Id,請在雲備份控制台-ECS應用備份-執行個體名稱/Id一欄查看。'
      en: 'Source SAP HANA instance ID, can be found in the Cloud Backup Console - ECS Application Backup - Instance Name/ID.'
    Type: String
  vaultId:
    Label:
      zh-cn: HBR備份庫ID
      en: Backup Vault ID
    Description:
      zh-cn: 備份庫的Id
      en: Backup vault ID
    Type: String
  databaseName:
    Label:
      zh-cn: 資料庫執行個體列表
      en: SAP HANA Database List
    Description:
      zh-cn: 需要恢複備份的SAP HANA資料庫執行個體列表,格式:<來源資料庫名>@<SID>:<目的資料庫名>,多個資料庫執行個體請以換行分隔。
      en: SAP HANA database list in format of "<Source SAP HANA database name>@<Source SAP HANA system Id>". Separate multiple SAP HANA database with line breaks.
    Type: List
    Default:
      - 'SYSTEMDB@<SID>:SYSTEMDB'
  HANASID:
    Type: String
    ConstraintDescription:
      zh-cn: '必須輸入3個字元,可包含大寫字母或數字,首位必須是大寫字母。'
      en: '3 characters,can including capital letter or number, must starting with capital letter.'
    Label:
      zh-cn: 目的執行個體SAP HANA SID
      en: SAP HANA  SID
    Description:
      zh-cn: 目的執行個體SAP HANA SID
      en: Destination instance SAP HANA SID
    AllowedPattern: '^[A-Z][A-Z0-9][A-Z0-9]$'
  masterPass:
    Type: String
    Label:
      zh-cn: 源執行個體SAP HANA Master帳號密碼
      en: SAP HANA Master Password
    Description:
      zh-cn: 源執行個體SAP HANA Master帳號密碼
      en: SAP HANA master password
    ConstraintDescription:
      zh-cn: '至少8個字元,至少包含一個數字,大寫字母和小寫字母,可以使用特殊字元(_,@,#,$),但不能以數字和特殊字元開頭。'
      en: 'Must be at least 8 characters with uppercase, lowercase, and numeric values,can use special characters include(_,@,#,$),but can''t staring with number and specical characters.'
    AllowedPattern: '^(?=.*[0-9].*)(?=.*[A-Z].*)(?=.*[a-z].*)[a-zA-Z][0-9a-zA-Z_@#$]{7,}$'
    NoEcho: true
  imageId:
    Type: String
    Label:
      zh-cn: 目的執行個體的作業系統版本
      en: Operating System And Version
    Description:
      zh-cn: '目的執行個體的作業系統版本,該作業系統為CSP官方收費版本,詳情串連:<a href=''https://market.aliyun.com/products/57742013/cmjj00037618.html'' target=''_blank''>SUSE15SP1-SAP</a>、<a href=''https://market.aliyun.com/products/57742013/cmjj00036800.html'' target=''_blank''>SUSE12SP4-SAP</a>、<a href=''https://market.aliyun.com/products/57742013/cmjj031975.html'' target=''_blank''>SUSE12SP3-SAP</a>。'
      en: 'Operating system and version: <a href=''https://market.aliyun.com/products/57742013/cmjj00037618.html'' target=''_blank''>SUSE15SP1-SAP</a>、<a href=''https://market.aliyun.com/products/57742013/cmjj00036800.html'' target=''_blank''>SUSE12SP4-SAP</a>、<a href=''https://market.aliyun.com/products/57742013/cmjj031975.html'' target=''_blank''>SUSE12SP3-SAP</a>.'
    AllowedValues:
      - SUSE15SP1-SAP
      - SUSE12SP4-SAP
      - SUSE12SP3-SAP
  customizedImage:
    Type: Boolean
    Label:
      zh-cn: 使用自訂鏡像
      en: Use Custom Image
    Description:
      zh-cn: 是否使用自訂鏡像作為目的執行個體的鏡像,如果選擇該項,'目的執行個體的作業系統版本'參數將無效,且需指定'自訂鏡像Id'參數
      en: Use custom image or not
    Default: false
  customizedImageId:
    Type: String
    Label:
      zh-cn: 自訂鏡像Id
      en: Custom Image Id
    Description:
      zh-cn: 使用自訂鏡像建立目的執行個體,僅'使用自訂鏡像'參數選中時有效
      en: Please enter a custom image id
    Default: ''
  instanceType:
    Type: String
    Label:
      zh-cn: 目的執行個體的執行個體規格
      en: Instance Type For SAP HANA Host
    Description:
      zh-cn: '<font color=''blue''><b>1.選擇機型前請先確認當前可用性區域下該機型是否有貨,部分機型需要提前報備</b></font><br><font color=''blue''><b>2.可選機型列表</b></font><br>[ecs.r5.2xlarge 非認證機型 64G]<br>[ecs.r5.4xlarge 非認證機型 128G]<br>[ecs.c5.8xlarge <font color=''green''>SAP認證機型 64G</font>]<br>[ecs.g5.8xlarge <font color=''green''>SAP認證機型 128G</font>]<br>[ecs.r5.8xlarge <font color=''green''>SAP認證機型 256G</font>]<br>[ecs.r6.13xlarge <font color=''green''>SAP認證機型 384G</font>]<br>[ecs.se1.14xlarge <font color=''green''>SAP認證機型 480G</font>]<br>[ecs.r5.16xlarge <font color=''green''>SAP認證機型 512G</font>]<br>[ecs.re4.20xlarge <font color=''green''>SAP認證機型 960G</font>]<br>[ecs.re4.40xlarge <font color=''green''>SAP認證機型 1920G</font>]<br>[ecs.re4e.40xlarge <font color=''green''>SAP認證機型 3840G</font>]<br><font color=''blue''><b>3.詳情請參考</font> <a href=''https://help.aliyun.com/document_detail/25378.html'' target=''_blank''><b>執行個體族詳情</b></a>。'
      en: '<font color=''blue''><b>Instance type list</b></font><br> [ecs.r5.2xlarge Non-certified instance type 64G]<br>[ecs.r5.4xlarge Non-certified instance type 128G]<br>[ecs.c5.8xlarge <font color=''green''>SAP certified instance type 64G</font>]<br>[ecs.g5.8xlarge <font color=''green''>SAP certified instance type 128G</font>]<br>[ecs.r5.8xlarge <font color=''green''>SAP certified instance type 256G</font>]<br>[ecs.r6.13xlarge <font color=''green''>SAP certified instance type 384G</font>]<br>[ecs.se1.14xlarge <font color=''green''>SAP certified instance type 480G</font>]<br>[ecs.r5.16xlarge <font color=''green''>SAP certified instance type 512G</font>]<br>[ecs.re4.20xlarge <font color=''green''>SAP certified instance type 960G</font>]<br>[ecs.re4.40xlarge <font color=''green''>SAP certified instance type 1920G</font>]<br>[ecs.re4e.40xlarge <font color=''green''>SAP certified instance type 3840G</font>].'
    AllowedValues:
      - ecs.r5.2xlarge(8vCPUs 64GiB)
      - ecs.r5.4xlarge(16vCPUs 128GiB)
      - ecs.c5.8xlarge(32vCPUs 64GiB)
      - ecs.g5.8xlarge(32vCPUs 128GiB)
      - ecs.r5.8xlarge(32vCPUs 256GiB)
      - ecs.r6.13xlarge(52vCPUs 384GiB)
      - ecs.se1.14xlarge(56vCPUs 480GiB)
      - ecs.r5.16xlarge(64vCPUs 512GiB)
      - ecs.re4.20xlarge(80vCPUs 960GiB)
      - ecs.re4.40xlarge(160vCPUs 1920GiB)
      - ecs.re4e.40xlarge(160vCPUs 3840GiB)
  ECSHostname:
    Type: String
    Label:
      zh-cn: 目的執行個體主機名稱
      en: Hostname
    Description:
      zh-cn: 目的執行個體主機名稱
      en: SAP HANA ECS hostname
    Default: hana001
    AllowedPattern: '^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-])*([a-zA-Z0-9])$'
    ConstraintDescription:
      zh-cn: 長度為 2-13 個字元,允許使用大小寫字母、數字或連字號(-),但不能以連字號(-)開頭或結尾
      en: 'The length is 2-13 characters,can starting with a capital or lowercase letter,and can contain numbers,or -,but can''t starting with - or end with -.'
  privateIpAddress:
    Type: String
    Label:
      zh-cn: 目的執行個體私人IP地址
      en: Private IP Address
    Description:
      zh-cn: '目的執行個體私人IP地址,請注意IP地址的範圍要在交換器網段。'
      en: 'Private IP address for SAP HANA ECS host,please pay attention:IP address should be within VSwitch CIdR Block.'
    ConstraintDescription:
      zh-cn: 請輸入正確的私人IP地址
      en: Please input the right private IP address
    AllowedPattern: '^((192\.168|172\.([1][6-9]|[2]\d|3[01]))(\.([2][0-4]\d|[2][5][0-5]|[01]?\d?\d)){2}|(\D)*10(\.([2][0-4]\d|[2][5][0-5]|[01]?\d?\d)){3})$'
  loginPassword:
    Type: String
    Label:
      zh-cn: 目的執行個體root使用者密碼
      en: root Passowrd
    Description:
      zh-cn: 目的執行個體root使用者登入密碼
      en: SAP HANA ECS root passowrd
    AllowedPattern: '^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\W_]+$)(?![a-z0-9]+$)(?![a-z\W_]+$)(?![0-9\W_]+$)[a-zA-Z0-9\W_]{8,}$'
    ConstraintDescription:
      zh-cn: 8-30個字元,且同時包含三項(大寫字母,小寫字母,數字或特殊符號)
      en: '8-30 characters,include(capital letter,lowercase letter,numbers or special characters).'
    NoEcho: true
  HANAInstanceNumber:
    Type: String
    Label:
      zh-cn: 目的執行個體SAP HANA執行個體編號
      en: SAP HANA Instance Number
    Description:
      zh-cn: 目的執行個體SAP HANA執行個體編號
      en: SAP HANA instance number
    ConstraintDescription:
      zh-cn: 2位元字,00-97
      en: '2 numbers,00-97.'
    AllowedPattern: '^([0-8][0-9]|9[0-6])$'
    Default: '00'
  systemDiskCategory:
    Default: cloud_ssd
    AllowedValues:
      - cloud_efficiency
      - cloud_ssd
    Label:
      zh-cn: 目的執行個體系統硬碟類型
      en: System Disk Type
    Description:
      zh-cn: '目的執行個體系統硬碟類型,系統硬碟分類: 高效雲端硬碟,SSD雲端硬碟。'
      en: 'System disk category: Ultra Disk,SSD disk.'
    Type: String
  systemDiskSize:
    Default: '100'
    Type: String
    Label:
      zh-cn: 目的執行個體系統硬碟大小
      en: System Disk Size
    Description:
      zh-cn: 目的執行個體系統硬碟大小,單位GB,容量20-500G
      en: '/ file system size,unit:GB,range:20~500G.'
    ConstraintDescription:
      zh-cn: 必須輸入整數,單位GB,容量20-500G
      en: 'Must be an integer,range:20~500G.'
    AllowedPattern: '(^2[0-9]$)|(^[3-9]\d$)|(^[1-4]\d{2}$)|500$'
  dataLogDiskCategory:
    Default: cloud_ssd
    AllowedValues:
      - cloud_essd PL1
      - cloud_essd PL2
      - cloud_essd PL3
      - cloud_ssd
    Label:
      zh-cn: /hana/data和/hana/log檔案系統所在磁碟類型
      en: /hana/data And /hana/log File System Disk Category
    Description:
      zh-cn: '1.可選磁碟類型:ESSD雲端硬碟PL1、ESSD雲端硬碟PL2、ESSD雲端硬碟PL3、SSD雲端硬碟。<br>2. ESSD 雲端硬碟容量越大,可供選擇的效能層級越高(460 GiB 以上可選 PL2,1260 GiB 以上可選 PL3),效能層級越高相應的費用也越高:<ul><li>    cloud_essd PL1(單盤IOPS效能上限5萬)</li><li>    cloud_essd PL2(單盤IOPS效能上限10萬)</li><li>    cloud_essd PL3(單盤IOPS效能上限100萬)</li></ul>如何合理選擇 ESSD 雲端硬碟效能層級,<a href=''https://help.aliyun.com/document_detail/122389.html'' target=''view_window''>查看詳情></a>。'
      en: '1. /hana/data and /hana/log file system disk category: ESSD disk,SSD disk.<br>2. The higher the performance level that you can select. For example, PL2 is available for an enhanced SSD of more than 460 GiB and PL3 is available for an enhanced SSD of more than 1260 GiB. A higher performance level indicates a higher fee:<ul><li>    cloud_essd PL1(up to 50,000 IOPS per disk)</li><li>    cloud_essd PL2(up to 100,000 IOPS per disk)</li><li>    cloud_essd PL3(up to 1,000,000 IOPS per disk)</li></ul>For more information about how to select the performance level of an enhanced SSD, <a href=''https://help.aliyun.com/document_detail/122389.html'' target=''view_window''>click here></a>.'
    Type: String
  dataSize:
    Type: String
    Label:
      zh-cn: 目的執行個體的/hana/data大小
      en: /hana/data File System Size
    Description:
      zh-cn: 目的執行個體的/hana/data檔案系統大小,單位GB,SAP官方推薦:Size >= 1 x RAM
      en: '/hana/data file system size,unit:GB,SAP recommendation:Size >= 1 x RAM.'
    ConstraintDescription:
      zh-cn: 必須輸入整數,容量20-32768G
      en: 'Must be an integer,range:20~32768G.'
    AllowedPattern: '(^[2-9]\d{1}$)|(^[1-9]\d{2}$)|(^[1-9]\d{3}$)|(^[1-2]\d{4}$)|(^3[0-2][0-7][0-6][0-8]$)'
  logSize:
    Type: String
    Label:
      zh-cn: 目的執行個體的/hana/log大小
      en: /hana/log File System Size
    Description:
      zh-cn: '目的執行個體的/hana/log檔案系統大小,單位GB,SAP官方推薦:[systems ≤ 512GB ] Sizeredolog = 1/2 x RAM;[systems > 512GB ] Sizeredolog(min) = 512GB。'
      en: '/hana/log file system size,unit:GB,SAP recommendation:[systems ≤ 512GB ] Sizeredolog = 1/2 x RAM;[systems > 512GB ] Sizeredolog(min) = 512GB.'
    ConstraintDescription:
      zh-cn: '必須輸入整數,容量20-32768GB。'
      en: 'Must be an integer,range:20~32768G.'
    AllowedPattern: '(^[2-9]\d{1}$)|(^[1-9]\d{2}$)|(^[1-9]\d{3}$)|(^[1-2]\d{4}$)|(^3[0-2][0-7][0-6][0-8]$)'
  sharedDiskCategory:
    Default: cloud_ssd
    AllowedValues:
      - cloud_efficiency
      - cloud_ssd
      - cloud_essd
    Label:
      zh-cn: 目的執行個體的/hana/shared檔案系統所在磁碟類型
      en: /hana/shared File System Disk Category
    Description:
      zh-cn: 目的執行個體的/hana/shared檔案系統所在磁碟類型:高效雲端硬碟、SSD雲端硬碟、ESSD雲端硬碟
      en: '/hana/shared file system disk category: Ultra Disk, SSD disk, ESSD disk.'
    Type: String
  sharedSize:
    Type: String
    Label:
      zh-cn: 目的執行個體的/hana/shared大小
      en: /hana/shared File System Size
    Description:
      zh-cn: 目的執行個體的/hana/shared檔案系統大小,單位GB,SAP官方推薦:Sizeinstallation(single-node) = MIN(1 x RAM; 1 TB)
      en: '/hana/shared file system size,unit:GB,SAP recommendation: Sizeinstallation(single-node) = MIN(1 x RAM; 1 TB).'
    ConstraintDescription:
      zh-cn: 必須輸入整數,容量20-32768GB
      en: 'Must be an integer,range:20~32768G.'
    AllowedPattern: '(^[2-9]\d{1}$)|(^[1-9]\d{2}$)|(^[1-9]\d{3}$)|(^[1-2]\d{4}$)|(^3[0-2][0-7][0-6][0-8]$)'
  usrsapDiskCategory:
    Default: cloud_ssd
    AllowedValues:
      - cloud_efficiency
      - cloud_ssd
      - cloud_essd
    Label:
      zh-cn: 目的執行個體的/usr/sap檔案系統所在磁碟類型
      en: /usr/sap File System Disk Category
    Description:
      zh-cn: 目的執行個體的/usr/sap檔案系統所在磁碟類型:高效雲端硬碟、SSD雲端硬碟、ESSD雲端硬碟
      en: '/usr/sap file system disk category: Ultra Disk, SSD disk, ESSD disk.'
    Type: String
  usrsapSize:
    Type: String
    Label:
      zh-cn: 目的執行個體的/usr/sap大小
      en: /usr/sap File System Size
    Description:
      zh-cn: 目的執行個體的/usr/sap檔案系統大小,單位GB
      en: '/usr/sap file system size,unit:GB.'
    Default: '50'
    ConstraintDescription:
      zh-cn: 必須輸入整數,容量20-32768G
      en: 'Must be an integer,range:20~32768G.'
    AllowedPattern: '(^[2-9]\d{1}$)|(^[1-9]\d{2}$)|(^[1-9]\d{3}$)|(^[1-2]\d{4}$)|(^3[0-2][0-7][0-6][0-8]$)'
  mediaPath:
    Type: String
    Label:
      zh-cn: SAP HANA軟體包OSS路徑
      en: SAP HANA Software OSS Path
    Description:
      zh-cn: '請從SAP官網下載SAP HANA安裝介質,上傳至SAP系統部署所在的OSS地區,輸入該目錄的路徑,例:oss://{bucket_name}/hana。'
      en: 'Please download the SAP HANA installation media from SAP software download center(Don''t need to extract, the packages are like these:51053381_part1.exe or.rar)and upload them into OSS bucket,input the full path starting with oss://. eg: oss://{bucket_name}/hana.'
    ConstraintDescription:
      zh-cn: 'oss:開頭,例:oss://{bucket_name}/hana。'
      en: 'Starting with oss.eg: oss://{bucket_name}/hana.'
    AllowedPattern: '^(oss|https|http)://[\S\w]+([\S\w])+$'
  systemUsage:
    Type: String
    Label:
      zh-cn: 目的執行個體的SAP HANA系統類別型
      en: SAP HANA System Usage
    Description:
      zh-cn: '目的執行個體的SAP HANA系統類別型,包括custom,development,test,production。'
      en: 'SAP HANA system usage(custom,development,test,production).'
    Default: custom
    AllowedValues:
      - custom
      - development
      - test
      - production
  HANASapSidAdmUid:
    Type: String
    Label:
      zh-cn: 目的執行個體的SAP HANA sidadm使用者Id
      en: SAP HANA sidadm User Id
    Description:
      zh-cn: '目的執行個體的sidadm user Id,只能填寫數字,大於500且小於65532,預設值是1001。'
      en: 'sidadm user Id,Only number,range:500~65532,default value:1001.'
    Default: '1001'
    ConstraintDescription:
      zh-cn: '只能填寫數字,大於500且小於65532。'
      en: 'Only number,range:500~65532.'
    AllowedPattern: '(^[5-9]\d{2}$)|(^[1-9]\d{3}$)|(^[1-5]\d{4}$)|(^6[0-5][0-5][0-3][0-2]$)'
  HANASapSysGid:
    Type: String
    Label:
      zh-cn: 目的執行個體的SAP HANA sapsys組Id
      en: SAP HANA sapsys Group Id
    Description:
      zh-cn: '目的執行個體的sapsys group Id,只能填寫數字,預設值是79。'
      en: 'Sapsys group Id,Only number,default value:79.'
    Default: '79'
    ConstraintDescription:
      zh-cn: 只能填寫數字
      en: Only number
    AllowedPattern: (^\d+$)
  userName:
    Label:
      zh-cn: 目的執行個體的使用者名稱
      en: Username of SYSTEMDB
    Description:
      zh-cn: 目的執行個體的使用者名稱
      en: Input username of SYSTEMDB.
    Type: String
    Default: SYSTEM
  weatherDeleteResource:
    Label:
      zh-cn: 驗證成功後保留雲資源.
      en: Retain Cloud Resources
    Description:
      zh-cn: '是否在驗證備份成功後,保留雲資源, 預設不保留。該參數為選中狀態且成功恢複備份時,''雲資源保留時間長度''參數將失效。'
      en: 'Whether to reserve cloud resources after verifying the successful backup, not reserved by default. When this parameter is selected and the backup is successfully restored, the''Cloud Resource Retention Duration'' parameter will be invalid.'
    Type: Boolean
    Default: false
  timeout:
    Label:
      zh-cn: 雲資源保留時間長度(單位:分鐘)
      en: 'Cloud Resource Retention Time (Unit: Minutes)'
    Description:
      zh-cn: 測試完成/失敗後,保留雲資源的時間長度(單位:分鐘)。
      en: 'After the test is completed/failed, the length of time to reserve cloud resources (unit: minutes).'
    Type: Number
    Default: '30'
  dingTalkWebhook:
    Label:
      zh-cn: DingTalk機器人Webhook地址
      en: DingTalk Robot Webhook
    Description:
      zh-cn: 'DingTalk自訂機器人Webhook地址,用以向DingTalk發送測試結果訊息和刪除雲資源審批訊息,更多請瀏覽<a href=''https://open-doc.dingtalk.com/microapp/serverapi2/qf2nxq'' target=''_blank''>DingTalk自訂機器人</a>。'
      en: 'Sends notification to DingTalk via webhook for asking approval. The execution remains paused until approved or rejected. Please refer https://open-doc.dingtalk.com/microapp/serverapi2/qf2nxq for details.'
    Type: String
Tasks:
  - Name: checkHanaInstanceType
    Action: 'ACS::CheckFor'
    Description:
      zh-cn: 查詢SAP HANA執行個體規格在當前可用性區域是否可用
      en: Check SAP HANA instance type availability in current available zones
    Properties:
      Service: ECS
      API: DescribeAvailableResource
      Parameters:
        ZoneId: '{{ zoneId }}'
        RegionId: '{{ACS::RegionId}}'
        InstanceType:
          'Fn::Select':
            - 0
            - 'Fn::Split':
                - (
                - '{{ instanceType }}'
        DestinationResource: InstanceType
      PropertySelector: 'AvailableZones.AvailableZone[0].Status'
      DesiredValues:
        - Available
    Retries: 2
  - Name: checkHanaBackupSetting
    Action: 'ACS::CheckFor'
    Description:
      zh-cn: 查詢源執行個體SAP HANADatabase Backup設定
      en: Check source SAP HANA backup settings
    Properties:
      Service: HBR
      API: DescribeHanaBackupSetting
      Parameters:
        VaultId: '{{ vaultId }}'
        ClusterId: '{{ sourceClusterId }}'
        DatabaseName: 
          'Fn::Select':
            - 0
            - 'Fn::Split':
              - '@'
              - '{{ ACS::TaskLoopItem }}'
      PropertySelector: HanaBackupSetting.CatalogBackupUsingBackint
      DesiredValues:
        - true
    Retries: 2
    Loop:
      Items: '{{ databaseName }}'
      RateControl:
        MaxErrors: 0
        Mode: Concurrency
        Concurrency: 1
  - Name: createStack
    Action: 'ACS::ExecuteAPI'
    Description:
      en: Create a SAP HANA single node stack.
      zh-cn: 建立SAP HANA單節點資源棧
    Properties:
      Service: ROS
      API: CreateStack
      Parameters:
        StackName: 'HBR-{{ACS::ExecutionId}}'
        TimeoutInMinutes: 60
        DisableRollback: true
        Parameters:
          - ParameterKey: ImageId
            ParameterValue: '{{ imageId }}'
          - ParameterKey: CustomizedImageId
            ParameterValue: '{{ customizedImageId }}'
          - ParameterKey: CustomizedImage
            ParameterValue: '{{ customizedImage }}'
          - ParameterKey: ZoneId
            ParameterValue: '{{ zoneId }}'
          - ParameterKey: VpcId
            ParameterValue: '{{ vpcId }}'
          - ParameterKey: VSwitchId
            ParameterValue: '{{ vSwitchId }}'
          - ParameterKey: InstanceType
            ParameterValue: '{{ instanceType }}'
          - ParameterKey: ECSHostname
            ParameterValue: '{{ ECSHostname }}'
          - ParameterKey: PrivateIpAddress
            ParameterValue: '{{ privateIpAddress }}'
          - ParameterKey: LoginPassword
            ParameterValue: '{{ loginPassword }}'
          - ParameterKey: HANASID
            ParameterValue: '{{ HANASID }}'
          - ParameterKey: HANAInstanceNumber
            ParameterValue: '{{ HANAInstanceNumber }}'
          - ParameterKey: SystemDiskCategory
            ParameterValue: '{{ systemDiskCategory }}'
          - ParameterKey: SystemDiskSize
            ParameterValue: '{{ systemDiskSize }}'
          - ParameterKey: DataLogDiskCategory
            ParameterValue: '{{ dataLogDiskCategory }}'
          - ParameterKey: DataSize
            ParameterValue: '{{ dataSize }}'
          - ParameterKey: LogSize
            ParameterValue: '{{ logSize }}'
          - ParameterKey: SharedDiskCategory
            ParameterValue: '{{ sharedDiskCategory }}'
          - ParameterKey: SharedSize
            ParameterValue: '{{ sharedSize }}'
          - ParameterKey: UsrsapDiskCategory
            ParameterValue: '{{ usrsapDiskCategory }}'
          - ParameterKey: UsrsapSize
            ParameterValue: '{{ usrsapSize }}'
          - ParameterKey: MasterPass
            ParameterValue: '{{ masterPass }}'
          - ParameterKey: MediaPath
            ParameterValue: '{{ mediaPath }}'
          - ParameterKey: SystemUsage
            ParameterValue: '{{ SystemUsage }}'
          - ParameterKey: HANASapSidAdmUid
            ParameterValue: '{{ HANASapSidAdmUid }}'
          - ParameterKey: HANASapSysGid
            ParameterValue: '{{ HANASapSysGid }}'
        TemplateURL: 'https://sap-automation-{{ACS::RegionId}}.oss-{{ACS::RegionId}}.aliyuncs.com/Public_V1/HANA/HANA_Single_Node.json'
    Outputs:
      StackId:
        Type: String
        ValueSelector: StackId
  - Name: untilStackReady
    Action: 'ACS::WaitFor'
    OnError: getExecutionFaildMessage
    Description:
      en: Wait the stack status util CREATE_COMPLETE
      zh-cn: 等待資源棧至建立成功狀態
    DelayType: Constant
    Delay: 300
    Retries: 12
    Properties:
      Service: ROS
      API: GetStack
      Parameters:
        StackId: '{{createStack.StackId}}'
      DesiredValues:
        - CREATE_COMPLETE
      StopRetryValues:
        - CREATE_FAILED
        - CHECK_FAILED
        - ROLLBACK_FAILED
        - ROLLBACK_COMPLETE
        - CREATE_ROLLBACK_COMPLETE
        - CREATE_ROLLBACK_FAILED
      PropertySelector: Status
    Outputs:
      HANAServerId:
        Type: String
        ValueSelector: '.Outputs[] | select(.OutputKey == "HANAServerId") | .OutputValue'
      HANAServerLog:
        Type: Json
        ValueSelector: '.Outputs[] | select(.OutputKey == "InstallLog") | .OutputValue'
  - Name: checkHanaServerLog
    Action: 'ACS::CheckFor'
    OnError: getExecutionFaildMessage
    Description:
      zh-cn: 檢查SAP HANA安裝日誌
      en: Check SAP HANA installation log
    Properties:
      Service: ROS
      API: GetStack
      Parameters:
        StackId: '{{createStack.StackId}}'
      PropertySelector: '.Outputs[] | select(.OutputKey == "InstallLog") | .OutputValue'
      DesiredValues:
        - '{"HANANode": "SUCCESS"}'
    Retries: 2
  - Name: createHANAInstance
    Action: 'ACS::ExecuteAPI'
    OnError: getExecutionFaildMessage
    Description:
      zh-cn: 建立HBR SAP HANA執行個體
      en: Create HBR SAP HANA instance
    Properties:
      Service: HBR
      API: CreateHanaInstance
      Parameters:
        VaultId: '{{ vaultId }}'
        EcsInstanceId: '{{ untilStackReady.HANAServerId }}'
        Host: '{{ privateIpAddress }}'
        HanaName: '{{ ECSHostname }}'
        InstanceNumber: '{{ HANAInstanceNumber }}'
        UserName: '{{ userName }}'
        Password: '{{ masterPass }}'
        UseSsl: true
    Outputs:
      ClusterId:
        Type: String
        ValueSelector: ClusterId
  - Name: createClients
    Action: 'ACS::ExecuteAPI'
    OnError: getExecutionFaildMessage
    Description:
      zh-cn: 建立HBR SAP HANA執行個體用戶端
      en: Create HBR SAP HANA instance client
    Properties:
      Service: HBR
      API: CreateClients
      Parameters:
        VaultId: '{{ vaultId }}'
        AlertSetting: INHERITED
        ClientInfo:
          - instanceId: '{{ untilStackReady.HANAServerId }}'
            accessKeyId: ''
            accessKeySecret: ''
            clusterId: '{{ createHANAInstance.ClusterId }}'
            sourceTypes:
              - HANA
    Outputs:
      TaskId:
        Type: String
        ValueSelector: TaskId
  - Name: waitForCreateClient
    Action: 'ACS::WaitFor'
    OnError: getExecutionFaildMessage
    Description:
      zh-cn: 等待用戶端建立完成
      en: Wait for the client to be created
    DelayType: Constant
    Delay: 5
    Retries: 15
    Properties:
      Service: HBR
      API: DescribeTask
      Parameters:
        TaskId: '{{ createClients.TaskId }}'
      PropertySelector: Description
      StopRetryValues:
        - completed
      DesiredValues:
        - completed
  - Name: waitForActivateClient
    Action: 'ACS::WaitFor'
    OnError: getExecutionFaildMessage
    Description:
      zh-cn: 等待HBR用戶端啟用完成
      en: Wait for client activation to complete
    Properties:
      Service: HBR
      API: DescribeClients
      Parameters:
        ClusterId: '{{ createHANAInstance.ClusterId }}'
        VaultId: '{{ vaultId }}'
        SourceType: HANA
        ClientType: ECS_AGENT
      PropertySelector: 'Clients.Client[].Status'
      StopRetryValues:
        - ACTIVATED
        - INSTALL_FAILED
      DesiredValues:
        - ACTIVATED
    Retries: 5
    Outputs:
      ClientId:
        Type: String
        ValueSelector: 'Clients.Client[].ClientId'
  - Name: RestoreBuckup
    Action: 'ACS::HBR::RestoreHanaDatabaseBackup'
    OnError: getExecutionFaildMessage
    Description:
      zh-cn: 恢複並驗證備份
      en: Restore and verify backup
    Properties:
      vaultId: '{{ vaultId }}'
      sourceClusterId: '{{ sourceClusterId }}'
      sourceSystemName:
        'Fn::Select':
          - 0
          - 'Fn::Split':
            - ':'
            - '{{ ACS::TaskLoopItem }}'
      clusterId: '{{ createHANAInstance.ClusterId }}'
      databaseName:
        'Fn::Select':
          - 1
          - 'Fn::Split':
            - ':'
            - '{{ ACS::TaskLoopItem }}'
      HANAInstanceServerId: '{{ untilStackReady.HANAServerId }}'
      HANASID: '{{ HANASID }}'
      masterClientId: '{{ waitForActivateClient.ClientId }}'
    Loop:
      Items: '{{ databaseName }}'
      RateControl:
        MaxErrors: 0
        Mode: Concurrency
        Concurrency: 1
  - Name: runCommand
    Action: 'ACS::ECS::RunCommand'
    OnSuccess: DingTalkNotify
    OnError: getExecutionFaildMessage
    Description:
      en: Verify the running status of the SAP HANA instance
      zh-cn: 校正SAP HANA執行個體運行狀態
    Properties:
      regionId: '{{ ACS::RegionId }}'
      commandContent:
        'Fn::Join':
          - ''
          - - 'su - '
            - 'Fn::Jq':
                - First
                - .key | ascii_downcase
                - key: '{{ HANASID }}'
            - 'adm -c "sapcontrol -nr '
            - '{{ HANAInstanceNumber }}'
            - ' -function GetProcessList"; if [[ $? -eq 3 ]]; then exit 0;fi'
      instanceId: '{{ untilStackReady.HANAServerId }}'
      commandType: RunShellScript
      timeout: '180'
    Outputs:
      commandOutputs:
        Type: String
        ValueSelector: invocationOutput
  - Name: getExecutionFaildMessage
    Action: 'ACS::ExecuteAPI'
    Description:
      en: Get execution failure information
      zh-cn: 擷取執行失敗資訊
    Properties:
      Service: OOS
      API: ListExecutions
      Parameters:
        ExecutionId: '{{ ACS::ExecutionId }}'
    Outputs:
      statusMessage:
        Type: String
        ValueSelector: 'Executions[].StatusMessage'
  - Name: DingTalkNotifyExecutionFailed
    Action: 'ACS::Notify'
    OnSuccess: sleepTask
    Description:
      en: Notification execution failure message
      zh-cn: 通知執行失敗訊息
    Properties:
      NotifyType: WebHook
      WebHook:
        URI: '{{ dingTalkWebhook }}'
        Headers:
          Content-Type: application/json
        Content:
          msgtype: markdown
          markdown:
            title: '{{ ACS::CurrentUTCTime }}-HBR自動化的測試執行失敗報告'
            text:
              'Fn::Join':
                - |+


                - - '#### {{ ACS::CurrentUTCTime }}-HBR自動化的測試執行失敗報告'
                  - '檢測資料庫:{{ databaseName }}'
                  - '錯誤資訊:{{ getExecutionFaildMessage.statusMessage }}'
                  - '**測試將在{{ timeout }}分鐘後自動清理測試雲端資源,如需保留雲資源,請到[OOS控制台](https://oos.console.aliyun.com/{{ ACS::RegionId }}/execution/detail/{{ ACS::ExecutionId }})取消執行**'
          at:
            atMobiles: []
            isAtAll: true
  - Name: DingTalkNotify
    Action: 'ACS::Notify'
    Description:
      en: Notify test results
      zh-cn: DingTalk通知測試結果
    Properties:
      NotifyType: WebHook
      WebHook:
        URI: '{{ dingTalkWebhook }}'
        Headers:
          Content-Type: application/json
        Content:
          msgtype: markdown
          markdown:
            title: '{{ ACS::CurrentUTCTime }}-HBR自動化的測試報告'
            text:
              'Fn::Join':
                - |+


                - - '#### {{ ACS::CurrentUTCTime }}-HBR自動化的測試報告'
                  - 測試結果:SUCCESS
                  - '檢測資料庫:{{ databaseName }}'
                  - '目的執行個體:{{ ECSHostname }}'
                  - '目的執行個體Id:{{ untilStackReady.HANAServerId }}'
                  - '**如果您選擇清理雲資源,測試將在{{ timeout }}分鐘後自動清理測試雲端資源,如需保留雲資源,請到[OOS控制台](https://oos.console.aliyun.com/{{ACS::RegionId}}/execution/detail/{{ ACS::ExecutionId }})取消執行**'
          at:
            atMobiles: []
            isAtAll: true
  - Name: whetherDeleteResource
    Action: 'ACS::Choice'
    Properties:
      DefaultTask: sleepTask
      Choices:
        - When: '{{ weatherDeleteResource }}'
          NextTask: 'ACS::END'
  - Name: sleepTask
    Action: 'ACS::Sleep'
    Properties:
      Duration: 'PT{{ timeout }}M'
  - Name: deleteStack
    Action: 'ACS::ExecuteApi'
    OnError: getCleanupFaildMessage
    Description:
      en: Delete the stack
      zh-cn: 刪除資源棧
    Properties:
      Service: ROS
      API: DeleteStack
      Parameters:
        StackId: '{{createStack.StackId}}'
  - Name: describeHanaInstances
    Action: 'ACS::ExecuteAPI'
    OnError: getCleanupFaildMessage
    Description:
      zh-cn: 查詢HBR SAP HANA執行個體
      en: Query HBR SAP HANA instance
    Properties:
      Service: HBR
      API: DescribeHanaInstances
      Parameters:
        VaultId: '{{ vaultId }}'
    Outputs:
      Hanas:
        Type: Json
        ValueSelector: Hanas
  - Name: whetherDeleteHanaInstances
    Action: 'ACS::Choice'
    Properties:
      DefaultTask: untilStackCleanup
      Choices:
        - When:
            'Fn::Equals':
              - '{{ ECSHostname }}'
              - 'Fn::Jq':
                  - First
                  - '.key.Hana[] | select(.Host == "{{ privateIpAddress }}") | .HanaName'
                  - key: '{{ describeHanaInstances.Hanas }}'
          NextTask: deleteHanaInstance
  - Name: deleteHanaInstance
    Action: 'ACS::ExecuteApi'
    OnError: getCleanupFaildMessage
    Description:
      en: Delete the stack
      zh-cn: 刪除測試SAP HANA執行個體
    Properties:
      Service: HBR
      API: DeleteHanaInstance
      Parameters:
        VaultId: '{{ vaultId }}'
        ClusterId: '{{ createHANAInstance.ClusterId }}'
        Sid: '{{ HANASID }}'
  - Name: untilStackCleanup
    Action: 'ACS::WaitFor'
    OnError: getCleanupFaildMessage
    OnSuccess: 'ACS::END'
    Description:
      en: Wait the stack status util DELETE_COMPLETE
      zh-cn: 等待資源棧至刪除成功狀態
    DelayType: Constant
    Delay: 300
    Retries: 12
    Properties:
      Service: ROS
      API: GetStack
      Parameters:
        StackId: '{{createStack.StackId}}'
      DesiredValues:
        - DELETE_COMPLETE
      StopRetryValues:
        - DELETE_FAILED
        - DELETE_COMPLETE
      PropertySelector: Status
  - Name: getCleanupFaildMessage
    Action: 'ACS::ExecuteAPI'
    Description:
      en: Get cleanup failure information
      zh-cn: 擷取清理失敗資訊
    Properties:
      Service: OOS
      API: ListExecutions
      Parameters:
        ExecutionId: '{{ ACS::ExecutionId }}'
    Outputs:
      statusMessage:
        Type: String
        ValueSelector: 'Executions[].StatusMessage'
  - Name: DingTalkNotifyCleanupFailed
    Action: 'ACS::Notify'
    Description:
      en: Notification cleanup failed
      zh-cn: 清理失敗通知
    Properties:
      NotifyType: WebHook
      WebHook:
        URI: '{{ dingTalkWebhook }}'
        Headers:
          Content-Type: application/json
        Content:
          msgtype: markdown
          markdown:
            title: '{{ ACS::CurrentUTCTime }}-HBR自動化的測試清理失敗報告'
            text:
              'Fn::Join':
                - |+


                - - '#### {{ ACS::CurrentUTCTime }}-HBR自動化的測試清理失敗報告'
                  - '檢測資料庫:{{ databaseName }}'
                  - '錯誤資訊:{{ getCleanupFaildMessage.statusMessage }}'
                  - '**自動清理雲資源失敗,請手動清理**'
          at:
            atMobiles: []
            isAtAll: true
Outputs:
  Result:
    Type: String
    Value: '{{ untilStackReady.HANAServerId }}'