diff --git a/tbclient/models.go b/tbclient/models.go index efe9c5b..51c1d2a 100644 --- a/tbclient/models.go +++ b/tbclient/models.go @@ -122,6 +122,8 @@ type InventoryVmRemoteAccess struct { type InventoryVm struct { Id string `json:"id,omitempty"` Datacenter string `json:"datacenter,omitempty"` + Name string `json:"name,omitempty"` + Description string `json:"description,omitempty"` OriginalName string `json:"originalName,omitempty"` OriginalDescription string `json:"originalDescription,omitempty"` CpuQty uint64 `json:"cpuQty,omitempty"` diff --git a/tbclient/tbclient_test.go b/tbclient/tbclient_test.go index 0ea3c9d..390678b 100644 --- a/tbclient/tbclient_test.go +++ b/tbclient/tbclient_test.go @@ -102,36 +102,27 @@ var lonDefaultNetwork = Network{ } var inventoryVm = InventoryVm{ - Id: "templatevm3", + Id: "templatevm1", Datacenter: "LON", - OriginalName: "na-edge1", - OriginalDescription: "na-edge1", - CpuQty: 2, - MemoryMb: 4096, + Name: "vmtemplate1 name", + Description: "vmtemplate1 description", + OriginalName: "Collab-mssql1", + OriginalDescription: "Collab-mssql1", + CpuQty: 4, + MemoryMb: 8192, NetworkInterfaces: []InventoryVmNic{ // TODO - contract needs to specify additional fields { InventoryNetworkId: "VLAN-PRIMARY", - Name: "Network adapter 1", + Name: "Network adapter 0", IpAddress: "198.18.133.115", - }, - { - InventoryNetworkId: "VLAN-PRIMARY", - Name: "Network adapter 2", - }, - { - InventoryNetworkId: "L2-VLAN-15", - Name: "Network adapter 3", - }, - { - InventoryNetworkId: "L2-VLAN-20", - Name: "Network adapter 4", + Type: "VIRTUAL_E1000", }, }, RemoteAccess: &InventoryVmRemoteAccess{ - RdpAutoLogin: true, - RdpEnabled: true, - SshEnabled: true, + RdpAutoLogin: false, + RdpEnabled: false, + SshEnabled: false, }, } @@ -1434,6 +1425,7 @@ func (suite *ContractTestSuite) TestGetAllInventoryVms() { // Then suite.Equal(4, len(inventoryVms)) + suite.Equal(inventoryVms[2], inventoryVm) suite.Contains(inventoryVms, inventoryVm) } diff --git a/tbclient/test_stubs/mappings/vm/getAllVms_no_filter_success.json b/tbclient/test_stubs/mappings/vm/getAllVms_no_filter_success.json deleted file mode 100644 index f010248..0000000 --- a/tbclient/test_stubs/mappings/vm/getAllVms_no_filter_success.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "id" : "80cc0840-3c59-4b14-a678-13a67ab3a5eb", - "request" : { - "urlPath" : "/topologies/lontopology/vms", - "method" : "GET" - }, - "response" : { - "status" : 200, - "body" : "{\"_embedded\":{\"vms\":[{\"uid\":\"lonvm1\",\"name\":\"Mail Server 1\",\"description\":\"Mail Server 1\",\"cpuQty\":3,\"memoryMb\":6144,\"nestedHypervisor\":false,\"osFamily\":\"LINUX\",\"inventoryVmId\":\"templatevm2\",\"remoteAccess\":{\"vmConsoleEnabled\":true,\"username\":\"user_name\",\"password\":\"password\",\"displayCredentials\":{\"username\":\"display_user_name\",\"password\":\"display_password\"},\"internalUrls\":[{\"location\":\"http://198.18.131.200:8080/myApp/start?foo=bar\",\"description\":\"My App Launch Page\"}]},\"guestAutomation\":{\"command\":\"cd /var/; sh script.sh\",\"delaySecs\":120},\"vmNetworkInterfaces\":[{\"uid\":\"lonvm1msnic\",\"ipAddress\":\"198.18.131.200\",\"name\":\"Network adapter 1\",\"macAddress\":\"00:50:56:00:00:07\",\"type\":\"VIRTUAL_E1000\",\"rdp\":{\"enabled\":true,\"autoLogin\":true},\"ssh\":{\"enabled\":true},\"inUse\":true,\"network\":{\"uid\":\"lontopologyv1nwk\",\"name\":\"Default Network\",\"inventoryNetwork\":{\"id\":\"VLAN-PRIMARY\",\"type\":\"ROUTED\",\"subnet\":\"198.18.128.0 /18\"},\"_links\":{\"self\":{\"href\":\"http://localhost/networks/lontopologyv1nwk\"}}}},{\"uid\":\"lonvm1natnic\",\"ipAddress\":\"198.18.131.201\",\"name\":\"Network adapter 2\",\"macAddress\":\"00:50:56:00:00:08\",\"type\":\"VIRTUAL_E1000\",\"inUse\":false,\"network\":{\"uid\":\"lontopologyv1nwk\",\"name\":\"Default Network\",\"inventoryNetwork\":{\"id\":\"VLAN-PRIMARY\",\"type\":\"ROUTED\",\"subnet\":\"198.18.128.0 /18\"},\"_links\":{\"self\":{\"href\":\"http://localhost/networks/lontopologyv1nwk\"}}}}],\"advancedSettings\":{\"nameInHypervisor\":\"Demo_007-VM\",\"biosUuid\":\"61 62 63 64 65 66 67 68-69 6a 6b 6c 6d 6e 6f 70\",\"notStarted\":false,\"allDisksNonPersistent\":false},\"type\":\"VM\",\"topology\":{\"uid\":\"lontopology\"},\"_links\":{\"self\":{\"href\":\"http://localhost/vms/lonvm1\"},\"topology\":{\"href\":\"http://localhost/topologies/lontopology\"}}},{\"uid\":\"lonvm2\",\"name\":\"Collab DB\",\"description\":\"Collab DB\",\"cpuQty\":8,\"memoryMb\":4608,\"nestedHypervisor\":false,\"osFamily\":\"WINDOWS\",\"inventoryVmId\":\"templatevm1\",\"remoteAccess\":{\"vmConsoleEnabled\":false},\"vmNetworkInterfaces\":[{\"uid\":\"lonvm2nic1\",\"ipAddress\":\"198.18.133.111\",\"name\":\"Network adapter 1\",\"macAddress\":\"00:50:56:00:00:09\",\"type\":\"VIRTUAL_E1000\",\"inUse\":false,\"network\":{\"uid\":\"lontopologyv1nwk\",\"name\":\"Default Network\",\"inventoryNetwork\":{\"id\":\"VLAN-PRIMARY\",\"type\":\"ROUTED\",\"subnet\":\"198.18.128.0 /18\"},\"_links\":{\"self\":{\"href\":\"http://localhost/networks/lontopologyv1nwk\"}}}}],\"advancedSettings\":{\"nameInHypervisor\":\"Win_10-VM\",\"biosUuid\":\"61 62 63 64 65 66 67 68-69 6a 6b 6c 6d 6e 6f 70\",\"notStarted\":false,\"allDisksNonPersistent\":false},\"type\":\"VM\",\"topology\":{\"uid\":\"lontopology\"},\"_links\":{\"self\":{\"href\":\"http://localhost/vms/lonvm2\"},\"topology\":{\"href\":\"http://localhost/topologies/lontopology\"}}},{\"uid\":\"lonvhw1\",\"name\":\"Cat9kv-17.10\",\"description\":\"Cat9kv-17.10\",\"cpuQty\":4,\"memoryMb\":18432,\"nestedHypervisor\":false,\"inventoryVmId\":\"templatevhw1\",\"remoteAccess\":{\"vmConsoleEnabled\":false},\"vmNetworkInterfaces\":[{\"uid\":\"lonvhw1nic1\",\"ipAddress\":\"198.18.133.111\",\"name\":\"Network adapter 1\",\"macAddress\":\"00:50:56:00:00:09\",\"type\":\"VIRTUAL_E1000\",\"inUse\":false,\"network\":{\"uid\":\"lontopologyv1nwk\",\"name\":\"Default Network\",\"inventoryNetwork\":{\"id\":\"VLAN-PRIMARY\",\"type\":\"ROUTED\",\"subnet\":\"198.18.128.0 /18\"},\"_links\":{\"self\":{\"href\":\"http://localhost/networks/lontopologyv1nwk\"}}}}],\"advancedSettings\":{\"nameInHypervisor\":\"Cat9kv-17.10\",\"biosUuid\":\"61 62 63 64 65 66 67 68-69 6a 6b 6c 6d 6e 6f 70\",\"notStarted\":false,\"allDisksNonPersistent\":false},\"topology\":{\"uid\":\"lontopology\"},\"type\":\"VHW\",\"_links\":{\"self\":{\"href\":\"http://localhost/vms/lonvhw1\"},\"topology\":{\"href\":\"http://localhost/topologies/lontopology\"}}}]},\"_links\":{\"self\":{\"href\":\"http://localhost/topologies/lontopology/vms\"}}}", - "headers" : { - "Content-Type" : "application/json" - }, - "transformers" : [ "response-template", "spring-cloud-contract" ] - }, - "uuid" : "80cc0840-3c59-4b14-a678-13a67ab3a5eb" -} diff --git a/tbclient/test_stubs/mappings/vm/getInventoryTemplateVirtualHardware_lonTopology.json b/tbclient/test_stubs/mappings/vm/getInventoryTemplateVirtualHardware_lonTopology.json deleted file mode 100644 index 044c8a8..0000000 --- a/tbclient/test_stubs/mappings/vm/getInventoryTemplateVirtualHardware_lonTopology.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "id" : "72ec05ef-42d5-4b95-8611-c46afcdc44c9", - "request" : { - "urlPath" : "/topologies/lontopology/inventory-template-vms", - "method" : "GET", - "queryParameters" : { - "filter" : { - "equalTo" : "type:equalTo:VHW" - } - } - }, - "response" : { - "status" : 200, - "body" : "{\"_embedded\":{\"inventoryVms\":[{\"datacenter\":\"LON\",\"id\":\"templatevhw1\",\"originalName\":\"Cat9kv-17.10\",\"originalDescription\":\"Cat9kv-17.10\",\"cpuQty\":4,\"memoryMb\":18432,\"networkInterfaces\":[{\"inventoryNetworkId\":\"VLAN-PRIMARY\",\"name\":\"Network adapter 0\",\"ipAddress\":\"198.18.133.115\"}],\"name\":\"templatevhw1 name\",\"description\":\"templatevhw1 description\",\"licensed\":true,\"templateVersion\":\"0.0.1\",\"username\":\"username\",\"password\":\"password\",\"managementIp\":\"10.1.1.1\",\"lastUpdated\":\"2020-12-16T14:00:00.000000Z\",\"type\":\"VHW\",\"architectures\":[{\"uid\":\"arcen\",\"name\":\"Enterprise Networking\"}]}]},\"_links\":{\"self\":{\"href\":\"http://localhost/topologies/lontopology/inventory-template-vms\"}}}", - "headers" : { - "Content-Type" : "application/json" - }, - "transformers" : [ "response-template", "spring-cloud-contract" ] - }, - "uuid" : "72ec05ef-42d5-4b95-8611-c46afcdc44c9" -} diff --git a/tbclient/test_stubs/mappings/vm/getVirtualHardware_success.json b/tbclient/test_stubs/mappings/vm/getVirtualHardware_success.json deleted file mode 100644 index 87b6e78..0000000 --- a/tbclient/test_stubs/mappings/vm/getVirtualHardware_success.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "id" : "59dc82e7-2815-48b6-94a2-e891e91f9a6e", - "request" : { - "urlPath" : "/topologies/lontopology/vms", - "method" : "GET", - "queryParameters" : { - "filter" : { - "equalTo" : "type:equalTo:VHW" - } - } - }, - "response" : { - "status" : 200, - "body" : "{\"_embedded\":{\"vms\":[{\"uid\":\"lonvhw1\",\"name\":\"Cat9kv-17.10\",\"description\":\"Cat9kv-17.10\",\"cpuQty\":4,\"memoryMb\":18432,\"nestedHypervisor\":false,\"inventoryVmId\":\"templatevhw1\",\"remoteAccess\":{\"vmConsoleEnabled\":false},\"vmNetworkInterfaces\":[{\"uid\":\"lonvhw1nic1\",\"ipAddress\":\"198.18.133.111\",\"name\":\"Network adapter 1\",\"macAddress\":\"00:50:56:00:00:09\",\"type\":\"VIRTUAL_E1000\",\"inUse\":false,\"network\":{\"uid\":\"lontopologyv1nwk\",\"name\":\"Default Network\",\"inventoryNetwork\":{\"id\":\"VLAN-PRIMARY\",\"type\":\"ROUTED\",\"subnet\":\"198.18.128.0 /18\"},\"_links\":{\"self\":{\"href\":\"http://localhost/networks/lontopologyv1nwk\"}}}}],\"advancedSettings\":{\"nameInHypervisor\":\"Cat9kv-17.10\",\"biosUuid\":\"61 62 63 64 65 66 67 68-69 6a 6b 6c 6d 6e 6f 70\",\"notStarted\":false,\"allDisksNonPersistent\":false},\"topology\":{\"uid\":\"lontopology\"},\"type\":\"VHW\",\"_links\":{\"self\":{\"href\":\"http://localhost/vms/lonvhw1\"},\"topology\":{\"href\":\"http://localhost/topologies/lontopology\"}}}]},\"_links\":{\"self\":{\"href\":\"http://localhost/topologies/lontopology/vms\"}}}", - "headers" : { - "Content-Type" : "application/json" - }, - "transformers" : [ "response-template", "spring-cloud-contract" ] - }, - "uuid" : "59dc82e7-2815-48b6-94a2-e891e91f9a6e" -}