Skip to content

Commit

Permalink
Enable deployment to HANA XSA
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorwolf committed Dec 1, 2020
1 parent 1f2718f commit db35894
Show file tree
Hide file tree
Showing 16 changed files with 333 additions and 88 deletions.
25 changes: 0 additions & 25 deletions .cdsrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,6 @@
"odata": {
"skipValidation": "true"
},
"build": {
"target": ".",
"tasks": [
{
"for": "hana",
"src": "db",
"options": {
"model": [
"db",
"srv"
]
}
},
{
"for": "node-cf",
"src": "srv",
"options": {
"model": [
"db",
"srv"
]
}
}
]
},
"auth": {
"passport": {
"strategy": "mock",
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ mta-op*
.DS_Store
*.orig
*.log

Makefile*
mta.yaml
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This example application demonstrates how to use an OData Service available on the [SAP Gateway Demo Server - ES5](https://developers.sap.com/tutorials/gateway-demo-signup.html) with the SAP Cloud SDK for NodeJS and the SAP Cloud Application Programming Model.

You can also run this app against your on premise [ABAP Developer Edition](https://blogs.sap.com/2019/07/01/as-abap-752-sp04-developer-edition-to-download/) using the SAP Cloud Connection. Here you can then configure end-to-end authentication with principal propagation. In that case the service in the ABAP Backend is called not with a technical user, but with the user that was authenticated in the SAP Cloud Platform.
You can also run this app against your on premise [ABAP Developer Edition](https://blogs.sap.com/2019/07/01/as-abap-752-sp04-developer-edition-to-download/) using the SAP Cloud Connector to establish the connection. Here you can then configure end-to-end authentication with principal propagation. In that case the service in the ABAP Backend is called not with a technical user, but with the user that was authenticated in the SAP Cloud Platform.

This example wouldn't work without the help of [Dennis Hempfing](https://github.com/mr-flannery) who steped in to help in this questions:

Expand Down Expand Up @@ -105,3 +105,30 @@ Authentication=PrincipalPropagation
### Deploy

`npm run deploy:cf`

## Deploy to SAP HANA XSA on Premise

It's possible to deploy this application also to an on Premise instance of SAP HANA.

### Preperation

The connection information to the ES5 system is provided via a user-provided service. Such a services needs a configuration file. The actual content can't be used in the destination. Please create *default-es5destination.json* in the root folder of the project and fill it with:

```JSON
{
"name": "ES5",
"url": "https://sapes5.sapdevcenter.com"
}
```

### Build

`npm run build:xsa`

### Deploy

`npm run deploy:xsa`

### Test

Start the Application: epmbp-consumer-app-app via the created Application Route from the SAP HANA XS Advanced Cockpit. You should be able to open the Link */catalog/SEPMRA_I_Product_E - Public Service from ES5* and see a list of Products returned as JSON.
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@sap/grunt-sapui5-bestpractice-build": "1.4.6"
},
"dependencies": {
"@sap/approuter": "^8.5.0"
"@sap/approuter": "^8.6.1"
},
"scripts": {
"start": "node node_modules/@sap/approuter/approuter.js"
Expand Down
2 changes: 1 addition & 1 deletion app/webapp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ <h2>Reading from Backend via CAP Middleware using CAP</h2>
<ul>
<li><a href="/catalog/Suppliers">/catalog/Suppliers</a></li>
<li><a href="/catalog/Products">/catalog/Products</a></li>
<li><a href="/catalog/SEPMRA_I_Product_E">/catalog/SEPMRA_I_Product_E - Public Service from ES5</a></li>
</ul>

<p><a href="/do/logout">Logout</a></p>
</body>

Expand Down
2 changes: 1 addition & 1 deletion app/xs-app.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
{
"source": "/sap/(.*)$",
"target": "/sap/$1",
"destination": "ES5_SDK"
"destination": "ES5"
},
{
"source": "^/app/logout.html$",
Expand Down
2 changes: 1 addition & 1 deletion db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"node": "^10"
},
"dependencies": {
"@sap/hdi-deploy": "^3.11.11"
"@sap/hdi-deploy": "^3.11.15"
},
"scripts": {
"postinstall": "node .build.js",
Expand Down
6 changes: 4 additions & 2 deletions db/schema.cds
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace my.bookshop;

using cuid from '@sap/cds/common';
using EPM_REF_APPS_PROD_MAN_SRV from '../srv/external/EPM_REF_APPS_PROD_MAN_SRV';

using ZPDCDS_SRV from '../srv/external/ZPDCDS_SRV';

entity Books {
key ID : Integer;
Expand Down Expand Up @@ -34,4 +34,6 @@ entity Products as projection on EPM_REF_APPS_PROD_MAN_SRV.Products;
entity A_BusinessPartner {
key BusinessPartner: String(10);
OrganizationBPName1: String(40);
}
}

entity SEPMRA_I_Product_E as projection on ZPDCDS_SRV.SEPMRA_I_Product_E;
22 changes: 14 additions & 8 deletions mta.yaml → mta-cf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,29 @@ _schema-version: "2.1"
version: 0.0.1
parameters:
enable-parallel-deployments: true
build-parameters:
before-all:
- builder: custom
commands:
- npm install --production
- npx -p @sap/cds-dk cds build --production

modules:
- name: epmbp-consumer-app-db
type: hdb
path: db
# build-parameters:
# ignore: ["node_modules/"]
path: gen/db
build-parameters:
ignore: ["node_modules/"]
parameters:
memory: 256M
disk-quota: 256M
requires:
- name: epmbp-consumer-app-db-hdi-container
- name: epmbp-consumer-app-srv
type: nodejs
path: srv
# build-parameters:
# ignore: ["node_modules/"]
path: gen/srv
build-parameters:
ignore: ["node_modules/"]
parameters:
memory: 256M
disk-quota: 1024M
Expand All @@ -36,8 +42,8 @@ modules:
- name: epmbp-consumer-app-app
type: nodejs
path: app
# build-parameters:
# ignore: ["node_modules/"]
build-parameters:
ignore: ["node_modules/"]
parameters:
memory: 256M
disk-quota: 1024M
Expand Down
87 changes: 87 additions & 0 deletions mta-xsa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
ID: epmbp-consumer-app
_schema-version: "2.1"
version: 0.0.1
parameters:
enable-parallel-deployments: true
build-parameters:
before-all:
- builder: custom
commands:
- npm install --production
- npx -p @sap/cds-dk cds build --production

modules:
- name: epmbp-consumer-app-db
type: hdb
path: gen/db
build-parameters:
ignore: ["node_modules/"]
parameters:
memory: 256M
disk-quota: 256M
requires:
- name: epmbp-consumer-app-db-hdi-container
- name: epmbp-consumer-app-srv
type: nodejs
path: gen/srv
build-parameters:
ignore: ["node_modules/"]
parameters:
memory: 256M
disk-quota: 1024M
provides:
- name: srv_api
properties:
url: ${default-url}
requires:
- name: epmbp-consumer-app-db-hdi-container
- name: epmbp-consumer-app-uaa
- name: es5destination
group: destinations
properties:
name: ES5
url: ~{url}

- name: epmbp-consumer-app-app
type: nodejs
path: app
build-parameters:
ignore: ["node_modules/"]
parameters:
memory: 256M
disk-quota: 1024M
requires:
- name: epmbp-consumer-app-uaa
- name: srv_api
group: destinations
properties:
forwardAuthToken: true
strictSSL: false
name: srv_api
url: ~{url}
- name: es5destination
group: destinations
properties:
name: ES5
url: ~{url}

resources:
- name: epmbp-consumer-app-db-hdi-container
type: com.sap.xs.hdi-container
parameters:
service-plan: hdi-shared
properties:
hdi-container-name: ${service-name}
- name: epmbp-consumer-app-uaa
type: com.sap.xs.uaa
parameters:
path: ./xs-security.json
service-plan: space
- name: es5destination
type: org.cloudfoundry.user-provided-service
properties:
url: https://sapes5.sapdevcenter.com
name: ES5
parameters:
service: es5destination
path: ./default-es5destination.json
32 changes: 31 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
"start": "cds run",
"start:local": "npm run deploy:local && npm start",
"build": "cds build/all --clean",
"build:cf": "mbt build -p=cf",
"build:cf": "cp mta-cf.yaml mta.yaml && mbt build -p=cf && rm mta.yaml",
"build:xsa": "cp mta-xsa.yaml mta.yaml && mbt build -p=xsa && rm mta.yaml",
"build:xs-security": "cds compile srv/ --to xsuaa > xs-security.json",
"generate-odata-client": "generate-odata-client --inputDir srv/external --outputDir srv/odata-client --forceOverwrite",
"deploy:local": "cds deploy",
"deploy:cf": "cf deploy mta_archives/epmbp-consumer-app_0.0.1.mtar -e cf.mtaext",
"deploy:xsa": "xs deploy mta_archives/epmbp-consumer-app_0.0.1.mtar",
"debug:cf": "cf ssh epmbp-consumer-app-srv -N -T -L 9229:127.0.0.1:9229",
"undeploy:cf": "cf undeploy epmbp-consumer-app --delete-services --delete-service-brokers"
},
Expand Down Expand Up @@ -56,6 +58,34 @@
"min": 1,
"max": 10
}
},
"ZPDCDS_SRV": {
"kind": "odata",
"model": "srv/external/ZPDCDS_SRV",
"credentials": {
"destination": "ES5",
"path": "/sap/opu/odata/sap/ZPDCDS_SRV",
"requestTimeout": 30000
}
}
},
"[production]": {
"requires": {
"uaa": {
"kind": "xsuaa"
},
"db": {
"kind": "hana",
"model": [
"db",
"srv"
]
}
},
"auth": {
"passport": {
"strategy": "JWT"
}
}
}
}
Expand Down
Loading

0 comments on commit db35894

Please sign in to comment.