def get_disks(remote_session, remote_vm_uuid): record_handles = expose_forest( remote_session, [remote_vm_uuid] + all_snapshots(remote_session, remote_vm_uuid)).split(',') print "Record Handles %s" % record_handles try: for record_handle in record_handles: record = get_expose_record(remote_session, record_handle) vdi_uuids = record['vdi_uuid'].split(',') if 'non_leaf_vdi_uuids' in record: vdi_uuids.extend(record['non_leaf_vdi_uuids'].split(',')) for vdi_uuid in vdi_uuids: url_full = '%s.vhd' % record['url_full_%s' % vdi_uuid] url_path = '%s.vhd' % record['url_path_%s' % vdi_uuid] dest = '%s.vhd' % vdi_uuid print("*** Client must download from %s into %s" % (url_full, dest)) if not os.access(dest, os.F_OK): bits.download(record['use_ssl'] == False, '%s:%s' % (record['ip'], record['port']), url_path, dest, record['username'], record['password']) size = os.stat(dest).st_size finally: for record_handle in record_handles: unexpose(remote_session, record_handle)
def get_disks(remote_session, remote_vm_uuid): record_handles = expose_forest(remote_session, [remote_vm_uuid] + all_snapshots(remote_session, remote_vm_uuid)).split(',') print "Record Handles %s" % record_handles try: for record_handle in record_handles: record = get_expose_record(remote_session, record_handle) vdi_uuids = record['vdi_uuid'].split(',') if 'non_leaf_vdi_uuids' in record: vdi_uuids.extend(record['non_leaf_vdi_uuids'].split(',')) for vdi_uuid in vdi_uuids: url_full = '%s.vhd' % record['url_full_%s' % vdi_uuid] url_path = '%s.vhd' % record['url_path_%s' % vdi_uuid] dest = '%s.vhd' % vdi_uuid print ("*** Client must download from %s into %s" % (url_full, dest)) if not os.access(dest, os.F_OK): bits.download( record['use_ssl'] == False, '%s:%s' % (record['ip'], record['port']), url_path, dest, record['username'], record['password']) size = os.stat(dest).st_size finally: for record_handle in record_handles: unexpose(remote_session, record_handle)
def get_metadata(remote_session, host, remote_vm_uuid): url_path = export_url_path(remote_session, remote_vm_uuid) dest = 'metadata-%s.raw' % remote_vm_uuid print ("*** Client must download from %s://%s%s into %s" % ("http", host, url_path, dest)) bits.download("http", host, url_path, dest) print 'Downloaded metadata file %s' % dest
def get_metadata(remote_session, host, remote_vm_uuid): url_path = export_url_path(remote_session, remote_vm_uuid) dest = 'metadata-%s.raw' % remote_vm_uuid print("*** Client must download from %s://%s%s into %s" % ("http", host, url_path, dest)) bits.download("http", host, url_path, dest) print 'Downloaded metadata file %s' % dest
def _testUploadDownload(self, vhd_filename, vdi_mb, chunksize): record = put_vhd(self, vhd_filename, vdi_mb, self.VDI_RAW) protocol = "http" dest = "download-frag-%s.vhd" % (vdi_mb) logging.debug("About to download " + record['url_path']) logging.debug("Fagment size is %d" % chunksize) bits.download(protocol,record['ip'] + ":80" , record['url_path'] + '.vhd' ,dest, record['username'], record['password'], chunksize) vhd.diff(vhd_filename, dest) return record
def _testUploadDownload(self, vhd_filename, vdi_mb): #Setup record for the VDI we're wanting to download record = put_vhd(self, vhd_filename, vdi_mb, self.VDI_RAW) protocol = "http" dest = "download-%s.vhd" % (vdi_mb) logging.debug("About to download " + record['url_path']) bits.download(protocol,record['ip'] + ":80" , record['url_path'] ,dest, record['username'], record['password']) vhd.diff(vhd_filename, dest) return record
def _testUploadDownload(self, vhd_filename, vdi_mb): #Setup record for the VDI we're wanting to download record = put_vhd(self, vhd_filename, vdi_mb, self.VDI_RAW) protocol = "http" dest = "download-%s.vhd" % (vdi_mb) logging.debug("About to download " + record['url_path']) bits.download(protocol, record['ip'] + ":80", record['url_path'], dest, record['username'], record['password']) vhd.diff(vhd_filename, dest) return record
def _testUploadDownload(self, vhd_filename, vdi_mb, chunksize): record = put_vhd(self, vhd_filename, vdi_mb, self.VDI_RAW) protocol = "http" dest = "download-frag-%s.vhd" % (vdi_mb) logging.debug("About to download " + record['url_path']) logging.debug("Fagment size is %d" % chunksize) bits.download(protocol, record['ip'] + ":80", record['url_path'] + '.vhd', dest, record['username'], record['password'], chunksize) vhd.diff(vhd_filename, dest) return record
def get_metadata(): url_path = export_url_path(remote_session, remote_vm_uuid) dest = 'metadata-%s.raw' % remote_vm_uuid print ("*** SCVMM must download from %s://%s%s into %s" % (protocol, remote_netloc, url_path, dest)) if protocol == 'https': remote_host_ref = get_this_host(remote_session) ssl_cert = \ remote_session.xenapi.host.get_server_certificate(remote_host_ref) print "*** SSL cert is %s" % ssl_cert bits.download(protocol, remote_netloc, url_path, dest) print 'Got metadata file %s' % dest
def _download_disk_contents (self, disk_url, dest): protocol = disk_url.split('/')[0].split(':')[0] if '@' in disk_url: serverip = disk_url.split('/')[2].split('@')[1] (username, password) = disk_url.split('/')[2].split('@')[0].split(':') else: serverip = disk_url.split('/')[2] username = '' password = '' disk_urlpath = '/' + disk_url.split('/')[3] destloc = dest if os.path.isdir(dest): destloc = dest + disk_urlpath print 'Downloading disk %s on server %s to %s' % (disk_urlpath, serverip, destloc) bits.download(protocol, serverip, disk_urlpath, destloc, username, password)
def _download_disk_contents(self, disk_url, dest): protocol = disk_url.split('/')[0].split(':')[0] if '@' in disk_url: serverip = disk_url.split('/')[2].split('@')[1] (username, password) = disk_url.split('/')[2].split('@')[0].split(':') else: serverip = disk_url.split('/')[2] username = '' password = '' disk_urlpath = '/' + disk_url.split('/')[3] destloc = dest if os.path.isdir(dest): destloc = dest + disk_urlpath print 'Downloading disk %s on server %s to %s' % (disk_urlpath, serverip, destloc) bits.download(protocol, serverip, disk_urlpath, destloc, username, password)
def get_disks(): global total_download_time global total_download_size record_handles = expose_forest(remote_session, extra_args, [remote_vm_uuid] + all_snapshots()) try: for record_handle in record_handles: record = get_expose_record(remote_session, record_handle) print "*** SSL cert is %s" % record['ssl_cert'].replace('|', '\n') vdi_uuids = record['vdi_uuid'].split(',') if 'non_leaf_vdi_uuids' in record: vdi_uuids.extend(record['non_leaf_vdi_uuids'].split(',')) for vdi_uuid in vdi_uuids: url_full = '%s.vhd' % record['url_full_%s' % vdi_uuid] url_path = '%s.vhd' % record['url_path_%s' % vdi_uuid] dest = '%s.vhd' % vdi_uuid print ("*** SCVMM must download from %s into %s" % (url_full, dest)) if not os.access(dest, os.F_OK): start = time.time() bits.download( record['use_ssl'] == 'true' and 'https' or 'http', '%s:%s' % (record['ip'], record['port']), url_path, dest, record['username'], record['password']) end = time.time() size = os.stat(dest).st_size print ("Downloaded %d MB in %d secs = %d Mbit/s" % (int(size) >> 20, int(end - start), int(size / (end - start)) >> 17)) total_download_time += (end - start) total_download_size += size finally: for record_handle in record_handles: unexpose(remote_session, record_handle)