LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 07-15-2018, 01:18 PM   #1
jettwa2001
Member
 
Registered: Dec 2007
Posts: 54

Rep: Reputation: 16
Red face kvm vm clobe


Not sure how to continue script stop and I'm new to scripting

#!/bin/bash
#: description : This script will create a template from source vm and then clone the to a new hypervisor.

#: Note : This script assume that vm's location is /images and user name and password for both hypervisor is XXXX XXXX


cd /images

virsh list --all

#read -p 'Please enter source vm FULL NAME from the above list: '

echo -n 'Please enter source vm from the above list: '
read source
echo "This is the source vm ${source}!!!"

virsh suspend $source

cp_source=`echo $source | cut -d - -f -4`

cp -p /images/$cp_source/*.img /images/$cp_source/template.img.`date +%Y.%m.%d.%H.%M.%S`[/CODE]
 
Old 07-15-2018, 03:55 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,710

Rep: Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972
Quote:
Originally Posted by jettwa2001 View Post
Not sure how to continue script stop and I'm new to scripting
Code:
#!/bin/bash
#: description  : This script will create a template from source vm and then clone the to a new hypervisor.
#: Note         : This script assume that vm's location is /images and user name and password for both hypervisor is XXXX XXXX

cd /images

virsh list --all

#read -p 'Please enter source vm FULL NAME from the above list: '

echo -n 'Please enter source vm from the above list: '
read source
echo "This is the source vm ${source}!!!"

virsh suspend $source

cp_source=`echo $source | cut -d - -f -4`

cp -p /images/$cp_source/*.img /images/$cp_source/template.img.`date +%Y.%m.%d.%H.%M.%S`
Confused by your post:
  • The sentence "Not sure how to continue script stop and I'm new to scripting" makes little sense. What are you asking?
  • You're 'new to scripting'??? You were posting about scripts SEVEN YEARS AGO. Seven years of experience (along with being a member here for ELEVEN YEARS), says you're not a 'newbie'.
  • You say you have two Red Hat 'certifications'....and scripting is part of the tests.
Please clarify your question; what isn't your script doing that you WANT it to do?
 
Old 07-16-2018, 01:15 AM   #3
jettwa2001
Member
 
Registered: Dec 2007
Posts: 54

Original Poster
Rep: Reputation: 16
Hi,

you are right it's a bit confusing so let me make it clear, When finish learning school about 8 years ago I couldn't find a job in the linux platform what I did find was a job a IT microsoft sys admin.

Only about 7 months ago I started a job as a linux Junior sys admin that's why I don't have enough experience, the fact that I have the cert it's but without experience not much I can do with them(Maybe it's better to take off my profile)

back to my issue I posted it late last night and was very frustrated and tired, what I'm trying to achieve is vm clone from one hypervisor to another.

My source vm's have been installed from pxe which maintain by a different team all of my vm's name look like this:

6 lab-it-test1-002-RH-8.0 running
14 lab-it-test1-012-RH-7.4 paused

Image dir look as follow:

drwxr-xr-x 2 root root 4096 Jul 11 09:47 lab-it-test1-002
drwxr-xr-x 2 root root 4096 Jul 15 09:28 lab-it-test1-012

this morning I found out that the space I have in this line before the "-4" cause the script to stop: cp_source=`echo $source | cut -d - -f -4`

Thx for you comment any tip on how to continue will be great.

in general my plan is to suspend the source vm, cp to create a template, resume source vm, sysprep my template with virt-sysprep, ssh to new hypervisor create new destination dir under /images, scp to old hypervisor and cp my template, setup my hostname + networking and install new vm using virt-install


Thx again and sorry for the confusion.
 
Old 07-16-2018, 07:35 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,710

Rep: Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972
Quote:
Originally Posted by jettwa2001 View Post
Hi,
you are right it's a bit confusing so let me make it clear, When finish learning school about 8 years ago I couldn't find a job in the linux platform what I did find was a job a IT microsoft sys admin. Only about 7 months ago I started a job as a linux Junior sys admin that's why I don't have enough experience, the fact that I have the cert it's but without experience not much I can do with them(Maybe it's better to take off my profile)
And none of that changes the fact that you have two 'certifications', and have been working with Linux for 7 months.
Quote:
back to my issue I posted it late last night and was very frustrated and tired, what I'm trying to achieve is vm clone from one hypervisor to another. My source vm's have been installed from pxe which maintain by a different team all of my vm's name look like this:

6 lab-it-test1-002-RH-8.0 running
14 lab-it-test1-012-RH-7.4 paused

Image dir look as follow:

drwxr-xr-x 2 root root 4096 Jul 11 09:47 lab-it-test1-002
drwxr-xr-x 2 root root 4096 Jul 15 09:28 lab-it-test1-012

this morning I found out that the space I have in this line before the "-4" cause the script to stop: cp_source=`echo $source | cut -d - -f -4`
Ok, so 'stop' with what error?? Did you read the man page for the command? Try to enter it manually on the command line to see if it works??? These are basic troubleshooting steps.
Quote:
Thx for you comment any tip on how to continue will be great. in general my plan is to suspend the source vm, cp to create a template, resume source vm, sysprep my template with virt-sysprep, ssh to new hypervisor create new destination dir under /images, scp to old hypervisor and cp my template, setup my hostname + networking and install new vm using virt-install Thx again and sorry for the confusion.
You need to read the LQ Rules about text-speak and not using it.
 
Old 07-19-2018, 09:38 AM   #5
jettwa2001
Member
 
Registered: Dec 2007
Posts: 54

Original Poster
Rep: Reputation: 16
thx I'm able to continue
I had a space issue
 
Old 07-19-2018, 09:51 AM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,710

Rep: Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972
Quote:
Originally Posted by jettwa2001 View Post
thx I'm able to continue I had a space issue
Great; and **AGAIN** you need to not use text-speak; AGAIN, read the LQ Rules. It's "thanks" not "thx"
 
  


Reply



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
firewalld help: trying to forward https from kvm host to kvm guest on same port GaWdLy Linux - Networking 4 07-15-2016 02:27 PM
[SOLVED] "No KVM, No qemu-kvm" Available error while trying to install KVM on CentOS 6.3 sriramdas Linux - Virtualization and Cloud 5 01-01-2013 10:46 AM
[SOLVED] Centos 6 and KVM - how to setup bridged networking in KVM in a -Class B- environment? rylan76 Linux - Virtualization and Cloud 7 11-07-2012 06:46 AM
LXer: Implementation Qemu-kvm 0.15.0, SpiceServer and Spice-Gtk-0.7 on Ubuntu 11.10 KVM Server the m LXer Syndicated Linux News 0 08-30-2011 04:40 PM
[Debian/Qemu/KVM] Why qemu --enable-kvm works but not kvm directly? gb2312 Linux - Virtualization and Cloud 2 03-21-2011 02:05 PM

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

All times are GMT -5. The time now is 12:48 AM.

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
Open Source Consulting | Domain Registration