예제 #1
0
 def snapshot_info(self, guest_id, snapshot_id):
     vm = self._vm_ref(guest_id)
     snap = vmware.get_snapshot(vm, snapshot_id)
     if snap:
         return self._snapshot_info(snap)
     else:
         raise EntityNotFound("Snapshot", snapshot_id)
예제 #2
0
    def guest_update(self, guest_id, guestdata):
        if not self.guests.get(guest_id):
            raise EntityNotFound("Guest", guest_id)

        self.guests[guest_id].update(guestdata)

        return self.guests[guest_id]
예제 #3
0
 def snapshot_info(self, guestname, snapshot_name):
     dom = self.libvirt_connection.lookupByUUIDString(guest_id)
     snap = self.libvirt_get_snapshot(dom, snapshot_id)
     if snap:
         return self.libvirt_snapshot_info(snap)
     else:
         raise EntityNotFound("Snapshot", snapshot_id)
예제 #4
0
    def network_interface_update(self, guest_id, interface_id, data):
        if not self.guests.get(guest_id):
            raise EntityNotFound("Guest", guest_id)

        nw_int = self.guests[guest_id]['network_interfaces'][interface_id]
        if data.get("network"):
            nw_int["network"] = data["network"]
        return nw_int
예제 #5
0
    def _disk_rec(self, vm_ref, disk_id):
        disk_id = str(disk_id)
        for disk in self.get_disks(vm_ref):
            if disk["userdevice"] == disk_id:
                return disk

        entity_info = "%s - on Guest" % (disk_id)
        raise EntityNotFound("Disk", entity_info)
예제 #6
0
    def network_interface_info(self, guest_id, network_interface_id):
        vm = self._vm_ref(guest_id)
        vifs = vmware.get_network_interfaces(vm)

        for vif in vifs:
            if vif.macAddress == network_interface_id:
                return self._network_interface_info(vif)

        entity_info = "%s - on Guest %s" % (network_interface_id, guest_id)
        raise EntityNotFound("NetworkInterface", entity_info)
예제 #7
0
    def _network_interface_ref(self, vm_ref, network_interface_id):
        vif_refs = self.connection.xenapi.VM.get_VIFs(vm_ref)

        for vif_ref in vif_refs:
            vif_rec = self.connection.xenapi.VIF.get_record(vif_ref)
            if vif_rec["MAC"] == network_interface_id:
                return vif_ref

        entity_info = "%s - on Guest" % (network_interface_id)
        raise EntityNotFound("NetworkInterface", entity_info)
예제 #8
0
    def network_interface_info(self, guest_id, network_interface_id):
        dom = self.libvirt_connection.lookupByUUIDString(guest_id)
        root = et.fromstring(dom.XMLDesc(0))

        nw_interfaces = self.network_interface_list(guest_id)

        for iface in nw_interfaces:
            if iface["id"] == network_interface_id:
                return iface

        raise EntityNotFound("Network interface", network_interface_id)
예제 #9
0
    def network_interface_delete(self, guest_id, network_interface_id):
        dom = self.libvirt_connection.lookupByUUIDString(guest_id)
        root = et.fromstring(dom.XMLDesc(0))

        iface_id = "address"  # defining the simplestack's libvirt id

        for iface in root.iter("interface"):
            for i in iface.getchildren():
                if i.attrib.get(iface_id) == network_interface_id:
                    dom.detachDeviceFlags(et.tostring(iface), 2)
                    return {"id": network_interface_id}

        raise EntityNotFound("Network interface", network_interface_id)
예제 #10
0
    def network_interface_create(self, guest_id, data):
        if not self.guests.get(guest_id):
            raise EntityNotFound("Guest", guest_id)
        mac = "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x" % (random.randint(
            0, 255), random.randint(0, 255), random.randint(
                0, 255), random.randint(0, 255), random.randint(
                    0, 255), random.randint(0, 255), random.randint(
                        0, 255), random.randint(0, 255))
        self.guests[guest_id]['network_interfaces'][mac] = {
            "id": mac,
            "number": "0",
            "mac": mac,
            "network": "network1"
        }

        return self.guests[guest_id]['network_interfaces'][mac]
예제 #11
0
 def guest_start(self, guest_id):
     if not self.guests.get(guest_id):
         raise EntityNotFound("Guest", guest_id)
     self.guests[guest_id]['state'] = "STARTED"
예제 #12
0
 def guest_reboot(self, guest_id, force=False):
     if not self.guests.get(guest_id):
         raise EntityNotFound("Guest", guest_id)
     self.guests[guest_id]['state'] = "STARTED"
예제 #13
0
 def guest_suspend(self, guest_id):
     if not self.guests.get(guest_id):
         raise EntityNotFound("Guest", guest_id)
     self.guests[guest_id]['state'] = "PAUSED"
예제 #14
0
 def guest_shutdown(self, guest_id, force=False):
     if not self.guests.get(guest_id):
         raise EntityNotFound("Guest", guest_id)
     self.guests[guest_id]['state'] = "STOPPED"
예제 #15
0
    def network_interface_info(self, guest_id, interface_id):
        if not self.guests.get(guest_id):
            raise EntityNotFound("Guest", guest_id)

        return self.guests[guest_id]['network_interfaces'][interface_id]
예제 #16
0
 def guest_delete(self, guest_id):
     if not self.guests.get(guest_id):
         raise EntityNotFound("Guest", guest_id)
     del self.guests[guest_id]
예제 #17
0
    def network_interface_list(self, guest_id):
        if not self.guests.get(guest_id):
            raise EntityNotFound("Guest", guest_id)

        return self.guests[guest_id]['network_interfaces'].values()
예제 #18
0
 def media_info(self, guest_id):
     if not self.guests.get(guest_id):
         raise EntityNotFound("Guest", guest_id)
     return {"name": self.guests[guest_id]["cd"]}
예제 #19
0
    def media_mount(self, guest_id, media_data):
        if not self.guests.get(guest_id):
            raise EntityNotFound("Guest", guest_id)

        self.guests[guest_id]["cd"] = media_data.get("name")