Exemple #1
0
    def disk_create(self, guest_id, data):
        vm_ref = self._vm_ref(guest_id)

        devices = []
        for vbd in self.connection.xenapi.VM.get_VBDs(vm_ref):
            devices.append(int(self.connection.xenapi.VBD.get_userdevice(vbd)))
        next_device = max(devices) + 1
        for device in range(next_device):
            if device not in devices:
                next_device = device
                break

        vbd_rec = {
            "VM": vm_ref,
            "userdevice": str(next_device),
            "bootable": False,
            "mode": "RW",
            "type": "Disk",
            "unpluggable": False,
            "empty": False,
            "other_config": {},
            "qos_algorithm_type": "",
            "qos_algorithm_params": {}
        }

        vdi_rec = ({
            "name_label": "New Disk",
            "name_description": "Simplestack generated disk",
            "virtual_size": str(data["size"] * 1024 * 1024 * 1024),
            "type": "system",
            "sharable": False,
            "read_only": False,
            "other_config": {},
            "xenstore_data": {},
            "sm_config": {},
            "tags": []
        })

        if data.get("storage_id"):
            raise FeatureNotImplemented()
        else:
            disks = self.get_disks(vm_ref)
            vdi_rec["SR"] = disks[0]["SR"]

        if "name" in data:
            vdi_rec["name_label"] = data["name"]
            vdi_rec["name_description"] = data["name"]

        vdi_ref = self.connection.xenapi.VDI.create(vdi_rec)
        vbd_rec["VDI"] = vdi_ref
        self.connection.xenapi.VBD.create(vbd_rec)

        disk_rec = self._disk_rec(vm_ref, next_device)
        return self._disk_info(disk_rec)
Exemple #2
0
 def connect(self):
     """
     Each hypervisor should implement this method to return its own connection
     object or just use the libvirt_connect() here.
     """
     raise FeatureNotImplemented()
Exemple #3
0
 def tag_delete(self, guest_id, tag_name):
     raise FeatureNotImplemented()
Exemple #4
0
 def tag_list(self, guest_id):
     raise FeatureNotImplemented()
Exemple #5
0
 def snapshot_create(self, guestname, name=None):
     raise FeatureNotImplemented()
Exemple #6
0
 def media_unmount(self, guest_id):
     raise FeatureNotImplemented()
Exemple #7
0
 def media_info(self, guest_id):
     raise FeatureNotImplemented()
Exemple #8
0
 def media_mount(self, guest_id, media_data):
     raise FeatureNotImplemented()
Exemple #9
0
 def disk_delete(self, guest_id, disk_id):
     raise FeatureNotImplemented()
Exemple #10
0
 def disk_update(self, guest_id, disk_id, data):
     raise FeatureNotImplemented()
Exemple #11
0
 def guest_update(self, guest_id, guestdata):
     raise FeatureNotImplemented()
Exemple #12
0
 def guest_export(self, guest_id):
     raise FeatureNotImplemented()
Exemple #13
0
 def guest_import(self, gueststream, guestsize, storage_id=None):
     raise FeatureNotImplemented()
Exemple #14
0
 def has_connection(*args, **kwargs):
     if not available:
         raise FeatureNotImplemented()
     return f(*args, **kwargs)