Revision 55cc0a44 test/ganeti.hypervisor.hv_kvm_unittest.py
b/test/ganeti.hypervisor.hv_kvm_unittest.py | ||
---|---|---|
1 | 1 |
#!/usr/bin/python |
2 | 2 |
# |
3 | 3 |
|
4 |
# Copyright (C) 2010 Google Inc. |
|
4 |
# Copyright (C) 2010, 2011 Google Inc.
|
|
5 | 5 |
# |
6 | 6 |
# This program is free software; you can redistribute it and/or modify |
7 | 7 |
# it under the terms of the GNU General Public License as published by |
... | ... | |
80 | 80 |
inst, nic, 2) |
81 | 81 |
|
82 | 82 |
|
83 |
class TestConsole(unittest.TestCase): |
|
84 |
def _Test(self, instance, hvparams): |
|
85 |
cons = hv_kvm.KVMHypervisor.GetInstanceConsole(instance, hvparams, {}) |
|
86 |
self.assertTrue(cons.Validate()) |
|
87 |
return cons |
|
88 |
|
|
89 |
def testSerial(self): |
|
90 |
instance = objects.Instance(name="kvm.example.com", |
|
91 |
primary_node="node6017") |
|
92 |
hvparams = { |
|
93 |
constants.HV_SERIAL_CONSOLE: True, |
|
94 |
constants.HV_VNC_BIND_ADDRESS: None, |
|
95 |
} |
|
96 |
cons = self._Test(instance, hvparams) |
|
97 |
self.assertEqual(cons.kind, constants.CONS_SSH) |
|
98 |
self.assertEqual(cons.host, instance.primary_node) |
|
99 |
self.assertEqual(cons.command[0], constants.SOCAT_PATH) |
|
100 |
|
|
101 |
def testVnc(self): |
|
102 |
instance = objects.Instance(name="kvm.example.com", |
|
103 |
primary_node="node7235", |
|
104 |
network_port=constants.VNC_BASE_PORT + 10) |
|
105 |
hvparams = { |
|
106 |
constants.HV_SERIAL_CONSOLE: False, |
|
107 |
constants.HV_VNC_BIND_ADDRESS: "192.0.2.1", |
|
108 |
} |
|
109 |
cons = self._Test(instance, hvparams) |
|
110 |
self.assertEqual(cons.kind, constants.CONS_VNC) |
|
111 |
self.assertEqual(cons.host, "192.0.2.1") |
|
112 |
self.assertEqual(cons.port, constants.VNC_BASE_PORT + 10) |
|
113 |
self.assertEqual(cons.display, 10) |
|
114 |
|
|
115 |
def testNoConsole(self): |
|
116 |
instance = objects.Instance(name="kvm.example.com", |
|
117 |
primary_node="node24325", |
|
118 |
network_port=0) |
|
119 |
hvparams = { |
|
120 |
constants.HV_SERIAL_CONSOLE: False, |
|
121 |
constants.HV_VNC_BIND_ADDRESS: None, |
|
122 |
} |
|
123 |
cons = self._Test(instance, hvparams) |
|
124 |
self.assertEqual(cons.kind, constants.CONS_MESSAGE) |
|
125 |
|
|
126 |
|
|
83 | 127 |
if __name__ == "__main__": |
84 | 128 |
testutils.GanetiTestProgram() |
Also available in: Unified diff