def main(): hosts_path = mkdtemp() hosts_file = os.path.join(hosts_path, HOSTS_FILE_NAME) operation_name = ctx.operation.name or "" ctx.logger.info( 'Handling sources for operation {0}'.format(operation_name)) inputs.pop(CLOUDIFY_CONTEXT) inputs.pop(CLOUDIFY_SCRIPT_PATH) if operation_name == CLOUDIFY_CREATE_OPERATION: private_key_val = inputs.get(ANSIBLE_PRIVATE_KEY, "") if private_key_val: try: is_file_path = os.path.exists(private_key_val) except TypeError: is_file_path = False if not is_file_path: private_key_file = os.path.join(hosts_path, str(uuid1())) with open(private_key_file, 'w') as outfile: outfile.write(private_key_val) os.chmod(private_key_file, 0o600) inputs.update({ANSIBLE_PRIVATE_KEY: private_key_file}) else: raise NonRecoverableError("No private key was provided") # could be updated private_key_val = inputs.get(ANSIBLE_PRIVATE_KEY, "") # inputs is of type proxy_tools.Proxy -> can't dump it hosts_dict = {"all": {"hosts": {"instance": {}}}} for key in inputs: if key in EXECLUDE_INPUTS: continue elif key == ANSIBLE_PRIVATE_KEY: # replace docker mapping to container volume hosts_dict['all']['hosts']['instance'][key] = \ inputs.get(key).replace(hosts_path, inputs.get(CONTAINER_VOLUME)) else: hosts_dict['all']['hosts']['instance'][key] = inputs.get(key) with open(hosts_file, 'w') as outfile: yaml.safe_dump(hosts_dict, outfile, default_flow_style=False) ctx.instance.runtime_properties['hosts_file'] = hosts_file ctx.instance.runtime_properties['private_key'] = private_key_val ctx.instance.update() elif operation_name == CLOUDIFY_DELETE_OPERATION: try: if os.path.exists(hosts_file): os.remove(hosts_file) except TypeError: ctx.logger.info("hosts file doesn't exist")
def _upload_blueprints(): blueprints = inputs.get('blueprints', []) for blueprint in blueprints: if 'path' not in blueprint: ctx.logger.error(""" Provided blueprint input is incorrect: {0} Expected format is: blueprints: - path: <PATH_1> id: <ID_1> filename: <FILENAME_1> tenant: <TENANT_1> visibility: <VISIBILITY_1> `path` is required """.format(blueprint)) continue # Create basic command cmd = ['cfy', 'blueprints', 'upload', blueprint['path']] # Add optional params blueprint_id = blueprint.get('id') if blueprint_id: cmd += ['-b', blueprint_id] blueprint_filename = blueprint.get('filename') if blueprint_filename: cmd += ['-n', blueprint_filename] cmd = _add_tenant_and_visibility(cmd, blueprint) _try_running_command( cmd, 'Could not upload blueprint {0}'.format(blueprint['path']))
def get_config(): ctx.logger.info( 'Getting config from properties, runtime_properties, and inputs.') _config = ctx.node.properties.get('resource_config', {}) _config.update(ctx.instance.runtime_properties.get('resource_config', {})) _config.update(inputs.get('resource_config', {})) return _config
def _upload_plugins(): plugins = inputs.get('plugins', []) for plugin in plugins: if 'wagon' not in plugin or 'yaml' not in plugin: ctx.logger.error(""" Provided plugin input is incorrect: {0} Expected format is: plugins: - wagon: <WAGON_1> yaml: <YAML_1> tenant: <TENANT_1> - wagon: <WAGON_2> yaml: <YAML_2> visibility: <VIS_2> Both `wagon` and `yaml` are required fields """.format(plugin)) continue cmd = [ 'cfy', 'plugins', 'upload', plugin['wagon'], '-y', plugin['yaml'] ] cmd = _add_tenant_and_visibility(cmd, plugin) _try_running_command( cmd, 'Could not upload plugin {0}'.format(plugin['wagon']))
def _main(args): cloudify_agent = prepare_cloudify_agent() logger = _setup_logger('installer') runner = _prepare_runner(logger) installer = Installer(logger, runner, cloudify_agent) if ctx_parameters.get('validate_only'): result = cloudify_agent else: result = installer.install() _return(result, cloudify_agent['old_agent_version'])
def __init__(self): self.snapshot_id = inputs.get('snapshot_id') self.old_deployment_id = inputs.get('old_deployment_id') self.snapshot_path = inputs.get('snapshot_path') self.restore = inputs.get('restore', False) self.transfer_agents = inputs.get('transfer_agents', True) self.restore_params = inputs.get('restore_params', [])
def _get_backup_params(): backup_params = inputs.get('backup_params', []) if backup_params: allowed_backup_params = { '--include-metrics', '--exclude-credentials', '--exclude-logs', '--exclude-events' } if not all(param in allowed_backup_params for param in backup_params): raise NonRecoverableError( 'The only backup parameters allowed are: {0}, ' 'but: {1} were provided'.format(list(allowed_backup_params), backup_params)) return backup_params
def tick(ctx, **kwargs): test_time = int(inputs.get('test_time', 30)) end_time = datetime.now() + timedelta(0, test_time) while True: current_data = str(datetime.now()) ctx.logger.info("test_func: {}".format(current_data)) if ctx.instance.runtime_properties.get('data'): ctx.logger.info("runtime test_func: {}".format( ctx.instance.runtime_properties.get('data'))) else: ctx.logger.info("There is no runtime data") ctx.instance.runtime_properties['data'] = current_data ctx.instance.update() if datetime.now() >= end_time: return sleep(1)
def _create_secrets(): secrets = inputs.get('secrets', []) for secret in secrets: if ('key' not in secret) or \ ('string' not in secret and 'file' not in secret) or \ ('string' in secret and 'file' in secret): ctx.logger.error(""" Provided secret input is incorrect: {0} Expected format is: secrets: - key: <KEY_1> string: <STRING_1> - key: <KEY_2> file: <FILE_2> tenant: <TENANT> `key` is required, as is one (and only one) of `string`/`file` """.format(secret)) continue # Create basic command cmd = ['cfy', 'secrets', 'create', secret['key'], '--update-if-exists'] # Add string or file as the value of the secret string = secret.get('string') if string: cmd += ['-s', string] else: cmd += ['-f', secret['file']] # The secrets' CLI command doesn't have a `-t` flag, so we handle it # separately here by actually switching to the tenant tenant = secret.pop('tenant', None) try: if tenant: _switch_tenant(tenant) cmd = _add_tenant_and_visibility(cmd, secret) _try_running_command( cmd, 'Could not create secret {0}'.format(secret['key'])) finally: if tenant: _switch_tenant(DEFAULT_TENANT)
def backup(**_): """ Create a snapshot on a Tier 1 cluster, and download it to a dedicated folder on the Tier 2 manager """ backup_params = _get_backup_params() snapshot_id = inputs.get('snapshot_id') if not snapshot_id: now = datetime.now() snapshot_id = now.strftime('%Y-%m-%d-%H:%M:%S') output_path = os.path.join(_snapshots_dir(), '{0}.zip'.format(snapshot_id)) if os.path.exists(output_path): raise NonRecoverableError( 'Snapshot with ID {0} already exists. Try a different name, ' 'or leave the `snapshot_id` parameter empty in order to create ' 'a snapshot ID based on the current date and time') with profile(get_current_master()): _create_snapshot(snapshot_id, backup_params) _download_snapshot(snapshot_id, output_path) return output_path
def start_kubernetes_master(): # Start Kubernetes Master ctx.logger.info('Attempting to start Kubernetes master.') init_command = 'sudo kubeadm init' cni_provider = inputs.get('cni-provider-blueprint', 'weave.yaml') # Each cni provider work with specific pod-cidr if cni_provider == 'flannel.yaml': init_command = '{0} {1}'.format(init_command, '--pod-network-cidr=10.244.0.0/16') elif cni_provider == 'calico.yaml': init_command = '{0} {1}'.format(init_command, '--pod-network-cidr=192.168.0.0/16') start_output = execute_command(init_command) ctx.logger.debug('start_master_command output: {0}'.format(start_output)) # Check if start succeeded. if start_output is False or not isinstance(start_output, basestring): ctx.logger.error('Kubernetes master failed to start.') cleanup_and_retry() ctx.logger.info('Kubernetes master started successfully.') return start_output
def backup(deployment_id=None, **_): """ Create a snapshot on a Tier 1 cluster, and download it to a dedicated folder on the Tier 2 manager """ snapshot_id = inputs.get('snapshot_id') if not snapshot_id: now = datetime.now() snapshot_id = now.strftime('%Y-%m-%d-%H:%M:%S') output_path = os.path.join(_snapshots_dir(deployment_id), '{0}.zip'.format(snapshot_id)) if os.path.exists(output_path): raise NonRecoverableError( 'Snapshot with ID {0} already exists. Try a different name, ' 'or leave the `snapshot_id` parameter empty in order to create ' 'a snapshot ID based on the current date and time') _create_snapshot(snapshot_id, deployment_id) execute_and_log( ['cfy', 'snapshots', 'download', snapshot_id, '-o', output_path], deployment_id=deployment_id) return output_path
def _create_tenants(): tenants = inputs.get('tenants', []) for tenant in tenants: cmd = ['cfy', 'tenants', 'create', tenant] _try_running_command(cmd, 'Could not create tenant {0}'.format(tenant))
from cloudify import ctx from cloudify.state import ctx_parameters as inputs if __name__ == '__main__': ctx.logger.info('Gather inventory data.') ansible_node = ctx.source.instance.runtime_properties terraform_node = ctx.target.instance.runtime_properties if 'sources' not in ansible_node: ansible_node['sources'] = { 'cloud_resources': { 'hosts': { } } } for cloud_resource_compute in terraform_node['resources']['eip']['instances']: ansible_inventory_entry = { cloud_resource_compute['attributes']['public_ip']: { 'ansible_host': cloud_resource_compute['attributes']['public_ip'], 'ansible_user': inputs.get('agent_user'), 'ansible_become': True, 'ansible_ssh_private_key_file': inputs.get('private_key'), 'ansible_ssh_common_args': '-o StrictHostKeyChecking=no' } } ansible_node['sources']['cloud_resources']['hosts'].update(ansible_inventory_entry)
else: raise OperationRetry('hostname output is empty !!, re-try again') if __name__ == '__main__': # echo 1 | sudo tee /proc/sys/net/bridge/bridge-nf-call-iptables status = execute_command( "sudo sysctl net.bridge.bridge-nf-call-iptables=1") if status is False: raise OperationRetry('Failed to set bridge-nf-call-iptables') # Set ``hostname`` as runtime properties for the current node set_hostname() private_master_ip = inputs.get('master_ip') public_master_ip = inputs.get('public_master_ip') bootstrap_token = inputs.get('bootstrap_token') bootstrap_hash = inputs.get('bootstrap_hash') master_port = inputs.get('master_port') # Set the ``public_master_ip`` as runtime property ctx.instance.runtime_properties['public_master_ip'] = public_master_ip # Join the cluster. join_command = ( 'sudo kubeadm join --token {0} --discovery-token-ca-cert-hash {1} ' '{2}:{3} --skip-preflight-checks'.format(bootstrap_token, bootstrap_hash, private_master_ip, master_port))
import json from os import path from cloudify import ctx from cloudify.state import ctx_parameters as inputs file_path = inputs.get('infra_info_file') with open(file_path, "r") as vars_file: ctx.instance.runtime_properties.update(json.load(vars_file))
ctx.logger.location('new backup: {0}'.format(backup.name)) if __name__ == '__main__': # Find out if the update script is being called from a relationship or a node operation. if ctx.type == RELATIONSHIP_INSTANCE: subject = ctx.target else: subject = ctx ctx.logger.info('{0}'.format(subject.instance.id)) # Find out if we are adding or removing backends. action = inputs.get('action', 'add') # Get the current backends. backends = subject.instance.runtime_properties.get('backends', {}) if not backends: subject.instance.runtime_properties['backends'] = {} # Find out this lifecyle operations backends. update_backends = inputs.get('update_backends') # Update the backends in the context. if action == 'add': backends.update(update_backends) else: for key in update_backends.keys(): try:
env_map["INSTANCES"] = get_instance_list(ctx.node.id) new_script_process = {"env": env_map} node_artifacts = {"war_file": "_a4c_topology_artifact/War/tomcat-war-types/warFiles/helloWorld.war"} relationship_artifacts = {} artifacts = node_artifacts.copy() artifacts.update(relationship_artifacts) download_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "downloads") new_script_process["env"].update(download_artifacts(artifacts, download_dir)) ctx.logger.info("Operation is executed with inputs {0}".format(inputs)) if inputs.get("process", None) is not None and inputs["process"].get("env", None) is not None: ctx.logger.info("Operation is executed with environment variable {0}".format(inputs["process"]["env"])) new_script_process["env"].update(inputs["process"]["env"]) operationOutputNames = None parsed_output = execute( ctx.download_resource("artifacts/artifact-test-types/scripts/create.sh"), new_script_process, operationOutputNames ) for k, v in parsed_output["outputs"].items(): ctx.logger.info("Output name: {0} value: {1}".format(k, v)) ctx.instance.runtime_properties["_a4c_OO:tosca.interfaces.node.lifecycle.Standard:create:{0}".format(k)] = v ctx.instance.runtime_properties["application_url"] = ( r"http://" + get_attribute(ctx, "floating_ip_address") + r":" + r"80" + r"/" + r"helloworld" )
host_instance = get_instance_host(ctx.instance.relationships, 'cloudify.relationships.contained_in', 'cloudify.nodes.Compute') if not host_instance: raise NonRecoverableError('Ambiguous host resolution data.') cloudify_agent = host_instance.runtime_properties.get('cloudify_agent', {}) linux_distro = cloudify_agent.get('distro') cfy_host = cloudify_agent.get('broker_ip') cfy_ssl_port = cloudify_agent.get('rest_port') agent_name = cloudify_agent.get('name') cfy_user = inputs.get('cfy_user', 'admin') cfy_pass = inputs.get('cfy_password', 'admin') cfy_tenant = inputs.get('cfy_tenant', 'default_tenant') agent_user = inputs.get('agent_user', 'centos') full_install = inputs.get('full_install', 'all') # Generate deployment file to be used as a reference inside the cfy.json generate_deployment_file() if not os.path.isfile(config_file): ctx.logger.info("Create config {} file".format(config_file)) deployment_file = os.path.expanduser('~') + "/deployment.json" # services config with open(config_file, 'w') as outfile: agent_file = "/root" if agent_user == "root" else ("/home/" +
output, error = process.communicate() ctx.logger.debug('command: {0} '.format(repr(command))) ctx.logger.debug('output: {0} '.format(output)) ctx.logger.debug('error: {0} '.format(error)) ctx.logger.debug('process.returncode: {0} '.format(process.returncode)) if process.returncode: ctx.logger.error('Running `{0}` returns {1} error: {2}.'.format( repr(command), process.returncode, repr(error))) return False return output if __name__ == '__main__': if not inputs.get("snapshot_name"): raise cfy_exc.NonRecoverableError('Backup name must be provided.') backup_dir = inputs["snapshot_name"].replace("/", "_") if inputs.get("snapshot_incremental"): ctx.logger.info("Snapshot for image automatically is created by VM " "snapshot logic, check by qemu-img snapshot -l") else: if ctx.instance.runtime_properties.get("vm_cloudinit"): execute_command( ["rm", "{}/vm_cloudinit-backup.qcow2".format(backup_dir)]) if ctx.instance.runtime_properties.get("vm_image"): execute_command( ["rm", "{}/vm_image-backup.qcow2".format(backup_dir)])
#!/usr/bin/env python import os from cloudify import ctx from cloudify.state import ctx_parameters as inputs try: import mysql.connector as mariadb except ImportError: import pip pip.main(['install', 'mysql-connector-python-rf']) import mysql.connector as mariadb if __name__ == '__main__': db_password = inputs.get('db_password', str()) mysql_commands = inputs.get('mysql_commands', []) db = mariadb.connect(user='******', passwd=db_password, db='mysql') cur = db.cursor() for mysql_command in mysql_commands: ctx.logger.debug('COMMAND: {0}'.format(mysql_command)) cur.execute(mysql_command) db.close()
return dict(map(convert, data.iteritems())) elif isinstance(data, collections.Iterable): return type(data)(map(convert, data)) else: return data return dump(convert(_config), Dumper=Dumper) def write_configuration(config, config_path): config = convert_yaml(config) ctx.logger.debug('type: {0}'.format(type(config))) ctx.logger.debug('Writing Salt configuration: {0}'.format(config)) temp_file = NamedTemporaryFile(delete=False) temp_file.write(config) temp_file.close() execute_command('sudo mv {0} {1}'.format(temp_file.name, config_path)) if __name__ == '__main__': salt_config = inputs.get('resource_config', {}) write_configuration(salt_config, MINION_CONFIG_PATH) # Restart Salt Daemon ctx.logger.debug('Restarting Salt.') execute_command('sudo systemctl restart salt-minion.service') # Log the Salt Finger execute_command('sudo salt-call --local key.finger')
ctx.logger.debug('command: {0} '.format(_command)) ctx.logger.debug('error: {0} '.format(error)) ctx.logger.debug('process.returncode: {0} '.format(process.returncode)) if process.returncode: ctx.logger.error('Running `{0}` returns error.'.format(_command)) return False return output if __name__ == '__main__': execute_command('sudo systemctl stop mariadb') cluster_addresses = inputs.get('cluster_addresses', []) master = inputs.get('master', ctx.instance.host_ip) if ctx.instance.host_ip not in cluster_addresses: cluster_addresses.append(ctx.instance.host_ip) config = """[galera] wsrep_on={0} binlog_format={1} default-storage-engine={2} innodb_autoinc_lock_mode={3} wsrep_provider={4} wsrep_cluster_name='{5}' wsrep_node_address='{6}' wsrep_node_name='{7}' wsrep_sst_method={8}
node_artifacts = { "war_file": "artifacts/tomcat-war-types/warFiles/helloWorld.war" } relationship_artifacts = {} artifacts = node_artifacts.copy() artifacts.update(relationship_artifacts) download_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'downloads') new_script_process['env'].update(download_artifacts(artifacts, download_dir)) ctx.logger.info('Operation is executed with inputs {0}'.format(inputs)) if inputs.get('process', None) is not None and inputs['process'].get( 'env', None) is not None: ctx.logger.info( 'Operation is executed with environment variable {0}'.format( inputs['process']['env'])) new_script_process['env'].update(inputs['process']['env']) operationOutputNames = None convert_env_value_to_string(new_script_process['env']) parsed_output = execute( ctx.download_resource( 'artifacts/tomcat-war-types/scripts/tomcat_install_war.sh'), new_script_process, operationOutputNames) for k, v in parsed_output['outputs'].items(): ctx.logger.info('Output name: {0} value: {1}'.format(k, v)) ctx.source.instance.runtime_properties[
host_instance = get_instance_host(ctx.instance.relationships, 'cloudify.relationships.contained_in', 'cloudify.nodes.Compute') if not host_instance: raise NonRecoverableError('Ambiguous host resolution data.') cloudify_agent = host_instance.runtime_properties.get('cloudify_agent', {}) linux_distro = cloudify_agent.get('distro') cfy_host = cloudify_agent.get('broker_ip') cfy_ssl_port = cloudify_agent.get('rest_port') if ctx.operation.retry_number == 0: # Allow user to provide specific values. update_host_address(host_instance=host_instance, hostname=inputs.get('hostname', socket.gethostname()), fqdn=inputs.get('fqdn', socket.getfqdn()), ip=inputs.get('ip', ctx.instance.host_ip), public_ip=inputs.get('public_ip')) # certificate logic if not linux_distro: distro, _, _ = \ platform.linux_distribution(full_distribution_name=False) linux_distro = distro.lower() ctx.logger.info("Set certificate as trusted") # cert config _, temp_cert_file = tempfile.mkstemp()
#!/usr/bin/env python import os from cloudify import ctx from cloudify.state import ctx_parameters as inputs try: import mysql.connector as mariadb except ImportError: import pip pip.main(['install', 'mysql-connector-python-rf']) import mysql.connector as mariadb if __name__ == '__main__': db_name = inputs.get('db_name') db_username = inputs.get('db_user_name') db_host = inputs.get('db_host') db_password = inputs.get('db_password') db = mariadb.connect( user=db_username, passwd=db_password, host=db_host, db='mysql') cur = db.cursor() cur.execute( "DROP DATABASE {0}".format(db_name)) db.close()
return output if __name__ == '__main__': hostname = execute_command('hostname') ctx.instance.runtime_properties['hostname'] = hostname.rstrip('\n') # Get the master cluster info. masters = \ [x for x in ctx.instance.relationships if x.target.instance.runtime_properties.get( 'KUBERNETES_MASTER', False)] if len(masters) != 1: bootstrap_token = inputs.get('bootstrap_token') master_ip = inputs.get('master_ip') master_port = inputs.get('master_port') else: props = masters[0].target.instance.runtime_properties bootstrap_token = props.get('bootstrap_token') master_ip = props.get('master_ip') master_port = props.get('master_port') if not bootstrap_token and not master_ip and not master_port: raise NonRecoverableError( 'The following required variables are empty: ' 'bootstrap_token, master_ip and master_port') # Join the cluster. join_command = \
raise OperationRetry('Retrying after error: {0}'.format(str(e))) else: sleep(5) ctx.logger.error('Ignoring error: {0}'.format(str(e))) else: sleep(5) ctx.logger.debug('Returning response: {0}'.format(response)) return response return None if __name__ == '__main__': # Initialize client. manager_admin_user = \ inputs.get('manager_admin_user', 'admin') manager_admin_password = \ inputs.get('manager_admin_user', 'admin') manager_tenant = \ inputs.get('manager_tenant', 'default_tenant') manager_ip = \ inputs.get('manager_ip') client = \ get_client( manager_ip, manager_admin_user, manager_admin_password, manager_tenant) if not ctx.node.properties.get('bootstrap'):
ctx.logger.debug('output: {0} '.format(output)) ctx.logger.debug('error: {0} '.format(error)) ctx.logger.debug('process.returncode: {0} '.format(process.returncode)) if process.returncode: ctx.logger.error('Running `{0}` returns error.'.format(_command)) return False return output if __name__ == '__main__': ctx.logger.info('Inputs : {0}'.format(repr(inputs))) runtime_properties = ctx.instance.runtime_properties runtime_properties["proxy_ports"] = inputs.get("ports") runtime_properties["proxy_nodes"] = inputs.get("nodes") runtime_properties["proxy_cluster"] = inputs.get("cluster") runtime_properties["proxy_name"] = inputs.get("name") runtime_properties["proxy_namespace"] = inputs.get("namespace") execute_command("sudo systemctl stop haproxy") config_text = HAPROXY_HEADER for port in inputs.get("ports", []): in_port = int(port['port']) out_port = int(port['nodePort']) config_text = (config_text + "\nfrontend {}\n\toption forceclose\n\t" "bind *:{}\n\tdefault_backend servers_{}_{}\n" "backend servers_{}_{}\n\toption forceclose".format(
if e.status_code == 404: raise SecretNotFoundError('Not Found error {0}'.format(str(e))) else: ctx.logger.error('Ignoring error: {0}'.format(str(e))) else: ctx.logger.debug('Returning response: {0}'.format(response)) return response return None if __name__ == '__main__': # Set script-wide variables from inputs. examples_tenant_name = inputs.get('tenant', 'examples') ctx.instance.runtime_properties[ 'examples_tenant_name'] = examples_tenant_name examples_plugins_urls = inputs.get('plugins', []) examples_secrets = inputs.get('secrets', {}) # Set the client. client = get_rest_client() # Make sure the examples tenant exists. tenant = check_api(client.tenants.get, examples_tenant_name) if tenant is None: check_api(client.tenants.create, examples_tenant_name) client = get_rest_client(tenant=examples_tenant_name) # Check if plugins are uploaded.
env_map = {} env_map['TARGET_NODE'] = ctx.target.node.id env_map['TARGET_INSTANCE'] = ctx.target.instance.id env_map['TARGET_INSTANCES'] = get_instance_list(ctx.target.node.id) env_map['SOURCE_NODE'] = ctx.source.node.id env_map['SOURCE_INSTANCE'] = ctx.source.instance.id env_map['SOURCE_INSTANCES'] = get_instance_list(ctx.source.node.id) env_map['CONTEXT_PATH'] = r'/' env_map['DOC_ROOT'] = r'/var/www' new_script_process = {'env': env_map} ctx.logger.info('Operation is executed with inputs {0}'.format(inputs)) if inputs.get('process', None) is not None and inputs['process'].get('env', None) is not None: ctx.logger.info('Operation is executed with environment variable {0}'.format(inputs['process']['env'])) new_script_process['env'].update(inputs['process']['env']) operationOutputNames = None parsed_output = execute(ctx.download_resource('artifacts/wordpress-type/scripts/config_wordpress.sh'), new_script_process, operationOutputNames) for k,v in parsed_output['outputs'].items(): ctx.logger.info('Output name: {0} value: {1}'.format(k, v)) ctx.source.instance.runtime_properties['_a4c_OO:tosca.interfaces.relationship.Configure:pre_configure_source:{0}'.format(k)] = v ctx.source.instance.runtime_properties['wordpress_url'] = r'http://' + get_attribute(ctx.source, 'public_ip_address') + r':' + r'80' + r'/' ctx.source.instance.update() ctx.target.instance.update()
if 'centos' in linux_distro: execute_command(['sudo', 'cp', temp_cert_file, CERT_CLOUDIFY_FILE]) execute_command(['sudo', 'update-ca-trust', 'extract']) execute_command([ 'sudo', 'bash', '-c', 'cat {0} >> {1}'.format(temp_cert_file, CERT_BUNDLE_FILE) ]) else: raise NonRecoverableError('Unsupported platform.') if __name__ == '__main__': plugin_directory = inputs.get( 'plugin_directory', '/usr/libexec/kubernetes/kubelet-plugins/' 'volume/exec/cloudify~mount/') host_instance = get_instance_host(ctx.instance.relationships, 'cloudify.relationships.contained_in', 'cloudify.nodes.Compute') if not host_instance: raise NonRecoverableError('Ambiguous host resolution data.') cloudify_agent = host_instance.runtime_properties.get('cloudify_agent', {}) linux_distro = cloudify_agent.get('distro') cfy_host = cloudify_agent.get('broker_ip') cfy_ssl_port = cloudify_agent.get('rest_port') agent_name = cloudify_agent.get('name')