blob: 886c002c4a0a97fd3c9f7a772362f9e875b4cd95 [file] [log] [blame]
andrewonlaba548f962014-10-21 19:28:43 -04001#!/usr/bin/env python
2
3'''
4This driver handles the optical switch emulator linc-oe.
5
6Please follow the coding style demonstrated by existing
7functions and document properly.
8
9If you are a contributor to the driver, please
10list your email here for future contact:
11
12 andrew@onlab.us
13
14OCT 20 2014
15'''
16
17import traceback
18import pexpect
19import struct
20import fcntl
21import os
22import signal
23import re
24import sys
25import core.teston
26sys.path.append("../")
27from math import pow
28from drivers.common.cli.emulatordriver import Emulator
29from drivers.common.clidriver import CLI
30
31class LincOEDriver(Emulator):
32 '''
33 LincOEDriver class will handle all emulator functions
34 '''
35 def __init__(self):
36 super(Emulator, self).__init__()
37 self.handle = self
38 self.wrapped = sys.modules[__name__]
39 self.flag = 0
40
41 def connect(self, **connectargs):
42 '''
43 Create ssh handle for Linc-OE cli
44 '''
45 for key in connectargs:
46 vars(self)[key] = connectargs[key]
47
48 self.name = self.options['name']
49 self.handle = \
50 super(LincOEDriver, self).connect(\
51 user_name = self.user_name,
52 ip_address = self.ip_address,
53 port = None,
54 pwd = self.pwd)
55
56 self.ssh_handle = self.handle
57
58 if self.handle :
59 main.log.info(self.name+": Starting Linc-OE CLI")
60 cmdStr = "sudo ./rel/linc/bin/linc console"
61
62 self.handle.sendline(cmdStr)
63 self.handle.expect(["linc@",pexpect.EOF,pexpect.TIMEOUT])
64
65 else:
66 main.log.error(self.name+
67 ": Connection failed to the host "+
68 self.user_name+"@"+self.ip_address)
69 main.log.error(self.name+
70 ": Failed to connect to Linc-OE")
71 return main.FALSE
72
73
74
75if __name__ != "__main__":
76 import sys
77 sys.modules[__name__] = LincOEDriver()
78