Skip to content

Instantly share code, notes, and snippets.

@cocampbe
Created August 8, 2017 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cocampbe/f4437e6b7d666c0cd5a48cb60c795b57 to your computer and use it in GitHub Desktop.
Save cocampbe/f4437e6b7d666c0cd5a48cb60c795b57 to your computer and use it in GitHub Desktop.
Oracle VM REST API info
Found this info here: http://blog.ls-al.com/oracle-vm-ovm-rest-api/
Had trouble finding the rest calls to create a vm clone from a template.
## CloneVM failing
## The value for the argument "serverPoolId" was found to be null
def cloneVm(s,baseUri,templateVm,vmName):
repo_id=get_id_from_name(s,baseUri,'Repository','ovs1')
sp_id=get_id_from_name(s,baseUri,'ServerPool','ovs-home')
template_id=get_id_from_name(s,baseUri,'Vm',templateVm)
print 'clone {} into repo_id {:20} ServerPool Id {:55}'.format(template_id,repo_id,sp_id)
data={ "serverPoolId": sp_id,
"repositoryId": repo_id,
"createTemplate": False
}
uri='{base}/Vm/{vmId}/clone'.format(base=baseUri,vmId=template_id)
r=s.put(uri,data=json.dumps(data))
job=r.json()
print job
# wait for the job to complete
vm_id=wait_for_job(job['id']['uri'],s)
print "new vm id:" + vm_id
@divya-create
Copy link

Can you please provide me the playbook for vm clone

@cocampbe
Copy link
Author

Can you please provide me the playbook for vm clone

Try my repo

@divya-create
Copy link

divya-create commented Dec 17, 2019 via email

@divya-create
Copy link

divya-create commented Dec 17, 2019 via email

@divya-create
Copy link

divya-create commented Dec 18, 2019 via email

@cocampbe
Copy link
Author

Hi Team, Thanks, Can i use clone_vm library . I will execute this in ansible. Have you tested create clone vm from template. I am not using github..i am using ansible with awx. Is this work?

On Tue, Dec 17, 2019 at 6:38 PM Court @.***> wrote: Can you please provide me the playbook for vm clone Try my repo https://github.com/cocampbe/ansible-ovm — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://gist.github.com/f4437e6b7d666c0cd5a48cb60c795b57?email_source=notifications&email_token=AOBH73KYJZEESGE4VNNLTQLQZDFOHA5CNFSM4J3NUK2KYY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAF6B5M#gistcomment-3113942, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOBH73MYAHKRSYMEEPTURJLQZDFOHANCNFSM4J3NUK2A .
-- Thanks & RegardsDivyalakshmi R

Yes, you are free to use it. Yes, I do builds with this library.

@cocampbe
Copy link
Author

Hi Team, Thanks, Is possible provide the Vm_clone library using OVM CLI. I have checked provided vm_clone library and its use REST API.

On Tue, Dec 17, 2019 at 6:38 PM Court @.***> wrote: Can you please provide me the playbook for vm clone Try my repo https://github.com/cocampbe/ansible-ovm — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://gist.github.com/f4437e6b7d666c0cd5a48cb60c795b57?email_source=notifications&email_token=AOBH73KYJZEESGE4VNNLTQLQZDFOHA5CNFSM4J3NUK2KYY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAF6B5M#gistcomment-3113942, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOBH73MYAHKRSYMEEPTURJLQZDFOHANCNFSM4J3NUK2A .
-- Thanks & RegardsDivyalakshmi R

You are free to create your own ansible modules that use the OVM CLI. I do not plan on writing modules that use the CLI.

@cocampbe
Copy link
Author

Hi Team, How to get user input for vmnamr,cpu,memory,boot disk name in ansible for clone vm from template. If you have this type of playbook and library.please share to me

On Wed, 18 Dec 2019, 00:47 Divyalakshmi, @.> wrote: Hi Team, Thanks, Is possible provide the Vm_clone library using OVM CLI. I have checked provided vm_clone library and its use REST API. On Tue, Dec 17, 2019 at 6:38 PM Court @.> wrote: > Can you please provide me the playbook for vm clone > > Try my repo https://github.com/cocampbe/ansible-ovm > > — > You are receiving this because you commented. > Reply to this email directly, view it on GitHub > https://gist.github.com/f4437e6b7d666c0cd5a48cb60c795b57?email_source=notifications&email_token=AOBH73KYJZEESGE4VNNLTQLQZDFOHA5CNFSM4J3NUK2KYY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAF6B5M#gistcomment-3113942, > or unsubscribe > https://github.com/notifications/unsubscribe-auth/AOBH73MYAHKRSYMEEPTURJLQZDFOHANCNFSM4J3NUK2A > . > -- Thanks & RegardsDivyalakshmi R

For building VMs I use the clone library to first create a VM from a template. I then use the ovm_modify module to change the cpu and memory.

@divya-create
Copy link

divya-create commented Dec 22, 2019 via email

@divya-create
Copy link

Hi Team,
I have already tried this ovm_clone and working fine. ThanksI need help for i have to give input in ovm_clone based on the input cvm clone create from template with ,The below input asked from user1.vm name2.repository3.server name4.cpu5.memory6.nic card details.
Please provide me the python library and playbook for this.

@divya-create
Copy link

divya-create commented Dec 31, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment