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 version 2 as
8 # published by the Free Software Foundation;
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/>.
18 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
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
27 from test_utils import skipIfNotAlive
34 class LinuxInterfaceTestCase(unittest.TestCase):
36 self.fedora_host = "nepi2.pl.sophia.inria.fr"
37 self.fedora_user = "inria_nepi"
39 self.ubuntu_host = "roseval.pl.sophia.inria.fr"
40 self.ubuntu_user = "alina"
43 def t_deploy(self, host, user):
44 from nepi.execution.resource import ResourceFactory
46 ResourceFactory.register_type(LinuxNode)
47 ResourceFactory.register_type(LinuxInterface)
48 ResourceFactory.register_type(LinuxChannel)
50 ec = ExperimentController()
52 node = ec.register_resource("linux::Node")
53 ec.set(node, "hostname", host)
54 ec.set(node, "username", user)
56 iface = ec.register_resource("linux::Interface")
57 chan = ec.register_resource("linux::Channel")
59 ec.register_connection(iface, node)
60 ec.register_connection(iface, chan)
64 while not all([ ec.state(guid) == ResourceState.STARTED \
65 for guid in [node, iface]]):
68 self.assertTrue(ec.state(node) == ResourceState.STARTED)
69 self.assertTrue(ec.state(iface) == ResourceState.STARTED)
70 self.assertTrue(ec.get(iface, "deviceName") == "eth0")
74 def test_deploy_fedora(self):
75 self.t_deploy(self.fedora_host, self.fedora_user)
77 def test_deploy_ubuntu(self):
78 self.t_deploy(self.ubuntu_host, self.ubuntu_user)
81 if __name__ == '__main__':