Esempio n. 1
0
 def destroy(self):
     #adding code to ensure bonds on the network are deleted before an attempt to destroy
     #network is made
     pifs=self.get("Host").ref.genParamGet("network",self.getUUID(),"PIF-uuids")
     if pifs:
       bond=self.get("Host").ref.genParamGet("pif",pifs,"bond-master-of")
       cli=self.get("Host").ref.getCLIInstance()
       if xenrt.isUUID(bond):
         cli.execute("bond-destroy",args ="uuid=%s" %(bond))
         time.sleep(120)
       else: # if not a bond, check whether there is a vlan
         vlan=cli.execute("vlan-list", args ="untagged-PIF=%s" %(pifs),minimal=True)
         if xenrt.isUUID(vlan):
           cli.execute("vlan-destroy", args ="uuid=%s" %(vlan))
           
     self.get("Host").ref.removeNetwork(nwuuid=self.getUUID())
Esempio n. 2
0
 def getparameters(self, root, uuid):
     if not xenrt.isUUID(uuid): return {}
     regexp = re.compile(r"\s*(?P<parameter>\S+)\s+\(.*\)\s*(?:\[DEPRECATED\])?:\s*(?P<value>.*)")
     cli = self.host.getCLIInstance()
     command = ["%s-param-list" % (root)]
     command.append("uuid=%s" % (uuid))
     parameters = cli.execute(string.join(command), strip=True)
     parameters = map(regexp.match, parameters.splitlines())
     return dict(map(lambda x:(x.group("parameter"), x.group("value")), parameters))
Esempio n. 3
0
    def destroy(self):
        #adding code to ensure bonds on the network are deleted before an attempt to destroy
        #network is made
        pifs = self.get("Host").ref.genParamGet("network", self.getUUID(),
                                                "PIF-uuids")
        if pifs:
            bond = self.get("Host").ref.genParamGet("pif", pifs,
                                                    "bond-master-of")
            cli = self.get("Host").ref.getCLIInstance()
            if xenrt.isUUID(bond):
                cli.execute("bond-destroy", args="uuid=%s" % (bond))
                time.sleep(120)
            else:  # if not a bond, check whether there is a vlan
                vlan = cli.execute("vlan-list",
                                   args="untagged-PIF=%s" % (pifs),
                                   minimal=True)
                if xenrt.isUUID(vlan):
                    cli.execute("vlan-destroy", args="uuid=%s" % (vlan))

        self.get("Host").ref.removeNetwork(nwuuid=self.getUUID())
Esempio n. 4
0
 def create(self):      
     self.context.cleanup(["VLAN"])
     # Ensure we select two PIFs on the same network! CA-63028
     nics = self.get("Host").ref.listSecondaryNICs(network="NPRI")
     nics = [0] + nics
     pifs = map(self.get("Host").ref.getNICPIF, nics)
     # including code to ensure existing bonds (if any) gets deleted
     bond=self.get("Host").ref.genParamGet("pif", pifs[0], "bond-slave-of")
     if xenrt.isUUID(bond):
       self.get("Host").ref.removeBond(bond,management=True)
     bridge, device = self.get("Host").ref.createBond(pifs[0:2])
     self.uuid = self.get("Host").ref.genParamGet("pif", pifs[0], "bond-slave-of")
     pifuuid = self.get("Host").ref.parseListForUUID("pif-list", "bond-master-of", self.uuid)
Esempio n. 5
0
 def getparameters(self, root, uuid):
     if not xenrt.isUUID(uuid): return {}
     regexp = re.compile(
         r"\s*(?P<parameter>\S+)\s+\(.*\)\s*(?:\[DEPRECATED\])?:\s*(?P<value>.*)"
     )
     cli = self.host.getCLIInstance()
     command = ["%s-param-list" % (root)]
     command.append("uuid=%s" % (uuid))
     parameters = cli.execute(string.join(command), strip=True)
     parameters = map(regexp.match, parameters.splitlines())
     return dict(
         map(lambda x: (x.group("parameter"), x.group("value")),
             parameters))
Esempio n. 6
0
 def create(self):
     self.context.cleanup(["VLAN"])
     # Ensure we select two PIFs on the same network! CA-63028
     nics = self.get("Host").ref.listSecondaryNICs(network="NPRI")
     nics = [0] + nics
     pifs = map(self.get("Host").ref.getNICPIF, nics)
     # including code to ensure existing bonds (if any) gets deleted
     bond = self.get("Host").ref.genParamGet("pif", pifs[0],
                                             "bond-slave-of")
     if xenrt.isUUID(bond):
         self.get("Host").ref.removeBond(bond, management=True)
     bridge, device = self.get("Host").ref.createBond(pifs[0:2])
     self.uuid = self.get("Host").ref.genParamGet("pif", pifs[0],
                                                  "bond-slave-of")
     pifuuid = self.get("Host").ref.parseListForUUID(
         "pif-list", "bond-master-of", self.uuid)