2 NEPI, a framework to manage network experiments
3 Copyright (C) 2013 INRIA
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 from nepi.execution.ec import ExperimentController
22 from nepi.execution.resource import ResourceState
23 from nepi.resources.linux.node import LinuxNode
24 from nepi.resources.linux.interface import LinuxInterface
25 from nepi.resources.linux.channel import LinuxChannel
26 from nepi.util.sshfuncs import RUNNING, FINISHED
28 from test_utils import skipIfNotAlive
35 class LinuxInterfaceTestCase(unittest.TestCase):
37 self.fedora_host = 'nepi2.pl.sophia.inria.fr'
38 self.fedora_user = 'inria_nepi'
40 self.ubuntu_host = 'roseval.pl.sophia.inria.fr'
41 self.ubuntu_user = 'alina'
44 def t_deploy(self, host, user):
45 from nepi.execution.resource import ResourceFactory
47 ResourceFactory.register_type(LinuxNode)
48 ResourceFactory.register_type(LinuxInterface)
49 ResourceFactory.register_type(LinuxChannel)
51 ec = ExperimentController()
53 node = ec.register_resource("LinuxNode")
54 ec.set(node, "hostname", host)
55 ec.set(node, "username", user)
57 iface = ec.register_resource("LinuxInterface")
58 chan = ec.register_resource("LinuxChannel")
60 ec.register_connection(iface, node)
61 ec.register_connection(iface, chan)
65 while not all([ ec.state(guid) == ResourceState.STARTED \
66 for guid in [node, iface]]) and not ec.finished:
69 self.assertTrue(ec.state(node) == ResourceState.STARTED)
70 self.assertTrue(ec.state(iface) == ResourceState.STARTED)
71 self.assertTrue(ec.get(iface, "deviceName") == "eth0")
75 def test_deploy_fedora(self):
76 self.t_deploy(self.fedora_host, self.fedora_user)
78 def test_deploy_ubuntu(self):
79 self.t_deploy(self.ubuntu_host, self.ubuntu_user)
82 if __name__ == '__main__':