1 | {"version":3,"file":"ova-read.js","names":["_assert","_interopRequireDefault","require","_find","_forEach","_pako","_sum","_xml2js","_interopRequireWildcard","_","_util","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","obj","MEMORY_UNIT_TO_FACTOR","k","m","g","RESOURCE_TYPE_TO_HANDLER","data","VirtualQuantity","nCpus","AllocationUnits","unit","quantity","memory","allocationUnitsToFactor","networks","AutomaticAllocation","enabled","Connection","name","push","disks","Address","address","AddressOnParent","position","Description","description","ElementName","Caption","caption","HostResource","resource","diskId","match","disk","undefined","parsed","replace","length","substring","split","fromEntries","map","couple","target","descriptionLabel","nameLabel","console","error","parseTarHeader","header","stringDeserializer","fileName","slice","sizeBuffer","fileSize","Uint8Array","byte","parseInt","ParsableFile","start","end","read","exports","ensureArray","value","Array","isArray","intValue","Math","pow","charAt","toLowerCase","cleanDisks","usedPositions","Set","nextPosition","keys","warn","add","parseOVF","fileFragment","xmlString","Promise","resolve","reject","xml2js","parseString","mergeAttrs","explicitArray","tagNameProcessors","processors","stripPrefix","attrNameProcessors","err","res","Envelope","DiskSection","Disk","References","File","files","VirtualSystem","system","hardware","VirtualHardwareSection","System","VirtualSystemIdentifier","AnnotationSection","Annotation","OperatingSystemSection","forEach","file","find","id","fileRef","capacityAllocationUnits","capacity","path","href","compression","handleItem","item","handler","ResourceType","Item","StorageItem","EthernetPortItem","GZIP_CHUNK_SIZE","parseGzipFromEnd","fileSlice","l","chunks","savedSize","currentDeflatedPos","inflate","pako","Inflate","compressed","Z_SYNC_FLUSH","chunk","result","pos","buffer","shift","resultBuffer","sum","c","index","parseOVAFile","parsableFile","skipVmdk","offset","HEADER_SIZE","tables","startsWith","endsWith","readFile","suppressUnhandledRejection","readVmdkGrainTable","forwardsInflater","parseGzipFromStart","resultStart","strm","total_out","isLast","total_in","assert","strictEqual","byteLength","ceil"],"sources":["../src/ova-read.js"],"sourcesContent":["import assert from 'assert'\nimport find from 'lodash/find'\nimport forEach from 'lodash/forEach'\nimport pako from 'pako'\nimport sum from 'lodash/sum'\nimport xml2js, { processors } from 'xml2js'\n\nimport { readVmdkGrainTable } from '.'\nimport { suppressUnhandledRejection } from './util'\n\n/********\n *\n * THIS FILE HAS TO WORK IN BOTH THE BROWSER AND NODE\n *\n ********/\n\n// See: http://opennodecloud.com/howto/2013/12/25/howto-ON-ovf-reference.html\n// See: http://www.dmtf.org/sites/default/files/standards/documents/DSP0243_1.0.0.pdf\n// See: http://www.dmtf.org/sites/default/files/standards/documents/DSP0243_2.1.0.pdf\n\nconst MEMORY_UNIT_TO_FACTOR = {\n k: 1024,\n m: 1048576,\n g: 1073741824,\n t: 1099511627776,\n}\nconst RESOURCE_TYPE_TO_HANDLER = {\n // CPU.\n 3: (data, { VirtualQuantity: nCpus }) => {\n data.nCpus = +nCpus\n },\n // RAM.\n 4: (data, { AllocationUnits: unit, VirtualQuantity: quantity }) => {\n data.memory = quantity * allocationUnitsToFactor(unit)\n },\n // Network.\n 10: ({ networks }, { AutomaticAllocation: enabled, Connection: name }) => {\n if (enabled) {\n networks.push(name)\n }\n },\n // Disk.\n 17: (\n { disks },\n {\n Address: address,\n AddressOnParent: position,\n Description: description = 'No description',\n ElementName: name,\n // OVA 2.0 uses caption\n Caption: caption = name,\n HostResource: resource,\n }\n ) => {\n const diskId = resource.match(/^(?:ovf:)?\\/disk\\/(.+)$/)\n const disk = diskId && disks[diskId[1]]\n if (position === undefined && address !== undefined) {\n // remove blanks\n let parsed = address.replace(/\\s+/g, '')\n // expecting \"{type=drive,bus=0,controller=0,target=0,unit=0}\"\n if (parsed[0] === '{' && parsed[parsed.length - 1] === '}') {\n parsed = parsed.substring(1, parsed.length - 1)\n // \"type=drive,bus=0,controller=0,target=0,unit=0\"\n parsed = parsed.split(',')\n // [\"type=drive\", \"bus=0\", \"controller=0\", \"target=0\", \"unit=0\"]\n parsed = Object.fromEntries(parsed.map(couple => couple.split('=')))\n // {type:\"drive\", bus:\"0\", controller:\"0\", target:\"0\",unit:\"0\"]\n // 'target' seems to be the field we want\n // https://www.ibm.com/support/knowledgecenter/linuxonibm/com.ibm.linux.z.ldva/ldva_r_XML_addressHostdev.html\n if ('target' in parsed) {\n position = +parsed.target\n }\n }\n }\n if (position === undefined) {\n position = 0\n }\n if (disk) {\n disk.descriptionLabel = description\n disk.nameLabel = caption\n disk.position = +position\n } else {\n // TODO: Log error in U.I.\n console.error(`No disk found: '${diskId}'.`)\n }\n },\n}\n\nfunction parseTarHeader(header, stringDeserializer) {\n const fileName = stringDeserializer(header.slice(0, 100), 'ascii').split('\\0')[0]\n if (fileName.length === 0) {\n return null\n }\n const sizeBuffer = header.slice(124, 124 + 12)\n // size encoding: https://codeistry.wordpress.com/2014/08/14/how-to-parse-a-tar-file/\n let fileSize = 0\n // If the leading byte is 0x80 (128), the non-leading bytes of the field are concatenated in big-endian order,\n // with the result being a positive number expressed in binary form.\n //\n // Source: https://www.gnu.org/software/tar/manual/html_node/Extensions.html\n if (new Uint8Array(sizeBuffer)[0] === 128) {\n for (const byte of new Uint8Array(sizeBuffer.slice(1))) {\n fileSize *= 256\n fileSize += byte\n }\n } else {\n fileSize = parseInt(stringDeserializer(sizeBuffer.slice(0, 11), 'ascii'), 8)\n }\n\n return { fileName, fileSize }\n}\n\nexport class ParsableFile {\n /** returns a ParsableFile */\n slice(start, end) {}\n\n /** reads the fragment, returns an ArrayBuffer */\n async read() {}\n}\n\nexport const ensureArray = value => {\n if (value === undefined) {\n return []\n }\n\n return Array.isArray(value) ? value : [value]\n}\n\nconst allocationUnitsToFactor = unit => {\n const intValue = unit.match(/\\^([0-9]+)$/)\n return intValue != null ? Math.pow(2, intValue[1]) : MEMORY_UNIT_TO_FACTOR[unit.charAt(0).toLowerCase()]\n}\n\nconst cleanDisks = disks => {\n const usedPositions = new Set()\n let nextPosition = Object.keys(disks).length\n for (const diskId in disks) {\n let position = disks[diskId].position\n if (position == null) {\n // TODO: Log error in U.I.\n console.error(`No position specified for '${diskId}'.`)\n delete disks[diskId]\n } else {\n if (usedPositions.has(position)) {\n console.warn(\n `There is at least two disks with position ${position}, we're changing the second one to ${nextPosition}`\n )\n disks[diskId].position = position = nextPosition\n nextPosition++\n }\n usedPositions.add(position)\n }\n }\n}\n\nexport async function parseOVF(fileFragment, stringDeserializer) {\n const xmlString = stringDeserializer(await fileFragment.read(), 'utf-8')\n return new Promise((resolve, reject) =>\n xml2js.parseString(\n xmlString,\n {\n mergeAttrs: true,\n explicitArray: false,\n tagNameProcessors: [processors.stripPrefix],\n attrNameProcessors: [processors.stripPrefix],\n },\n (err, res) => {\n if (err) {\n reject(err)\n return\n }\n\n const {\n Envelope: {\n DiskSection: { Disk: disks },\n References: { File: files },\n VirtualSystem: system,\n },\n } = res\n\n const data = {\n disks: {},\n networks: [],\n }\n const hardware = system.VirtualHardwareSection\n\n // Get VM name/description.\n data.nameLabel = hardware.System.VirtualSystemIdentifier\n data.descriptionLabel =\n (system.AnnotationSection && system.AnnotationSection.Annotation) ||\n (system.OperatingSystemSection && system.OperatingSystemSection.Description)\n\n // Get disks.\n forEach(ensureArray(disks), disk => {\n const file = find(ensureArray(files), file => file.id === disk.fileRef)\n const unit = disk.capacityAllocationUnits\n\n data.disks[disk.diskId] = {\n capacity: disk.capacity * ((unit && allocationUnitsToFactor(unit)) || 1),\n path: file && file.href,\n compression: file && file.compression,\n }\n })\n // Get hardware info: CPU, RAM, disks, networks...\n const handleItem = item => {\n const handler = RESOURCE_TYPE_TO_HANDLER[item.ResourceType]\n if (!handler) {\n return\n }\n handler(data, item)\n }\n forEach(ensureArray(hardware.Item), handleItem)\n forEach(ensureArray(hardware.StorageItem), handleItem)\n forEach(ensureArray(hardware.EthernetPortItem), handleItem)\n // Remove disks which not have a position.\n // (i.e. no info in hardware.Item section.)\n cleanDisks(data.disks)\n resolve(data)\n }\n )\n )\n}\n\nconst GZIP_CHUNK_SIZE = 4 * 1024 * 1024\n\n// start and end are negative numbers\n// used with streamOptimized format where only the footer has the directory address filled\nasync function parseGzipFromEnd(start, end, fileSlice, header) {\n const l = end - start\n const chunks = []\n let savedSize = 0\n let currentDeflatedPos = 0\n const inflate = new pako.Inflate()\n while (currentDeflatedPos < header.fileSize) {\n const slice = fileSlice.slice(currentDeflatedPos, currentDeflatedPos + GZIP_CHUNK_SIZE)\n const compressed = await slice.read()\n inflate.push(compressed, pako.Z_SYNC_FLUSH)\n const chunk = inflate.result.slice()\n chunks.push({ pos: currentDeflatedPos, buffer: chunk })\n savedSize += chunk.length\n if (savedSize - chunks[0].buffer.length >= l) {\n savedSize -= chunks[0].buffer.length\n chunks.shift()\n }\n currentDeflatedPos += GZIP_CHUNK_SIZE\n }\n let resultBuffer = new Uint8Array(sum(chunks.map(c => c.buffer.length)))\n let index = 0\n chunks.forEach(c => {\n resultBuffer.set(c.buffer, index)\n index += c.buffer.length\n })\n resultBuffer = resultBuffer.slice(start, end)\n return resultBuffer.buffer\n}\n\n/**\n *\n * @param parsableFile: ParsableFile\n * @param stringDeserializer function (ArrayBuffer, encoding) => String\n * @param skipVmdk if true avoid parsing the VMDK file tables\n * @returns {Promise<{tables: {}}>}\n */\nexport async function parseOVAFile(parsableFile, stringDeserializer, skipVmdk = false) {\n let offset = 0\n const HEADER_SIZE = 512\n let data = { tables: {} }\n while (true) {\n const header = parseTarHeader(await parsableFile.slice(offset, offset + HEADER_SIZE).read(), stringDeserializer)\n offset += HEADER_SIZE\n if (header === null) {\n break\n }\n const fileSlice = parsableFile.slice(offset, offset + header.fileSize)\n fileSlice.fileName = header.fileName\n if (!(header.fileName.startsWith('PaxHeader/') || header.fileName.startsWith('.'))) {\n if (header.fileName.toLowerCase().endsWith('.ovf')) {\n const res = await parseOVF(fileSlice, stringDeserializer)\n data = { ...data, ...res }\n }\n if (!skipVmdk && header.fileName.toLowerCase().endsWith('.vmdk')) {\n const readFile = async (start, end) => fileSlice.slice(start, end).read()\n readFile.fileName = header.fileName\n data.tables[header.fileName] = suppressUnhandledRejection(readVmdkGrainTable(readFile))\n }\n }\n if (!skipVmdk && header.fileName.toLowerCase().endsWith('.vmdk.gz')) {\n let forwardsInflater = new pako.Inflate()\n\n const readFile = async (start, end) => {\n // if next read is further down the stream than previous read, re-uses the previous zstream\n async function parseGzipFromStart(start, end, fileSlice) {\n const chunks = []\n const resultStart = () => forwardsInflater.strm.total_out - forwardsInflater.result.length\n if (forwardsInflater.result != null && start < resultStart()) {\n // the block we are reading starts before the last decompressed chunk, reset stream\n forwardsInflater = new pako.Inflate()\n }\n let isLast = false\n while (true) {\n if (forwardsInflater.strm.total_out > start) {\n let chunk = forwardsInflater.result\n if (resultStart() < start) {\n chunk = chunk.slice(start - resultStart())\n }\n if (forwardsInflater.strm.total_out > end) {\n chunk = chunk.slice(0, -(forwardsInflater.strm.total_out - end))\n isLast = true\n }\n chunks.push(chunk)\n }\n if (isLast) {\n // don't move the stream forwards if we took our last chunk\n // gives the next read operation an opportunity to read from the same position\n break\n }\n const slice = fileSlice.slice(\n forwardsInflater.strm.total_in,\n forwardsInflater.strm.total_in + GZIP_CHUNK_SIZE\n )\n forwardsInflater.push(await slice.read(), pako.Z_SYNC_FLUSH)\n }\n const resultBuffer = new Uint8Array(sum(chunks.map(c => c.length)))\n let index = 0\n chunks.forEach(c => {\n resultBuffer.set(c, index)\n index += c.length\n })\n assert.strictEqual(resultBuffer.buffer.byteLength, end - start)\n return resultBuffer.buffer\n }\n\n if (start === end) {\n return new Uint8Array(0)\n }\n if (start >= 0 && end >= 0) {\n return parseGzipFromStart(start, end, fileSlice)\n } else if (start < 0 && end < 0) {\n return parseGzipFromEnd(start, end, fileSlice, header)\n }\n }\n readFile.fileName = header.fileName\n data.tables[header.fileName] = suppressUnhandledRejection(readVmdkGrainTable(readFile))\n }\n offset += Math.ceil(header.fileSize / 512) * 512\n }\n return data\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,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