def __init__ self try self os subprocess Popen usr local bin omshell s

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def __init__(self):
try:
self.os = subprocess.Popen(['/usr/local/bin/omshell'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True)
self.os.stdin.write("server 127.0.0.1\n")
self.os.stdin.write("port 7911\n")
self.os.stdin.write("key omapi_key TyZrylPA2SrgEKkX0BXMN4qIuCy73Fj8aj8dFKRM6z2UBj6ekHD18Pb6BIin3EQJBZFlCQG6T7TwD7S3qKJr+w==\n")
self.os.stdin.write("connect\n")
self.os.stdin.write("new host\n")
except:
pass
def __del__(self):
#self.os.kill()
pass
# Внесение абонента в DHCP
def addAbon(self, abon):
for row in abon:
self.os.stdin.write("set name = \"a" + str(row[0]) + "\"\n")
self.os.stdin.write("open\n")
self.os.stdin.write("set ip-address = " + str(row[1]) + "\n")
self.os.stdin.write("set hardware-address = " + str(row[2]) + "\n")
self.os.stdin.write("set hardware-type = 1\n")
self.os.stdin.write("create\n")
#print self.os.communicate()[0]