Debian Codegraph @

vm_test.go

raw symbols SCIP
1 /*
2 * Copyright 2016 Skyscape Cloud Services. All rights reserved. Licensed under the Apache v2 License.
3 */
4
5 package govcd
6
7 import (
8 // "fmt"
9 "github.com/hmrc/vmware-govcd/testutil"
10 . "gopkg.in/check.v1"
11 )
12
13 func (s *K) Test_FindVMByHREF(c *C) {
14
15 // Get the Org populated
16 testServer.ResponseMap(1, testutil.ResponseMap{
17 "/api/vApp/vm-11111111-1111-1111-1111-111111111111": testutil.Response{200, nil, vmExample},
18 })
19
20 vm_href := vcdu_api.String() + "/vApp/vm-11111111-1111-1111-1111-111111111111"
21 vm, err := s.client.FindVMByHREF(vm_href)
22 _ = testServer.WaitRequest()
23 testServer.Flush()
24
25 c.Assert(err, IsNil)
26 c.Assert(vm.VM.Name, Equals, "testvmxnet")
27 c.Assert(vm.VM.VirtualHardwareSection.Item, NotNil)
28 }
29
30 var vmExample = `<?xml version="1.0" encoding="UTF-8"?>
31 <Vm xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vmw="http://www.vmware.com/schema/ovf" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" needsCustomization="true" nestedHypervisorEnabled="false" deployed="false" status="8" name="testvmxnet" id="urn:vcloud:vm:11111111-1111-1111-1111-111111111111" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111" type="application/vnd.vmware.vcloud.vm+xml" xsi:schemaLocation="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.22.0/CIM_VirtualSystemSettingData.xsd http://www.vmware.com/schema/ovf http://www.vmware.com/schema/ovf 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://10.10.6.11/api/v1.5/schema/master.xsd http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.22.0/CIM_ResourceAllocationSettingData.xsd">
32 <Link rel="power:powerOn" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/power/action/powerOn"/>
33 <Link rel="deploy" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/action/deploy" type="application/vnd.vmware.vcloud.deployVAppParams+xml"/>
34 <Link rel="edit" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111" type="application/vnd.vmware.vcloud.vm+xml"/>
35 <Link rel="remove" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111"/>
36 <Link rel="down" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/metadata" type="application/vnd.vmware.vcloud.metadata+xml"/>
37 <Link rel="down" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/productSections/" type="application/vnd.vmware.vcloud.productSections+xml"/>
38 <Link rel="down" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/metrics/historic" type="application/vnd.vmware.vcloud.metrics.historicUsageSpec+xml"/>
39 <Link rel="metrics" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/metrics/historic" type="application/vnd.vmware.vcloud.metrics.historicUsageSpec+xml"/>
40 <Link rel="screen:thumbnail" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/screen"/>
41 <Link rel="media:insertMedia" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/media/action/insertMedia" type="application/vnd.vmware.vcloud.mediaInsertOrEjectParams+xml"/>
42 <Link rel="media:ejectMedia" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/media/action/ejectMedia" type="application/vnd.vmware.vcloud.mediaInsertOrEjectParams+xml"/>
43 <Link rel="disk:attach" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/disk/action/attach" type="application/vnd.vmware.vcloud.diskAttachOrDetachParams+xml"/>
44 <Link rel="disk:detach" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/disk/action/detach" type="application/vnd.vmware.vcloud.diskAttachOrDetachParams+xml"/>
45 <Link rel="enable" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/action/enableNestedHypervisor"/>
46 <Link rel="customizeAtNextPowerOn" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/action/customizeAtNextPowerOn"/>
47 <Link rel="snapshot:create" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/action/createSnapshot" type="application/vnd.vmware.vcloud.createSnapshotParams+xml"/>
48 <Link rel="reconfigureVm" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/action/reconfigureVm" name="testvmxnet" type="application/vnd.vmware.vcloud.vm+xml"/>
49 <Link rel="up" href="http://localhost:4444/api/vApp/vapp-22222222-2222-2222-2222-222222222222" type="application/vnd.vmware.vcloud.vApp+xml"/>
50 <Description/>
51 <ovf:VirtualHardwareSection xmlns:vcloud="http://www.vmware.com/vcloud/v1.5" ovf:transport="" vcloud:href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/virtualHardwareSection/" vcloud:type="application/vnd.vmware.vcloud.virtualHardwareSection+xml">
52 <ovf:Info>Virtual hardware requirements</ovf:Info>
53 <ovf:System>
54 <vssd:ElementName>Virtual Hardware Family</vssd:ElementName>
55 <vssd:InstanceID>0</vssd:InstanceID>
56 <vssd:VirtualSystemIdentifier>testvmxnet</vssd:VirtualSystemIdentifier>
57 <vssd:VirtualSystemType>vmx-09</vssd:VirtualSystemType>
58
59 </ovf:System>
60 <ovf:Item>
61 <rasd:Address>00:50:56:01:35:88</rasd:Address>
62 <rasd:AddressOnParent>1</rasd:AddressOnParent>
63 <rasd:AutomaticAllocation>true</rasd:AutomaticAllocation>
64 <rasd:Connection vcloud:ipAddress="10.40.0.11" vcloud:primaryNetworkConnection="true" vcloud:ipAddressingMode="POOL">Development Network</rasd:Connection>
65 <rasd:Description>Vmxnet3 ethernet adapter on "Development Network"</rasd:Description>
66 <rasd:ElementName>Network adapter 1</rasd:ElementName>
67 <rasd:InstanceID>1</rasd:InstanceID>
68 <rasd:ResourceSubType>VMXNET3</rasd:ResourceSubType>
69 <rasd:ResourceType>10</rasd:ResourceType>
70
71 </ovf:Item>
72 <ovf:Item>
73 <rasd:Address>0</rasd:Address>
74 <rasd:Description>SCSI Controller</rasd:Description>
75 <rasd:ElementName>SCSI Controller 0</rasd:ElementName>
76 <rasd:InstanceID>2</rasd:InstanceID>
77 <rasd:ResourceSubType>lsilogic</rasd:ResourceSubType>
78 <rasd:ResourceType>6</rasd:ResourceType>
79
80 </ovf:Item>
81 <ovf:Item>
82 <rasd:AddressOnParent>0</rasd:AddressOnParent>
83 <rasd:Description>Hard disk</rasd:Description>
84 <rasd:ElementName>Hard disk 1</rasd:ElementName>
85 <rasd:HostResource vcloud:capacity="65536" vcloud:storageProfileOverrideVmDefault="false" vcloud:busSubType="lsilogic" vcloud:storageProfileHref="http://localhost:4444/api/vdcStorageProfile/33333333-3333-3333-3333-333333333333" vcloud:busType="6"/>
86 <rasd:InstanceID>2000</rasd:InstanceID>
87 <rasd:Parent>2</rasd:Parent>
88 <rasd:ResourceType>17</rasd:ResourceType>
89
90 </ovf:Item>
91 <ovf:Item>
92 <rasd:Address>1</rasd:Address>
93 <rasd:Description>IDE Controller</rasd:Description>
94 <rasd:ElementName>IDE Controller 1</rasd:ElementName>
95 <rasd:InstanceID>3</rasd:InstanceID>
96 <rasd:ResourceType>5</rasd:ResourceType>
97
98 </ovf:Item>
99 <ovf:Item>
100 <rasd:AddressOnParent>0</rasd:AddressOnParent>
101 <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
102 <rasd:Description>CD/DVD Drive</rasd:Description>
103 <rasd:ElementName>CD/DVD Drive 1</rasd:ElementName>
104 <rasd:HostResource/>
105 <rasd:InstanceID>3002</rasd:InstanceID>
106 <rasd:Parent>3</rasd:Parent>
107 <rasd:ResourceType>15</rasd:ResourceType>
108
109 </ovf:Item>
110 <ovf:Item vcloud:href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/virtualHardwareSection/cpu" vcloud:type="application/vnd.vmware.vcloud.rasdItem+xml">
111 <rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
112 <rasd:Description>Number of Virtual CPUs</rasd:Description>
113 <rasd:ElementName>1 virtual CPU(s)</rasd:ElementName>
114 <rasd:InstanceID>4</rasd:InstanceID>
115 <rasd:Reservation>0</rasd:Reservation>
116 <rasd:ResourceType>3</rasd:ResourceType>
117 <rasd:VirtualQuantity>1</rasd:VirtualQuantity>
118 <rasd:Weight>0</rasd:Weight>
119 <vmw:CoresPerSocket ovf:required="false">1</vmw:CoresPerSocket>
120 <Link rel="edit" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/virtualHardwareSection/cpu" type="application/vnd.vmware.vcloud.rasdItem+xml"/>
121
122 </ovf:Item>
123 <ovf:Item vcloud:href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/virtualHardwareSection/memory" vcloud:type="application/vnd.vmware.vcloud.rasdItem+xml">
124 <rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
125 <rasd:Description>Memory Size</rasd:Description>
126 <rasd:ElementName>512 MB of memory</rasd:ElementName>
127 <rasd:InstanceID>5</rasd:InstanceID>
128 <rasd:Reservation>0</rasd:Reservation>
129 <rasd:ResourceType>4</rasd:ResourceType>
130 <rasd:VirtualQuantity>512</rasd:VirtualQuantity>
131 <rasd:Weight>0</rasd:Weight>
132 <Link rel="edit" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/virtualHardwareSection/memory" type="application/vnd.vmware.vcloud.rasdItem+xml"/>
133
134 </ovf:Item>
135 <Link rel="edit" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/virtualHardwareSection/" type="application/vnd.vmware.vcloud.virtualHardwareSection+xml"/>
136 <Link rel="down" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/virtualHardwareSection/cpu" type="application/vnd.vmware.vcloud.rasdItem+xml"/>
137 <Link rel="edit" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/virtualHardwareSection/cpu" type="application/vnd.vmware.vcloud.rasdItem+xml"/>
138 <Link rel="down" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/virtualHardwareSection/memory" type="application/vnd.vmware.vcloud.rasdItem+xml"/>
139 <Link rel="edit" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/virtualHardwareSection/memory" type="application/vnd.vmware.vcloud.rasdItem+xml"/>
140 <Link rel="down" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/virtualHardwareSection/disks" type="application/vnd.vmware.vcloud.rasdItemsList+xml"/>
141 <Link rel="edit" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/virtualHardwareSection/disks" type="application/vnd.vmware.vcloud.rasdItemsList+xml"/>
142 <Link rel="down" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/virtualHardwareSection/media" type="application/vnd.vmware.vcloud.rasdItemsList+xml"/>
143 <Link rel="down" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/virtualHardwareSection/networkCards" type="application/vnd.vmware.vcloud.rasdItemsList+xml"/>
144 <Link rel="edit" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/virtualHardwareSection/networkCards" type="application/vnd.vmware.vcloud.rasdItemsList+xml"/>
145 <Link rel="down" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/virtualHardwareSection/serialPorts" type="application/vnd.vmware.vcloud.rasdItemsList+xml"/>
146 <Link rel="edit" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/virtualHardwareSection/serialPorts" type="application/vnd.vmware.vcloud.rasdItemsList+xml"/>
147
148 </ovf:VirtualHardwareSection>
149 <ovf:OperatingSystemSection xmlns:vcloud="http://www.vmware.com/vcloud/v1.5" ovf:id="101" vcloud:href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/operatingSystemSection/" vcloud:type="application/vnd.vmware.vcloud.operatingSystemSection+xml" vmw:osType="centos64Guest">
150 <ovf:Info>Specifies the operating system installed</ovf:Info>
151 <ovf:Description>CentOS 4/5/6/7 (64-bit)</ovf:Description>
152 <Link rel="edit" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/operatingSystemSection/" type="application/vnd.vmware.vcloud.operatingSystemSection+xml"/>
153
154 </ovf:OperatingSystemSection>
155 <NetworkConnectionSection href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/networkConnectionSection/" type="application/vnd.vmware.vcloud.networkConnectionSection+xml" ovf:required="false">
156 <ovf:Info>Specifies the available VM network connections</ovf:Info>
157 <PrimaryNetworkConnectionIndex>1</PrimaryNetworkConnectionIndex>
158 <NetworkConnection needsCustomization="true" network="Development Network">
159 <NetworkConnectionIndex>1</NetworkConnectionIndex>
160 <IpAddress>10.40.0.11</IpAddress>
161 <IsConnected>true</IsConnected>
162 <MACAddress>00:50:56:01:35:88</MACAddress>
163 <IpAddressAllocationMode>POOL</IpAddressAllocationMode>
164
165 </NetworkConnection>
166 <Link rel="edit" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/networkConnectionSection/" type="application/vnd.vmware.vcloud.networkConnectionSection+xml"/>
167
168 </NetworkConnectionSection>
169 <GuestCustomizationSection href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/guestCustomizationSection/" type="application/vnd.vmware.vcloud.guestCustomizationSection+xml" ovf:required="false">
170 <ovf:Info>Specifies Guest OS Customization Settings</ovf:Info>
171 <Enabled>true</Enabled>
172 <ChangeSid>false</ChangeSid>
173 <VirtualMachineId>11111111-1111-1111-1111-111111111111</VirtualMachineId>
174 <JoinDomainEnabled>false</JoinDomainEnabled>
175 <UseOrgSettings>false</UseOrgSettings>
176 <AdminPasswordEnabled>true</AdminPasswordEnabled>
177 <AdminPasswordAuto>true</AdminPasswordAuto>
178 <AdminAutoLogonEnabled>false</AdminAutoLogonEnabled>
179 <AdminAutoLogonCount>0</AdminAutoLogonCount>
180 <ResetPasswordRequired>false</ResetPasswordRequired>
181 <ComputerName>testvmxnet3</ComputerName>
182 <Link rel="edit" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/guestCustomizationSection/" type="application/vnd.vmware.vcloud.guestCustomizationSection+xml"/>
183
184 </GuestCustomizationSection>
185 <RuntimeInfoSection xmlns:vcloud="http://www.vmware.com/vcloud/v1.5" vcloud:href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/runtimeInfoSection" vcloud:type="application/vnd.vmware.vcloud.virtualHardwareSection+xml">
186 <ovf:Info>Specifies Runtime info</ovf:Info>
187 <VMWareTools version="2147483647"/>
188
189 </RuntimeInfoSection>
190 <SnapshotSection href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/snapshotSection" type="application/vnd.vmware.vcloud.snapshotSection+xml" ovf:required="false">
191 <ovf:Info>Snapshot information section</ovf:Info>
192
193 </SnapshotSection>
194 <VAppScopedLocalId>vm</VAppScopedLocalId>
195 <VmCapabilities href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/vmCapabilities/" type="application/vnd.vmware.vcloud.vmCapabilitiesSection+xml">
196 <Link rel="edit" href="http://localhost:4444/api/vApp/vm-11111111-1111-1111-1111-111111111111/vmCapabilities/" type="application/vnd.vmware.vcloud.vmCapabilitiesSection+xml"/>
197 <MemoryHotAddEnabled>false</MemoryHotAddEnabled>
198 <CpuHotAddEnabled>false</CpuHotAddEnabled>
199
200 </VmCapabilities>
201 <StorageProfile href="http://localhost:4444/api/vdcStorageProfile/33333333-3333-3333-3333-333333333333" name="BASIC-Any" type="application/vnd.vmware.vcloud.vdcStorageProfile+xml"/>
202 </Vm>
203 `