VMware Cloud Community
mackov83
Enthusiast
Enthusiast

Edit OrgVDC Resources with API

Is there anybody out there who has successfully been able to edit resources, in particular CPU and Memory of an OrgVDC?

 

Unfortunately, it seems both creation and edits of VDCs are yet to be migrated from /api to /cloudapi endpoints.

 

The link to the required parameters can be found here: VMware Cloud Director API - VMware API Explorer

Below is the body I was sending:

 

 

 

<AdminVdc xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:extension_v1.5="http://www.vmware.com/vcloud/extension/v1.5" name="Test Org VDC1">
    <AllocationModel>Flex</AllocationModel>
    <ComputeCapacity>
        <Cpu>
            <Units>MHz</Units>
            <Allocated>8000</Allocated>
            <Limit>8000</Limit>
        </Cpu>
        <Memory>
            <Units>MB</Units>
            <Allocated>30000</Allocated>
            <Limit>30000</Limit>
        </Memory>
    </ComputeCapacity>
    <NicQuota>0</NicQuota>
    <NetworkQuota>1000</NetworkQuota>
</AdminVdc>

 

 

 

 

If I remove any of the optional elements, "Allocation Model", "Compute Capacity", "NicQuota" or "Network Quota", I am greeted with a 400 Bad Request and a message in Postman that they are missing. As soon as I include them all, I end up with a 500 Server Error.

 

I should add that when creating the OrgVDC in the first place, even though many parameters were listed as optional, I had to supply values in order for the creation to work. Therefore, it seems that the documentation is not correct, and can only assume APIs are not included in QA tests.

Reply
0 Kudos
4 Replies
mackov83
Enthusiast
Enthusiast

I believe I have confirmed that the documentation does not match reality. With 10.5, below is what I believe is the minimum required parameters:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AdminVdc xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:vmext="http://www.vmware.com/vcloud/extension/v1.5" name="Scripting OrgVDC01">
    <AllocationModel>Flex</AllocationModel>
    <ComputeCapacity>
        <Cpu>
            <Units>MHz</Units>
            <Allocated>6000</Allocated>
            <Limit>6000</Limit>
            <Reserved>0</Reserved>
        </Cpu>
        <Memory>
            <Units>MB</Units>
            <Allocated>30720</Allocated>
            <Limit>30720</Limit>
            <Reserved>0</Reserved>
        </Memory>
    </ComputeCapacity>
    <NicQuota>0</NicQuota>
    <NetworkQuota>0</NetworkQuota>
    <ResourceGuaranteedMemory>1.0</ResourceGuaranteedMemory>
    <ResourceGuaranteedCpu>0.0</ResourceGuaranteedCpu>
    <ProviderVdcReference href="https://vcloud.example.com/api/admin/providervdc/f72a0ee2-698a-459a-a3f5-1dac1943c466" id="urn:vcloud:providervdc:f72a0ee2-698a-459a-a3f5-1dac1943c466" type="application/vnd.vmware.admin.providervdc+xml" name="Test PVDC"/>
</AdminVdc>

 

Reply
0 Kudos
MHTX
Contributor
Contributor

 

Sorry - wish I could delete my post, it was wrong. But apparently I can only edit my response, not delete it. 

Mike

Tags (3)
Reply
0 Kudos
MHTX
Contributor
Contributor

I feel your pain. The API documentation is spotty and not nearly detailed enough. I have a Postman call that adds a second storage profile to an existing Org VDC, maybe that will help you. 

It's a POST call to the url:  /api/admin/vdc/{{ovdcsId}}/vdcStorageProfiles - where the variable is a short version of the OrgVDC ID. 

The body looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<UpdateVdcStorageProfiles
    <AddStorageProfile>
        <Enabled>true</Enabled>
        <Units>MB</Units>
        <Limit>0</Limit>
        <Default>false</Default>
        <ProviderVdcStorageProfile
    </AddStorageProfile>
</UpdateVdcStorageProfiles>
 
Now one of the key failure points in this was the header for me. In the Header of the API call, I had to specify the Content-Type as:
application/vnd.vmware.admin.updateVdcStorageProfiles+xml
I find that with all of these XML calls, I have to update the content-type for every call. Maybe check that on your call?
 
Mike
 
Tags (3)
Reply
0 Kudos
mackov83
Enthusiast
Enthusiast

@MHTX thanks for the info, but I am across the content-type header, I picked that up pretty quickly. You can also just put *+xml which will do the trick also.

Through starting with a full config and removing items one at a time, I actually have it working now. The main issue for me was:

  1. The documentation states most of the settings as optional, which is what I would expect for a PUT (change)
  2. There are settings that you MUST provide, even though they are listed as optional
  3. The server 500 error seems a wrong error code when it's just expecting a setting to be supplied. As mentioned originally, Postman gave error 400 when I needed NicQuota and NetworkQuota, but then a 500 error where other settings where missing,
Reply
0 Kudos