Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch Scaleway to salt.utils.cloud.bootstrap() #25549

Merged
merged 3 commits into from Jul 23, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
95 changes: 4 additions & 91 deletions salt/cloud/clouds/scaleway.py
Expand Up @@ -272,98 +272,11 @@ def __query_node_data(server_name):
finally:
raise SaltCloudSystemExit(str(exc))

ssh_username = config.get_cloud_config_value(
'ssh_username', server_, __opts__, default='root'
vm_['ssh_host'] = ip_address

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vm_ doesn't exist should be server_, same thing for next occurrences

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ip_address is not defined should be assigned from data['public_ip']['address']

if data.get('public_ip') is not None:
  ip_address = data['public_ip']['address']

vm_['ssh_password'] = config.get_cloud_config_value(
'ssh_password', vm_, __opts__
)

if config.get_cloud_config_value('deploy', server_, __opts__) is True:
deploy_script = script(server_)
if data.get('public_ip') is not None:
ip_address = data['public_ip']['address']

deploy_kwargs = {
'opts': __opts__,
'host': ip_address,
'username': ssh_username,
'script': deploy_script,
'name': server_['name'],
'tmp_dir': config.get_cloud_config_value(
'tmp_dir', server_, __opts__, default='/tmp/.saltcloud'
),
'deploy_command': config.get_cloud_config_value(
'deploy_command', server_, __opts__,
default='/tmp/.saltcloud/deploy.sh',
),
'start_action': __opts__['start_action'],
'parallel': __opts__['parallel'],
'sock_dir': __opts__['sock_dir'],
'conf_file': __opts__['conf_file'],
'minion_pem': server_['priv_key'],
'minion_pub': server_['pub_key'],
'keep_tmp': __opts__['keep_tmp'],
'preseed_minion_keys': server_.get('preseed_minion_keys', None),
'display_ssh_output': config.get_cloud_config_value(
'display_ssh_output', server_, __opts__, default=True
),
'sudo': config.get_cloud_config_value(
'sudo', server_, __opts__, default=(ssh_username != 'root')
),
'sudo_password': config.get_cloud_config_value(
'sudo_password', server_, __opts__, default=None
),
'tty': config.get_cloud_config_value(
'tty', server_, __opts__, default=False
),
'script_args': config.get_cloud_config_value(
'script_args', server_, __opts__
),
'script_env': config.get_cloud_config_value('script_env', server_,
__opts__),
'minion_conf': salt.utils.cloud.minion_config(__opts__, server_)
}

# Deploy salt-master files, if necessary
if config.get_cloud_config_value('make_master', server_, __opts__) is True:
deploy_kwargs['make_master'] = True
deploy_kwargs['master_pub'] = server_['master_pub']
deploy_kwargs['master_pem'] = server_['master_pem']
master_conf = salt.utils.cloud.master_config(__opts__, server_)
deploy_kwargs['master_conf'] = master_conf

if master_conf.get('syndic_master', None):
deploy_kwargs['make_syndic'] = True

deploy_kwargs['make_minion'] = config.get_cloud_config_value(
'make_minion', server_, __opts__, default=True
)

# Store what was used to the deploy the BareMetal server
event_kwargs = copy.deepcopy(deploy_kwargs)
del event_kwargs['minion_pem']
del event_kwargs['minion_pub']
del event_kwargs['sudo_password']
if 'password' in event_kwargs:
del event_kwargs['password']
ret['deploy_kwargs'] = event_kwargs

salt.utils.cloud.fire_event(
'event',
'executing deploy script',
'salt/cloud/{0}/deploying'.format(server_['name']),
{'kwargs': event_kwargs},
transport=__opts__['transport']
)

deployed = salt.utils.cloud.deploy_script(**deploy_kwargs)

if deployed:
log.info('Salt installed on {0}'.format(server_['name']))
else:
log.error(
'Failed to start Salt on BareMetal server {0}'.format(
server_['name']
)
)
ret = salt.utils.cloud.bootstrap(vm_, __opts__)

ret.update(data)

Expand Down