def _install_coreos(self, node_id, provision_config_id, network, password):
self.info('Installing CoreOS...')
# boot in to the provision configuration
self.info('Booting into Provision configuration profile...')
self.request('linode.boot', params={'LinodeID': node_id, 'ConfigID': provision_config_id})
# connect to the server via ssh
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
while True:
try:
ssh.connect(str(network['public']), username='root', password=password, allow_agent=False, look_for_keys=False)
break
except:
continue
# copy the cloud config
self.info('Pushing cloud config...')
cloud_config_template = string.Template(self._get_cloud_config())
cloud_config = cloud_config_template.safe_substitute(public_ipv4=network['public'], private_ipv4=network['private'], gateway=network['gateway'],
hostname=network['hostname'])
sftp = ssh.open_sftp()
sftp.open('cloud-config.yaml', 'w').write(cloud_config)
self.info('Installing...')
commands = [
'wget https://raw.githubusercontent.com/coreos/init/master/bin/coreos-install -O $HOME/coreos-install',
'chmod +x $HOME/coreos-install',
'$HOME/coreos-install -d /dev/sdb -C ' + self.coreos_channel + ' -V ' + self.coreos_version + ' -c $HOME/cloud-config.yaml -t /dev/shm'
]
for command in commands:
stdin, stdout, stderr = ssh.exec_command(command)
stdout.channel.recv_exit_status()
print stdout.read()
ssh.close()
provision-linode-cluster.py 文件源码
python
阅读 19
收藏 0
点赞 0
评论 0
评论列表
文章目录