Removed resource compile_all action from CLI

It was not used and not implemented anymore

Change-Id: I7cf2044eb2c23c4b46fe839af3dc216049f7e37c
This commit is contained in:
Jedrzej Nowak 2015-12-29 11:58:35 +01:00
parent 7b64f2e074
commit b9d230aa95
3 changed files with 0 additions and 137 deletions

View File

@ -1,27 +0,0 @@
# Example script that uses the "compiled resources" functionality
To run this code, first compile the resources with
```bash
solar resource compile_all
```
Please note that you don't have to anymore write
```python
node1 = resource.create('node1', 'resources/ro_node/', {'ip': '10.0.0.3', 'ssh_key': '/vagrant/.vagrant/machines/solar-dev1/virtualbox/private_key', 'ssh_user': 'vagrant'})
```
but instead you can do:
```python
import resources_compiled
node1 = resources_compiled.RoNodeResource('node1', None, {})
node1.ip = '10.0.0.3'
node1.ssh_key = '/vagrant/.vagrant/machines/solar-dev1/virtualbox/private_key'
node1.ssh_user = 'vagrant'
```
Resources aren't anymore a collection of dicts with inputs that are hard to
trace, but they are full Python classes for which you can use your IDE's
autocompletion, etc. functionality.

View File

@ -1,91 +0,0 @@
#!/usr/bin/env python
"""
To run this code, first compile the resources with
solar resource compile_all
NOTE: this script might be outdated, the idea is just to show how
compiled resources work.
"""
import click
import json
import requests
import sys
import time
from solar.core import actions
from solar.core.resource import composer as cr
from solar.core import resource
from solar.core import signals
from solar.dblayer.model import ModelMeta
from solar.core.resource_provider import GitProvider, RemoteZipProvider
import resources_compiled
@click.group()
def main():
pass
@click.command()
def deploy():
ModelMeta.remove_all()
signals.Connections.clear()
node1 = resources_compiled.RoNodeResource('node1', None, {})
node1.ip = '10.0.0.3'
node1.ssh_key = '/vagrant/.vagrant/machines/solar-dev1/virtualbox/private_key'
node1.ssh_user = 'vagrant'
rabbitmq_service1 = resources_compiled.RabbitmqServiceResource('rabbitmq_service1', None, {'management_port': 15672, 'port': 5672, 'container_name': 'rabbitmq_service1', 'image': 'rabbitmq:3-management'})
openstack_vhost = resource.create('openstack_vhost', 'resources/rabbitmq_vhost/', {'vhost_name': 'openstack'})[0]
openstack_rabbitmq_user = resource.create('openstack_rabbitmq_user', 'resources/rabbitmq_user/', {'user_name': 'openstack', 'password': 'openstack_password'})[0]
####
# connections
####
# rabbitmq
signals.connect(node1, rabbitmq_service1)
signals.connect(rabbitmq_service1, openstack_vhost)
signals.connect(rabbitmq_service1, openstack_rabbitmq_user)
signals.connect(openstack_vhost, openstack_rabbitmq_user, {'vhost_name': 'vhost_name'})
errors = cr.validate_resources()
if errors:
for r, error in errors:
print 'ERROR: %s: %s' % (r.name, error)
sys.exit(1)
# run
actions.resource_action(rabbitmq_service1, 'run')
actions.resource_action(openstack_vhost, 'run')
actions.resource_action(openstack_rabbitmq_user, 'run')
time.sleep(10)
@click.command()
def undeploy():
ModelMeta.remove_all()
resources = resource.load_all()
resources = {r.name: r for r in resources}
actions.resource_action(resources['openstack_rabbitmq_user'], 'remove')
actions.resource_action(resources['openstack_vhost'], 'remove')
actions.resource_action(resources['rabbitmq_service1'], 'remove')
ModelMeta.remove_all()
main.add_command(deploy)
main.add_command(undeploy)
if __name__ == '__main__':
main()

View File

@ -13,7 +13,6 @@
# under the License.
import json
import os
import sys
import click
@ -26,7 +25,6 @@ from solar.core.log import log
from solar.core import resource as sresource
from solar.core.resource import composer as cr
from solar import errors
from solar import utils
@click.group()
@ -64,23 +62,6 @@ def action(dry_run_mapping, dry_run, action, resource):
))
@resource.command()
def compile_all():
from solar.core.resource import compiler
destination_path = utils.read_config()['resources-compiled-file']
if os.path.exists(destination_path):
os.remove(destination_path)
resources_files_mask = utils.read_config()['resources-files-mask']
for path in utils.find_by_mask(resources_files_mask):
meta = utils.yaml_load(path)
meta['base_path'] = os.path.dirname(path)
compiler.compile(meta)
@resource.command()
def clear_all():
from solar.dblayer.model import ModelMeta