Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions pyvolt-dpsim-demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ Ensure that the following Helm Chart Repos are set up or add them locally:

```bash
helm repo add sogno https://sogno-platform.github.io/helm-charts

helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo add influxdata https://influxdata.github.io/helm-charts
helm repo add grafana https://grafana.github.io/helm-charts
helm repo update
```
### HugePages

The current setup requires HugePages support for the real-time simulator. This can be checked and activated (temporarily) as follows:
The current setup requires HugePages support for the real-time simulator. But if you want a keycloak sso service, do not do this. This can be checked and activated (temporarily) as follows:

```bash
# Verify HugePages
Expand All @@ -34,7 +33,7 @@ cat /proc/meminfo | grep Huge
AnonHugePages: 104448 kB
ShmemHugePages: 0 kB
FileHugePages: 0 kB
HugePages_Total: 0 <-- we require a minimum of 1024
HugePages_Total: 0 <-- we require a minimum of 1024
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Expand Down Expand Up @@ -87,16 +86,29 @@ helm install influxdb influxdata/influxdb -f database/influxdb-helm-values.yaml
helm install telegraf influxdata/telegraf -f ts-adapter/telegraf-values.yaml
```

### KeyCloak:

The following installation will deploy a KeyCloak instance that is available at the nodePort specified in the keycloak_values.yaml file. The username and password both are "user" for the admin panel.
Per default at port 31250: http://localhost:31250

```bash
helm install my-release -f keycloak/keycloak_values.yaml bitnami/keycloak
```
Please wait for 3 minutes for the keycloak to deploy properly. To create keycloak realm, client and user run the python script keycloak_createion.py.

```bash
python3 keycloak/keycloak_creation.py
```
### Visualization

The following installation will deploy a Grafana instance that is available at the nodePort specified in the grafana_values.yaml file.
Per defautl at port 31230: http://localhost:31230
The following installation will deploy a Grafana instance that is available at the nodePort specified in the grafana_values.yaml file.
Per default at port 31230: http://localhost:31230

```bash
helm install grafana grafana/grafana -f visualization/grafana_values.yaml
kubectl apply -f visualization/dashboard-configmap.yaml
```
The configmap contains a demo dashboard and should automatically be recognized by the grafana instance. Username and password for Grafana are set to "demo".
The configmap contains a demo dashboard and should automatically be recognized by the grafana instance. The username and password for Grafana are set to "demo".It's also the same in the case of login with oauth.

### CIM Editor Pintura

Expand All @@ -109,7 +121,7 @@ helm install pintura sogno/pintura -f cim-editor/pintura_values.yaml
### DPsim Simulation

```bash
helm install dpsim-demo sogno/dpsim-demo
helm install dpsim -demo sogno/dpsim-demo
```

### State-Estimation
Expand Down
9 changes: 8 additions & 1 deletion pyvolt-dpsim-demo/demo-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ helm install influxdb influxdata/influxdb -f database/influxdb-helm-values.yaml

helm install telegraf influxdata/telegraf -f ts-adapter/telegraf-values.yaml

helm install my-release -f keycloak/keycloak_values.yaml bitnami/keycloak

sleep 5m

python3 keycloak/keycloak_creation.py

helm install grafana grafana/grafana -f visualization/grafana_values.yaml

kubectl apply -f visualization/dashboard-configmap.yaml

helm install pintura sogno/pintura -f cim-editor/pintura_values.yaml
Expand All @@ -15,4 +22,4 @@ helm install dpsim-demo sogno/dpsim-demo

helm install pyvolt-demo sogno/pyvolt-service -f state-estimation/se_values.yaml

kubectl get pods
kubectl get pods
5 changes: 5 additions & 0 deletions pyvolt-dpsim-demo/demo-teardown.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ helm uninstall influxdb
helm uninstall telegraf

helm uninstall grafana

kubectl delete -f visualization/dashboard-configmap.yaml

helm uninstall pintura

helm uninstall dpsim-demo

helm uninstall pyvolt-demo

helm uninstall my-release

kubectl delete pvc data-my-release-postgresql-0
152 changes: 152 additions & 0 deletions pyvolt-dpsim-demo/keycloak/keycloak_creation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
from json.tool import main
from re import X
import string
import requests
import ast
import json

def get_token():

lurl = 'http://localhost:31250/auth/realms/master/protocol/openid-connect/token'

params = {

'client_id': 'admin-cli',
'grant_type': 'password',
'username' : 'user',
'password': 'user'
}
x = requests.post(lurl, params, verify=False).content.decode('utf-8')
return ast.literal_eval(x)['access_token']

def create_realm():
url = "http://localhost:31250/auth/admin/realms"

payload = json.dumps({
"id": "grafana",
"realm": "grafana",
"enabled": True
})
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + str(get_token())
}

response = requests.request("POST", url, headers=headers, data=payload)

print('Realm created')

def create_client():
url = "http://localhost:31250/auth/admin/realms/grafana/clients"

payload = json.dumps({
"clientId": "grafana",
"name": "grafana",
"adminUrl": "http://localhost:31230",
"alwaysDisplayInConsole": False,
"secret": "Z6RT9ViirQTPgV9AQqoZwGm38XHyUROY",

"access": {
"view": True,
"configure": True,
"manage": True
},
"attributes": {},
"authenticationFlowBindingOverrides": {},
"authorizationServicesEnabled": True,
"bearerOnly": False,
"directAccessGrantsEnabled": True,
"enabled": True,
"protocol": "openid-connect",
"description": "grafana",
"rootUrl": "http://localhost:31230",
"surrogateAuthRequired": False,
"clientAuthenticatorType": "client-secret",
"defaultRoles": [
"manage-account",
"view-profile"
],
"redirectUris": [
"http://localhost:31230/*",
"http://localhost:31230/login/generic_oauth"
],
"webOrigins": [],
"notBefore": 0,
"consentRequired": False,
"standardFlowEnabled": True,
"implicitFlowEnabled": False,
"serviceAccountsEnabled": True,
"publicClient": False,
"frontchannelLogout": False,
"fullScopeAllowed": False,
"nodeReRegistrationTimeout": 0,
"defaultClientScopes": [
"web-origins",
"role_list",
"profile",
"roles",
"email"
],
"optionalClientScopes": [
"address",
"phone",
"offline_access",
"microprofile-jwt"
]
})
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + str(get_token())
}

response = requests.request("POST", url, headers=headers, data=payload)

print('client created')


def create_user():
url = "http://localhost:31250/auth/admin/realms/grafana/users"

payload = json.dumps({
"createdTimestamp": 1588880747548,
"username": "demo",
"enabled": True,
"totp": False,
"emailVerified": True,
"firstName": "user",
"lastName": "grafana",
"email": "user_grafana@grafana.com",
"disableableCredentialTypes": [],
"requiredActions": [],
"notBefore": 0,
"access": {
"manageGroupMembership": True,
"view": True,
"mapRoles": True,
"impersonate": True,
"manage": True
},
"credentials": [{
"type":"password",
"value":"demo",
"temporary":False,
}],
"realmRoles": [
"mb-user"
]
})
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + str(get_token())
}

response = requests.request("POST", url, headers=headers, data=payload)

print('user created')

def function():
create_realm()
create_client()
create_user()

function()
Loading