3 # NEPI, a framework to manage network experiments
4 # Copyright (C) 2013 INRIA
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
22 from nepi.execution.ec import ExperimentController
23 from nepi.execution.resource import ResourceState
24 from nepi.resources.linux.node import LinuxNode
25 from nepi.resources.linux.interface import LinuxInterface
26 from nepi.resources.linux.channel import LinuxChannel
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]]):
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__':