-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from VOLTTRON/develop
Merge develop to main for release of 1.3
- Loading branch information
Showing
19 changed files
with
217 additions
and
88 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This directory includes a mix of utility scripts, example ansible playbooks, and a complete set of configuration files for using vagrant to provision VMs and then use the tooling of this repo to deploy volttron onto those VMs. | ||
The scripts and components here are meant as a starting point and/or example to demonstrate how the system can be used; they have not been developed, tested, or evaluated to a standard that would make them suitable for all uses. | ||
Community members are encouraged to understand and modify them to meet their specific needs, and/or reach out to the core development team for assistance if needed. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/bin/bash | ||
|
||
doc_string=" | ||
A script which parses a configuration store file from a VOLTTRON platform into a | ||
directory structure suitable for use in the ansible-based recipe system. For | ||
each configuration store entry, the key is parsed as a path and the full | ||
directory structure generated. In the event that a key is an exact subset of | ||
another key (i.e. some path would need to be both a file and a directory), a | ||
directory is created with '.d' appended to the name, with the file keeping the | ||
original name. The recipes system will ignore the '.d' ending of any directory | ||
name when parsing the paths back into keys. | ||
Options: | ||
-cs (--configuration-store) is the full path to the configuration store file | ||
-o (--output-dir) is the directory within which the configuration store | ||
output files will be placed (this directory can be passed | ||
to an agent's spec in the recipe system; when doing so it is | ||
not included as part of the generated keys). | ||
" | ||
|
||
if ! [ -x "$(command -v jq)" ]; then | ||
echo "this script requires the jq command line tool; please install (https://stedolan.github.io/jq/download/)" >&2 | ||
exit 1 | ||
fi | ||
|
||
config_store_path="" | ||
output_dir_path="" | ||
## parse arguments | ||
while (( "$#" )); do | ||
case "$1" in | ||
-h|--help) | ||
printf "${doc_string}" | ||
exit 0 | ||
;; | ||
-cs|--configuration-store) | ||
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then | ||
config_store_path=$2 | ||
shift 2 | ||
else | ||
echo "Error: Argument for $1 is missing" >&2 | ||
exit 1 | ||
fi | ||
;; | ||
-o|--output-dir) | ||
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then | ||
output_dir_path=$2 | ||
shift 2 | ||
else | ||
echo "Error: Argument for $1 is missing" >&2 | ||
exit 1 | ||
fi | ||
;; | ||
*) | ||
echo "unrecognized argument '$1'" >&2 | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
## validate arguments and compute vars | ||
if [ -z "$config_store_path" ]; then | ||
echo "path to configuration store (-cs PATH_TO_FILE or --configuration-store PATH_TO_FILE) is required)." >&2 | ||
exit 1 | ||
fi | ||
if [ -z "$output_dir_path" ]; then | ||
echo "path to output directory (-o PAT or --output-dir PATH) is required)." >&2 | ||
exit 1 | ||
fi | ||
if [[ ! $config_store_path == *\.store ]]; then | ||
## Note: could probably expand logic here to support other patterns, left as an exercise to whoever needs that | ||
echo "the input config store must end in '.store'" | ||
exit 1 | ||
fi | ||
mkdir -p $output_dir_path | ||
|
||
## do the parsing | ||
cat $config_store_path | jq -c 'keys[]' | while read an_entry; do | ||
echo "entry is ${an_entry}" | ||
this_out_dir=${output_dir_path}/$(dirname $(echo $an_entry|tr -d '"')) | ||
this_out_file=$(basename $(echo $an_entry|tr -d '"')) | ||
if [ -f $this_out_dir ]; then | ||
this_out_dir=${this_out_dir}.d | ||
fi | ||
mkdir -p ${this_out_dir} | ||
echo "-> put output in [${this_out_dir}]/[${this_out_file}]" | ||
cat $config_store_path | jq -r ".[$an_entry].data" | cat > ${this_out_dir}/${this_out_file} | ||
done |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
- name: configure agents | ||
hosts: all | ||
|
||
tasks: | ||
|
||
- name: Limit to single inventory host | ||
fail: | ||
msg: "update-agent is only allowed to update a single host, select one of {{ ansible_play_hosts_all }} with `-l HOST`" | ||
when: (ansible_play_hosts | length) != 1 | ||
delegate_to: localhost | ||
run_once: true | ||
|
||
- include_role: | ||
name: volttron.deployment.set_defaults | ||
- name: confirm agent_identity was provided and is valid | ||
fail: | ||
msg: "agent_identity provided '{{ agent_identity | default('') }}' is not one of {{ identities }}; configure with `-e agent_identity=AGENT_IDENTITY` " | ||
when: (agent_identity | default("")) not in identities | ||
vars: | ||
identities: "{{ host_configuration['agents'].keys() | default([]) }}" | ||
|
||
- debug: | ||
msg: | ||
- "item is: {{ item }}" | ||
vars: | ||
- item: "{{ host_configuration['agents'][agent_identity] | combine({'force_install': True}, recursive=true) }}" | ||
|
||
- include_role: | ||
name: volttron.deployment.ansible_venv | ||
- include_role: | ||
name: volttron.deployment.copy_agent_configs | ||
|
||
- name: update agent | ||
volttron.deployment.volttron_agent: | ||
volttron_root: "{{ volttron_root }}" | ||
volttron_home: "{{ volttron_home }}" | ||
volttron_venv: "{{ volttron_venv }}" | ||
agent_vip_id: "{{ agent_identity }}" | ||
agent_spec: "{{ this_spec }}" | ||
agent_configs_dir: "{{ host_configs_dir }}" | ||
vars: | ||
- this_spec: "{{ host_configuration['agents'][agent_identity] | combine({'force_install': True}, recursive=true) }}" |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,10 @@ | ||
### download volttron source from github and place at volttron_root | ||
### registers `volttron_source_changed` fact (based on hash of tarball) | ||
--- | ||
- name: "Download volttron repository tarball [{{ source_url }}]" | ||
get_url: | ||
url: "{{ source_url }}" | ||
dest: "/tmp/volttron-{{ volttron_git_branch | regex_replace('/', '.') }}.tar.gz" | ||
force: yes | ||
use_proxy: yes | ||
vars: | ||
source_url: "https://github.com/{{ volttron_git_organization }}/{{ volttron_git_repo }}/archive/{{ volttron_git_branch }}.tar.gz" | ||
- name: Clone git repo for volttron root | ||
ansible.builtin.git: | ||
repo: https://github.com/volttron/volttron | ||
dest: "{{ volttron_root }}" | ||
version: "{{ volttron_git_branch }}" | ||
force: "{{ volttron_git_force_clone }}" | ||
environment: | ||
http_proxy: "{{ http_proxy }}" | ||
https_proxy: "{{ https_proxy }}" | ||
|
||
- name: Stat volttron dir | ||
stat: | ||
path: "{{ volttron_root }}" | ||
register: volttron_path_stat | ||
|
||
- name: Stat tar file | ||
stat: | ||
path: "/tmp/volttron-{{ volttron_git_branch | regex_replace('/', '.') }}.tar.gz" | ||
get_checksum: yes | ||
register: new_tar_stat | ||
|
||
- name: Stat old tar | ||
stat: | ||
path: "{{ ansible_env.HOME }}/volttron-source.tar.gz" | ||
get_checksum: yes | ||
register: old_tar_stat | ||
|
||
- name: Check if volttron source is updated | ||
set_fact: | ||
volttron_source_changed: "{{ (not volttron_path_stat.stat.exists or not old_tar_stat.stat.exists or (new_tar_stat.stat.checksum != old_tar_stat.stat.checksum)) }}" | ||
|
||
- name: "[re]establish volttron source directory" | ||
when: volttron_source_changed | ||
block: | ||
- name: Move new file | ||
command: mv "/tmp/volttron-{{ volttron_git_branch | regex_replace('/', '.') }}.tar.gz" "{{ ansible_env.HOME }}/volttron-source.tar.gz" | ||
|
||
- name: Remove volttron source root dir if exists | ||
file: | ||
path: "{{ volttron_root }}" | ||
state: absent | ||
|
||
- name: Create a path to unarchive into | ||
file: | ||
path: "/tmp/volttron_source" | ||
state: absent | ||
- name: Create a path to unarchive into | ||
file: | ||
path: "/tmp/volttron_source" | ||
state: directory | ||
- name: Extract source archive | ||
unarchive: | ||
src: "{{ ansible_env.HOME }}/volttron-source.tar.gz" | ||
dest: "/tmp/volttron_source" | ||
remote_src: yes | ||
|
||
- name: Place source tree at volttron root | ||
command: mv "/tmp/volttron_source/{{volttron_git_repo}}-{{ volttron_git_branch | regex_replace('/', '-') }}" "{{ volttron_root }}" | ||
- name: Cleanup unarchive artifacts | ||
file: | ||
path: "/tmp/volttron_source" | ||
state: absent | ||
## end of block to update volttron source |
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
Oops, something went wrong.