github.com/vnpaycloud-console/gophercloud/v2@v2.0.5/openstack/baremetal/inventory/testing/fixtures.go (about) 1 package testing 2 3 import ( 4 "fmt" 5 6 "github.com/vnpaycloud-console/gophercloud/v2/openstack/baremetal/inventory" 7 ) 8 9 const InventorySample = `{ 10 "bmc_address": "192.167.2.134", 11 "boot": { 12 "current_boot_mode": "bios", 13 "pxe_interface": "52:54:00:4e:3d:30" 14 }, 15 "cpu": { 16 "architecture": "x86_64", 17 "count": 2, 18 "flags": [ 19 "fpu", 20 "mmx", 21 "fxsr", 22 "sse", 23 "sse2" 24 ], 25 "frequency": "2100.084" 26 }, 27 "disks": [ 28 { 29 "hctl": null, 30 "model": "", 31 "name": "/dev/vda", 32 "rotational": true, 33 "serial": null, 34 "size": 13958643712, 35 "vendor": "0x1af4", 36 "wwn": null, 37 "wwn_vendor_extension": null, 38 "wwn_with_extension": null 39 } 40 ], 41 "hostname": "myawesomehost", 42 "interfaces": [ 43 { 44 "client_id": null, 45 "has_carrier": true, 46 "ipv4_address": "172.24.42.101", 47 "mac_address": "52:54:00:47:20:4d", 48 "name": "eth1", 49 "product": "0x0001", 50 "vendor": "0x1af4" 51 }, 52 { 53 "client_id": null, 54 "has_carrier": true, 55 "ipv4_address": "172.24.42.100", 56 "mac_address": "52:54:00:4e:3d:30", 57 "name": "eth0", 58 "product": "0x0001", 59 "vendor": "0x1af4", 60 "speed_mbps": 1000 61 } 62 ], 63 "memory": { 64 "physical_mb": 2048, 65 "total": 2105864192 66 }, 67 "system_vendor": { 68 "manufacturer": "Bochs", 69 "product_name": "Bochs", 70 "serial_number": "Not Specified", 71 "firmware": { 72 "version": "1.2.3.4" 73 } 74 } 75 }` 76 77 // ExtraDataJSONSample contains extra hardware sample data reported by the inspection process. 78 const ExtraDataJSONSample = ` 79 { 80 "cpu": { 81 "logical": { 82 "number": 16 83 }, 84 "physical": { 85 "clock": 2105032704, 86 "cores": 8, 87 "flags": "lm fpu fpu_exception wp vme de" 88 } 89 }, 90 "disk": { 91 "sda": { 92 "rotational": 1, 93 "vendor": "TEST" 94 } 95 }, 96 "firmware": { 97 "bios": { 98 "date": "01/01/1970", 99 "vendor": "test" 100 } 101 }, 102 "ipmi": { 103 "Fan1A RPM": { 104 "unit": "RPM", 105 "value": 3120 106 }, 107 "Fan1B RPM": { 108 "unit": "RPM", 109 "value": 2280 110 } 111 }, 112 "memory": { 113 "bank0": { 114 "clock": 1600000000.0, 115 "description": "DIMM DDR3 Synchronous Registered (Buffered) 1600 MHz (0.6 ns)" 116 }, 117 "bank1": { 118 "clock": 1600000000.0, 119 "description": "DIMM DDR3 Synchronous Registered (Buffered) 1600 MHz (0.6 ns)" 120 } 121 }, 122 "network": { 123 "em1": { 124 "Autonegotiate": "on", 125 "loopback": "off [fixed]" 126 }, 127 "p2p1": { 128 "Autonegotiate": "on", 129 "loopback": "off [fixed]" 130 } 131 }, 132 "system": { 133 "ipmi": { 134 "channel": 1 135 }, 136 "kernel": { 137 "arch": "x86_64", 138 "version": "3.10.0" 139 }, 140 "motherboard": { 141 "vendor": "Test" 142 }, 143 "product": { 144 "name": "test", 145 "vendor": "Test" 146 } 147 } 148 } 149 ` 150 151 // NUMADataJSONSample contains NUMA sample data reported by the inspection process. 152 const NUMADataJSONSample = ` 153 { 154 "numa_topology": { 155 "cpus": [ 156 { 157 "cpu": 6, 158 "numa_node": 1, 159 "thread_siblings": [ 160 3, 161 27 162 ] 163 }, 164 { 165 "cpu": 10, 166 "numa_node": 0, 167 "thread_siblings": [ 168 20, 169 44 170 ] 171 } 172 ], 173 "nics": [ 174 { 175 "name": "p2p1", 176 "numa_node": 0 177 }, 178 { 179 "name": "p2p2", 180 "numa_node": 1 181 } 182 ], 183 "ram": [ 184 { 185 "numa_node": 0, 186 "size_kb": 99289532 187 }, 188 { 189 "numa_node": 1, 190 "size_kb": 100663296 191 } 192 ] 193 } 194 } 195 ` 196 197 var StandardPluginDataSample = fmt.Sprintf(` 198 { 199 "all_interfaces": { 200 "eth0": { 201 "client_id": null, 202 "has_carrier": true, 203 "ipv4_address": "172.24.42.101", 204 "mac_address": "52:54:00:47:20:4d", 205 "name": "eth1", 206 "product": "0x0001", 207 "vendor": "0x1af4", 208 "pxe_enabled": true 209 }, 210 "eth1": { 211 "client_id": null, 212 "has_carrier": true, 213 "ipv4_address": "172.24.42.100", 214 "mac_address": "52:54:00:4e:3d:30", 215 "name": "eth0", 216 "product": "0x0001", 217 "vendor": "0x1af4", 218 "speed_mbps": 1000, 219 "pxe_enabled": false 220 } 221 }, 222 "boot_interface": "52:54:00:4e:3d:30", 223 "configuration": { 224 "collectors": ["default", "logs"], 225 "managers": [ 226 { 227 "name": "generic_hardware_manager", 228 "version": "1.1" 229 } 230 ] 231 }, 232 "error": null, 233 "extra": %s, 234 "valid_interfaces": { 235 "eth0": { 236 "client_id": null, 237 "has_carrier": true, 238 "ipv4_address": "172.24.42.101", 239 "mac_address": "52:54:00:47:20:4d", 240 "name": "eth1", 241 "product": "0x0001", 242 "vendor": "0x1af4", 243 "pxe_enabled": true 244 } 245 }, 246 "lldp_raw": { 247 "eth0": [ 248 [ 249 1, 250 "04112233aabbcc" 251 ], 252 [ 253 5, 254 "737730312d646973742d31622d623132" 255 ] 256 ] 257 }, 258 "macs": [ 259 "52:54:00:4e:3d:30" 260 ], 261 "parsed_lldp": { 262 "eth0": { 263 "switch_chassis_id": "11:22:33:aa:bb:cc", 264 "switch_system_name": "sw01-dist-1b-b12" 265 } 266 }, 267 "root_disk": { 268 "hctl": null, 269 "model": "", 270 "name": "/dev/vda", 271 "rotational": true, 272 "serial": null, 273 "size": 13958643712, 274 "vendor": "0x1af4", 275 "wwn": null, 276 "wwn_vendor_extension": null, 277 "wwn_with_extension": null 278 } 279 }`, ExtraDataJSONSample) 280 281 var Inventory = inventory.InventoryType{ 282 SystemVendor: inventory.SystemVendorType{ 283 Manufacturer: "Bochs", 284 ProductName: "Bochs", 285 SerialNumber: "Not Specified", 286 Firmware: inventory.SystemFirmwareType{ 287 Version: "1.2.3.4", 288 }, 289 }, 290 BmcAddress: "192.167.2.134", 291 Boot: inventory.BootInfoType{ 292 CurrentBootMode: "bios", 293 PXEInterface: "52:54:00:4e:3d:30", 294 }, 295 CPU: inventory.CPUType{ 296 Count: 2, 297 Flags: []string{"fpu", "mmx", "fxsr", "sse", "sse2"}, 298 Frequency: "2100.084", 299 Architecture: "x86_64", 300 }, 301 Disks: []inventory.RootDiskType{ 302 { 303 Rotational: true, 304 Model: "", 305 Name: "/dev/vda", 306 Size: 13958643712, 307 Vendor: "0x1af4", 308 }, 309 }, 310 Interfaces: []inventory.InterfaceType{ 311 { 312 Vendor: "0x1af4", 313 HasCarrier: true, 314 MACAddress: "52:54:00:47:20:4d", 315 Name: "eth1", 316 Product: "0x0001", 317 IPV4Address: "172.24.42.101", 318 }, 319 { 320 IPV4Address: "172.24.42.100", 321 MACAddress: "52:54:00:4e:3d:30", 322 Name: "eth0", 323 Product: "0x0001", 324 HasCarrier: true, 325 Vendor: "0x1af4", 326 SpeedMbps: 1000, 327 }, 328 }, 329 Memory: inventory.MemoryType{ 330 PhysicalMb: 2048.0, 331 Total: 2.105864192e+09, 332 }, 333 Hostname: "myawesomehost", 334 } 335 336 var ExtraData = inventory.ExtraDataType{ 337 CPU: inventory.ExtraDataSection{ 338 "logical": map[string]any{ 339 "number": float64(16), 340 }, 341 "physical": map[string]any{ 342 "clock": float64(2105032704), 343 "cores": float64(8), 344 "flags": "lm fpu fpu_exception wp vme de", 345 }, 346 }, 347 Disk: inventory.ExtraDataSection{ 348 "sda": map[string]any{ 349 "rotational": float64(1), 350 "vendor": "TEST", 351 }, 352 }, 353 Firmware: inventory.ExtraDataSection{ 354 "bios": map[string]any{ 355 "date": "01/01/1970", 356 "vendor": "test", 357 }, 358 }, 359 IPMI: inventory.ExtraDataSection{ 360 "Fan1A RPM": map[string]any{ 361 "unit": "RPM", 362 "value": float64(3120), 363 }, 364 "Fan1B RPM": map[string]any{ 365 "unit": "RPM", 366 "value": float64(2280), 367 }, 368 }, 369 Memory: inventory.ExtraDataSection{ 370 "bank0": map[string]any{ 371 "clock": 1600000000.0, 372 "description": "DIMM DDR3 Synchronous Registered (Buffered) 1600 MHz (0.6 ns)", 373 }, 374 "bank1": map[string]any{ 375 "clock": 1600000000.0, 376 "description": "DIMM DDR3 Synchronous Registered (Buffered) 1600 MHz (0.6 ns)", 377 }, 378 }, 379 Network: inventory.ExtraDataSection{ 380 "em1": map[string]any{ 381 "Autonegotiate": "on", 382 "loopback": "off [fixed]", 383 }, 384 "p2p1": map[string]any{ 385 "Autonegotiate": "on", 386 "loopback": "off [fixed]", 387 }, 388 }, 389 System: inventory.ExtraDataSection{ 390 "ipmi": map[string]any{ 391 "channel": float64(1), 392 }, 393 "kernel": map[string]any{ 394 "arch": "x86_64", 395 "version": "3.10.0", 396 }, 397 "motherboard": map[string]any{ 398 "vendor": "Test", 399 }, 400 "product": map[string]any{ 401 "name": "test", 402 "vendor": "Test", 403 }, 404 }, 405 } 406 407 var NUMATopology = inventory.NUMATopology{ 408 CPUs: []inventory.NUMACPU{ 409 { 410 CPU: 6, 411 NUMANode: 1, 412 ThreadSiblings: []int{3, 27}, 413 }, 414 { 415 CPU: 10, 416 NUMANode: 0, 417 ThreadSiblings: []int{20, 44}, 418 }, 419 }, 420 NICs: []inventory.NUMANIC{ 421 { 422 Name: "p2p1", 423 NUMANode: 0, 424 }, 425 { 426 Name: "p2p2", 427 NUMANode: 1, 428 }, 429 }, 430 RAM: []inventory.NUMARAM{ 431 { 432 NUMANode: 0, 433 SizeKB: 99289532, 434 }, 435 { 436 NUMANode: 1, 437 SizeKB: 100663296, 438 }, 439 }, 440 } 441 442 var StandardPluginData = inventory.StandardPluginData{ 443 AllInterfaces: map[string]inventory.ProcessedInterfaceType{ 444 "eth0": { 445 InterfaceType: inventory.InterfaceType{ 446 Vendor: "0x1af4", 447 HasCarrier: true, 448 MACAddress: "52:54:00:47:20:4d", 449 Name: "eth1", 450 Product: "0x0001", 451 IPV4Address: "172.24.42.101", 452 }, 453 PXEEnabled: true, 454 }, 455 "eth1": { 456 InterfaceType: inventory.InterfaceType{ 457 IPV4Address: "172.24.42.100", 458 MACAddress: "52:54:00:4e:3d:30", 459 Name: "eth0", 460 Product: "0x0001", 461 HasCarrier: true, 462 Vendor: "0x1af4", 463 SpeedMbps: 1000, 464 }, 465 }, 466 }, 467 BootInterface: "52:54:00:4e:3d:30", 468 Configuration: inventory.ConfigurationType{ 469 Collectors: []string{"default", "logs"}, 470 Managers: []inventory.HardwareManager{ 471 { 472 Name: "generic_hardware_manager", 473 Version: "1.1", 474 }, 475 }, 476 }, 477 Error: "", 478 Extra: ExtraData, 479 MACs: []string{"52:54:00:4e:3d:30"}, 480 ParsedLLDP: map[string]inventory.ParsedLLDP{ 481 "eth0": map[string]any{ 482 "switch_chassis_id": "11:22:33:aa:bb:cc", 483 "switch_system_name": "sw01-dist-1b-b12", 484 }, 485 }, 486 RawLLDP: map[string][]inventory.LLDPTLVType{ 487 "eth0": { 488 { 489 Type: 1, 490 Value: "04112233aabbcc", 491 }, 492 { 493 Type: 5, 494 Value: "737730312d646973742d31622d623132", 495 }, 496 }, 497 }, 498 RootDisk: inventory.RootDiskType{ 499 Rotational: true, 500 Model: "", 501 Name: "/dev/vda", 502 Size: 13958643712, 503 Vendor: "0x1af4", 504 }, 505 ValidInterfaces: map[string]inventory.ProcessedInterfaceType{ 506 "eth0": { 507 InterfaceType: inventory.InterfaceType{ 508 Vendor: "0x1af4", 509 HasCarrier: true, 510 MACAddress: "52:54:00:47:20:4d", 511 Name: "eth1", 512 Product: "0x0001", 513 IPV4Address: "172.24.42.101", 514 }, 515 PXEEnabled: true, 516 }, 517 }, 518 }