How to configure Hybrid Linked Mode (HLM) using vCenter REST API

This is going to be my first 2019 post and in this post, I am excited to share couple of ways to configure Hybrid Linked Mode (HLM) using REST API. One of the ways is using UI REST client i.e. apiexplorer and another way is using python. If you are not already familiar with vCenter server REST APIs, I would suggest to first go over my earlier post i.e. Getting started with vCenter REST APIs.
Before I move further, I would like to point out that I am not explaining end to end steps required to configure HLM since Emad already has a detailed post on it here. My focus is on vCenter REST API required to link your Onprem vCenter server to VMware cloud on AWS (Cloud vCenter).

Notes:
1. As you might know, there are 2 ways from which user can configure HLM. One way is to configure HLM from Cloud vCenter,where you can see both VCs (onprem and cloud VC) from cloud vCenter vSphere client (H5C) and another way is to configure HLM using vCenter cloud gateway,which allows users to see both VCs  from vCenter cloud gateway H5C. Here is my new post on configuring HLM through vCenter cloud gateway using API

2. Just to avoid any confusion: Since this HLM linking operation is done from vCenter server or vCenter cloud gateway, REST API also comes from vCenter itself and not from CSP (Cloud services platform APIs, which are about Cloud services console operations)

3. Great news  is that API remains exactly same no matter which way you go for. Only change is: If you are configuring HLM from cloud vCenter (i.e. VMC VC), API end-point would be VMC VC IP/FQDN and if you are configuring HLM using vCenter cloud gateway, API end-point would be vCenter cloud gateway.

How to do HLM linking from H5C UI

You could see, in order to link, we need to pass PSC details and cloud administrator group(s). This is exactly we will do using REST API.

HLM APIs overview

Below are the REST APIs available around HLM. We are more interested in POST /hvc/links call as this is the key API for configuring HLM no matter its from VMC VC or vCenter cloud gateway.

Invoking from UI REST client i.e. APIExplorer

By now you might have already used apiexplorer (swagger based) vCenter REST client. To access it, just browse “https://[vCenter IP]/apiexplorer”. If you see above screen-shot, there are multiple APIs on HLM operations. The one we are interested in is “/hvc/links” POST method, which is responsible for HLM linking.

As part of above request body, we need to pass exactly the same details as we passed while configuring from UI. Let us take a look the “request_body” spec I passed.

{
“spec”: {
“port”: “443”,
“domain_name”: “vsphere.local”,
“username”: “Administrator@vsphere.local”,
“ssl_thumbprint”: “F9:1C:2B:E7:C5:A0:CC:02:D3:37:33:04:B0:2D:2F:6C:77:50:EB:9C”,
“admin_groups”: [
“yourcloudadmingroup@yourdomain.local”
],
“password”: “VMW!23,
“psc_hostname”: “10.161.2.5”
}
}

Let us go over each parameter passed.

port: 443 is default  Onprem PSC TCP port (can be custom port also)

domain_name: Onprem PSC default SSO domain

username, password, psc_hostname: Onprem PSC credentials

ssl_thumbprint :
If you need to pass, this is Onprem PSC SSL thumbprint, you can get it using one of the ways posted here . I am going to write a post on how to get vCenter/PSC thumbprint using API itself, please stay tuned.

admin_groups: here you specify cloud administrator group(s).  Before configuring HLM linking (apart from HLM standard requirements that Emad has posted here) , identity source must be configured on both Onprem and VMC first and cloud admin groups must be given global permissions on both VCs.

HLM linking using python

By this time, I am sure you know everything about the API, now lets head on to python way of doing these things.

This script is available on my github repo HERE

# Author: Vikas Shitole
# Website: www.vThinkBeyondVM.com
# Product: VMware Cloud on AWS (VMC)
# Description: Python script to configure Hybrid Linked Mode (HLM) between Onprem and VMC VC
# How to setup vCenter REST API environment?: http://vthinkbeyondvm.com/getting-started-with-vcenter-server-rest-apis-using-python/</pre>
<pre>import requests
import json
import ssl
import atexit
import sys
import argparse
import getpass

from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

s=requests.Session()
s.verify=False

def get_args():
    """ Get arguments from CLI """
    parser = argparse.ArgumentParser(
        description='Arguments for HLM linking')

    parser.add_argument('-s', '--host',
                        required=True,
                        action='store',
                        help='VMC VC IP or FQDN')

    parser.add_argument('-u', '--user',
                        required=True,
                        action='store',
                        help='VMC VC username')

    parser.add_argument('-p', '--password',
                        required=False,
                        action='store',
                        help='VMC VC password:')

    parser.add_argument('-o', '--port',
                        type=int,
                        default=443,
                        action='store',
                        help='PSC port')

    parser.add_argument('-d', '--domainname',
                        type=str,
			default='vsphere.local',
                        action='store',
                        help='Onprem PSC domain name')

    parser.add_argument('-pu', '--pscuser',
                        required=False,
			default='Administrator@vsphere.local',
                        action='store',
                        help='Onprem PSC username')

    parser.add_argument('-pp', '--pscpass',
                        required=False,
                        action='store',
                        help='Onprem PSC password')

    parser.add_argument('-ph', '--pschost',
                        required=True,
                        action='store',
                        help='Onprem PSC host IP or FQDN')

    parser.add_argument('-a', '--admingroup',
                        required=False,
                        action='store',
                        default='yourcloudadmin@yourdomain.local',
                        help='Cloud admins group')	

    parser.add_argument('-pt', '--pscthumb',
                        required=True,
                        action='store',
                        help='Onprem PSC thumbprint')

    args = parser.parse_args()

    if not args.password:
        args.password = getpass.getpass(
            prompt='Enter VMC VC password:')

    if not args.pscpass:
        args.pscpass = getpass.getpass(
            prompt='Enter PSC password:')

    return args

args = get_args()
headers = {'content-type':'application/json'}
session_response= s.post('https://'+args.host+'/rest/com/vmware/cis/session',auth=(args.user,args.password))

if session_response.ok:
	print ("Session creation is successful")
else:
	print ("Session creation is failed, please check")
	quit()

payload = {
  "spec": {
    "port": args.port,
    "domain_name": args.domainname,
    "username": args.pscuser,
    "ssl_thumbprint": args.pscthumb,
    "admin_groups": [
      args.admingroup
    ],
    "password": args.pscpass,
    "psc_hostname": args.pschost
  }
}

json_payload = json.loads(json.dumps(payload))
json_response = s.post('https://'+args.host+'/rest/hvc/links',headers=headers,json=json_payload)
if json_response.ok:
	print ("HLM link is established")
else:
	print ("HLM link is NOT established, please check")
print (json_response)
print (json_response.text)

Below is how you would run the script, take a look at the what parameters need to be passed. Each parameter is explained in above script as well.

I hope you enjoyed reading this post. Here is my new post on configuring HLM through vCenter cloud gateway using API.

189 thoughts on “How to configure Hybrid Linked Mode (HLM) using vCenter REST API

  1. Hi, I dont have any knowledge in API’s and any programming language. However i would like to build those skills as I have lot of experience with VMware products. I’ve seen lot of your posts and impressed with your programming skills.
    I need your advise in terms how to build this skills.
    – where do i start?
    -What should i learn first?
    Thanks.

  2. You ought to take part in a contest for one of the highest quality websites on the internet.
    I most certainly will recommend this site!

  3. Greate post. Keep writing such kind of information on your page.

    Im really impressed by it.
    Hello there, You have done an excellent job.
    I will certainly digg it and personally recommend to my
    friends. I’m sure they’ll be benefited from this web site.

    My blog; xe888apk

  4. Have you ever thought about including a little bit
    more than just your articles? I mean, what you say
    is important and all. However just imagine if you added some great photos or video clips to give
    your posts more, “pop”! Your content is excellent but
    with images and video clips, this website could
    undeniably be one of the best in its niche. Wonderful blog!

    Feel free to visit my web blog … ex88 game, 918kiss-m.com,

  5. hello there and thank you for your information – I have definitely picked up anything new from right here.
    I did however expertise several technical points using this web site, as I experienced to reload the site lots of times previous to I could get it to load properly.
    I had been wondering if your web host is OK? Not that
    I am complaining, but sluggish loading instances times will very frequently affect your placement in google and can damage your quality score if advertising and marketing with Adwords.

    Well I am adding this RSS to my e-mail and can look out for much more of your respective
    intriguing content. Ensure that you update this again very soon.

    my web page … apl sky777

  6. Excellent beat ! I would like to apprentice even as you amend your web site,
    how could i subscribe for a blog site? The account aided me a appropriate deal.
    I have been a little bit acquainted of this your broadcast provided brilliant transparent idea

    Also visit my web blog live22 ios download

  7. I really like your blog.. very nice colors & theme. Did you create this
    website yourself or did you hire someone to do it for you?
    Plz respond as I’m looking to create my own blog and would like to know where u got this from.
    cheers

    my web page; greatwall99

  8. Admiring the time and energy you put into your website and
    in depth information you present. It’s awesome to come
    across a blog every once in a while that isn’t the same old rehashed material.

    Wonderful read! I’ve saved your site and I’m including
    your RSS feeds to my Google account.

    Also visit my web page: http://www.anapapansion.ru

  9. Normally I don’t learn post on blogs, however I would like
    to say that this write-up very forced me to try
    and do it! Your writing style has been surprised me.
    Thank you, very nice post.

  10. An impressive share! I’ve just forwarded this onto a colleague who
    was doing a little research on this. And he in fact ordered me dinner due to the
    fact that I stumbled upon it for him… lol. So allow me to reword this….
    Thanks for the meal!! But yeah, thanx for spending the time to discuss this subject here
    on your web page.

    my blog post: argonautsofwi.com

  11. I just wanted to jot down a word so as to say thanks to you for all the
    splendid tips and hints you are writing on this
    site. My time intensive internet look up has at the end been paid with sensible insight to talk about with my partners.

    I would express that most of us visitors actually are very
    much fortunate to live in a great network with very many brilliant professionals with very beneficial plans.
    I feel really blessed to have used the web page
    and look forward to so many more fabulous times reading
    here. Thanks once again for a lot of things.

    Also visit my web page :: equipifieds.com

  12. I precisely had to appreciate you once again. I’m not certain the things I would have accomplished in the absence of these thoughts provided by you over this theme.

    It seemed to be a real hard situation in my view, however ,
    viewing a specialized form you solved the issue forced me to jump for delight.

    I will be grateful for your support as well as believe you realize what an amazing job that you are undertaking training men and
    women with the aid of your web site. Probably you have never got to know any of us.

    Here is my blog post … kodeforest.net

  13. Please let me know if you’re looking for a article author for
    your blog. You have some really great articles and I believe I would be
    a good asset. If you ever want to take some of the load off, I’d love to write some
    articles for your blog in exchange for a link back to mine.
    Please shoot me an e-mail if interested. Many thanks!

    my web page – Ivy

  14. It’s a pity you don’t have a donate button! I’d
    without a doubt donate to this outstanding blog! I suppose for now
    i’ll settle for book-marking and adding your RSS feed to my
    Google account. I look forward to new updates and will share this site with
    my Facebook group. Talk soon!

    Also visit my web site – digitalnomadads.com

  15. Great goods from you, man. I’ve understand your stuff previous to and
    you’re just extremely excellent. I actually like what you have
    acquired here, really like what you are saying and the way in which
    you say it. You make it entertaining and you still care
    for to keep it smart. I cant wait to read much more from you.
    This is actually a wonderful website.

    Look at my homepage; http://www.shltaxi.com

  16. This design is spectacular! You obviously 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!)
    Great job. I really loved what you had to say, and more than that, how you presented it.
    Too cool!

    Look at my web site – Collette

  17. Saya akan segera genggam rss feed Anda karena saya tidak bisa
    Saya telah berselancar on-line lebih dari tiga jam akhir-akhir ini, tapi Saya tidak pernah
    menemukan artikel menarik seperti milik Anda. It’s pretty value
    cukup untuk saya. Menurut pendapat saya , jika semua pemilik situs web dan blogger membuat tepat materi konten seperti yang Anda lakukan ,
    web akan lebih banyak membantu dari sebelumnya.

    My site Situs joker Gaming

  18. I am very happy to read this. This is the kind of manual that
    needs to be given and not the accidental misinformation that
    is at the other blogs. Appreciate your sharing this
    best doc.

    My page Rico

  19. I became honored to get a call from my friend when he found the important ideas shared on your site.

    Studying your blog article is a real brilliant experience.
    Many thanks for considering readers like me, and I hope for you the best of achievements being a professional in this arena.

    my page Sherlene

  20. Great beat ! I wish to apprentice even as you amend your website, how could
    i subscribe for a blog website? The account helped me a acceptable deal.
    I had been tiny bit acquainted of this your broadcast provided vivid
    clear idea

    My webpage; equipifieds.com

  21. Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point.
    You clearly know what youre talking about, why throw
    away your intelligence on just posting videos to your blog when you could be giving us something informative to read?

    My page; kebe.top

  22. It’s a pity you don’t have a donate button! I’d
    definitely donate to this excellent blog! I guess for now i’ll settle for bookmarking and adding your RSS feed to my Google account.
    I look forward to fresh updates and will share this
    website with my Facebook group. Talk soon!

    Here is my web site :: equipifieds.com

  23. Woah! I’m reaⅼly loving the temρlate/theme of this sitе.
    It’s simple, yet effective. A lot of ttimes it’s
    difficult tto get that “perfect balance” between supеrb usability and
    visual appearance. I must say you havе done a
    amazing job with this. In additi᧐n, the blog lоads very fast for me on Internet explorer.
    Superb Blog!

  24. I was wondering if you ever considered changing the page layout of your
    blog? Its very well written; I love what youve got to
    say. But maybe you could a little more in the way of content so people could connect with it better.

    Youve got an awful lot of text for only having 1 or 2 images.

    Maybe you could space it out better?

    Feel free to surf to my webpage :: http://www.makemoneydonothing.com/user/profile/214523

  25. I usually do not leave a response, however I browsed
    a lot of responses on How to configure Hybrid Linked Mode (HLM) using vCenter REST API
    | vThinkBeyondVM. I do have some questions for you if you tend not to
    mind. Could it be only me or do a few of these comments look like they are coming from brain dead people?
    😛 And, if you are writing on additional places, I’d like to keep up with anything
    new you have to post. Would you make a list of every one
    of your social networking sites like your linkedin profile,
    Facebook page or twitter feed?

    Also visit my webpage; biblioray.pusku.com

  26. What i do not realize is in fact how you’re now not actually
    much more well-favored than you might be now.

    You’re very intelligent. You realize therefore considerably in relation to this subject, produced me for my part imagine it from a lot of various angles.

    Its like men and women don’t seem to be involved except it is something to do with Lady gaga!
    Your personal stuffs outstanding. At all times take care of it up!

    Look into my web-site; new.miamisprings.com

  27. We stumbled over here coming from a different web address and thought I may as well check things out.

    I like what I see so i am just following you.
    Look forward to exploring your web page for a second
    time.

    Feel free to surf to my website; ivyshorses.com

  28. hello there and thank you for your info ? I’ve certainly picked
    up anything new from right here. I did however expertise a few technical issues using this website,
    as I experienced to reload the web site many
    times previous to I could get it to load properly. I had been wondering if your web host is OK?
    Not that I am complaining, but slow loading instances times will
    often affect your placement in google and could damage your quality score if advertising and marketing with
    Adwords. Well I am adding this RSS to my email and could look out for
    much more of your respective intriguing content. Make sure
    you update this again soon.

    my website :: http://www.information-brokers.ipt.pw/out/phoenix-askmeclassifieds-com

  29. Can I simply just say what a comfort to uncover somebody who genuinely
    understands what they’re talking about over the internet.
    You actually understand how to bring a problem to light and make it important.
    More people must read this and understand this side of your story.
    I can’t believe you’re not more popular because you most certainly possess the gift.

    Also visit my homepage http://www.ocpsoft.org

  30. Thanks, I’ve recently been looking for info approximately this topic for ages and yours is
    the greatest I have discovered till now. However, what concerning the
    conclusion? Are you certain in regards to the supply?

    Visit my web blog: riyapola.com

  31. I would like to use the chance of saying thanks to you for that professional instruction I have often enjoyed browsing your site.
    We’re looking forward to the particular commencement of
    my school research and the complete groundwork would never have
    been complete without checking out your
    website. If I can be of any assistance to others, I
    might be thankful to help by means of what I have discovered from here.

    My web blog; Tawnya

  32. Thank you so much with regard to giving me an update on this
    theme on your web-site. Please realise that if a fresh post becomes available
    or in the event that any changes occur on the current post, I would be thinking about
    reading a lot more and finding out how to make good using of those strategies you reveal.
    Thanks for your time and consideration of other men and
    women by making this website available.

    Also visit my site http://www.shltaxi.com

  33. Thank you a bunch for sharing this with all people you actually
    realize what you are talking approximately! Bookmarked.
    Kindly also consult with my website =). We will have a hyperlink exchange agreement between us

    Here is my webpage :: http://www.theezentrepreneur.com/groups/diabetes-diet-tips-that-be-of-benefit-the-diabetic-enjoy-the-kitchen-connoisseur/

  34. Hi there! I could have sworn I’ve been to your blog before but after going through some of the articles I realized it’s new to me.
    Nonetheless, I’m definitely happy I came across it and I’ll be bookmarking it and checking back regularly!

    Feel free to visit my web site :: graceforglory.org

  35. I have been exploring for a little for any high quality articles or blog posts in this kind of space .
    Exploring in Yahoo I finally stumbled upon this website.
    Reading this information So i am happy to show that
    I have a very good uncanny feeling I came upon exactly what I needed.
    I so much unquestionably will make sure to do
    not disregard this site and give it a glance on a relentless basis.

    Also visit my webpage :: http://www.lifeadventureexplore.com/groups/diet-solutions-for-obesity-1363103830/

  36. My spouse and I absolutely love your blog and find many of your post’s to be exactly what I’m looking for.

    Would you offer guest writers to write content in your case?
    I wouldn’t mind producing a post or elaborating on a few of the subjects
    you write concerning here. Again, awesome blog!

    My web blog science-marketplace.org

  37. I all the time used to read post in news papers
    but now as I am a user of internet therefore from now I
    am using net for articles or reviews, thanks to web.

  38. I wanted to follow along and allow you to know how much I liked discovering this blog today.
    I’d personally consider it an honor to do things at my place of work and be able to make use of the tips shared on your blog and
    also be a part of visitors’ remarks like this. Should a position regarding guest
    article writer become offered at your end, please let me know.

    My webpage: http://www.theezentrepreneur.com

  39. Thank you a lot for providing individuals with remarkably
    superb possiblity to read critical reviews from this website.
    It is usually so pleasing and as well , jam-packed with a good time for me personally and my office colleagues to search
    your blog the equivalent of three times a week to learn the latest guidance
    you will have. And definitely, I am just usually astounded for the special secrets you give.
    Certain 4 tips in this article are without a doubt the most
    efficient we have all ever had.

    Also visit my page Vilma

  40. Have you ever thought about writing an e-book or guest authoring on other blogs?
    I have a blog based upon on the same subjects you discuss and would really like to have you share
    some stories/information. I know my viewers would value your work.
    If you are even remotely interested, feel free to send me an e mail.

    Feel free to visit my website onehubracing.com

  41. Hi there, i read your blog occasionally and i own a
    similar one and i was just curious if you get a
    lot of spam responses? If so how do you stop it, any plugin or anything you can suggest?

    I get so much lately it’s driving me insane so any support is very much appreciated.

    Also visit my site – https://vadatahub.org/

  42. Helpful info. Fortunate me I discovered your web site unintentionally, and I’m surprised why this twist of fate did
    not happened in advance! I bookmarked it.

  43. I am now not sure the place you are getting your information, however great topic.

    I needs to spend some time finding out much more or working out more.
    Thank you for wonderful info I used to be looking for this information for my mission.

    Feel free to surf to my web page; astravo.net.ru

  44. I just now wanted to thank you a lot more for this
    amazing web-site you have produced here. It really is full of useful tips for those who are seriously interested in this particular subject,
    especially this very post. You’re really all so sweet as well as thoughtful of
    others and also reading the blog posts is an excellent delight in my opinion. And such a generous surprise!
    Jeff and I usually have pleasure making use of your
    guidelines in what we must do in the near future.

    Our record is a distance long and tips will be
    put to very good use.

    Here is my web-site; Jamal

  45. A lot of thanks for all your labor on this site.
    My mum delights in conducting internet research and it is obvious why.

    We all notice all relating to the powerful form you render practical secrets via the web site and
    as well foster response from the others on the issue plus my child is always being taught so much.
    Take advantage of the remaining portion of the new year.
    You are conducting a wonderful job.[X-N-E-W-L-I-N-S-P-I-N-X]I’m really inspired together with your
    writing skills as well as with the structure for your weblog.
    Is that this a paid theme or did you modify it yourself?
    Either way stay up the excellent high quality writing, it’s uncommon to look a great blog
    like this one these days.

    My web-site … oigari.com

Leave a Reply

Your email address will not be published. Required fields are marked *