Couple of weeks back vSphere 7.0 released & if you ask me, it is a massive release with several cool features and capabilities including “vSphere with Kubernetes”. I was going through all the REST APIs introduced as part of multiple features shipped in this release and I see that this is the first release, where REST APIs are hands down dominating traditional SOAP based APIs. New capabilities have not only been exposed through REST APIs but also some of the older capabilities have provided REST API support as well. In this series of posts, I would like to introduce you these REST APIs as I did for vSphere Supervisor Cluster last week. In this post, I will touch upon new APIs introduced as part of “Virtual Machine” Management & demonstrate them using Postman client and Python.
Where do I get REST API documentation? This is available as part of H5C API Explorer itself since vSphere 6.5: H5C >> Menu >> Developer center >> API explorer or you can look documentation at VMware {code} site as well.
Since vSphere 6.5, when it comes to REST APIs with respect to VM life cycle, only minimal support was available i.e. Get, Create (POST call) and Delete VMs. With vSphere 7.0, I see there is huge progress made with respect to supporting key capabilities such as relocate, normal clone, instant clone & register VMs operations. Traditionally automating these VM life cycle ops have been challenging for several users using SOAP APIs, now with REST API support, it has drastically simpler to consume/automate these capabilities. Below is how its POST call URLs look like
Relocate ops:
POST https://{server}/rest/vcenter/vm/{vm}?action=relocate
POST https://{server}/rest/vcenter/vm/{vm}?vmw-task=true&action=relocate
Only difference between them is that 2nd API also returns task object, which will help user track the progress of the operation.
Clone ops:
POST https://{server}/rest/vcenter/vm?action=clone
POST https://{server}/rest/vcenter/vm?vmw-task=true&action=clone
Similar to relocate API, second API returns task object.
Instant clone ops:
POST https://{server}/rest/vcenter/vm?action=instant-clone
Register ops
POST https://{server}/rest/vcenter/vm?action=register
POST https://{server}/rest/vcenter/vm/{vm}?action=unregister
Note that there is no change to existing SOAP APIs for all the existing capabilities, it should continue to work fine without any impact
Let us now understand one of the APIs in more detail. Without a doubt, it should be all time famous capability i.e. vMotion (relocate).
POST https://{server}/rest/vcenter/vm/{vm}?action=relocate
Below is how payload for this API look like
{
"spec" : {
"disks" : [
{
"value" : {
"datastore" : "datastore_moid"
},
"key" : "disk key"
}
],
"placement" : {
"cluster" : "cluster_moid",
"folder" : "folder_moid",
"datastore" : "datastore_moid",
"host" : "host_moid",
"resource_pool" : "resourcepool_moid"
}
}
}
let us understand each of the parameter being passed in brief. For detailed documentation, please refer official documentation from API Explorer or from vmware {code} portal.
disks []: This spec has 2 values such as datastore and key as follows, it is required field to pass details for all the VM disks.
datastore : required: This parameter under “disks[]” should be the destination datastore for the VM disks. This should be datastore_moid and moid found using existing REST API:
GET https://{server}/rest/vcenter/datastore
sample value : “datastore-21”
key: required: this must be the disk key(s) for the VM to be migrated and it can be found using existing REST API. sample value : “2000”
GET https://{server}/rest/vcenter/vm/{vm}/hardware/disk
placement : destination spec
cluster: this should be cluster moid. This can be specified if we would like DRS to find the right host for placement. This can be optional param. moid can be found using API: sample value : “domain-c9”
GET https://{server}/rest/vcenter/cluster
folder: destination VM folder. This is optional param. moid can be found using API. sample value : “group-v4”
GET https://{server}/rest/vcenter/folder
datastore: This is under placement_spec: This is required if you want relocate VM configuration folders/files to destination. The “datastore” property briefed before above is for VM disks.
host: destination host. It is optional if cluster or resource pool is passed. sample value : “host-32”
moid can be found using API: GET https://{server}/rest/vcenter/host
resource_pool: destination resource pool. This is not required if host or cluster is specified. sample value : “resgroup-34”
moid can be found using API: GET https://{server}/rest/vcenter/resource-pool
Note that there are couple of noteworthy points wrt relocate and clone REST APIs. As of vSphere 7.0, it does not give an option to specify destination network & it does not support cross vCenter migration/clone as well . I hope in future releases, both of these key aspects will be supported through REST APIs
Let us invoke this API. I did it using both postman REST client and Python.
Postman way:
Note: In my case, I am relocating the VM from one cluster to other DRS enabled cluster. If you do not have DRS enabled cluster, you can go with passing destination host instead. I passed just enough params as shown below in Postman client but you may pass as per your requirement.
Here is the payload passed for easy copy paste.
{
“spec” : {
“disks” : [
{
“value” : {
“datastore” : “datastore-57”
},
“key” : “2000”
}
],
“placement” : {
“cluster” : “domain-c9”,
“datastore” : “datastore-57”
}
}
}
Python way:
Here is the equivalent python script for the same on my github repo. Below is how you would execute this python script
You can see API returned 200 ok response. how cool is that!
I hope you enjoyed this post. Please stay tuned for next post in this REST API series.
References:
– How to get started guide on REST APIs using Postman and python
– Introduction to vSphere Supervisor cluster APIs
Good Afternoon everybody ! can anyone recommend where I can purchase Limitless CBD CBD Tincture Terpene Infused Oil Natural Flavor 500mg 2500mg?
We’re a bunch of volunteers and opening a new scheme in our
community. Your site provided us with valuable information to
work on. You have performed an impressive job and our whole group will likely be thankful to you.
I like what you guys are usually up too. This sort of clever work and exposure!
Keep up the good works guys I’ve added you guys
to my personal blogroll.
my web blog; 3win8 Ios Download
This design is incredible! You definitely know how to keep a reader amused.
Between your wit and your videos, I was almost moved to start my
own blog (well, almost…HaHa!) Fantastic job.
I really enjoyed what you had to say, and more than that,
how you presented it. Too cool!
My web blog – jackpot king855 (918kiss-m.com)
Wow that was strange. I just wrote an really long comment but
after I clicked submit my comment didn’t appear.
Grrrr… well I’m not writing all that over again. Anyways, just wanted to say great blog!
Also visit my site :: game epicwin online
What a data of un-ambiguity and preserveness of precious
familiarity on the topic of unpredicted feelings.
Review my homepage; i 918kiss plus
I’ve been exploring for a bit for any high-quality
articles or weblog posts in this kind of area .
Exploring in Yahoo I at last stumbled upon this website.
Reading this info So i am satisfied to show that I have a
very good uncanny feeling I found out exactly what I needed.
I such a lot indisputably will make sure to do not fail to remember this web site and
provides it a look on a constant basis.
My web page – 918kiss xe88
Hello, i believe that i noticed you visited my site thus i got here to return the choose?.I am trying to in finding issues to improve my site!I
assume its good enough to make use of a few of your concepts!!
Also visit my web-site; cara id test greatwall99
You actually make it seem so easy with your presentation but I find this topic to be really something which I think I would
never understand. It seems too complex and extremely broad for me.
I’m looking forward for your next post, I will try to get the hang of it!
Hello! I know this is kind of off topic but I was wondering
which blog platform are you using for this
website? I’m getting sick and tired of WordPress because I’ve had problems with hackers and I’m
looking at options for another platform. I would be
great if you could point me in the direction of a good platform.
Here is my page – test id club suncity
Hello to every body, it’s my first visit of this web site; this website
consists of amazing and in fact good stuff in favor of visitors.
Feel free to visit my web blog … game slot rollex11
Hey! I know this is kind of off topic but I was wondering which blog platform are you
using for this site? I’m getting fed up of WordPress
because I’ve had problems with hackers and I’m looking at alternatives for another platform.
I would be fantastic if you could point me in the
direction of a good platform.
my webpage :: test 918kaya (918Kiss-M.com)
Magnificent beat ! I wish to apprentice at the same time as you amend your web site, how could i subscribe
for a weblog web site? The account helped me a acceptable deal.
I were tiny bit familiar of this your broadcast provided vivid transparent concept
my page: id live22
Hey! I understand this is kind of off-topic but I needed to ask.
Does managing a well-established website like yours take a
lot of work? I’m completely new to blogging however I
do write in my diary every day. I’d like to start a blog so I can share my
own experience and views online. Please let me know
if you have any recommendations or tips for brand new aspiring bloggers.
Thankyou!
Here is my site :: free download game lpe88; Bert,
This web site really has all the info I needed about this subject
and didn’t know who to ask.
my web page – download game wm casino
What’s up, I desire to subscribe for this blog to take latest updates,
therefore where can i do it please help out.
Also visit my webpage – playboy2 free download
Great website. Plenty of useful information here. I am sending it to a few
buddies ans also sharing in delicious. And naturally, thanks
on your sweat!
Also visit my web-site: gem ace333
Thanks for another informative blog. The place else may
just I get that type of info written in such a perfect manner?
I’ve a undertaking that I am simply now operating on, and I’ve been on the
glance out for such info.
my site; id ntc33
I am really thankful to the owner of this web site
who has shared this great piece of writing at at this time.
my web site; Download Game Sky1388
Asking questions are genuinely good thing if you are not understanding anything totally, except this article offers
fastidious understanding even.
I pay a quick visit everyday some sites and blogs to read content,
except this blog presents feature based posts.
Feel free to surf to my blog post; calibet slot
Hey there! Do you know if they make any plugins to assist with Search Engine Optimization? I’m trying to
get my blog to rank for some targeted keywords but I’m not
seeing very good gains. If you know of any please share.
Appreciate it!
my blog … joker688 (918kiss-m.com)
wonderful submit, very informative. I wonder why the
other specialists of this sector don’t realize this.
You must proceed your writing. I am sure, you have
a great readers’ base already!
My web site – joker123 login pc
Pretty! This was a really wonderful post. Thank you for providing these details.
Feel free to surf to my blog … Ok388 android download
Its like you read my mind! You appear to know so much about
this, like you wrote the book in it or something. I think that you could do with a few pics to drive the message home a bit, but other than that, this is great blog.
A fantastic read. I’ll certainly be back.
Feel free to visit my web site Kiosk Wukong333 Vip
This post offers clear idea designed for the new people of blogging, that genuinely how to do blogging
and site-building.
my homepage … download 918kiss 2 ios
Do you mind if I quote a couple of your posts as long as I provide credit and sources back to your blog?
My blog site is in the exact same area of interest as yours and my visitors would genuinely benefit from a lot of the information you present here.
Please let me know if this alright with you. Regards!
Very soon this website will be famous amid all blogging and site-building users, due to it’s fastidious
articles or reviews
Thanks for one’s marvelous posting! I certainly enjoyed reading it, you might be a great author.
I will remember to bookmark your blog and will eventually come back down the road.
I want to encourage one to continue your great posts, have a
nice afternoon!
This site was… how do I say it? Relevant!! Finally I’ve found something that helped me.
Kudos!
When someone writes an piece of writing he/she retains the idea of a user in his/her mind that
how a user can understand it. Thus that’s why this piece of writing is perfect.
Thanks!
Hey! I could have sworn I’ve been to this website before but after
browsing through some of the post I realized it’s new to me.
Anyhow, I’m definitely glad I found it and I’ll be book-marking and checking back
frequently!
Woԝ that was odd. I ϳust wrοte an veгy long comment but after I clicked sᥙbmit my comment didn’t
sһow up. Grrrr… well I’m not writing all that over again.
Anyway, just wanted to say greаt blog!
Saya akan segera pegang rss Anda karena saya tidak bisa
Tersimpan sebagai favorit , Saya sangat suka situs web Anda
!
Feel free to surf to my web blog :: Live joker123
These are truly wonderful ideas in concerning blogging.
You have touched some fastidious things here.
Any way keep up wrinting.
Good day! I could have sworn I’ve been to this web site before but after going through a few of the posts I realized it’s new
to me. Anyways, I’m definitely pleased I stumbled upon it and I’ll be bookmarking it and checking back frequently!
Thank you for the auspicious writeup. It in truth was a enjoyment account it.
Look complex to far added agreeable from you! However,
how could we communicate?
Definitely believe that which you said. Your favorite justification appeared to be on the net the simplest
thing to be aware of. I say to you, I definitely
get annoyed while people think about worries that they plainly don’t know about.
You managed to hit the nail upon the top as well as defined
out the whole thing without having side effect , people can take a
signal. Will probably be back to get more. Thanks
Woah! I’m really enjoying the template/theme of this website.
It’s simple, yet effective. A lot of times it’s tough to get that “perfect balance” between user friendliness
and appearance. I must say you have done a superb job with this.
Also, the blog loads extremely quick for me on Safari. Exceptional Blog!
Hi there! I’m at work browsing your blog from my new iphone 4!
Just wanted to say I love reading your blog and look forward
to all your posts! Keep up the great work!
Thanks very nice blog!
Heyа thhis is kinda of offf topic but I was wanting to know іf blogs use WYSIᎳYG editors or if you have
to manually code withh HTML. I’m starting a bⅼߋg soon but have no coding know-how so
I wanted to get guіdance frlm someone with exрerience.
Any help would be enormously appreciated!
Saya akan segera rebut rss feed Anda karena saya tidak bisa
Wow, tulisan ini bagus , adik perempuan saya sedang menganalisis hal-hal seperti , jadi saya akan
beri tahu dia.
Feel free to surf to my web blog – Joker888 test [Josephine]
Hello! Do you know if they make any plugins to assist with SEO?
I’m trying to get my blog to rank for some targeted keywords
but I’m not seeing very good success. If you know of any please share.
Cheers!
Your mode of explaining everything in this article is really fastidious,
all be able to effortlessly be aware of it, Thanks a lot.
Good post. I learn something new and challenging on blogs I stumbleupon on a daily basis.
It will always be helpful to read articles from other authors and use something from their sites.
Hello, i read your blog from time to time and i own a similar
one and i was just wondering if you get a lot of spam feedback?
If so how do you stop it, any plugin or anything you can recommend?
I get so much lately it’s driving me crazy so any assistance is very much
appreciated.
I just like the valuable information you supply to your articles.
I will bookmark your weblog and check again right here regularly.
I’m rather sure I will be told many new stuff right here!
Best of luck for the following!
Ahaa, its pleasant discussion on the topic of this piece of writing
here at this blog, I have read all that, so now me also commenting here.
Yes! Finally someone writes about website.
If you desire to improve your know-how only keep visiting this site and be updated with the hottest information posted here.
My brother recommended I might like this blog.
He was totally right. This post truly made my day. You cann’t imagine
simply how much time I had spent for this information! Thanks!
Useful info. Lucky me I discovered your web site by chance, and
I am stunned why this twist of fate did not happened in advance!
I bookmarked it.
Saya tidak bisa menolak berkomentar. Sempurna ditulis!
Feel free to visit my web-site – Situs joker188 slot – gameaco.com,
Saya akan segera genggam rss feed Anda karena saya tidak bisa
Ini waktu tepat untuk membuat beberapa rencana untuk masa depan dan sekarang waktu
untuk bahagia. Saya pelajari kirim ini dan jika saya boleh saya ingin
merekomendasikan Anda beberapa menarik hal atau saran .
Mungkin Anda bisa menulis artikel berikutnya yang berhubungan dengan
artikel ini. Saya ingin membaca lebih lagi hal
tentang itu!
my blog post – Joker123 pro
When I originally commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get
four emails with the same comment. Is there any way you can remove people from that service?
Appreciate it!
Wonderful goods from you, man. I have understand your stuff previous to and you’re just extremely fantastic.
I actually like what you have acquired here, really like what you’re saying
and the way in which you say it. You make it enjoyable and you still take care of to keep it
smart. I cant wait to read much more from you.
This is actually a tremendous website.
My brother recommended I would possibly like this blog.
He was once entirely right. This submit actually made my day.
You cann’t imagine simply how so much time I had spent for
this information! Thanks!
Thanks for your personal marvelous posting!
I truly enjoyed reading it, you could be a great author.I will be sure to bookmark your blog and may come back someday.
I want to encourage you to definitely continue your great work, have a nice day!
Hi I am so excited I found your blog page, I really found you by error, while I was looking on Yahoo for something else, Anyways I am here now and would just like to say thanks a lot for a
remarkable post and a all round entertaining blog (I also love the theme/design), I don’t have time to look over
it all at the moment but I have bookmarked it and also added in your RSS feeds, so when I have time I will be back to read much more, Please do keep up
the awesome job.
Thank you for the auspicious writeup. It in fact was a amusement account it.
Look advanced to far added agreeable from you! However,
how can we communicate?
This is a very good tip particularly to those new to the blogosphere.
Brief but very accurate info… Many thanks for sharing
this one. A must read article!
I think this is among the so much important info for me.
And i am glad reading your article. But wanna remark on few general things, The web site style is wonderful, the articles is in point of fact great : D.
Just right process, cheers
Нello colleagues, its fantastic article onn the topic
of cltureand fully exрlained, keep it upp alⅼ thee time.
When I initially commented I appear to have clicked on the -Notify me when new comments are added- checkbox and from
now on every time a comment is added I recieve 4 emails
with the exact same comment. Is there a means you are able to remove
me from that service? Cheers!
Hurrah, that’s what I was exploring for, what a material! existing here
at this blog, thanks admin of this website.
I am now not sure the place you’re getting your information, but
great topic. I needs to spend some time finding out more or working out
more. Thanks for excellent info I was looking for this info for my mission.
I was suggested this blog by my cousin. I am not sure whether this
post is written by him as nobody else know
such detailed about my trouble. You’re amazing! Thanks!
I think this is one of the most important info for me.
And i am glad reading your article. But want
to remark on few general things, The web site style is ideal, the articles is really excellent : D.
Good job, cheers
I all the time used to read piece of writing in news papers but now
as I am a user of net so from now I am using net for posts, thanks to web.
Quality content is the key to attract the viewers to visit the site, that’s
what this web site is providing.
It’s appropriate time to make a few plans for the future and
it is time to be happy. I have read this publish and if
I could I want to recommend you few attention-grabbing things or suggestions.
Perhaps you can write subsequent articles relating to this
article. I want to read more things about it!
I really like reading through an article that will make people think.
Also, thank you for allowing for me to comment!
Of course you’ve probably lost a large volume of traffic but at least you can stop on your own from losing anymore.
Weblog allows for you to achieve a potentially infinite
number of consumers for your businesses.
Increasing the traffic through the site means that to help the sales on the
site. Include little extras such as a tiny bandage, a prepared
food label or classroom stickers. The landing page is key in making
cash.
I was very pleased to uncover this great site.
I need to to thank you for ones time for this particularly wonderful read!!
I definitely really liked every part of it and I have you book
marked to see new things on your web site.
Thanks on your marvelous posting! I seriously enjoyed reading it, you could be a great author.
I will be sure to bookmark your blog and definitely will come back later on. I want to encourage
that you continue your great work, have a nice morning!
Why viewers still make use of to read news papers when in this technological
world all is available on net?
Greetings! Very helpful advice within this article!
It is the little changes which will make the most important changes.
Thanks for sharing!
You need be persistent and want success however if you would like your blog to
complete well. Visitors in many cases get annoyed that they can’t
enjoy encounter of visiting your website and they just leave.
What’s up everybody, here every person is sharing such familiarity,
therefore it’s fastidious to read this web site, and I used to pay a
quick visit this webpage daily.
For latest information you have to pay a quick visit world wide web and on web I found this web site as a best website for
newest updates.
Awesome issues here. I’m very satisfied to look your
post. Thank you so much and I am taking a look ahead to touch you.
Will you please drop me a e-mail?
Good info. Lucky me I discovered your blog by accident (stumbleupon).
I have book-marked it for later!