Contributor
Contributor

VCloud Rest API with ruby


Hi


I am new to vcloud rest api. I am currently trying to add a network to a VM in vcloud director.


I am using vcloud-rest ruby gem (https://github.com/astratto/vcloud-rest)


While adding a network it gives me the following error:


/usr/local/share/gems/gems/vcloud-rest-1.3.0/lib/vcloud-rest/connection.rb:233:in `humanize_badrequest': BadRequest - unhandled error: Bad request  - Unexpected JAXB Exception  - cvc-complex-type.2.4.a: Invalid content was found starting with element 'NetworkConnection'. One of '{"http://www.vmware.com/vcloud/v1.5":Link, WC[##other:"http://www.vmware.com/vcloud/v1.5"]}' is expected.. (VCloudClient::UnhandledError)
Please report this issue.
    from /usr/local/share/gems/gems/vcloud-rest-1.3.0/lib/vcloud-rest/connection.rb:177:in `rescue in send_request'
    from /usr/local/share/gems/gems/vcloud-rest-1.3.0/lib/vcloud-rest/connection.rb:163:in `send_request'
    from /usr/local/share/gems/gems/vcloud-rest-1.3.0/lib/vcloud-rest/vcloud/vm.rb:231:in `add_vm_network'
    from add_network.rb:20:in `block in <main>'
    from add_network.rb:19:in `each'
    from add_network.rb:19:in `<main>'


 


My Payload looks like this:


<?xml version="1.0" encoding="UTF-8"?>
<NetworkConnectionSection xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" type="application/vnd.vmware.vcloud.networkConnectionSection+xml" href="https://<vcdurl>/api/vApp/vm-ce72e6cd-82a4-4333-a351-cbc2077cd659/networkConnectionSection/" ovf:required="false" xsi:schemaLocation="http://schemas.dmtf.org/ovf/envelope/1 http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd http://www.vmware.com/vcloud/v1.5 http://<vcdurl>/api/v1.5/schema/master.xsd">
    <ovf:Info>Specifies the available VM network connections</ovf:Info>
    <PrimaryNetworkConnectionIndex>0</PrimaryNetworkConnectionIndex>
    <NetworkConnection network="Management" needsCustomization="true">
        <NetworkConnectionIndex>0</NetworkConnectionIndex>
        <IpAddress>x.x.x.x</IpAddress>
        <IsConnected>true</IsConnected>
        <MACAddress>xx.xx.xx.xx.xx.xx</MACAddress>
        <IpAddressAllocationMode>POOL</IpAddressAllocationMode>
    </NetworkConnection>
    <Link rel="edit" type="application/vnd.vmware.vcloud.networkConnectionSection+xml" href="https://<vcdurl>/api/vApp/vm-ce72e6cd-82a4-4333-a351-cbc2077cd659/networkConnectionSection/"/>
<NetworkConnection network="AppNet0" needsCustomization="false"><NetworkConnectionIndex>1</NetworkConnectionIndex><IsConnected>true</IsConnected><IpAddressAllocationMode>MANUAL</IpAddressAllocationMode><IpAddress>y.y.y.y</IpAddress></NetworkConnection></NetworkConnectionSection>


 


am I doing anyting wrong here?

0 Kudos
1 Reply
Enthusiast
Enthusiast

HI,

Your XML-body doesn't seem to be correct. Try sample from VMware docs with minimum changes.

0 Kudos