| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
package govcd |
| 6 |
|
| 7 |
import ( |
| 8 |
"github.com/hmrc/vmware-govcd/testutil" |
| 9 |
|
| 10 |
. "gopkg.in/check.v1" |
| 11 |
) |
| 12 |
|
| 13 |
func (s *S) Test_NetRefresh(c *C) { |
| 14 |
|
| 15 |
|
| 16 |
testServer.ResponseMap(1, testutil.ResponseMap{ |
| 17 |
"/api/network/44444444-4444-4444-4444-4444444444444": testutil.Response{200, nil, orgvdcnetExample}, |
| 18 |
}) |
| 19 |
|
| 20 |
network, err := s.vdc.FindVDCNetwork("networkName") |
| 21 |
_ = testServer.WaitRequest() |
| 22 |
testServer.Flush() |
| 23 |
|
| 24 |
c.Assert(err, IsNil) |
| 25 |
c.Assert(network.OrgVDCNetwork.Name, Equals, "networkName") |
| 26 |
|
| 27 |
testServer.Response(200, nil, orgvdcnetExample) |
| 28 |
err = network.Refresh() |
| 29 |
_ = testServer.WaitRequest() |
| 30 |
testServer.Flush() |
| 31 |
|
| 32 |
c.Assert(err, IsNil) |
| 33 |
c.Assert(network.OrgVDCNetwork.Name, Equals, "networkName") |
| 34 |
|
| 35 |
} |
| 36 |
|
| 37 |
var orgvdcnetExample = ` |
| 38 |
<?xml version="1.0" encoding="UTF-8"?> |
| 39 |
<OrgVdcNetwork xmlns="http://www.vmware.com/vcloud/v1.5" status="1" name="networkName" id="urn:vcloud:network:cb0f4c9e-1a46-49d4-9fcb-d228000a6bc1" href="http://localhost:4444/api/network/cb0f4c9e-1a46-49d4-9fcb-d228000a6bc1" type="application/vnd.vmware.vcloud.orgVdcNetwork+xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://10.6.32.3/api/v1.5/schema/master.xsd"> |
| 40 |
<Link rel="up" href="http://localhost:4444/api/vdc/214cd6b2-3f7a-4ee5-9b0a-52b4001a4a84" type="application/vnd.vmware.vcloud.vdc+xml"/> |
| 41 |
<Link rel="down" href="http://localhost:4444/api/network/cb0f4c9e-1a46-49d4-9fcb-d228000a6bc1/metadata" type="application/vnd.vmware.vcloud.metadata+xml"/> |
| 42 |
<Link rel="down" href="http://localhost:4444/api/network/cb0f4c9e-1a46-49d4-9fcb-d228000a6bc1/allocatedAddresses/" type="application/vnd.vmware.vcloud.allocatedNetworkAddress+xml"/> |
| 43 |
<Description>This routed network was created with Create VDC.</Description> |
| 44 |
<Configuration> |
| 45 |
<IpScopes> |
| 46 |
<IpScope> |
| 47 |
<IsInherited>false</IsInherited> |
| 48 |
<Gateway>192.168.109.1</Gateway> |
| 49 |
<Netmask>255.255.255.0</Netmask> |
| 50 |
<IsEnabled>true</IsEnabled> |
| 51 |
<IpRanges> |
| 52 |
<IpRange> |
| 53 |
<StartAddress>192.168.109.2</StartAddress> |
| 54 |
<EndAddress>192.168.109.100</EndAddress> |
| 55 |
</IpRange> |
| 56 |
</IpRanges> |
| 57 |
</IpScope> |
| 58 |
</IpScopes> |
| 59 |
<FenceMode>natRouted</FenceMode> |
| 60 |
<RetainNetInfoAcrossDeployments>false</RetainNetInfoAcrossDeployments> |
| 61 |
</Configuration> |
| 62 |
<IsShared>false</IsShared> |
| 63 |
</OrgVdcNetwork> |
| 64 |
` |