summaryrefslogtreecommitdiff
path: root/cloudinit/sources/DataSourceCloudSigma.py
diff options
context:
space:
mode:
authorKiril Vladimiroff <kiril.vladimiroff@cloudsigma.com>2014-05-30 14:50:57 -0400
committerScott Moser <smoser@ubuntu.com>2014-05-30 14:50:57 -0400
commit5067b44d18c1338520acd7ea7363371853edde6f (patch)
treedf02ac7428c2fb813e3c2eb8c6535d8ea6fd0a1b /cloudinit/sources/DataSourceCloudSigma.py
parente0650257e1ef728304a0c7230c0a2d2710a8ac5f (diff)
parent2d36a7ce4a0ccec3bd2881dd99d6d5012a85fe3c (diff)
downloadvyos-cloud-init-5067b44d18c1338520acd7ea7363371853edde6f.tar.gz
vyos-cloud-init-5067b44d18c1338520acd7ea7363371853edde6f.zip
CloudSigma: only poll on serial device after dmidecode check.
On systems with a ttyS1 and nothing attached, the read attempts that the cloud sigma datasource would do would block. Also, Add timeouts for reading/writting from/to the serial console LP: #1316475
Diffstat (limited to 'cloudinit/sources/DataSourceCloudSigma.py')
-rw-r--r--cloudinit/sources/DataSourceCloudSigma.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/cloudinit/sources/DataSourceCloudSigma.py b/cloudinit/sources/DataSourceCloudSigma.py
index ad2a044a..707cd0ce 100644
--- a/cloudinit/sources/DataSourceCloudSigma.py
+++ b/cloudinit/sources/DataSourceCloudSigma.py
@@ -16,10 +16,12 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from base64 import b64decode
+import os
import re
from cloudinit import log as logging
from cloudinit import sources
+from cloudinit import util
from cloudinit.cs_utils import Cepko
LOG = logging.getLogger(__name__)
@@ -40,12 +42,40 @@ class DataSourceCloudSigma(sources.DataSource):
self.ssh_public_key = ''
sources.DataSource.__init__(self, sys_cfg, distro, paths)
+ def is_running_in_cloudsigma(self):
+ """
+ Uses dmidecode to detect if this instance of cloud-init is running
+ in the CloudSigma's infrastructure.
+ """
+ uname_arch = os.uname()[4]
+ if uname_arch.startswith("arm") or uname_arch == "aarch64":
+ # Disabling because dmidecode in CMD_DMI_SYSTEM crashes kvm process
+ LOG.debug("Disabling CloudSigma datasource on arm (LP: #1243287)")
+ return False
+
+ dmidecode_path = util.which('dmidecode')
+ if not dmidecode_path:
+ return False
+
+ LOG.debug("Determining hypervisor product name via dmidecode")
+ try:
+ cmd = [dmidecode_path, "--string", "system-product-name"]
+ system_product_name, _ = util.subp(cmd)
+ return 'cloudsigma' in system_product_name.lower()
+ except:
+ LOG.warn("Failed to get hypervisor product name via dmidecode")
+
+ return False
+
def get_data(self):
"""
Metadata is the whole server context and /meta/cloud-config is used
as userdata.
"""
dsmode = None
+ if not self.is_running_in_cloudsigma():
+ return False
+
try:
server_context = self.cepko.all().result
server_meta = server_context['meta']