{"id":20661850,"url":"https://github.com/mirantis/solar","last_synced_at":"2025-04-19T15:49:25.023Z","repository":{"id":34440674,"uuid":"38374835","full_name":"Mirantis/solar","owner":"Mirantis","description":"This repo is OUTDATED!!! We moved to OpenStack","archived":false,"fork":false,"pushed_at":"2020-02-26T11:52:36.000Z","size":2815,"stargazers_count":8,"open_issues_count":11,"forks_count":16,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-04-15T22:58:25.836Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/openstack/solar","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mirantis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-01T14:12:04.000Z","updated_at":"2024-04-15T22:58:25.837Z","dependencies_parsed_at":"2022-08-24T14:23:47.633Z","dependency_job_id":null,"html_url":"https://github.com/Mirantis/solar","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mirantis%2Fsolar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mirantis%2Fsolar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mirantis%2Fsolar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mirantis%2Fsolar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mirantis","download_url":"https://codeload.github.com/Mirantis/solar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224958549,"owners_count":17398500,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T19:11:52.809Z","updated_at":"2024-11-16T19:11:53.468Z","avatar_url":"https://github.com/Mirantis.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![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\u0026service=github)](https://coveralls.io/github/Mirantis/solar?branch=master)\n\n# Requirements\n\n## Supported development platforms\n\nLinux or MacOS\n\n## Additional software\n\n[VirtualBox](https://www.virtualbox.org/wiki/Downloads): 5.x\n\n[Vagrant](http://www.vagrantup.com/downloads.html): 1.7.x\n\nNote: Make sure that [Vagrant VirtualBox Guest plugin](https://github.com/dotless-de/vagrant-vbguest) is installed `vagrant plugin install vagrant-vbguest`\n\nNote: If you are using VirtualBox 5.0 it's worth uncommenting paravirtprovider setting in `vagrant-settings.yaml` for speed improvements:\n```bash\nparavirtprovider: kvm\n```\n\nFor details see Customizing `vagrant-settings.yaml` section.\n\n# Setup development env\n\nSetup environment:\n```bash\ncd solar\nvagrant up\n```\n\nLogin into vm, the code is available in /vagrant directory\n```bash\nvagrant ssh\nsolar --help\n```\n\n\nGet ssh details for running slave nodes (vagrant/vagrant):\n```bash\nvagrant ssh-config\n```\n\nYou can make/restore snapshots of boxes (this is way faster than reprovisioning them)\nwith the `snapshotter.py` script:\n\n```bash\n./snapshotter.py take -n my-snapshot\n./snapshotter.py show\n./snapshotter.py restore -n my-snapshot\n```\n`snapshoter.py` to run requires python module `click`.\n\n1. On debian based systems you can install it via `sudo aptitude install python-click-cli`,\n2. On fedora 22 you can install it via `sudo dnf install python-click`,\n3. If you use virtualenv or similar tool then you can install it just with `pip install click`,\n4. If you don't have virtualenv and your operating system does not provide package for it then `sudo pip install click`.\n5. If you don't have `pip` then [install it](https://pip.pypa.io/en/stable/installing/) and then execute command step 4.\n\n# Solar usage\n\nFor now  all commands should be executed from `solar-dev` machine from `/vagrant` directory.\n\nBasic flow is:\n\n1. Create some resources (look at `examples/openstack/openstack.py`) and connect\n   them between each other, and place them on nodes.\n1. Run `solar changes stage` (this stages the changes)\n1. Run `solar changes process` (this prepares orchestrator graph, returning\n   change UUID)\n1. Run `solar orch run-once \u003cchange-uuid\u003e` (or `solar orch run-once last`\n   to run the lastly created graph)\n1. Observe progress of orch with `watch 'solar orch report \u003cchange-uuid\u003e'`\n   (or `watch 'solar orch report last'`).\n\nSome very simple cluster setup:\n```bash\ncd /vagrant\n\nsolar resource create nodes templates/nodes.yaml '{\"count\": 2}'\nsolar resource create mariadb_service resources/mariadb_service '{\"image\": \"mariadb\", \"root_password\": \"mariadb\", \"port\": 3306}'\nsolar resource create keystone_db resources/mariadb_db/ '{\"db_name\": \"keystone_db\", \"login_user\": \"root\"}'\nsolar resource create keystone_db_user resources/mariadb_user/ user_name=keystone user_password=keystone  # another valid format\n\nsolar connect node1 mariadb_service\nsolar connect node1 keystone_db\nsolar connect mariadb_service keystone_db '{\"root_password\": \"login_password\", \"port\": \"login_port\", \"ip\": \"db_host\"}'\n# solar connect mariadb_service keystone_db_user 'root_password-\u003elogin_password port-\u003elogin_port'  # another valid format\nsolar connect keystone_db keystone_db_user\n\nsolar changes stage\nsolar changes process\n# \u003cuid\u003e\nsolar orch run-once \u003cuid\u003e # or solar orch run-once last\nwatch 'solar orch report \u003cuid\u003e' # or solar orch report last\n```\n\nYou can fiddle with the above configuration like this:\n```bash\nsolar resource update keystone_db_user '{\"user_password\": \"new_keystone_password\"}'\nsolar resource update keystone_db_user user_password=new_keystone_password   # another valid format\n\nsolar changes stage\nsolar changes process\n\u003cuid\u003e\nsolar orch run-once \u003cuid\u003e\n```\n\nTo get data for the resource `bar` (raw and pretty-JSON):\n```bash\nsolar resource show --tag 'resources/bar'\nsolar resource show --json --tag 'resources/bar' | jq .\nsolar resource show --name 'resource_name'\nsolar resource show --name 'resource_name' --json | jq .\n```\n\nTo clear all resources/connections:\n```bash\nsolar resource clear_all\n```\n\nShow the connections/graph:\n```bash\nsolar connections show\nsolar connections graph\n```\n\nYou can also limit graph to show only specific resources:\n\n```bash\nsolar connections graph --start-with mariadb_service --end-with keystone_db\n```\n\nYou can make sure that all input values are correct and mapped without duplicating your values with this command:\n```bash\nsolar resource validate\n```\n\nDisconnect\n```bash\nsolar disconnect mariadb_service node1\n```\n\nTag a resource:\n```bash\nsolar resource tag node1 test-tags # Remove tags\nsolar resource tag node1 test-tag --delete\n```\n\n# Low level API\n\n## Usage:\n\nCreating resources:\n\n```python\nfrom solar.core.resource import virtual_resource as vr\nnode1 = vr.create('node1', 'resources/ro_node/', 'rs/', {'ip':'10.0.0.3', 'ssh_key' : '/vagrant/tmp/keys/ssh_private', 'ssh_user':'vagrant'})[0]\n\nnode2 = vr.create('node2', 'resources/ro_node/', 'rs/', {'ip':'10.0.0.4', 'ssh_key' : '/vagrant/tmp/keys/ssh_private', 'ssh_user':'vagrant'})[0]\n\nkeystone_db_data = vr.create('mariadb_keystone_data', 'resources/data_container/', 'rs/', {'image' : 'mariadb', 'export_volumes' : ['/var/lib/mysql'], 'ip': '', 'ssh_user': '', 'ssh_key': ''}, connections={'ip' : 'node2.ip', 'ssh_key':'node2.ssh_key', 'ssh_user':'node2.ssh_user'})[0]\n\nnova_db_data = vr.create('mariadb_nova_data', 'resources/data_container/', 'rs/', {'image' : 'mariadb', 'export_volumes' : ['/var/lib/mysql'], 'ip': '', 'ssh_user': '', 'ssh_key': ''}, connections={'ip' : 'node1.ip', 'ssh_key':'node1.ssh_key', 'ssh_user':'node1.ssh_user'})[0]\n```\n\nTo make connection after resource is created use `signal.connect`.\n\nTo test notifications:\n\n```python\nkeystone_db_data.args    # displays node2 IP\n\nnode2.update({'ip': '10.0.0.5'})\n\nkeystone_db_data.args   # updated IP\n```\n\nIf you close the Python shell you can load the resources like this:\n\n```python\nfrom solar.core import resource\nnode1 = resource.load('rs/node1')\n\nnode2 = resource.load('rs/node2')\n\nkeystone_db_data = resource.load('rs/mariadb_keystone_data')\n\nnova_db_data = resource.load('rs/mariadb_nova_data')\n```\nConnections are loaded automatically.\n\nYou can also load all resources at once:\n\n```python\nfrom solar.core import resource\nall_resources = resource.load_all('rs')\n```\n\n## Dry run\n\nSolar CLI has possibility to show dry run of actions to be performed.\nTo see what will happen when you run Puppet action, for example, try this:\n\n```bash\nsolar resource action keystone_puppet run -d\n```\n\nThis should print out something like this:\n\n```bash\nEXECUTED:\n73c6cb1cf7f6cdd38d04dd2d0a0729f8: (0, 'SSH RUN', ('sudo cat /tmp/puppet-modules/Puppetfile',), {})\n3dd4d7773ce74187d5108ace0717ef29: (1, 'SSH SUDO', ('mv \"1038cb062449340bdc4832138dca18cba75caaf8\" \"/tmp/puppet-modules/Puppetfile\"',), {})\nae5ad2455fe2b02ba46b4b7727eff01a: (2, 'SSH RUN', ('sudo librarian-puppet install',), {})\n208764fa257ed3159d1788f73c755f44: (3, 'SSH SUDO', ('puppet apply -vd /tmp/action.pp',), {})\n```\n\nBy default every mocked command returns an empty string. If you want it to return\nsomething else (to check how would dry run behave in different situation) you provide\na mapping (in JSON format), something along the lines of:\n\n```bash\nsolar resource action keystone_puppet run -d -m \"{\\\"73c\\\": \\\"mod 'openstack-keystone'\\n\\\"}\"\n```\n\nThe above means the return string of first command (with hash `73c6c...`) will be\nas specified in the mapping. Notice that in mapping you don't have to specify the\nwhole hash, just it's unique beginning. Also, you don't have to specify the whole\nreturn string in mapping. Dry run executor can read file and return it's contents\ninstead, just use the `\u003e` operator when specifying hash:\n\n```bash\nsolar resource action keystone_puppet run -d -m \"{\\\"73c\u003e\\\": \\\"./Puppetlabs-file\\\"}\"\n```\n\n# Resource compiling\n\nYou can compile all `meta.yaml` definitions into Python code with classes that\nderive from `Resource`. To do this run\n\n```bash\nsolar resource compile_all\n```\n\nThis generates file `resources_compiled.py` in the main directory (do not commit\nthis file into the repo). Then you can import classes from that file, create\ntheir instances and assign values just like these were normal properties.\nIf your editor supports Python static checking, you will have autocompletion\nthere too. An example on how to create a node with this:\n\n```python\nimport resources_compiled\n\nnode1 = resources_compiled.RoNodeResource('node1', None, {})\nnode1.ip = '10.0.0.3'\nnode1.ssh_key = '/vagrant/.vagrant/machines/solar-dev1/virtualbox/private_key'\nnode1.ssh_user = 'vagrant'\n```\n\n# Higher-level API\n\nThere's also a higher-level API that allows to write resource instances in more\nfunctional way, and in particular avoid `for` loops. Here's an example:\n\n```python\nfrom solar import template\n\nnodes = template.nodes_from('templates/riak_nodes.yaml')\n\nriak_services = nodes.on_each(\n    'resources/riak_node',\n    {\n        'riak_self_name': 'riak{num}',\n        'riak_hostname': 'riak_server{num}.solar',\n        'riak_name': 'riak{num}@riak_server{num}.solar',\n    }\n)\n\nriak_master_service = riak_services.take(0)\nriak_slave_services = riak_services.tail()\n\nriak_master_service.connect_list(\n    riak_slave_services,\n    {\n        'riak_name': 'join_to',\n    }\n)\n```\n\nFor full Riak example, please look at `examples/riak/riaks-template.py`.\n\nFull documentation of individual functions is found in the `solar/template.py` file.\n\n\n# Customizing vagrant-settings.yaml\n\nSolar is shipped with sane defaults in `vagrant-setting.yaml_defaults`. If you need to adjust them for your needs, e.g. changing resource allocation for VirtualBox machines, you should just compy the file to `vagrant-setting.yaml` and make your modifications.\n\n# Image based provisioning with Solar\n\n* In `vagrant-setting.yaml_defaults` or `vagrant-settings.yaml` file uncomment `preprovisioned: false` line.\n* Run `vagrant up`, it will take some time because it builds image for bootstrap and IBP images.\n* Now you can run provisioning `/vagrant/examples/provisioning/provision.sh`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmirantis%2Fsolar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmirantis%2Fsolar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmirantis%2Fsolar/lists"}