VMware Cloud Community
LVSCLOUD
Contributor
Contributor

Unzip using VCO

Hi,

Does anybody have any sample code on how to unzip using VCO? I found a very promising blog post at might-virtualization, however the example is now missing.

Reply
0 Kudos
13 Replies
Andreas_Diemer
Enthusiast
Enthusiast

Sorry

I Look for my saved Code and will provide

Andreas Diemer

Senior Consultant

adiemer@vmware.com<mailto:adiemer@vmware.com>

+49 152 09359277 Mobile

+49 89 3706 17161 Office

+49 6325 988038 Fax

VMware Global, Inc. | Zweigniederlassung Deutschland | Freisinger Str. 3, 85716 Unterschleißheim

Sitz: Unterschleißheim | Amtsgericht München HRB 149743 | Geschäftsführer: Joanne Holloway, Tom Jurewicz

Amtsgericht Muenchen HRB 149743 | Geschaeftsfuehrer: Joanne Holloway, Tom Jurewicz

Hinweis:

Diese E-Mail, einschließlich sämtlicher mit Ihr übertragener Dateien, ist vertraulich und für die ausschließliche Verwendung durch die Person oder das Unternehmen vorgesehen, an die/das sie adressiert ist.

Sollten Sie diese E-Mail fälschlicherweise erhalten haben, benachrichtigen Sie bitte den Systemverwalter.

Disclaimer:

This email message is for the sole use of the intended recipient and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited.

If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.

Am 26.07.2012 um 22:00 schrieb LVSCLOUD <communities-emailer@vmware.com<mailto:communities-emailer@vmware.com>>:

VMware Communities<http://communities.vmware.com/index.jspa>

Unzip using VCO

created by LVSCLOUD<http://communities.vmware.com/people/LVSCLOUD> in Orchestrator - View the full discussion<http://communities.vmware.com/message/2083954#2083954

------ for correct and / or useful answers please award points visit http://www.vcoteam.info & http://mighty-virtualization.blogspot.com
Reply
0 Kudos
Subnet88
Enthusiast
Enthusiast

Hi Andreas,

Did you manage to find this code?

Reply
0 Kudos
Burke-
VMware Employee
VMware Employee

Wouldn't it be easier to use a command line tool that unzips files, then use the "command" object in vco to call that tool with the name of the archive to be unzipped and any other command line switches??

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
Reply
0 Kudos
Subnet88
Enthusiast
Enthusiast

That would probably work, but I want to keep my VCO appliance as close to pristine as possible.  Do you have any documentation as to what files are overwritten during an automated update of a VCO appliance? If I could be sure that no other packages would be removed, it would not be an issue to tackle this problem in this manner.

Reply
0 Kudos
mobcdi
Enthusiast
Enthusiast

Could the vix plugin which is a fling on labs.vmware.com be useful in  your case but transferring the file over the the guestvm and running a  suitable script or command there also via the vix workflow . Apologies  if I misunderstood your query

Reply
0 Kudos
Subnet88
Enthusiast
Enthusiast

Thanks for the idea Michael, but the idea is to upload am OVA file via a WAvemaker web portalm have the VCO server unzip it and feed it into the upload an ovf workflow for vCloud Director.   I could be making this whole thing over-Complex, so please tell me if you think so.

Reply
0 Kudos
tschoergez
Leadership
Leadership

Hi!

In that situation: Where is your Wavemaker frontend running?

Maybe it was another idea to let the frontend to the unzipping, and give the unzipped ova data to the workflow...
http://dev.wavemaker.com/forums/?q=node/8628
Cheers,

Joerg

Reply
0 Kudos
Subnet88
Enthusiast
Enthusiast

Unfortunately, my Java knowledge is nearly nill, and while actively developing, I do not have time to learn. When I saw the blog post with unzipping in VCO itself, I thought my issue was solved.

Reply
0 Kudos
mobcdi
Enthusiast
Enthusiast

The standard vix worflows listed when i installed the plugin seem to  operate on files, folders on guest vm's with only 1 workflow to copy a  file from vCO server to a guest but I'm just scratching the surface of  vCO so wouldn't be the best to advise you, hope more knowledgeable  members can help you out.

Reply
0 Kudos
Subnet88
Enthusiast
Enthusiast

Unfortunately nothing the VIX plugin can do for me will help.

I have been able to peacemeal together SOME code, and can successfully call the zip java class, but am unable to call the java.io.file class as there is already a file class being handled by VCO.

From vco, what would be the best method to create a file, and write to the file from a java stream?

below is my current code

I currently fail on "destinationFilePath =  new java.io.File(zipPath,entry.getName());" with "TypeError: [JavaPackage java.io.File] is not a function, it is org.mozilla.javascript.NativeJavaPackage."

               
           
                        /*
                         * STEP 1 : Create directory with the name of the zip file
                         *
                         * For e.g. if we are going to extract c:/demo.zip create c:/demo
                         * directory where we can extract all the zip entries
                         *
                         */
var length = strZipFile.length
                        var fSourceZip = new File(strZipFile);
                        var zipPath = strZipFile.substr(0, length-4);
                        var temp = new File(zipPath);
                        temp.createDirectory();
                        System.log(zipPath + " created");
                      
                        /*
                         * STEP 2 : Extract entries while creating required
                         * sub-directories
                         *
                         */
                        var zipFile = java.util.zip.ZipFile(strZipFile);
System.log("Called zip java class")
                        var e = zipFile.entries();
                      
                        while(e.hasMoreElements())
                        {
                                var entry = e.nextElement();
                                destinationFilePath =  new java.io.File(zipPath,entry.getName());
                                //create directories if required.
                                destinationFilePath.getParentFile().mkdirs();
                              
                                //if the entry is directory, leave it. Otherwise extract it.
                                if(entry.isDirectory())
                                {
                                        continue;
                                }
                                else
                                {
                                        System.log("Extracting " + destinationFilePath);
                                      
                                        /*
                                         * Get the InputStream for current entry
                                         * of the zip file using
                                         *
                                         * InputStream getInputStream(Entry entry) method.
                                         */
var stream = zipFile.getInputStream(entry)
System.log("Retrieved Stream")
                                       
                                         var CHUCK_LEN = 5 * 1024 * 1024;                                                                             
                                        var b;
var buffer
                                        /*
                                         * read the current entry from the zip file, extract it
                                         * and write the extracted file.
                                         */
                                        fos = new java.io.FileOutputStream(destinationFilePath);
                                        bos = new java.io.BufferedOutputStream(fos,1024);
                                        while ((b = bis.read(buffer, 0, 1024)) != -1) {
                                                        bos.write(buffer, 0, b);
                                        }
                                      
                                        //flush the output stream and close it.
                                        bos.flush();
                                        bos.close();
                                      
                                        //close the input stream.
                                        bis.close();
                                }
                        }
               
               
              
       

Reply
0 Kudos
cdecanini_
VMware Employee
VMware Employee

Not sure if this is going to help you but the VMware Lifecycle Manager Application has a plug-in with the scripting objects to unzip. (zipreader) The issue is of course that LCM has is EOL and I am not sure it can be found anywhere.

This was added to LCM because it was missing in vCO (Back then it was a quick fix for the LCM team to add it instead of requesting a feature in vCO and wait for the next release).

I can talk with the VCO product manager about bringing this feature in vCO but it will not help you as the next vCO release has been frozen.

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
Reply
0 Kudos
Subnet88
Enthusiast
Enthusiast

Thanks Christophe,

It would be great if you could put that feature request in for me.

In the mean time,  Would you be able to reach out internally to see if anybody else has had to come up with a work-around?

Reply
0 Kudos
cdecanini_
VMware Employee
VMware Employee

I have located LCM vmoapp files here: https://my.vmware.com/web/vmware/details?productId=32&downloadGroup=VLCM120

The problem is I do not know how you can get a license number for it. If it is still possible to get one (i.e eval license) here is the process:

[if you could not source a LCM license the plug-in will not be installed when restarting the server]

  • Download.
  • (No need of installing the vmoapp file since it will contain a lot of things you do not need)
  • Rename the vmoapp .zip
  • Unzip
  • In the configurator install vmware-vmosdk-lcm.dar
  • Select Same as vCO for the plug-in config (this will create a bunch of tables in your vCO database - alternatively you can set a different one)
  • In the licenses tab, go to the plug-in license and enter the LCM serial number.
  • Restart the server.

Screen shot 2012-08-23 at 2.11.10 PM.png

Next week I will be at VMworld and will discuss the inclusion of this feature in the next next vCO release with the product Manager.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
Reply
0 Kudos