Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
remi_astier
Advisor
Advisor
SAP HANA Cloud brings interesting possibilities for admins, such as automating the creation of new instances or shutting down non productive instances overnight.

The command line utility for Cloud Foundry enables us to do just that. For simplicity we'll use an external machine with a good old crontab.

Below are the commands you can put in a script to automate tasks. If you're using windows, please refer to this link for the syntax for the windows command line and PowerShell.

Log into Cloud Foundry


Before performing an action, you need to be authenticated. This is done with the
cf login command. It takes parameters such as:

  • -a The cloud foundry API url of the dataceter

  • -o The target organization

  • -s The target space

  • -u User name and -p password. For security, the password is read from a file.


cf login -u my.email@sap.com -o my_org -s my_space -a https://api.cf.eu20.hana.ondemand.com -p "$(<$HOME/.ssh/.toto)"

Perform the Action


Now you're ready to execute an action using either

  • cf create-service to create a HANA Cloud instance, a Relational Data Lake, or any other services of the SAP Cloud Platform.

  • cf update-service to start/stop/resize a service instance.


Create a new instance


cf create-service hana-cloud hana tst_cf_db -c '{ ... }'

A sample json value is:
{"data":{"edition":"cloud","memory":32,"systempassword":"PereNoel2021","whitelistIPs":["10.2.3.0/24"],"vcpu":2}}

The json data must have compatible values for memory and cpu, otherwise an error message informs you of the correct values.
For instance, a request of 32 GB of memory for 4 vcpus will return:
Invalid Parameter (memory): HANA with 4 CPUs requires 64 GB memory (32)

This is quite useful because Azure and AWS have slightly different ratios of memory per vcpu.

Stop an instance


cf update-service tst_cf_db -c '{​​​​​"data":{"serviceStopped":true}}'

Start an instance


cf update-service tst_cf_db -c '{​​​​​"data":{"serviceStopped":false}}'

Increase the size:


The challenge is to come up with the correct values of memory, vcpu and storage. Bear in mind that currently, storage capacity once increased cannot be reduced.

An easy way to obtain the correct values is to execute the command multiple times to get the correct calculated values from the error messages. This example shows how to increase from 2 vcpu to 4.
cf update-service tst_cf_db -c '{"data": {"vcpu":4}}'

FAILED [...] HANA with 4 CPUs requires 64 GB memory (32)


cf update-service tst_cf_db -c '{"data": {"vcpu":4, "memory":64}}'

FAILED [...] HANA with 64 GB memory requires at least 200 GB storage (120)


cf update-service tst_cf_db -c '{"data": {"vcpu":4, "memory":64, "storage":200}}'

OK

Decrease the size:


Decreasing the size unfortunately requires opening a ticket. This roadmap item tracks the possibility to do it from the command line.

 

All the commands are described in the documentation.
6 Comments