summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKim Hagen <kim.sidney@gmail.com>2018-10-23 23:36:27 +0200
committerKim Hagen <kim.sidney@gmail.com>2018-10-23 23:36:27 +0200
commit9967bc76410b7ecddc6d02411cd3bda08a5a7b9a (patch)
treeca2e8fd927c0adac75ddd77bbaade85e3d2a24c3
parent28f66957d027264260e7b82616ffc9e7b67616e7 (diff)
downloadvyos-cloud-init-9967bc76410b7ecddc6d02411cd3bda08a5a7b9a.tar.gz
vyos-cloud-init-9967bc76410b7ecddc6d02411cd3bda08a5a7b9a.zip
Use dhcp for google cloud source
Rework check to see which part of ssh key is which
-rw-r--r--cloudinit/config/cc_vyos.py9
-rw-r--r--cloudinit/sources/DataSourceGCE.py8
2 files changed, 11 insertions, 6 deletions
diff --git a/cloudinit/config/cc_vyos.py b/cloudinit/config/cc_vyos.py
index b073239c..290d3665 100644
--- a/cloudinit/config/cc_vyos.py
+++ b/cloudinit/config/cc_vyos.py
@@ -20,7 +20,6 @@
import os
import sys
-import base64
import ast
from cloudinit import util
@@ -58,11 +57,9 @@ def set_ssh_login(config, user, key_string, key_x):
for key in key_parts:
if 'ssh-dss' in key or 'ssh-rsa' in key:
key_type = key
- try:
- if base64.b64decode(key):
- key_data = key
- except:
- pass
+
+ if key.startswith('AAAAB3NzaC1yc2E') or key.startswith('AAAAB3NzaC1kc3M'):
+ key_data = key
if not key_type:
util.logexc(log, 'Key type not defined, wrong ssh key format.')
diff --git a/cloudinit/sources/DataSourceGCE.py b/cloudinit/sources/DataSourceGCE.py
index d8162623..f72d9836 100644
--- a/cloudinit/sources/DataSourceGCE.py
+++ b/cloudinit/sources/DataSourceGCE.py
@@ -2,8 +2,10 @@
#
# This file is part of cloud-init. See LICENSE file for license information.
+import os
import datetime
import json
+from subprocess import call
from base64 import b64decode
@@ -18,6 +20,7 @@ LOG = logging.getLogger(__name__)
MD_V1_URL = 'http://metadata.google.internal/computeMetadata/v1/'
BUILTIN_DS_CONFIG = {'metadata_url': MD_V1_URL}
REQUIRED_FIELDS = ('instance-id', 'availability-zone', 'local-hostname')
+DEFAULT_PRIMARY_NIC = 'eth0'
class GoogleMetadataFetcher(object):
@@ -50,6 +53,11 @@ class GoogleMetadataFetcher(object):
class DataSourceGCE(sources.DataSource):
dsname = 'GCE'
+ process_name = 'dhclient'
+
+ tmpps = os.popen("ps -Af").read()
+ if process_name not in tmpps[:]:
+ call(['/sbin/dhclient', DEFAULT_PRIMARY_NIC])
def __init__(self, sys_cfg, distro, paths):
sources.DataSource.__init__(self, sys_cfg, distro, paths)