summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorKiril Vladimiroff <kiril.vladimiroff@cloudsigma.com>2014-05-30 14:17:57 +0300
committerKiril Vladimiroff <kiril.vladimiroff@cloudsigma.com>2014-05-30 14:17:57 +0300
commit882f7186143c337e0f30f4ed2c0415f238ed5c83 (patch)
tree7c0bcf4b7c3a748176957563329808242fae6ab2 /cloudinit
parent2f9b47be819e4aa90d0cfd940557b90cbd6912de (diff)
downloadvyos-cloud-init-882f7186143c337e0f30f4ed2c0415f238ed5c83.tar.gz
vyos-cloud-init-882f7186143c337e0f30f4ed2c0415f238ed5c83.zip
Add timeouts for reading/writing from/to to the serial console
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/cs_utils.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/cloudinit/cs_utils.py b/cloudinit/cs_utils.py
index 4e53c31a..1db3f110 100644
--- a/cloudinit/cs_utils.py
+++ b/cloudinit/cs_utils.py
@@ -35,6 +35,8 @@ import platform
import serial
+READ_TIMEOUT = 60
+WRITE_TIMEOUT = 10
SERIAL_PORT = '/dev/ttyS1'
if platform.system() == 'Windows':
SERIAL_PORT = 'COM2'
@@ -76,7 +78,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')