Set hostname in launch node
Since nova does not believe in the existence of hostnames, we need to set them ourselves when we boot new servers in launch-node. Change-Id: Ib318224a09c1b0b748ab31e1ed507975b3190784
This commit is contained in:
parent
9288fed03c
commit
f6e9e389b9
@ -84,6 +84,13 @@ def bootstrap_server(server, key, cert, environment, name,
|
|||||||
ssh_client.ssh('bash -x install_puppet.sh')
|
ssh_client.ssh('bash -x install_puppet.sh')
|
||||||
|
|
||||||
certname = cert[:(0 - len('.pem'))]
|
certname = cert[:(0 - len('.pem'))]
|
||||||
|
shortname = name.split('.')[0]
|
||||||
|
with ssh_client.open('/etc/hosts', 'w') as f:
|
||||||
|
f.write('127.0.0.1 localhost\n')
|
||||||
|
f.write('127.0.1.1 %s %s\n' % (name, shortname))
|
||||||
|
with ssh_client.open('/etc/hostname', 'w') as f:
|
||||||
|
f.write('%s\n' % (shortname,))
|
||||||
|
ssh_client.ssh("hostname %s" % (name,))
|
||||||
ssh_client.ssh("mkdir -p /var/lib/puppet/ssl/certs")
|
ssh_client.ssh("mkdir -p /var/lib/puppet/ssl/certs")
|
||||||
ssh_client.ssh("mkdir -p /var/lib/puppet/ssl/private_keys")
|
ssh_client.ssh("mkdir -p /var/lib/puppet/ssl/private_keys")
|
||||||
ssh_client.ssh("mkdir -p /var/lib/puppet/ssl/public_keys")
|
ssh_client.ssh("mkdir -p /var/lib/puppet/ssl/public_keys")
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import contextlib
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import paramiko
|
import paramiko
|
||||||
@ -55,3 +56,10 @@ class SSHClient(object):
|
|||||||
ftp = self.client.open_sftp()
|
ftp = self.client.open_sftp()
|
||||||
ftp.put(source, dest)
|
ftp.put(source, dest)
|
||||||
ftp.close()
|
ftp.close()
|
||||||
|
|
||||||
|
@contextlib.contextmanager
|
||||||
|
def open(self, path, mode):
|
||||||
|
ftp = self.client.open_sftp()
|
||||||
|
f = ftp.open(path, mode)
|
||||||
|
yield f
|
||||||
|
ftp.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user