当fenceMode被隔离时,如何通过REST api将父网络添加到现有vapp

时间:2015-07-31 22:44:42

标签: vmware vcloud-director-rest-api

我通过我的模板在vcd主机上实例化vapp,vapp网络配置部分xml看起来像:

<?xml version="1.0" encoding="UTF-8"?>
<NetworkConfigSection xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" type="application/vnd.vmware.vcloud.networkConfigSection+xml" href="https://mycloud.stratogen.com/api/vApp/vapp-0991d221-1b3e-47aa-ab69-2d8f300f454d/networkConfigSection/" ovf:required="false" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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://mycloud.stratogen.com/api/v1.5/schema/master.xsd">
    <ovf:Info>The configuration parameters for logical networks</ovf:Info>
    <Link rel="edit" type="application/vnd.vmware.vcloud.networkConfigSection+xml" href="https://mycloud.stratogen.com/api/vApp/vapp-0991d221-1b3e-47aa-ab69-2d8f300f454d/networkConfigSection/"/>
    <NetworkConfig networkName="VM Network">
        <Link rel="repair" href="https://mycloud.stratogen.com/api/admin/network/86d21d4f-0b15-44e3-877e-5b5160ea9271/action/reset"/>
        <Description>The VM Network network</Description>
        <Configuration>
            <IpScope>
                <IsInherited>false</IsInherited>
                <Gateway>192.168.254.1</Gateway>
                <Netmask>255.255.255.0</Netmask>
                <IpRanges>
                    <IpRange>
                        <StartAddress>192.168.254.100</StartAddress>
                        <EndAddress>192.168.254.199</EndAddress>
                    </IpRange>
                </IpRanges>
            </IpScope>
            <FenceMode>isolated</FenceMode>
            <RetainNetInfoAcrossDeployments>false</RetainNetInfoAcrossDeployments>
        </Configuration>
        <IsDeployed>false</IsDeployed>
    </NetworkConfig>
</NetworkConfigSection>

所以,我已经阅读了有关NetworkConfigSection的官方vmware文档,并尝试添加ParentNetwork并切换到natRouted fence模式,就像在示例中一样: https://pubs.vmware.com/vcd-51/index.jsp?topic=%2Fcom.vmware.vcloud.api.doc_51%2FGUID-92622A15-E588-4FA1-92DA-A22A4757F2A0.html

所以,现在我的XML看起来像:

<?xml version="1.0" encoding="UTF-8"?>
<NetworkConfigSection xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" type="application/vnd.vmware.vcloud.networkConfigSection+xml" href="https://mycloud.stratogen.com/api/vApp/vapp-0991d221-1b3e-47aa-ab69-2d8f300f454d/networkConfigSection/" ovf:required="false" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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://mycloud.stratogen.com/api/v1.5/schema/master.xsd">
    <ovf:Info>The configuration parameters for logical networks</ovf:Info>
    <Link rel="edit" type="application/vnd.vmware.vcloud.networkConfigSection+xml" href="https://mycloud.stratogen.com/api/vApp/vapp-0991d221-1b3e-47aa-ab69-2d8f300f454d/networkConfigSection/"/>
    <NetworkConfig networkName="VM Network">
        <Link rel="repair" href="https://mycloud.stratogen.com/api/admin/network/86d21d4f-0b15-44e3-877e-5b5160ea9271/action/reset"/>
        <Description>The VM Network network</Description>
        <Configuration>
        <IpScopes>
            <IpScope>
                <IsInherited>false</IsInherited>
                <Gateway>192.168.254.1</Gateway>
                <Netmask>255.255.255.0</Netmask>
                <IpRanges>
                    <IpRange>
                        <StartAddress>192.168.254.100</StartAddress>
                        <EndAddress>192.168.254.199</EndAddress>
                    </IpRange>
                </IpRanges>
            </IpScope>
        </IpScopes>
            <FenceMode>natRouted</FenceMode>
            <ParentNetwork
            type="application/vnd.vmware.vcloud.network+xml"
            name="Internet"
            href="https://vcloud.example.com/api/network/54" />

            <RetainNetInfoAcrossDeployments>false</RetainNetInfoAcrossDeployments>
        </Configuration>
        <IsDeployed>false</IsDeployed>
    </NetworkConfig>
</NetworkConfigSection>

之后我提交了PUT请求来编辑URL,我收到了一个错误:

<?xml version="1.0" encoding="UTF-8"?>
<Error xmlns="http://www.vmware.com/vcloud/v1.5" minorErrorCode="BAD_REQUEST" message="Bad request
 - Unexpected JAXB Exception
 - cvc-complex-type.2.4.a: Invalid content was found starting with element \'ParentNetwork\'. One of \'{&quot;http://www.vmware.com/vcloud/v1.5&quot;:RetainNetInfoAcrossDeployments, &quot;http://www.vmware.com/vcloud/v1.5&quot;:Features, &quot;http://www.vmware.com/vcloud/v1.5&quot;:SyslogServerSettings, &quot;http://www.vmware.com/vcloud/v1.5&quot;:RouterInfo}\' is expected." majorErrorCode="400" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://mycloud.stratogen.com/api/v1.5/schema/master.xsd"></Error>

如何使用vCloudDirector rest api?

将父网络添加到现有vApp

感谢。

0 个答案:

没有答案