LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices


Reply
  Search this Thread
Old 04-27-2017, 02:01 AM   #1
devUnix
Member
 
Registered: Oct 2010
Posts: 606

Rep: Reputation: 59
vSphere / ESXi - Renaming Directory Names in Data-Store and Moving things around in Data-Store


Hi,


There is this VMWare suite in our infrastructure. vSphere 6.0 is being used.

I have been assigned this task:

A VM running RHEL 6 needs to be migrated to a new VM that will have RHEL 7.

This needs done automatically from within a Shell Script (Bash, for instance). We cannot delete the existing VM and its associated disks. We need to create the new VM with the same name and in the same Data-Store and in the same Path/Directory where the current VM is lying.
---

I have prepared the steps with the commands. However, I am stuck at this stage:

When I create a New VM with the Same Name as the Existing VM's Name, I am manually renaming the Old VM from "ExampleHost" to "ExampleHost-Pre-Upgrade".

Then I am deploying the OVF. As the name is already existing in the Data-Store and in the directory/path, it automatically renames the path from "ExampleHost" to "ExampleHost_1/ExampleHost.vmdk".

That "_1" part is a problem.

We also have 3 Additional Disks:
  1. ExampleHost-backup.vmdk
  2. ExampleHost-log.vmdk
  3. ExampleHost-x.vmdk

So their existing path / directory names (or Disk File Names) are:
  1. ExampleHost/ExampleHost-backup.vmdk
  2. ExampleHost/ExampleHost-log.vmdk
  3. ExampleHost/ExampleHost-x.vmdk

I have been asked to move only the existing ExampleHost-backup.vmdk from the Old VM to the New VM. I am able to do it as the disk file name with the path name remains the same as before: "ExampleHost/ExampleHost-backup.vmdk" so I can simply detach it from the old one and attach it to the new one.

However, I need to create the rest 2 disks afresh with the same name/path. This will not be allowed as there are already disk file names there.

So, how to rename the VM from a command-line such that the VM's Name gets changed to "*-Pre-Upgrade" and also its disk file names get changed to "ExampleHost/Pre-Upgrade-ExampleHost-log.vmdk" similarly for "ExampleHost/Pre-Upgrade-ExampleHost-x.vmdk".

Please note: I mentioned above: That "_1" part is a problem.

So, I have been asked to make sure that the new disk file name/path with the containing directory name remains the same as before: ExampleHost/ExampleHost.vmdk. There must not be an underscore "_" appended to the directory name as in: ExampleHost_1/ExampleHost.vmdk. So, we do need to rename the old root disk file name first to ExampleHost-Pre-Upgrade/ExamExampleHost.vmdk before deploying the OVF. So that I can easily add the New Disks in "ExampleHost/" as this will not contain the other 3 disks.

So, we need to first rename the old VM Name to something else and also Change the Path/Directory Name so that the new Path / Directory Name will be the same as the old one.

My second problem is also related and is as follows:

I need to fetch information on the Path / Directory where the VM is currently deployed so that the new VM can be deployed in the same path/directory when I deploy the OVF from the command line.


Please note that using the GUI, I am able to achieve all that, but I need a command line approach here because I need to write a script to do it all automatically. The end user will only input these 2 things:

Host Name (which is same as the VM Name)
IP Address

I need to take care of the rest of the things from within a Bash Script.
 
Old 04-27-2017, 09:13 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 22,316

Rep: Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017
Quote:
Originally Posted by devUnix View Post
Hi,
There is this VMWare suite in our infrastructure. vSphere 6.0 is being used. I have been assigned this task:

A VM running RHEL 6 needs to be migrated to a new VM that will have RHEL 7.

This needs done automatically from within a Shell Script (Bash, for instance). We cannot delete the existing VM and its associated disks. We need to create the new VM with the same name and in the same Data-Store and in the same Path/Directory where the current VM is lying.
---
I have prepared the steps with the commands. However, I am stuck at this stage:

When I create a New VM with the Same Name as the Existing VM's Name, I am manually renaming the Old VM from "ExampleHost" to "ExampleHost-Pre-Upgrade".

Then I am deploying the OVF. As the name is already existing in the Data-Store and in the directory/path, it automatically renames the path from "ExampleHost" to "ExampleHost_1/ExampleHost.vmdk". That "_1" part is a problem. We also have 3 Additional Disks:
  1. ExampleHost-backup.vmdk
  2. ExampleHost-log.vmdk
  3. ExampleHost-x.vmdk
So their existing path / directory names (or Disk File Names) are:
  1. ExampleHost/ExampleHost-backup.vmdk
  2. ExampleHost/ExampleHost-log.vmdk
  3. ExampleHost/ExampleHost-x.vmdk
I have been asked to move only the existing ExampleHost-backup.vmdk from the Old VM to the New VM. I am able to do it as the disk file name with the path name remains the same as before: "ExampleHost/ExampleHost-backup.vmdk" so I can simply detach it from the old one and attach it to the new one. However, I need to create the rest 2 disks afresh with the same name/path. This will not be allowed as there are already disk file names there.

So, how to rename the VM from a command-line such that the VM's Name gets changed to "*-Pre-Upgrade" and also its disk file names get changed to "ExampleHost/Pre-Upgrade-ExampleHost-log.vmdk" similarly for "ExampleHost/Pre-Upgrade-ExampleHost-x.vmdk".

Please note: I mentioned above: That "_1" part is a problem.

So, I have been asked to make sure that the new disk file name/path with the containing directory name remains the same as before: ExampleHost/ExampleHost.vmdk. There must not be an underscore "_" appended to the directory name as in: ExampleHost_1/ExampleHost.vmdk. So, we do need to rename the old root disk file name first to ExampleHost-Pre-Upgrade/ExamExampleHost.vmdk before deploying the OVF. So that I can easily add the New Disks in "ExampleHost/" as this will not contain the other 3 disks.

So, we need to first rename the old VM Name to something else and also Change the Path/Directory Name so that the new Path / Directory Name will be the same as the old one.

My second problem is also related and is as follows:

I need to fetch information on the Path / Directory where the VM is currently deployed so that the new VM can be deployed in the same path/directory when I deploy the OVF from the command line. Please note that using the GUI, I am able to achieve all that, but I need a command line approach here because I need to write a script to do it all automatically. The end user will only input these 2 things:

Host Name (which is same as the VM Name)
IP Address

I need to take care of the rest of the things from within a Bash Script.
Ok...sounds simple enough. So as you've been asked many times over the years, post what you have written/done/tried, and tell us where you're stuck. This sounds VERY much (again) like a homework question. We will be happy to help you with your script(s), but again, we aren't going to write them for you.

Show us what you've done/tried and tell us where you're stuck.

::EDIT:: Sounds like more of the same from here: http://www.linuxquestions.org/questi...le-4175604216/
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Sources of Data Deluge: Why We Now Store and Analyze More Data than Ever LXer Syndicated Linux News 0 05-09-2016 04:21 PM
Best Data Structure to store data in C meenakshi.khurana Programming 7 10-18-2011 09:54 PM
How store data on Knoppix ? vinic222 Linux - Newbie 5 01-03-2008 12:22 PM
store data in / bruse Linux - Newbie 2 05-01-2005 12:28 PM
Store Data in Flash subrahmanyam Linux - Newbie 1 11-08-2004 01:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud

All times are GMT -5. The time now is 02:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration