Skip to content

Commit

Permalink
Release 1.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
predix-adoption-bot committed Mar 23, 2019
1 parent 7ed2013 commit 1ed119b
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LABEL maintainer="Predix Edge Adoption"
LABEL hub="https://hub.docker.com"
LABEL org="https://hub.docker.com/u/predixedge"
LABEL repo="predix-edge-sample-scaler-python"
LABEL version="1.0.5"
LABEL version="1.0.6"
LABEL support="https://forum.predix.io"
LABEL license="https://github.com/PredixDev/predix-docker-samples/blob/master/LICENSE.md"

Expand Down
42 changes: 35 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ The manual steps for Edge are in the Manual Set Up section below. (The cloud ma

For DevBox, Mac and Linux

For DevBox install the yq tool

```bash
sudo pip install yq
```

If you have a Predix Cloud account with an org/space:

```bash
Expand All @@ -181,9 +187,16 @@ To get started developing locally you will need to pull the core Predix Edge Doc

Install the Predix Edge Broker

Using a browser, log in to https://artifactory.predix.io using your predix username and password. GE users will use the SSO feature to login, use your SSO where it says your-predix-account below.
Check the version of the Broker in the docker-compose-edge-broker.yml

```bash
cat docker-compose-edge-broker.yml
```

Using a browser, log in to https://artifactory.predix.io using your predix username and password. GE users will use the SSO feature to login, use your SSO where it says your-predix-account below.

Click the `Artifacts` icon and navigate to the `predix-ext/predix-edge/<edgeos-version-here>/os` folder and `Download` the `edge-broker` container version that matches the docker-compose-edge-broker.yml.

Click the `Artifacts` icon and navigate to the predix-ext/predix-edge/<latest-version-here>/os folder and Download the `edge-broker` container.
**Changing the** command to use the **version** you downloaded, using a tool on your computer, untar it, e.g.

```bash
Expand All @@ -203,11 +216,18 @@ docker load -i *.tar
```

Now repeat the steps for the OPCUA Adapter and Cloud Gateway

Check the version of the OPCUA Adapter and Cloud Gateway in the docker-compose-local.yml

```bash
predix-ext/predix-edge/<latest-version-here>/apps/adapters/<latest-opcua-adapter-here>
cat docker-compose-edge-local.yml
```

```bash
predix-ext/predix-edge/<latest-version-here>/apps/gateway/<latest-cloud-gateway-here>
predix-ext/predix-edge/<edgeos-version-here>/apps/adapters/<opcua-adapter-version-here>
```
```bash
predix-ext/predix-edge/<edgeos-version-here>/apps/gateway/<cloud-gateway-version-here>
```

Finally, create a [Docker Swarm](https://docs.docker.com/engine/swarm/) on your machine. You only need to do this once on your machine. If you have done so in the past you can disregard this step.
Expand Down Expand Up @@ -367,7 +387,15 @@ This file is used by the Cloud Gateway service and contains properties indicatin

### Step 6. Run the App and Validate the Results

#### Step 1: Get Access Token
#### Step 1: Make data Dir Writeable

First let's make the data dir writeable. This is needed when running the app because the username inside the container does not match your username.

```bash
chmod 777 ./data
```

#### Step 2: Get Access Token

The result of this app is to publish a scaled value to Predix Cloud Time Series. In order to do so, the app requires a UAA token with permissions to ingest data. On a Predix Edge device, apps obtain this token from the device once it is enrolled to Edge Manager.

Expand All @@ -376,10 +404,10 @@ During development, though, you must generate a token to be used by the app. To
The script takes three input parameters:
- `my-client-id` - the client id for your instance of UAA: it must have permissions to ingest data into your Time Series instance
- `my-secret` - the client secret for that client id
- `my-uaa-url` - must be the full URL including the /oauth/token ending
- `my-uaa-issuerid-url` - must be the full URL including the /oauth/token ending

```bash
./scripts/get-access-token.sh my-client-id my-secret my-uaa-url
./scripts/get-access-token.sh my-client-id my-secret my-uaa-issuerid-url
```

After you run the script, a file named *access_token* will be created in the data folder of the app. The app is configured to use this file to obatin the token for transmitting data to the cloud.
Expand Down
2 changes: 1 addition & 1 deletion config/config-cloud-gateway.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"timeseries": {
"transport_addr": "wss://gateway-predix-data-services.run.aws-usw02-pr.ice.predix.io/v1/stream/messages",
"predix_zone_id": "your-predix-zone-id"
"predix_zone_id": "your-predix-zone-id",
"token_file": "/edge-agent/access_token",
"proxy_url": "$https_proxy"
}
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ services:
- predix-edge-broker_net

edge-app:
image: "predixedge/predix-edge-sample-scaler-python:1.0.5"
image: "predixedge/predix-edge-sample-scaler-python:1.0.6"
environment:
- PYTHONUNBUFFERED=0 # To shows print statements in docker logs
- BROKER=predix-edge-broker
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ services:
networks:
- predix-edge-broker_net
edge-app:
image: "predixedge/predix-edge-sample-scaler-python:1.0.5"
image: "predixedge/predix-edge-sample-scaler-python:1.0.6"
environment:
- PYTHONUNBUFFERED=0 # To shows print statements in docker logs
- BROKER=predix-edge-broker
Expand Down
28 changes: 21 additions & 7 deletions scripts/get-access-token.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# get command line paramaters

set -e

CLIENT_ID=$1
SECRET=$2
UAA_URL=$3

echo "usage: createAccessTokenFile <clientId> <secret> <uaa-issuerid-url>"

# base64 encide the client and secret
AUTH='Authorization: Basic '$(echo -n $CLIENT_ID:$SECRET | base64)
Expand All @@ -11,10 +15,20 @@ AUTH='Authorization: Basic '$(echo -n $CLIENT_ID:$SECRET | base64)
RESULT=$(curl -X POST $UAA_URL -H "$AUTH" -H 'Content-Type: application/x-www-form-urlencoded' -d grant_type=client_credentials)

# parse out the access token from the result - this requires jq to be installed on your machine (brew install jq)
ACCESS_TOKEN=$( echo "$RESULT" | jq -r '.["access_token"]' )

# copy the access token to the access_token file in the data folder of your app - where the Cloud Gateway container will look for it
mkdir -p data
printf "%s" "$ACCESS_TOKEN" > ./data/access_token

echo 'token refreshed'
if [[ $( echo "$RESULT" | jq 'has("access_token")') == true ]]; then
ACCESS_TOKEN=$( echo "$RESULT" | jq -r '.["access_token"]' )
# copy the access token to the access_token file in the data folder of your app - where the Cloud Gateway container will look for it
mkdir -p ./data
printf "%s" "$ACCESS_TOKEN" > ./data/access_token
chmod -R 777 data
echo 'token refreshed'
else
echo "Coult not fetch token : $RESULT"
echo "Please check if the paramters passed are correct"
echo "$CLIENT_ID $SECRET $UAA_URL"
echo "CURL COMAND : curl -X POST $UAA_URL -H "$AUTH" -H 'Content-Type: application/x-www-form-urlencoded' -d grant_type=client_credentials"
mkdir -p ./data
printf "%s" "" > ./data/access_token
chmod -R 777 data
exit 1
fi
4 changes: 0 additions & 4 deletions scripts/quickstart-edge-starter-sample-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ function init() {
echo 'Please launch the script from the root dir of the project'
exit 1
fi
if [[ ! $currentDir == *"$REPO_NAME" ]]; then
mkdir -p $APP_DIR
cd $APP_DIR
fi

check_internet

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

setup(
name='predix-edge-sample-scaler-python',
version='1.0.5',
version='1.0.6',
description='Predix Edge Sample Python App',
long_description=long_description,
install_requires=install_requires,
Expand Down
8 changes: 4 additions & 4 deletions version.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "Predix Edge Sample Scaler Python",
"version": "1.0.5",
"version": "1.0.6",
"private": true,
"dependencies": {
"local-setup": "https://github.com/PredixDev/local-setup#1.0.106",
"predix-scripts": "https://github.com/PredixDev/predix-scripts#1.1.242",
"local-setup": "https://github.com/PredixDev/local-setup#1.0.107",
"predix-scripts": "https://github.com/PredixDev/predix-scripts#1.1.246",
"predix-webapp-starter": "https://github.com/PredixDev/predix-webapp-starter.git#2.0.92",
"predix-edge-sample-scaler-python": "https://github.com/PredixDev/predix-edge-sample-scaler-python.git#1.0.5",
"predix-edge-sample-scaler-python": "https://github.com/PredixDev/predix-edge-sample-scaler-python.git#1.0.6",
"opcua": "https://artifactory.predix.io/artifactory/PREDIX-EXT/predix-edge/2_1_0/apps/adapters/predix-edge-opc-ua-adapter-amd64-20181002-1.1.0.tar.gz#",
"predix-edge-broker": "https://artifactory.predix.io/artifactory/PREDIX-EXT/predix-edge/2_1_0/os/predix-edge-broker-amd64-20180917-1.0.2.tar.gz#",
"cloud_gateway": "https://artifactory.predix.io/artifactory/PREDIX-EXT/predix-edge/2_1_0/apps/gateway/predix-edge-cloud-gateway-amd64-20181002-1.1.0.tar.gz#"
Expand Down

0 comments on commit 1ed119b

Please sign in to comment.