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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#!/usr/bin/python
import logging
import os.path
import subprocess
import unittest
logging.basicConfig(level=logging.DEBUG)
class OpenStackGlanceTest(unittest.TestCase):
def testOpenSSHDaemon(self):
cmd = ["pgrep", "sshd"]
logging.debug("Cmd: %s" % (cmd))
output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]
logging.debug("Cmd output: %s" % (output))
self.assertNotEquals(output, "")
def testOpenPorts(self):
cmd = ["netstat", "-atuvpn"]
logging.debug("Cmd: %s" % (cmd))
output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]
logging.debug("Cmd output: %s" % (output))
output2 = filter(lambda l: int(l.split()[3].split(':')[-1]) == 22,
output.strip().split('\n')[2:])
self.assertTrue(len(output2) >= 2, output2)
def testGlanceAPIDaemon(self):
cmd = ["pgrep", "glance-api"]
logging.debug("Cmd: %s" % (cmd))
output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]
logging.debug("Cmd output: %s" % (output))
self.assertNotEquals(output, "")
def testGlanceRegistryDaemon(self):
cmd = ["pgrep", "glance-registry"]
logging.debug("Cmd: %s" % (cmd))
output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]
logging.debug("Cmd output: %s" % (output))
self.assertNotEquals(output, "")
if __name__ == '__main__':
unittest.main()
|