X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=src%2Fnepi%2Fresources%2Fplanetlab%2Fopenvswitch%2Fovs.py;h=842f5c2c54d83133b10ab2a39ebd8b38b303df60;hb=09ac796bac9aa2c41c5ad830f404fe128fffb22d;hp=bffc61ef85c44ac45238ea582542bcd45bff85c9;hpb=4b0e922489532434f0968647886021542b77cece;p=nepi.git diff --git a/src/nepi/resources/planetlab/openvswitch/ovs.py b/src/nepi/resources/planetlab/openvswitch/ovs.py index bffc61ef..842f5c2c 100644 --- a/src/nepi/resources/planetlab/openvswitch/ovs.py +++ b/src/nepi/resources/planetlab/openvswitch/ovs.py @@ -19,7 +19,8 @@ # Alexandros Kouvakas -from nepi.execution.resource import ResourceManager, clsinit_copy, ResourceState +from nepi.execution.resource import ResourceManager, clsinit_copy, \ + ResourceState from nepi.execution.attribute import Attribute, Flags from nepi.resources.planetlab.node import PlanetlabNode from nepi.resources.linux.application import LinuxApplication @@ -114,11 +115,13 @@ class OVSWitch(LinuxApplication): # TODO: Validate! return True - def provision(self): + def do_provision(self): # create home dir for ovs self.node.mkdir(self.ovs_home) # create dir for ovs checks self.node.mkdir(self.ovs_checks) + + super(OVSWitch, self).do_provision() def check_sliver_ovs(self): """ Check if sliver-ovs exists. If it does not exist, we interrupt @@ -136,14 +139,16 @@ class OVSWitch(LinuxApplication): stderr = "check_cmd_stderr") (out, err), proc = self.node.check_output(self.ovs_checks, 'check_cmd_exitcode') + if out != "0\n": msg = "Command sliver-ovs does not exist on the VM" self.debug(msg) raise RuntimeError, msg + msg = "Command sliver-ovs exists" self.debug(msg) - def deploy(self): + def do_deploy(self): """ Wait until node is associated and deployed """ node = self.node @@ -152,19 +157,15 @@ class OVSWitch(LinuxApplication): self.ec.schedule(reschedule_delay, self.deploy) else: - try: - self.discover() - self.provision() - self.check_sliver_ovs() - self.servers_on() - self.create_bridge() - self.assign_contr() - self.ovs_status() - except: - self._state = ResourceState.FAILED - raise - - self._state = ResourceState.READY + self.do_discover() + self.do_provision() + self.check_sliver_ovs() + self.servers_on() + self.create_bridge() + self.assign_contr() + self.ovs_status() + + super(OVSWitch, self).do_deploy() def servers_on(self): """ Start the openvswitch servers and also checking @@ -201,9 +202,11 @@ class OVSWitch(LinuxApplication): # Check if the servers are running or not (out, err), proc = self.node.check_output(self.ovs_checks, 'status_srv_exitcode') + if out != "0\n": self.debug("Servers are not running") raise RuntimeError, msg + self.info("Servers started") def del_old_br(self): @@ -279,19 +282,7 @@ class OVSWitch(LinuxApplication): (out, err), proc = self.node.check_output(self.ovs_home, 'show_stdout') self.info(out) - def start(self): - """ Start the RM. It means nothing special for - ovswitch for now. - """ - pass - - def stop(self): - """ Stop the RM.It means nothing - for ovswitch for now. - """ - pass - - def release(self): + def do_release(self): """ Delete the bridge and close the servers """ @@ -314,9 +305,8 @@ class OVSWitch(LinuxApplication): sudo = True) if proc.poll(): - self.fail() self.error(msg, out, err) raise RuntimeError, msg - - self._state = ResourceState.RELEASED - + + super(OVSWitch, self).do_release() +