<commit_before>[![Build Status](https://travis-ci.org/Mirantis/solar.svg?branch=master)](https://travis-ci.org/Mirantis/solar) [![Coverage Status](https://coveralls.io/repos/Mirantis/solar/badge.svg?branch=master&service=github)](https://coveralls.io/github/Mirantis/solar?branch=master)

# Requirements

## Supported development platforms

Linux or MacOS

## Additional software

[VirtualBox](https://www.virtualbox.org/wiki/Downloads): 5.x

[Vagrant](http://www.vagrantup.com/downloads.html): 1.7.x

Note: Make sure that [Vagrant VirtualBox Guest plugin](https://github.com/dotless-de/vagrant-vbguest) is installed `vagrant plugin install vagrant-vbguest`

Note: If you are using VirtualBox 5.0 it's worth uncommenting paravirtprovider setting in `vagrant-settings.yaml` for speed improvements:
```bash
paravirtprovider: kvm
```

For details see Customizing `vagrant-settings.yaml` section.

# Setup development env

Setup environment:
```bash
cd solar
vagrant up
```

Login into vm, the code is available in /vagrant directory
```bash
vagrant ssh
solar --help
```


Get ssh details for running slave nodes (vagrant/vagrant):
```bash
vagrant ssh-config
```

You can make/restore snapshots of boxes (this is way faster than reprovisioning them)
with the `snapshotter.py` script:

```bash
./snapshotter.py take -n my-snapshot
./snapshotter.py show
./snapshotter.py restore -n my-snapshot
```
`snapshoter.py` to run requires python module `click`. On debian based systems you can install it via `sudo apt-get install python-click-cli`

# Solar usage

For now  all commands should be executed from `solar-dev` machine from `/vagrant` directory.

Basic flow is:

1. Create some resources (look at `examples/openstack/openstack.py`) and connect
   them between each other, and place them on nodes.
1. Run `solar changes stage` (this stages the changes)
1. Run `solar changes process` (this prepares orchestrator graph, returning
   change UUID)
1. Run `solar orch run-once <change-uuid>` (or `solar orch run-once last`
   to run the lastly created graph)
1. Observe progress of orch with `watch 'solar orch report <change-uuid>'`
   (or `watch 'solar orch report last'`).

Some very simple cluster setup:
```bash
cd /vagrant

solar resource create nodes templates/nodes.yaml '{"count": 2}'
solar resource create mariadb_service resources/mariadb_service '{"image": "mariadb", "root_password": "<PASSWORD>", "port": 3306}'
solar resource create keystone_db resources/mariadb_db/ '{"db_name": "keystone_db", "login_user": "root"}'
solar resource create keystone_db_user resources/mariadb_user/ user_name=keystone user_password=<PASSWORD>  # another valid format

solar connect node1 mariadb_service
solar connect node1 keystone_db
solar connect mariadb_service keystone_db '{"root_password": "<PASSWORD>", "port": "login_port", "ip": "db_host"}'
# solar connect mariadb_service keystone_db_user 'root_password->login_password port->login_port'  # another valid format
solar connect keystone_db keystone_db_user

solar changes stage
solar changes process
# <uid>
solar orch run-once <uid> # or solar orch run-once last
watch 'solar orch report <uid>' # or solar orch report last
```

You can fiddle with the above configuration like this:
```bash
solar resource update keystone_db_user '{"user_password": "<PASSWORD>"}'
solar resource update keystone_db_user user_password=<PASSWORD>   # another valid format

solar changes stage
solar changes process
<uid>
solar orch run-once <uid>
```

To get data for the resource `bar` (raw and pretty-JSON):
```bash
solar resource show --tag 'resources/bar'
solar resource show --json --tag 'resources/bar' | jq .
solar resource show --name 'resource_name'
solar resource show --name 'resource_name' --json | jq .
```

To clear all resources/connections:
```bash
solar resource clear_all
solar connections clear_all
```

Show the connections/graph:
```bash
solar connections show
solar connections graph
```

You can also limit graph to show only specific resources:

```bash
solar connections graph --start-with mariadb_service --end-with keystone_db
```

You can make sure that all input values are correct and mapped without duplicating your values with this command:
```bash
solar resource validate
```

Disconnect
```bash
solar disconnect mariadb_service node1
```

Tag a resource:
```bash
solar resource tag node1 test-tags # Remove tags
solar resource tag node1 test-tag --delete
```

# Low level API<commit_msg>Command `connections clear_all` does not exists any more<commit_after>[![Build Status](https://travis-ci.org/Mirantis/solar.svg?branch=master)](https://travis-ci.org/Mirantis/solar) [![Coverage Status](https://coveralls.io/repos/Mirantis/solar/badge.svg?branch=master&service=github)](https://coveralls.io/github/Mirantis/solar?branch=master)

# Requirements

## Supported development platforms

Linux or MacOS

## Additional software

[VirtualBox](https://www.virtualbox.org/wiki/Downloads): 5.x

[Vagrant](http://www.vagrantup.com/downloads.html): 1.7.x

Note: Make sure that [Vagrant VirtualBox Guest plugin](https://github.com/dotless-de/vagrant-vbguest) is installed `vagrant plugin install vagrant-vbguest`

Note: If you are using VirtualBox 5.0 it's worth uncommenting paravirtprovider setting in `vagrant-settings.yaml` for speed improvements:
```bash
paravirtprovider: kvm
```

For details see Customizing `vagrant-settings.yaml` section.

# Setup development env

Setup environment:
```bash
cd solar
vagrant up
```

Login into vm, the code is available in /vagrant directory
```bash
vagrant ssh
solar --help
```


Get ssh details for running slave nodes (vagrant/vagrant):
```bash
vagrant ssh-config
```

You can make/restore snapshots of boxes (this is way faster than reprovisioning them)
with the `snapshotter.py` script:

```bash
./snapshotter.py take -n my-snapshot
./snapshotter.py show
./snapshotter.py restore -n my-snapshot
```
`snapshoter.py` to run requires python module `click`. On debian based systems you can install it via `sudo apt-get install python-click-cli`

# Solar usage

For now  all commands should be executed from `solar-dev` machine from `/vagrant` directory.

Basic flow is:

1. Create some resources (look at `examples/openstack/openstack.py`) and connect
   them between each other, and place them on nodes.
1. Run `solar changes stage` (this stages the changes)
1. Run `solar changes process` (this prepares orchestrator graph, returning
   change UUID)
1. Run `solar orch run-once <change-uuid>` (or `solar orch run-once last`
   to run the lastly created graph)
1. Observe progress of orch with `watch 'solar orch report <change-uuid>'`
   (or `watch 'solar orch report last'`).

Some very simple cluster setup:
```bash
cd /vagrant

solar resource create nodes templates/nodes.yaml '{"count": 2}'
solar resource create mariadb_service resources/mariadb_service '{"image": "mariadb", "root_password": "<PASSWORD>", "port": 3306}'
solar resource create keystone_db resources/mariadb_db/ '{"db_name": "keystone_db", "login_user": "root"}'
solar resource create keystone_db_user resources/mariadb_user/ user_name=keystone user_password=<PASSWORD>  # another valid format

solar connect node1 mariadb_service
solar connect node1 keystone_db
solar connect mariadb_service keystone_db '{"root_password": "<PASSWORD>", "port": "login_port", "ip": "db_host"}'
# solar connect mariadb_service keystone_db_user 'root_password->login_password port->login_port'  # another valid format
solar connect keystone_db keystone_db_user

solar changes stage
solar changes process
# <uid>
solar orch run-once <uid> # or solar orch run-once last
watch 'solar orch report <uid>' # or solar orch report last
```

You can fiddle with the above configuration like this:
```bash
solar resource update keystone_db_user '{"user_password": "<PASSWORD>"}'
solar resource update keystone_db_user user_password=<PASSWORD>   # another valid format

solar changes stage
solar changes process
<uid>
solar orch run-once <uid>
```

To get data for the resource `bar` (raw and pretty-JSON):
```bash
solar resource show --tag 'resources/bar'
solar resource show --json --tag 'resources/bar' | jq .
solar resource show --name 'resource_name'
solar resource show --name 'resource_name' --json | jq .
```

To clear all resources/connections:
```bash
solar resource clear_all
```

Show the connections/graph:
```bash
solar connections show
solar connections graph
```

You can also limit graph to show only specific resources:

```bash
solar connections graph --start-with mariadb_service --end-with keystone_db
```

You can make sure that all input values are correct and mapped without duplicating your values with this command:
```bash
solar resource validate
```

Disconnect
```bash
solar disconnect mariadb_service node1
```

Tag a resource:
```bash
solar resource tag node1 test-tags # Remove tags
solar resource tag node1 test-tag --delete
```

# Low level API
{'fraction_non_alphanumeric': 0.10743523606594146, 'fraction_numerical': 0.00448581361444432, 'mean_word_length': 5.214634146341464, 'pattern_counts': {'":': 20, '<': 27, '<?xml version=': 0, '>': 31, 'https://': 12, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7069765', 'n_tokens_mistral': 2904, 'n_tokens_neox': 2752, 'n_words': 987}