Created
May 5, 2017 01:54
-
-
Save michaeldye/434a8d879dc953fb7963781f2f43d880 to your computer and use it in GitHub Desktop.
reg_synchro-staging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USER=<exch_user> | |
PASS=<exch_password> | |
EMAIL=<exch_email> | |
DEVICE_ID=<device_id> | |
PARTNER_ID=<ha_partner_device_id> | |
TOKEN=<exchange_token_to-set> | |
ANAX_API="http://localhost" | |
curl -vLX PUT --header 'Content-Type: application/json' --header 'Accept: application/json' -H "Authorization:Basic $USER:$PASS" -d '{"token":"'$TOKEN'","name":"'$DEVICE_ID'","registeredMicroservices":[],"msgEndPoint":"","softwareVersions":{}}' 'https://exchange.staging.bluehorizon.network/v1/devices/'$DEVICE_ID | jq -r '.' | |
read -d '' newhzndevice <<EOF | |
{ | |
"account": { | |
"id": "$USER", | |
"email": "$EMAIL" | |
}, | |
"id": "$DEVICE_ID", | |
"name": "$DEVICE_ID", | |
"token": "$TOKEN", | |
"ha_device": true | |
} | |
EOF | |
echo -e " | |
[D] hzndevice payload: $newhzndevice" | |
echo "Updating horizon with out device id and token" | |
echo "$newhzndevice" | curl -vS -X POST -H "Content-Type: application/json" --data @- "$ANAX_API/horizondevice" | |
#### | |
read -d '' locationattribute <<EOF | |
{ | |
"id": "location", | |
"short_type": "location", | |
"label": "Registered Location Facts", | |
"publishable": false, | |
"mappings": { | |
"lat": "<lat>", | |
"lon": "<lon>", | |
"user_provided_coords": true, | |
"use_gps": false | |
} | |
} | |
EOF | |
echo -e " | |
[D] location payload: $locationattribute" | |
echo "Setting workload independent location attributes" | |
echo "$locationattribute" | curl -vS -X POST -H "Content-Type: application/json" --data @- "$ANAX_API/service/attribute" | |
#### | |
read -d '' synchroservice <<EOF | |
{ | |
"sensor_url": "https://bluehorizon.network/documentation/synchrophasor-device-api", | |
"sensor_name": "synchrophasor", | |
"attributes": [ | |
{ | |
"id": "compute", | |
"short_type": "compute", | |
"label": "Compute Resources", | |
"publishable": true, | |
"mappings": { | |
"ram": 128, | |
"cpus": 1 | |
} | |
}, | |
{ | |
"id": "ha", | |
"short_type": "ha", | |
"label": "HA Partner", | |
"publishable": true, | |
"mappings": { | |
"partnerID": ["$PARTNER_ID"] | |
} | |
} | |
] | |
} | |
EOF | |
echo -e " | |
[D] synchroservice payload: $synchroservice" | |
echo "Registering synchrophasor service" | |
echo "$synchroservice" | curl -vS -X POST -H "Content-Type: application/json" --data @- "$ANAX_API/service" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment