diff options
author | Kiril Vladimiroff <kiril.vladimiroff@cloudsigma.com> | 2014-05-30 14:50:57 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2014-05-30 14:50:57 -0400 |
commit | 5067b44d18c1338520acd7ea7363371853edde6f (patch) | |
tree | df02ac7428c2fb813e3c2eb8c6535d8ea6fd0a1b /cloudinit/cs_utils.py | |
parent | e0650257e1ef728304a0c7230c0a2d2710a8ac5f (diff) | |
parent | 2d36a7ce4a0ccec3bd2881dd99d6d5012a85fe3c (diff) | |
download | vyos-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/cs_utils.py')
-rw-r--r-- | cloudinit/cs_utils.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/cloudinit/cs_utils.py b/cloudinit/cs_utils.py index 4e53c31a..dcf56431 100644 --- a/cloudinit/cs_utils.py +++ b/cloudinit/cs_utils.py @@ -35,6 +35,10 @@ import platform import serial +# these high timeouts are necessary as read may read a lot of data. +READ_TIMEOUT = 60 +WRITE_TIMEOUT = 10 + SERIAL_PORT = '/dev/ttyS1' if platform.system() == 'Windows': SERIAL_PORT = 'COM2' @@ -76,7 +80,9 @@ class CepkoResult(object): self.result = self._marshal(self.raw_result) def _execute(self): - connection = serial.Serial(SERIAL_PORT) + connection = serial.Serial(port=SERIAL_PORT, + timeout=READ_TIMEOUT, + writeTimeout=WRITE_TIMEOUT) connection.write(self.request) return connection.readline().strip('\x04\n') |