Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 469122009DC for ; Tue, 2 May 2017 14:36:03 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 451AA160BAC; Tue, 2 May 2017 12:36:03 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 64316160BA1 for ; Tue, 2 May 2017 14:36:02 +0200 (CEST) Received: (qmail 26032 invoked by uid 500); 2 May 2017 12:36:01 -0000 Mailing-List: contact dev-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list dev@cloudstack.apache.org Received: (qmail 26020 invoked by uid 99); 2 May 2017 12:36:01 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 May 2017 12:36:01 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id B230BC0254 for ; Tue, 2 May 2017 12:36:00 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.285 X-Spam-Level: X-Spam-Status: No, score=-0.285 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-2.796, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001, T_REMOTE_IMAGE=0.01, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id NKmFTWguRzyZ for ; Tue, 2 May 2017 12:35:58 +0000 (UTC) Received: from mail-io0-f172.google.com (mail-io0-f172.google.com [209.85.223.172]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id E8F635F4A7 for ; Tue, 2 May 2017 12:35:57 +0000 (UTC) Received: by mail-io0-f172.google.com with SMTP id r16so157946269ioi.2 for ; Tue, 02 May 2017 05:35:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to; bh=+Htjh2yfogvr2K6j70QjaW//pn16GLhHLJns3f90uy4=; b=oXFeDAw6A078Y8UWfj98PZXNpM88QORYD0DYbLrk3M9TCxBptpT102egC5LxypE0Ei hwD0qbEDqC+aB3I0Dpnx4ei/+JXOiIq4b4SFX2TFqfcWgx+Ar5QTNaXRcJfilPh+VOSK FJpXoNc9kIGYwSSN2dNYMdJ1L/0CeFd3cAMjw+jDA05LzUu89MaHuIBimQEFkDuvl1Fl 6rUL1uoTZC5c+19cRxkUaI2kqhIFJay4ZCkajyQhTjciM8Lo7eDGehOgTdoZFE9qypLB +0gtr7ytKwlJjRE8AGsOoprXDV8AjCBqIKz4mp5ZxhrXlqvpom0ONS6Ga31OwqK0rM3i E04Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to; bh=+Htjh2yfogvr2K6j70QjaW//pn16GLhHLJns3f90uy4=; b=cv1myFa5ArboL4psANzXRGO4P8qKSmQa6R2Na57iI1TmdgICe3W+eeN3biIMHqgjNB RumTkuvZPtPssAwET6k3NcEE73eglFM3AzWriB8XOwhCXI4SZrN47hPOD0L+4QmzClfT qCb2F9f7HYlmZifKpfO8Gyi+AKcKpBLwtXjsAfiPBOv3AQwFFvsjozep3yMU4aDZhIDT idrOUVd7Y2lcv6s9IJNBOIKyJKfmo1fVmObbL9Z5wZ7M2Tgv8eIdoQ69skg3Ab5hwSG0 mI7L0FUbJmWBu18fetsXkJUkpRmiZc8aviutwokaPoeRlSNRSoAMl6x+SpUuvmNhQTlX Hm9Q== X-Gm-Message-State: AN3rC/67+x6DwW/eXcMxcIgjoLUVOyd9pbP6olaxeOgtvrGKW7TgKFTj bb5g1fmhSaTcf2cwhdh7mIigodJUV99E X-Received: by 10.157.3.78 with SMTP id 72mr10993205otv.118.1493728557206; Tue, 02 May 2017 05:35:57 -0700 (PDT) MIME-Version: 1.0 Sender: williamstevens@gmail.com Received: by 10.182.125.133 with HTTP; Tue, 2 May 2017 05:35:56 -0700 (PDT) In-Reply-To: References: From: Will Stevens Date: Tue, 2 May 2017 08:35:56 -0400 X-Google-Sender-Auth: pcEowpgZoe5K2771w2nhO5ihKJg Message-ID: Subject: Re: ovf file parser To: "dev@cloudstack.apache.org" Content-Type: multipart/alternative; boundary=94eb2c03863e0b15b6054e89c864 archived-at: Tue, 02 May 2017 12:36:03 -0000 --94eb2c03863e0b15b6054e89c864 Content-Type: text/plain; charset=UTF-8 Hey Abhinandan, First, can you give us a bit more context regarding what you are doing so we can highlight potential areas to watch out for? I have done some OVF parsing/modification and there are a bunch of gotchas to be aware of. I will try to outline some of the ones I found. I have not tried to use the vim25.jar, so I can't really help on that front. In my use case, I was exporting VMs via the ovftool from a source VMware environment, and I was migrating them to an ACS managed VMware environment. In doing so, I also wanted to support VMs with multiple disks using a Root volume and multiple Data volumes, as well as change the nic type (vmxnet3), assign static IPs, etc... I have not had the time to open source my migration tool, but it is on my todo list. My general flow was: - Export the VM with ovftool - Extract the resulting OVA into its parts (OVF, VMDKs, Manifest) - Duplicate the OVF file, once per VMDK - Modify a OVF file to be specific for each of the VMDKs (one OVF per VMDK) - Take each VMDK and the corresponding OVF and recompress them back into an OVA - Treat the first OVA as a template and the rest as data disks My initial (naive) approach was to just treat the OVF as a well behaved XML file and use standard XML libs (in my case in Python) to parse and manipulate the OVF file. This approach had a few pitfalls which I will outline here. VMware is VERY picky about the format of the OVF file, if the file is not perfect, VMware won't import it (or at least the VM won't launch). There were two main items which caused me issues. a) The tag MUST have all of the namespace definitions even if they are not used in the file. This is something that most XML parsers are confused by. Most XML parsers will only include the namespaces used in the file when the file is saved. I had to ensure that the resulting OVF files had all of the original namespace definitions for the file to import correctly. If I remember correctly, they even had to be in the right order. I did this by changing the resulting file after saving it with the XML lib. b) VMware uses namespaces which actually collide with each other. For example, both the default namespace and the 'ovf' namespace share the same URL. Again, XML libraries don't understand this, so I had to manage that manually. Luckily, the way VMware handles these namespaces is relatively consistent, so I was able to find a workaround. Basically, the default namespace will apply to all of the elements, and the 'ovf' namespace will be applied only in the attributes. Because of this I was able to just use the 'ovf' namespace and then after exporting the file, I did a find replace from ' On Tue, May 2, 2017 at 3:49 AM, Abhinandan Prateek < abhinandan.prateek@shapeblue.com> wrote: > Hello, > > I am looking at vim25.jar to put together ovftool like functionality > specially around parsing and generating OVF files. vim25.jar is already > included as non-oss dependency and used by vmware hypervisor plugin. I see > that some OVF parsing capabilities are present in this jar, but it seems to > be tied to host connection/context. Can anyone who has used this can tell > me if I can use it as a standalone OVF manipulation api any pointer to good > resource on that will be nice. > > Regards, > -abhi > > > > abhinandan.prateek@shapeblue.com > www.shapeblue.com > 53 Chandos Place, Covent Garden, London WC2N 4HSUK > @shapeblue > > > > --94eb2c03863e0b15b6054e89c864--