tenant create issue -- anyone got working code ?

RESTful knowledge exchange

tenant create issue -- anyone got working code ?

Veeam Logoby dahal » Sat May 21, 2016 11:47 pm

Hi,

I want to know what is wrong in this request.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<CreateCloudTenantSpec xmlns="http://www.veeam.com/ent/v1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <Name>tenant01</Name>
 <Description>tenant01-company-A</Description>
 <Password>tenant01-pass</Passworad>
 <Enabled>true</Enabled>
 <LeaseExpirationDate>2016-12-31T00:00:00</LeaseExpirationDate>
 <Resources>
   <BackupResource>
     <Name>Cloud Repository</Name>
     <RepositoryUid>urn:veeam:Repository:2582dfa9-247e-4053-9597-640fbca522a9</RepositoryUid>
     <QuotaMb>307200</QuotaMb>
   </BackupResource>
 </Resources>
 <ComputeResources>
   <ComputeResource>
     <CloudHardwarePlanUid>
 </CloudHardwarePlanUid>
     <PlatformType>HyperV</PlatformType>
     <UseNetworkFailoverResources>false</UseNetworkFailoverResources>
   </ComputeResource>
 </ComputeResources>
 <ThrottlingEnabled>false</ThrottlingEnabled>
 <ThrottlingSpeedLimit>1</ThrottlingSpeedLimit>
 <ThrottlingSpeedUnit>MBps</ThrottlingSpeedUnit>
 <PublicIpCount>0</PublicIpCount>
 <BackupServerUid>urn:veeam:BackupServer:6db752e7-d9a6-48ba-8e6d-da16e315cf0c</BackupServerUid>
</CreateCloudTenantSpec>



~this results in a erorr like this:
Code: Select all
<?xml version="1.0" encoding="utf-8"?><Error StatusCode="500" Message="Cannot parse 'EntityUid'. String: &quot;&#xA;&#x9; &quot;" xmlns="http://www.veeam.com/ent/v1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><FirstChanceExceptionMessage>Cannot parse 'EntityUid'. String: "
 "</FirstChanceExceptionMessage><StackTrace>Veeam.Backup.Interaction.RestAPI.CRestAPICommunicationException: Cannot parse 'EntityUid'. String: "
 " ---&gt; System.Exception: Cannot parse 'EntityUid'. String: "
 "&#xD;
   at Veeam.Backup.Interaction.RestAPI.EntityUid.Parse(String entityUidStr)&#xD;
   at Veeam.Backup.Interaction.RestAPI.EntityUid.ParseAndCheck(String entityUidStr, EntityTypes type, Boolean shouldBeGuidIdentifier)&#xD;
   at Veeam.Backup.Enterprise.RestAPIService.CRestApiCloudTenantsScope.ComputeResourceCreateSpecToInfo(CloudTenantComputeResourceCreateListType resources)&#xD;
   at Veeam.Backup.Enterprise.RestAPIService.CRestApiCloudTenantsScope.CreateCloudTenant(CreateCloudTenantSpecType spec)&#xD;
   at Veeam.Backup.Enterprise.RestAPIService.CEnterpriseRestServiceStub.CreateCloudTenant(CreateCloudTenantSpecType spec)&#xD;
   at SyncInvokeCreateCloudTenant(Object , Object[] , Object[] )&#xD;
   at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]&amp; outputs)&#xD;
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)&#xD;
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)&#xD;
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc&amp; rpc)&#xD;
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)&#xD;
   --- End of inner exception stack trace ---</StackTrace></Error>

which i am not able to understand.

has anyone got a working example/code -- preferably PHP .. The above is from a software that I am using to test basic API functionality.


Thanks,
dahal
Lurker
 
Posts: 1
Liked: never
Joined: Sat May 21, 2016 11:42 pm
Full Name: Shashi

Re: tenant create issue -- anyone got working code ?

Veeam Logoby tdewin » Mon May 23, 2016 5:53 am 2 people like this post

Think the problem is that you have the replica hardware plan defined but not supply any id to the hardware plan (maybe you don't want to use it?)

First of all, know that there is an excellent browser to try out api calls without actually writing code : http://<yourserver>:9399/web/#/api/

So first look up the backup server:
http://win-j303eaucth5:9399/api/backupServers
Code: Select all
<Ref Href="http://win-j303eaucth5:9399/api/backupServers/cfb4d5c4-67e8-48e9-93ed-80f38a170193" Type="BackupServerReference" UID="urn:veeam:BackupServer:cfb4d5c4-67e8-48e9-93ed-80f38a170193" Name="WIN-J303EAUCTH5">

You can extract the urn of the backup server : urn:veeam:BackupServer:cfb4d5c4-67e8-48e9-93ed-80f38a170193

In the xml there should also be a link to the repositories connected to this backup server
Code: Select all
<Link Href="http://win-j303eaucth5:9399/api/backupServers/cfb4d5c4-67e8-48e9-93ed-80f38a170193/repositories" Type="RepositoryReferenceList" Rel="Down"/>


Follow it : http://win-j303eaucth5:9399/api/backupS ... positories
Code: Select all
<Ref Href="http://win-j303eaucth5:9399/api/repositories/297f2d9e-33eb-4d35-bc07-cd135337c9c4" Type="RepositoryReference" UID="urn:veeam:Repository:297f2d9e-33eb-4d35-bc07-cd135337c9c4" Name="Default Backup Repository">

You get references to the repositories like this. I extracted the default repository UID -> urn:veeam:Repository:297f2d9e-33eb-4d35-bc07-cd135337c9c4

Then you can do a POST on http://win-j303eaucth5:9399/api/cloud/tenants . Fill in the urns you looked up earlier
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<CreateCloudTenantSpec xmlns="http://www.veeam.com/ent/v1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Name>test1</Name>
  <Description/>
  <Password>Mysecretpass</Password>
  <Enabled>true</Enabled>
  <LeaseExpirationDate>2099-12-31T00:00:00</LeaseExpirationDate>
  <Resources>
    <BackupResource>
      <Name>Backup resource</Name>
      <RepositoryUid>urn:veeam:Repository:297f2d9e-33eb-4d35-bc07-cd135337c9c4</RepositoryUid>
      <QuotaMb>1024</QuotaMb>
    </BackupResource>
  </Resources>
  <ThrottlingEnabled>true</ThrottlingEnabled>
  <ThrottlingSpeedLimit>1</ThrottlingSpeedLimit>
  <ThrottlingSpeedUnit>MBps</ThrottlingSpeedUnit>
  <BackupServerUid>urn:veeam:BackupServer:cfb4d5c4-67e8-48e9-93ed-80f38a170193</BackupServerUid>
</CreateCloudTenantSpec>


This created a user for me. If you need a more elaborated example, check Prebens example (solution architect for Veeam) : https://github.com/poulpreben/veeam-cloudconnect

Finally, if you did want to apply hardware plans, you need to lookup the uid for the plan. I guess you can look it up via http://win-j303eaucth5:9399/api/cloud/hardwarePlans, but I don't have a demo running to test it quickly
tdewin
Veeam Software
 
Posts: 1047
Liked: 361 times
Joined: Fri Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin

Re: tenant create issue -- anyone got working code ?

Veeam Logoby v.Eremin » Mon May 23, 2016 4:04 pm

Timothy is right. Reference resource representation of Hardware Plan (http://EM:9399/web/#/api/cloud/hardwarePlans) contains Hardware Plans UIDs. Feel free to grab the one you need.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13295
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to RESTful API



Who is online

Users browsing this forum: No registered users and 3 guests