UNSOLVED

Nbohari

updated

7 years ago

N

Nbohari

14 Posts

0

2930

December 10th, 2019 13:00

Request for help : RP4VM V5.2 REST API

Hello,

I am creating a script for book marking and failover processes in our lab using PowerShell.

So far my understanding is for any operation on the copy the following information is required.

ClusterID

GroupID

CopyID

Question 1

As per REST API guide for  5.2 

Enable image access
PUT
https://{vRPA_IP_address}/fapi/rest/5_2/groups/{groupId}/
clusters/{ clusterId}/copies/{copyId}/image_access/latest/enable

Which clusterId is this? The Production side or remote side where the copy resides?

Question 2

When I try to find copyID using $URL="https:// :7225/fapi/rest/5_2/groups/472133857/state

Invoke-RestMethod -Credential $rpcreds -Uri $URL

My copyUIDs are blank even though the transfer is enabled and everything looks good on the RP4VM monitor in the vCenter.

roupUID : @{id=472133857}
enabled : True
sourceCopiesUIDs : {@{groupUID=; globalCopyUID=}}
groupCopiesState : { @{copyUID=; enabled=True; regulated=False; suspended=False; active=False; removable=True; activePrimaryRPA=2; activeSecondaryRPAsList=System.Object[];

NOTE: This RP4VM environment is not licensed, could this be an issue?

Any help will be greatly appreciated.

 

 

 

  • Idan

    4 Apprentice

    675 Posts

    2398

    0

    Posted January 26th, 2020 05:00

    Hi there,

    I sent some examples offline, should you have other questions/comments, please reach out.

     

    Regards,

    Idan

  • chalies

    1 Message

    2320

    0

    Posted February 17th, 2020 17:00

    Hello.

    I have the same problem.

    ex)

    https://{vRPA_IP_address}/fapi/rest/5_2/groups/{groupId}/clusters/{clusterId}/copies/{copyId}/failover

    I can't find groupId, clusterId, copyId

    I would be grateful if you could give me an example.

    Thank you.

     

     

  • Idan

    4 Apprentice

    675 Posts

    2291

    0

    Posted February 18th, 2020 01:00

    Hi there,

    Here's a failover example:

    PUT https://10.0.0.1/fapi/rest/5_2/groups/321612967/clusters/7060873902970707117/copies/0/failover?startTransfer=true&usePredefinedFailoverNetworks=true

    Note that failover (as well as recover production) requires Test (AKA image access) to be performed first.

     

    To get the cluster UID, run:

    GET /clusters

    To get the group UID, run:

    GET /groups

    To get copyId, run:

    GET /groups/{groupId}/settings

     

    Hope that helps,

    Idan

     

  • 1965

    0

    Posted April 28th, 2020 02:00

    Thank you for the insight. I have a similar issue in trying to get the cluster ID with /clusters. All I return is the cluster name:

    clustersInformation
    -------------------
    {@{clusterUID=; clusterName=NA2-PDVRPACL01}, @{clusterUID=; clusterName=NA1-PDVRPACL01}}

    This is not so critical as I can obtain the cluster ID through the CLI and that is static. However, I also need to obtain the splitter ID so I can dynamically check the state of the splitters since we add and remove hosts periodically form the protected cluster. I cannot find where to obtain that information. 

  • Idan

    4 Apprentice

    675 Posts

    1952

    0

    Posted April 28th, 2020 05:00

    Take a look at GET /splitters/settings.

  • 1946

    0

    Posted April 28th, 2020 06:00

    That returns a null for splitter ID:

    clusterUID splittersSettings
    ---------- -----------------
    @{id=6691660245944692135} {@{JsonSubType=EsxSplitterSettings; splitterUID=; splitterName=NA1-PROD; attachedUserVolumes=System.Object[]; arrayUID=; singleSplittersInfo=System.Object[]; singleSplitterName=ESX}}

  • 1917

    0

    Posted April 29th, 2020 06:00

    I misunderstood when you said try /splitters/settings I thought you were looking for /cluster/{clusterID}/splitters/settings which gives the above output. Just /splitters/settings gives this:

    innerSet
    --------
    {@{clusterUID=; splittersSettings=System.Object[]}, @{clusterUID=; splittersSettings=System.Object[]}}

    If I use a format-list on /cluster/{clusterID}/splitters/settings the return is a bit different but still no splitter ID

    clusterUID : @{id=5065980402614411360}
    splittersSettings : {@{JsonSubType=EsxSplitterSettings; splitterUID=; splitterName=SA1-PROD; attachedUserVolumes=System.Object[]; arrayUID=; singleSplittersInfo=System.Object[]; singleSplitterName=ESX}}

  • Idan

    4 Apprentice

    675 Posts

    1896

    0

    Posted April 30th, 2020 04:00

    Can you please attach the full raw output ? and please send over the full call you're trying to run.

     

    Regards,

    Idan

     

  • 1727

    1

    Posted June 4th, 2020 06:00

    @Idan ,

    I am sorry I did not get back to this post. I eventually figured this out I am using PowerShell for the scripting. Here is the script:

    $ credential   =   Get-Credential
    $ username   =   $ credential.GetNetworkCredential () .UserName
    $ password   =   $ credential.GetNetworkCredential () .password
    $ credPair   =   "$($ username ) : $($ password )"
    $ encodedCredentials   =   [ System.Convert ] ::ToBase64String ([ System.Text.Encoding ] ::ASCII.GetBytes ($ credPair ))
    $ headers   =   @ {   Authorization   =   " Basic  $ encodedCredentials "   }
    $ comp   =   " /splitters/settings "
    $ outfile   =   " .\Splitter Version.csv "
    # This section parses the data from the csv and starts to iterate through the sites
    foreach   ($ s   in   $ rp4vmcl )   {
         $ cluster   =   $ s.cluster_name
         $ uid   =   $ s.cluster_uid
         $ curl   =   $ s.cluster_url
         $ url   =   "$ curl /clusters/ $ uid $ comp "
    # the following captures all the splitter settings
         $ results   =   Invoke-RestMethod   - Method GET  - uri  $ url   - SkipCertificateCheck  - Headers  $ headers
    # This part captures the cluster information
         $ cversp   =   Invoke-RestMethod   - Method GET  - uri  $ curl / system / version  - SkipCertificateCheck  - Headers  $ headers
         $ cversion   =   $ cversp.version
         $ outarray   =   @ ()
         $ record   =   [ ordered ]   @ {
             " Site "   =   ""
             " Cluster Version "   =   ""
             " Server "   =   ""
             " Splitter Version "   =   ""
         }
         foreach   ($ id   in   $ results )   {
             $ suid   =   $ results.splittersSettings.splitterUID.id
             $ surl   =   "$ curl /clusters/ $ uid /splitters/ $ suid /state "
    # One more time to the API to get more indepth splitter information
             $ splitters   =   Invoke-RestMethod   - Method GET  - uri  $ surl   - SkipCertificateCheck  - Headers  $ headers
             $ ssplit =   $ splitters.singleSplittersState
             $ i   =   0
             $ ss   =   $ ssplit.count
    #now we iterate throught the splitters to get our information
             while   ($ i   -ne   $ ss )   {
                 $ key01   =   $ ssplit [$ i ] .osAndVersionInfo.key [ 0 ]
    Sometimes the  data  is presented out of order so we validate the  data  is  in  the right palace.
                 if   ($ key01   -ne   " Splitter version " )   {
                     $ sver   =   $ ssplit [$ i ] .osAndVersionInfo.value [ 1 ]
                     $ shost   =   $ ssplit [$ i ] .osAndVersionInfo.value [ 0 ]   |   % {$ _.Split ( "   " )[ 1 ]}
                 }
                 else   {
                     $ sver   =   $ ssplit [$ i ] .osAndVersionInfo.value [ 0 ]
                     $ shost   =   $ ssplit [$ i ] .osAndVersionInfo.value [ 1 ]   |   % {$ _.Split ( "   " )[ 1 ]}
                 }
                 $ record . " Site "   =   $ cluster
                 $ record . " Cluster Version "   =   $ cversion
                 $ record . " Server "   =   $ shost
                 $ record . " Splitter Version "   =   $ sver
                 $ objrecord   =   New-Object  PSObject  - property  $ record
                 $ outarray   +=   $ objrecord
                 $ i ++
             }
         }
         $ outarray   |   Export-CSV   - Path  $ outfile   - Append
    }