def undeploy(): resources = resource.load_all() resources = {r.name: r for r in resources} for name in reversed(resources_to_run): try: actions.resource_action(resources[name], 'remove') except errors.SolarError as e: print 'WARNING: %s' % str(e) ModelMeta.remove_all()
def undeploy(): resources = map(resource.wrap_resource, db.get_list(collection=db.COLLECTIONS.resource)) resources = {r.name: r for r in resources} for name in reversed(resources_to_run): try: actions.resource_action(resources[name], 'remove') except errors.SolarError as e: print 'WARNING: %s' % str(e) db.clear() signals.Connections.clear()
def deploy(): setup_resources() # run resources = map(resource.wrap_resource, db.get_list(collection=db.COLLECTIONS.resource)) resources = {r.name: r for r in resources} for name in resources_to_run: try: actions.resource_action(resources[name], 'run') except errors.SolarError as e: print 'WARNING: %s' % str(e) raise time.sleep(10)
def deploy(): setup_resources() # run resources = resource.load_all() resources = {r.name: r for r in resources} for name in resources_to_run: try: actions.resource_action(resources[name], 'run') except errors.SolarError as e: print 'WARNING: %s' % str(e) raise time.sleep(10)
def run(dry_run_mapping, dry_run, action, tags): if dry_run: dry_run_executor = executors.DryRunExecutor( mapping=json.loads(dry_run_mapping)) resources = filter(lambda r: Expression(tags, r.tags).evaluate(), orm.DBResource.all()) for r in resources: resource_obj = sresource.load(r['id']) actions.resource_action(resource_obj, action) if dry_run: click.echo('EXECUTED:') for key in dry_run_executor.executed: click.echo('{}: {}'.format( click.style(dry_run_executor.compute_hash(key), fg='green'), str(key)))
def action(dry_run_mapping, dry_run, action, resource): if dry_run: dry_run_executor = executors.DryRunExecutor( mapping=json.loads(dry_run_mapping)) click.echo( 'action {} for resource {}'.format(action, resource) ) r = sresource.load(resource) actions.resource_action(r, action) if dry_run: click.echo('EXECUTED:') for key in dry_run_executor.executed: click.echo('{}: {}'.format( click.style(dry_run_executor.compute_hash(key), fg='green'), str(key) ))
def action(dry_run_mapping, dry_run, action, resource): if dry_run: dry_run_executor = executors.DryRunExecutor( mapping=json.loads(dry_run_mapping)) click.echo('action {} for resource {}'.format(action, resource)) r = sresource.load(resource) try: actions.resource_action(r, action) except errors.SolarError as e: log.debug(e) sys.exit(1) if dry_run: click.echo('EXECUTED:') for key in dry_run_executor.executed: click.echo('{}: {}'.format( click.style(dry_run_executor.compute_hash(key), fg='green'), str(key)))
def run(dry_run_mapping, dry_run, action, tags): if dry_run: dry_run_executor = executors.DryRunExecutor(mapping=json.loads(dry_run_mapping)) resources = filter( lambda r: Expression(tags, r.tags).evaluate(), orm.DBResource.all() ) for r in resources: resource_obj = sresource.load(r['id']) actions.resource_action(resource_obj, action) if dry_run: click.echo('EXECUTED:') for key in dry_run_executor.executed: click.echo('{}: {}'.format( click.style(dry_run_executor.compute_hash(key), fg='green'), str(key) ))
def run(dry_run_mapping, dry_run, action, tags): from solar.core import actions from solar.core import resource if dry_run: dry_run_executor = executors.DryRunExecutor(mapping=json.loads(dry_run_mapping)) resources = filter( lambda r: Expression(tags, r.get('tags', [])).evaluate(), db.get_list('resource')) for resource in resources: resource_obj = sresource.load(resource['id']) actions.resource_action(resource_obj, action) if dry_run: click.echo('EXECUTED:') for key in dry_run_executor.executed: click.echo('{}: {}'.format( click.style(dry_run_executor.compute_hash(key), fg='green'), str(key) ))
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()
def undeploy(): db = get_db() resources = map(resource.wrap_resource, db.get_list(collection=db.COLLECTIONS.resource)) 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') db.clear() signals.Connections.clear()
def deploy(): db = get_db() db.clear() 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 = '******' 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': '******' })[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 = vr.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)
def deploy(): db = get_db() db.clear() 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 = '******' 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': '******'})[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 = vr.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)
def solar_resource(self, ctxt, resource_name, action): log.debug('TASK solar resource NAME %s ACTION %s', resource_name, action) res = resource.load(resource_name) return actions.resource_action(res, action)
def action(self, action): if action in self.actions: actions.resource_action(self, action) else: raise Exception('Uuups, action is not available')
def solar_resource(ctxt, resource_name, action): res = resource.load(resource_name) return actions.resource_action(res, action)