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)
def connect(self): """ Each hypervisor should implement this method to return its own connection object or just use the libvirt_connect() here. """ raise FeatureNotImplemented()
def tag_delete(self, guest_id, tag_name): raise FeatureNotImplemented()
def tag_list(self, guest_id): raise FeatureNotImplemented()
def snapshot_create(self, guestname, name=None): raise FeatureNotImplemented()
def media_unmount(self, guest_id): raise FeatureNotImplemented()
def media_info(self, guest_id): raise FeatureNotImplemented()
def media_mount(self, guest_id, media_data): raise FeatureNotImplemented()
def disk_delete(self, guest_id, disk_id): raise FeatureNotImplemented()
def disk_update(self, guest_id, disk_id, data): raise FeatureNotImplemented()
def guest_update(self, guest_id, guestdata): raise FeatureNotImplemented()
def guest_export(self, guest_id): raise FeatureNotImplemented()
def guest_import(self, gueststream, guestsize, storage_id=None): raise FeatureNotImplemented()
def has_connection(*args, **kwargs): if not available: raise FeatureNotImplemented() return f(*args, **kwargs)