Enable SRM on vsphere by replacing the workflow of reading settings from cdrom with reading from attached independent disk

We run three steps to create the vmdk file as follows. Then use the created vmdk file to upload and attach to VM as independent disk.

           Convert a file with content, such as environment settings, to an iso file
                        Tool: genisoimage (ref: http://linux.die.net/man/1/genisoimage)
                        Command: `genisoimage -o #{iso_file_path} #{original_file_path}`

           Convert the iso file to one vmdk file
                        Tool: qemu-img (To install, run `sudo apt-get install qemu`)
                        Command: `qemu-img convert -O vmdk #{iso_file} #{env.vmdk}`

           Convert the vmdk file to esx type vmdk files (one descriptor file, i.e. env.vmdk and one content file, i.e. env-flat.vmdk)
                        Tools: vmware-vdiskmanager (VMware Virtual Disk Manager, ref: http://www.vmware.com/pdf/VirtualDiskManager.pdf)
                        Command: `vmware-vdiskmanager -r #{original_vmdk_file} -t 4 #{new_vmdk_file}`
Note:
You need to install qemu and vdiskmanager and make sure vdiskmanager is in your system path
Instruction on how to install vdiskmanager:
Download vdiskmanager.tar from link https://github.com/vchs/bosh/blob/wip_remove_iso_f1/stemcell_builder/stages/system_vdiskmanager/assets/vdiskmanager.tar
Then run the following commands:
tar -xvf vdiskmanager.tar
module_dir=`ls -d /lib/modules/3.*-virtual | tail -1`
install_dir="${module_dir}/vdiskmanager"
perl vmware-vix-disklib-distrib/vmware-install.pl "$install_dir"
Hi Caleb,
I don't fully understand the scenario. But when one deletes a VM through CPI, the associated folder in the datastore is deleted, including env.json and the vmdk file. I am unsure about the migration issue though.

Best Regards,
Xin Yao

From: caleb miles <notifications@github.com<mailto:notifications@github.com>>
Reply-To: cloudfoundry/bosh <reply@reply.github.com<mailto:reply@reply.github.com>>
Date: Tuesday, July 8, 2014 3:11 PM
To: cloudfoundry/bosh <bosh@noreply.github.com<mailto:bosh@noreply.github.com>>
Cc: Xin Yao <xyao@vmware.com<mailto:xyao@vmware.com>>
Subject: Re: [bosh] Enable SRM on vsphere by replacing the workflow of reading settings from cdrom with reading from attached independent disk (#581)


In bosh_vsphere_cpi/lib/cloud/vsphere/agent_env.rb:

> +
> +      module_dir = (`ls -d /lib/modules/3.*-virtual | tail -1`).strip
> +      vdiskmanager = find_bin("#{module_dir}/vdiskmanager/bin", 'vmware-vdiskmanager')
> +      output = `#{vdiskmanager} -r #{env_source_vmdk} -t 4 #{target_vmdk_file} 2>&1`
> +      fail "#{$?.exitstatus} -#{output}" if $?.exitstatus != 0
> +      target_files
> +    end
> +
> +    def set_vmdk_content(vm, location, env)
> +      @logger.info('Setting env from vmdk')
> +      env_json = JSON.dump(env)
> +
> +      vmdk_path = "[#{location[:datastore]}] #{location[:vm]}/env.vmdk"
> +      @cpi.detach_independent_disk(vm, vmdk_path, location)
> +
> +      @file_provider.upload_file(location[:datacenter],


When vm will be migrated to another datastore env.json won't be migrated. In case of ISO image we can determine location of env.json based on cdrom information about ISO since ISO is not being migrated with vm. In the case that a CDROM drive was never attached to a VM we will have no way of determining where the env.iso or env.json files are located. This will break get_current_env method and will also leave old env.json around after VM is deleted. Do you think there is a way you can determine env.json location after vm was migrated?

-
Reply to this email directly or view it on GitHub<https://urldefense.proofpoint.com/v1/url?u=https://github.com/cloudfoundry/bosh/pull/581/files%23r14683217&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=L3LUbYIHReE4mdemHaEAVA%3D%3D%0A&m=ToRxE%2FVC9v9yOgJ4hoKtGx27KgaSmd6j9nmM1eTGJbY%3D%0A&s=10f4a06848911e3d34ae073dfeffc8923fe9b78b7b7b29fb6ba94041a40cb7c0>.