def get_name_vm_dest(self): self.P = physical_host(self.ip_physique) self.ssh = Ssh(self.ip_physique) self.ssh.del_keyfile() self.ssh.del_keyfile_client(self.ip_physique) if self.no_pxe == True: print "no_pxe : %s" % self.no_pxe self.ssh.copy_id_client(self.ip_physique) name_vm_dest = self.ssh.exec_cmd("hostname") try: self.name_vm_dest = name_vm_dest[0].strip() except: if self.no_pxe == True: print "" print "!!! ATTENTION L'OPTION 'SERVEUR PXE' A ETE DESACTIVE AFIN DE PASSER PAR UN LIVECD DANS LE CEDEROM !!!" print "" print "Assurez vous que : " print " - Le port du switch soit bien UnTaggé avec le vlan %s" % self.vlan print " - Votre LiveCD soit bien inséré et configuré avec l'ip correspondante :" print " # ip addr add %s/24 dev eth0" % self.ip_physique print " - Le paquet 'dcfldd' soit installé sur le livecd" else: print "connexion impossible avec le serveur physique, le CFp2v est bien descendu sur le serveur physique ?" sys.exit() self.new_name_vm_ip = self.ip_physique return self.name_vm_dest
def get_name_vm_dest(self): self.P = physical_host(self.ip_physique) self.ssh = Ssh(self.ip_physique) self.ssh.del_keyfile() self.ssh.del_keyfile_client(self.ip_physique) if self.no_pxe == True: print "no_pxe : %s" % self.no_pxe self.ssh.copy_id_client(self.ip_physique) name_vm_dest = self.ssh.exec_cmd("hostname") try : self.name_vm_dest = name_vm_dest[0].strip() except: if self.no_pxe == True: print "" print "!!! ATTENTION L'OPTION 'SERVEUR PXE' A ETE DESACTIVE AFIN DE PASSER PAR UN LIVECD DANS LE CEDEROM !!!" print "" print "Assurez vous que : " print " - Le port du switch soit bien UnTaggé avec le vlan %s" % self.vlan print " - Votre LiveCD soit bien inséré et configuré avec l'ip correspondante :" print " # ip addr add %s/24 dev eth0" % self.ip_physique print " - Le paquet 'dcfldd' soit installé sur le livecd" else: print "connexion impossible avec le serveur physique, le CFp2v est bien descendu sur le serveur physique ?" sys.exit() self.new_name_vm_ip = self.ip_physique return self.name_vm_dest
def __init__(self, ip_srv_phy="", xenmgtconf="", ds="", vg_name=""): xenmgtconf = {} execfile("/etc/xen/xenmgt-p2v.conf", xenmgtconf) self.xenmgtconf = xenmgtconf self.bs = self.xenmgtconf["DD_BS"] self.P = physical_host(ip_srv_phy) self.ip_srv_phy = ip_srv_phy self.ssh = Ssh(self.ip_srv_phy) self.type_p2v = "PARA" self.type_vm = "P2V" self.sysadmin = ds self.vgname = vg_name
def MappingDevice(self): P = physical_host(ip_physique) # Verifiaction de la presence du device New_dev = "0" AFFICHE_PARTITIONS = "" for i in self.tri(partitions[type_p2v]): if type_p2v == "HVM": AFFICHE_PARTITIONS += " %s -> taille : %s\n" % (partitions[type_p2v][i]["DEVICE"],partitions[type_p2v][i]["SIZE"]) if type_p2v == "PARA": if partitions[type_p2v][i]["DEVICE"] == "/dev/cciss/c0d0p1": CheckDevice = P.exec_cmd_ssh("file %s | grep -v ERROR | wc -l" % partitions[type_p2v][i]["DEVICE"])[0].strip() if CheckDevice == "0": New_dev = "/dev/sda" pass if New_dev <> "0": fic_exec = "/etc/xen/P2V/%s/%s.sh" % (name_vm_dest,name_vm_dest) result = file(fic_exec,"r").read().replace("/dev/cciss/c0d0p","/dev/sda") file(fic_exec,"w").write(result)
def MappingDevice(self): P = physical_host(ip_physique) # Verifiaction de la presence du device New_dev = "0" AFFICHE_PARTITIONS = "" for i in self.tri(partitions[type_p2v]): if type_p2v == "HVM": AFFICHE_PARTITIONS += " %s -> taille : %s\n" % ( partitions[type_p2v][i]["DEVICE"], partitions[type_p2v][i]["SIZE"], ) if type_p2v == "PARA": if partitions[type_p2v][i]["DEVICE"] == "/dev/cciss/c0d0p1": CheckDevice = P.exec_cmd_ssh("file %s | grep -v ERROR | wc -l" % partitions[type_p2v][i]["DEVICE"])[ 0 ].strip() if CheckDevice == "0": New_dev = "/dev/sda" pass if New_dev <> "0": fic_exec = "/etc/xen/P2V/%s/%s.sh" % (name_vm_dest, name_vm_dest) result = file(fic_exec, "r").read().replace("/dev/cciss/c0d0p", "/dev/sda") file(fic_exec, "w").write(result)
def is_livecd(self): P = physical_host(self.ip_physique) self.is_livecd = P.is_livecd() return self.is_livecd