github.com/vnpaycloud-console/gophercloud/v2@v2.0.5/internal/acceptance/clients/clients.go (about) 1 // Package clients contains functions for creating OpenStack service clients 2 // for use in acceptance tests. It also manages the required environment 3 // variables to run the tests. 4 package clients 5 6 import ( 7 "context" 8 "fmt" 9 "net/http" 10 "os" 11 "strings" 12 13 "github.com/vnpaycloud-console/gophercloud/v2" 14 "github.com/vnpaycloud-console/gophercloud/v2/openstack" 15 baremetalHTTPBasic "github.com/vnpaycloud-console/gophercloud/v2/openstack/baremetal/httpbasic" 16 baremetalNoAuth "github.com/vnpaycloud-console/gophercloud/v2/openstack/baremetal/noauth" 17 blockstorageNoAuth "github.com/vnpaycloud-console/gophercloud/v2/openstack/blockstorage/noauth" 18 ) 19 20 // AcceptanceTestChoices contains image and flavor selections for use by the acceptance tests. 21 type AcceptanceTestChoices struct { 22 // ImageID contains the ID of a valid image. 23 ImageID string 24 25 // FlavorID contains the ID of a valid flavor. 26 FlavorID string 27 28 // FlavorIDResize contains the ID of a different flavor available on the same OpenStack installation, that is distinct 29 // from FlavorID. 30 FlavorIDResize string 31 32 // FloatingIPPool contains the name of the pool from where to obtain floating IPs. 33 FloatingIPPoolName string 34 35 // MagnumKeypair contains the ID of a valid key pair. 36 MagnumKeypair string 37 38 // MagnumImageID contains the ID of a valid magnum image. 39 MagnumImageID string 40 41 // NetworkName is the name of a network to launch the instance on. 42 NetworkName string 43 44 // NetworkID is the ID of a network to launch the instance on. 45 NetworkID string 46 47 // SubnetID is the ID of a subnet to launch the instance on. 48 SubnetID string 49 50 // ExternalNetworkID is the network ID of the external network. 51 ExternalNetworkID string 52 53 // DBDatastoreType is the datastore type for DB tests. 54 DBDatastoreType string 55 56 // DBDatastoreTypeID is the datastore type version for DB tests. 57 DBDatastoreVersion string 58 } 59 60 // AcceptanceTestChoicesFromEnv populates a ComputeChoices struct from environment variables. 61 // If any required state is missing, an `error` will be returned that enumerates the missing properties. 62 func AcceptanceTestChoicesFromEnv() (*AcceptanceTestChoices, error) { 63 imageID := os.Getenv("OS_IMAGE_ID") 64 flavorID := os.Getenv("OS_FLAVOR_ID") 65 flavorIDResize := os.Getenv("OS_FLAVOR_ID_RESIZE") 66 magnumImageID := os.Getenv("OS_MAGNUM_IMAGE_ID") 67 magnumKeypair := os.Getenv("OS_MAGNUM_KEYPAIR") 68 networkName := os.Getenv("OS_NETWORK_NAME") 69 networkID := os.Getenv("OS_NETWORK_ID") 70 subnetID := os.Getenv("OS_SUBNET_ID") 71 floatingIPPoolName := os.Getenv("OS_POOL_NAME") 72 externalNetworkID := os.Getenv("OS_EXTGW_ID") 73 dbDatastoreType := os.Getenv("OS_DB_DATASTORE_TYPE") 74 dbDatastoreVersion := os.Getenv("OS_DB_DATASTORE_VERSION") 75 76 missing := make([]string, 0, 3) 77 if imageID == "" { 78 missing = append(missing, "OS_IMAGE_ID") 79 } 80 if flavorID == "" { 81 missing = append(missing, "OS_FLAVOR_ID") 82 } 83 if flavorIDResize == "" { 84 missing = append(missing, "OS_FLAVOR_ID_RESIZE") 85 } 86 if floatingIPPoolName == "" { 87 missing = append(missing, "OS_POOL_NAME") 88 } 89 if externalNetworkID == "" { 90 missing = append(missing, "OS_EXTGW_ID") 91 } 92 93 /* // Temporarily disabled, see https://github.com/gophercloud/gophercloud/issues/1345 94 if networkID == "" { 95 missing = append(missing, "OS_NETWORK_ID") 96 } 97 if subnetID == "" { 98 missing = append(missing, "OS_SUBNET_ID") 99 } 100 */ 101 102 if networkName == "" { 103 networkName = "private" 104 } 105 notDistinct := "" 106 if flavorID == flavorIDResize { 107 notDistinct = "OS_FLAVOR_ID and OS_FLAVOR_ID_RESIZE must be distinct." 108 } 109 110 if len(missing) > 0 { 111 text := "You're missing some important setup:\n * These environment variables must be provided: %s\n" 112 return nil, fmt.Errorf(text, strings.Join(missing, ", ")) 113 } 114 115 if notDistinct != "" { 116 text := "You're missing some important setup:\n * %s\n" 117 return nil, fmt.Errorf(text, notDistinct) 118 } 119 120 return &AcceptanceTestChoices{ 121 ImageID: imageID, 122 FlavorID: flavorID, 123 FlavorIDResize: flavorIDResize, 124 FloatingIPPoolName: floatingIPPoolName, 125 MagnumImageID: magnumImageID, 126 MagnumKeypair: magnumKeypair, 127 NetworkName: networkName, 128 NetworkID: networkID, 129 SubnetID: subnetID, 130 ExternalNetworkID: externalNetworkID, 131 DBDatastoreType: dbDatastoreType, 132 DBDatastoreVersion: dbDatastoreVersion, 133 }, nil 134 } 135 136 // NewBlockStorageV1Client returns a *ServiceClient for making calls 137 // to the OpenStack Block Storage v1 API. An error will be returned 138 // if authentication or client creation was not possible. 139 func NewBlockStorageV1Client() (*gophercloud.ServiceClient, error) { 140 ao, err := openstack.AuthOptionsFromEnv() 141 if err != nil { 142 return nil, err 143 } 144 145 client, err := openstack.AuthenticatedClient(context.TODO(), ao) 146 if err != nil { 147 return nil, err 148 } 149 150 client = configureDebug(client) 151 152 return openstack.NewBlockStorageV1(client, gophercloud.EndpointOpts{ 153 Region: os.Getenv("OS_REGION_NAME"), 154 }) 155 } 156 157 // NewBlockStorageV2Client returns a *ServiceClient for making calls 158 // to the OpenStack Block Storage v2 API. An error will be returned 159 // if authentication or client creation was not possible. 160 func NewBlockStorageV2Client() (*gophercloud.ServiceClient, error) { 161 ao, err := openstack.AuthOptionsFromEnv() 162 if err != nil { 163 return nil, err 164 } 165 166 client, err := openstack.AuthenticatedClient(context.TODO(), ao) 167 if err != nil { 168 return nil, err 169 } 170 171 client = configureDebug(client) 172 173 return openstack.NewBlockStorageV2(client, gophercloud.EndpointOpts{ 174 Region: os.Getenv("OS_REGION_NAME"), 175 }) 176 } 177 178 // NewBlockStorageV3Client returns a *ServiceClient for making calls 179 // to the OpenStack Block Storage v3 API. An error will be returned 180 // if authentication or client creation was not possible. 181 func NewBlockStorageV3Client() (*gophercloud.ServiceClient, error) { 182 ao, err := openstack.AuthOptionsFromEnv() 183 if err != nil { 184 return nil, err 185 } 186 187 client, err := openstack.AuthenticatedClient(context.TODO(), ao) 188 if err != nil { 189 return nil, err 190 } 191 192 client = configureDebug(client) 193 194 return openstack.NewBlockStorageV3(client, gophercloud.EndpointOpts{ 195 Region: os.Getenv("OS_REGION_NAME"), 196 }) 197 } 198 199 // NewBlockStorageV2NoAuthClient returns a noauth *ServiceClient for 200 // making calls to the OpenStack Block Storage v2 API. An error will be 201 // returned if client creation was not possible. 202 func NewBlockStorageV2NoAuthClient() (*gophercloud.ServiceClient, error) { 203 client, err := blockstorageNoAuth.NewClient(gophercloud.AuthOptions{ 204 Username: os.Getenv("OS_USERNAME"), 205 TenantName: os.Getenv("OS_TENANT_NAME"), 206 }) 207 if err != nil { 208 return nil, err 209 } 210 211 client = configureDebug(client) 212 213 return blockstorageNoAuth.NewBlockStorageNoAuthV2(client, blockstorageNoAuth.EndpointOpts{ 214 CinderEndpoint: os.Getenv("CINDER_ENDPOINT"), 215 }) 216 } 217 218 // NewBlockStorageV3NoAuthClient returns a noauth *ServiceClient for 219 // making calls to the OpenStack Block Storage v3 API. An error will be 220 // returned if client creation was not possible. 221 func NewBlockStorageV3NoAuthClient() (*gophercloud.ServiceClient, error) { 222 client, err := blockstorageNoAuth.NewClient(gophercloud.AuthOptions{ 223 Username: os.Getenv("OS_USERNAME"), 224 TenantName: os.Getenv("OS_TENANT_NAME"), 225 }) 226 if err != nil { 227 return nil, err 228 } 229 230 client = configureDebug(client) 231 232 return blockstorageNoAuth.NewBlockStorageNoAuthV3(client, blockstorageNoAuth.EndpointOpts{ 233 CinderEndpoint: os.Getenv("CINDER_ENDPOINT"), 234 }) 235 } 236 237 // NewComputeV2Client returns a *ServiceClient for making calls 238 // to the OpenStack Compute v2 API. An error will be returned 239 // if authentication or client creation was not possible. 240 func NewComputeV2Client() (*gophercloud.ServiceClient, error) { 241 ao, err := openstack.AuthOptionsFromEnv() 242 if err != nil { 243 return nil, err 244 } 245 246 client, err := openstack.AuthenticatedClient(context.TODO(), ao) 247 if err != nil { 248 return nil, err 249 } 250 251 client = configureDebug(client) 252 253 return openstack.NewComputeV2(client, gophercloud.EndpointOpts{ 254 Region: os.Getenv("OS_REGION_NAME"), 255 }) 256 } 257 258 // NewBareMetalV1Client returns a *ServiceClient for making calls 259 // to the OpenStack Bare Metal v1 API. An error will be returned 260 // if authentication or client creation was not possible. 261 func NewBareMetalV1Client() (*gophercloud.ServiceClient, error) { 262 ao, err := openstack.AuthOptionsFromEnv() 263 if err != nil { 264 return nil, err 265 } 266 267 client, err := openstack.AuthenticatedClient(context.TODO(), ao) 268 if err != nil { 269 return nil, err 270 } 271 272 client = configureDebug(client) 273 274 return openstack.NewBareMetalV1(client, gophercloud.EndpointOpts{ 275 Region: os.Getenv("OS_REGION_NAME"), 276 }) 277 } 278 279 // NewBareMetalV1NoAuthClient returns a *ServiceClient for making calls 280 // to the OpenStack Bare Metal v1 API. An error will be returned 281 // if authentication or client creation was not possible. 282 func NewBareMetalV1NoAuthClient() (*gophercloud.ServiceClient, error) { 283 return baremetalNoAuth.NewBareMetalNoAuth(baremetalNoAuth.EndpointOpts{ 284 IronicEndpoint: os.Getenv("IRONIC_ENDPOINT"), 285 }) 286 } 287 288 // NewBareMetalV1HTTPBasic returns a *ServiceClient for making calls 289 // to the OpenStack Bare Metal v1 API. An error will be returned 290 // if authentication or client creation was not possible. 291 func NewBareMetalV1HTTPBasic() (*gophercloud.ServiceClient, error) { 292 return baremetalHTTPBasic.NewBareMetalHTTPBasic(baremetalHTTPBasic.EndpointOpts{ 293 IronicEndpoint: os.Getenv("IRONIC_ENDPOINT"), 294 IronicUser: os.Getenv("OS_USERNAME"), 295 IronicUserPassword: os.Getenv("OS_PASSWORD"), 296 }) 297 } 298 299 // NewBareMetalIntrospectionV1Client returns a *ServiceClient for making calls 300 // to the OpenStack Bare Metal Introspection v1 API. An error will be returned 301 // if authentication or client creation was not possible. 302 func NewBareMetalIntrospectionV1Client() (*gophercloud.ServiceClient, error) { 303 ao, err := openstack.AuthOptionsFromEnv() 304 if err != nil { 305 return nil, err 306 } 307 308 client, err := openstack.AuthenticatedClient(context.TODO(), ao) 309 if err != nil { 310 return nil, err 311 } 312 313 client = configureDebug(client) 314 315 return openstack.NewBareMetalIntrospectionV1(client, gophercloud.EndpointOpts{ 316 Region: os.Getenv("OS_REGION_NAME"), 317 }) 318 } 319 320 // NewDBV1Client returns a *ServiceClient for making calls 321 // to the OpenStack Database v1 API. An error will be returned 322 // if authentication or client creation was not possible. 323 func NewDBV1Client() (*gophercloud.ServiceClient, error) { 324 ao, err := openstack.AuthOptionsFromEnv() 325 if err != nil { 326 return nil, err 327 } 328 329 client, err := openstack.AuthenticatedClient(context.TODO(), ao) 330 if err != nil { 331 return nil, err 332 } 333 334 client = configureDebug(client) 335 336 return openstack.NewDBV1(client, gophercloud.EndpointOpts{ 337 Region: os.Getenv("OS_REGION_NAME"), 338 }) 339 } 340 341 // NewDNSV2Client returns a *ServiceClient for making calls 342 // to the OpenStack Compute v2 API. An error will be returned 343 // if authentication or client creation was not possible. 344 func NewDNSV2Client() (*gophercloud.ServiceClient, error) { 345 ao, err := openstack.AuthOptionsFromEnv() 346 if err != nil { 347 return nil, err 348 } 349 350 client, err := openstack.AuthenticatedClient(context.TODO(), ao) 351 if err != nil { 352 return nil, err 353 } 354 355 client = configureDebug(client) 356 357 return openstack.NewDNSV2(client, gophercloud.EndpointOpts{ 358 Region: os.Getenv("OS_REGION_NAME"), 359 }) 360 } 361 362 // NewIdentityV2Client returns a *ServiceClient for making calls 363 // to the OpenStack Identity v2 API. An error will be returned 364 // if authentication or client creation was not possible. 365 func NewIdentityV2Client() (*gophercloud.ServiceClient, error) { 366 ao, err := openstack.AuthOptionsFromEnv() 367 if err != nil { 368 return nil, err 369 } 370 371 client, err := openstack.AuthenticatedClient(context.TODO(), ao) 372 if err != nil { 373 return nil, err 374 } 375 376 client = configureDebug(client) 377 378 return openstack.NewIdentityV2(client, gophercloud.EndpointOpts{ 379 Region: os.Getenv("OS_REGION_NAME"), 380 }) 381 } 382 383 // NewIdentityV2AdminClient returns a *ServiceClient for making calls 384 // to the Admin Endpoint of the OpenStack Identity v2 API. An error 385 // will be returned if authentication or client creation was not possible. 386 func NewIdentityV2AdminClient() (*gophercloud.ServiceClient, error) { 387 ao, err := openstack.AuthOptionsFromEnv() 388 if err != nil { 389 return nil, err 390 } 391 392 client, err := openstack.AuthenticatedClient(context.TODO(), ao) 393 if err != nil { 394 return nil, err 395 } 396 397 client = configureDebug(client) 398 399 return openstack.NewIdentityV2(client, gophercloud.EndpointOpts{ 400 Region: os.Getenv("OS_REGION_NAME"), 401 Availability: gophercloud.AvailabilityAdmin, 402 }) 403 } 404 405 // NewIdentityV2UnauthenticatedClient returns an unauthenticated *ServiceClient 406 // for the OpenStack Identity v2 API. An error will be returned if 407 // authentication or client creation was not possible. 408 func NewIdentityV2UnauthenticatedClient() (*gophercloud.ServiceClient, error) { 409 ao, err := openstack.AuthOptionsFromEnv() 410 if err != nil { 411 return nil, err 412 } 413 414 client, err := openstack.NewClient(ao.IdentityEndpoint) 415 if err != nil { 416 return nil, err 417 } 418 419 client = configureDebug(client) 420 421 return openstack.NewIdentityV2(client, gophercloud.EndpointOpts{}) 422 } 423 424 // NewIdentityV3Client returns a *ServiceClient for making calls 425 // to the OpenStack Identity v3 API. An error will be returned 426 // if authentication or client creation was not possible. 427 func NewIdentityV3Client() (*gophercloud.ServiceClient, error) { 428 ao, err := openstack.AuthOptionsFromEnv() 429 if err != nil { 430 return nil, err 431 } 432 433 client, err := openstack.AuthenticatedClient(context.TODO(), ao) 434 if err != nil { 435 return nil, err 436 } 437 438 client = configureDebug(client) 439 440 return openstack.NewIdentityV3(client, gophercloud.EndpointOpts{ 441 Region: os.Getenv("OS_REGION_NAME"), 442 }) 443 } 444 445 // NewIdentityV3UnauthenticatedClient returns an unauthenticated *ServiceClient 446 // for the OpenStack Identity v3 API. An error will be returned if 447 // authentication or client creation was not possible. 448 func NewIdentityV3UnauthenticatedClient() (*gophercloud.ServiceClient, error) { 449 ao, err := openstack.AuthOptionsFromEnv() 450 if err != nil { 451 return nil, err 452 } 453 454 client, err := openstack.NewClient(ao.IdentityEndpoint) 455 if err != nil { 456 return nil, err 457 } 458 459 client = configureDebug(client) 460 461 return openstack.NewIdentityV3(client, gophercloud.EndpointOpts{}) 462 } 463 464 // NewImageV2Client returns a *ServiceClient for making calls to the 465 // OpenStack Image v2 API. An error will be returned if authentication or 466 // client creation was not possible. 467 func NewImageV2Client() (*gophercloud.ServiceClient, error) { 468 ao, err := openstack.AuthOptionsFromEnv() 469 if err != nil { 470 return nil, err 471 } 472 473 client, err := openstack.AuthenticatedClient(context.TODO(), ao) 474 if err != nil { 475 return nil, err 476 } 477 478 client = configureDebug(client) 479 480 return openstack.NewImageV2(client, gophercloud.EndpointOpts{ 481 Region: os.Getenv("OS_REGION_NAME"), 482 }) 483 } 484 485 // NewNetworkV2Client returns a *ServiceClient for making calls to the 486 // OpenStack Networking v2 API. An error will be returned if authentication 487 // or client creation was not possible. 488 func NewNetworkV2Client() (*gophercloud.ServiceClient, error) { 489 ao, err := openstack.AuthOptionsFromEnv() 490 if err != nil { 491 return nil, err 492 } 493 494 client, err := openstack.AuthenticatedClient(context.TODO(), ao) 495 if err != nil { 496 return nil, err 497 } 498 499 client = configureDebug(client) 500 501 return openstack.NewNetworkV2(client, gophercloud.EndpointOpts{ 502 Region: os.Getenv("OS_REGION_NAME"), 503 }) 504 } 505 506 // NewObjectStorageV1Client returns a *ServiceClient for making calls to the 507 // OpenStack Object Storage v1 API. An error will be returned if authentication 508 // or client creation was not possible. 509 func NewObjectStorageV1Client() (*gophercloud.ServiceClient, error) { 510 ao, err := openstack.AuthOptionsFromEnv() 511 if err != nil { 512 return nil, err 513 } 514 515 client, err := openstack.AuthenticatedClient(context.TODO(), ao) 516 if err != nil { 517 return nil, err 518 } 519 520 client = configureDebug(client) 521 522 return openstack.NewObjectStorageV1(client, gophercloud.EndpointOpts{ 523 Region: os.Getenv("OS_REGION_NAME"), 524 }) 525 } 526 527 // NewSharedFileSystemV2Client returns a *ServiceClient for making calls 528 // to the OpenStack Shared File System v2 API. An error will be returned 529 // if authentication or client creation was not possible. 530 func NewSharedFileSystemV2Client() (*gophercloud.ServiceClient, error) { 531 ao, err := openstack.AuthOptionsFromEnv() 532 if err != nil { 533 return nil, err 534 } 535 536 client, err := openstack.AuthenticatedClient(context.TODO(), ao) 537 if err != nil { 538 return nil, err 539 } 540 541 client = configureDebug(client) 542 543 return openstack.NewSharedFileSystemV2(client, gophercloud.EndpointOpts{ 544 Region: os.Getenv("OS_REGION_NAME"), 545 }) 546 } 547 548 // NewLoadBalancerV2Client returns a *ServiceClient for making calls to the 549 // OpenStack Octavia v2 API. An error will be returned if authentication 550 // or client creation was not possible. 551 func NewLoadBalancerV2Client() (*gophercloud.ServiceClient, error) { 552 ao, err := openstack.AuthOptionsFromEnv() 553 if err != nil { 554 return nil, err 555 } 556 557 client, err := openstack.AuthenticatedClient(context.TODO(), ao) 558 if err != nil { 559 return nil, err 560 } 561 562 client = configureDebug(client) 563 564 return openstack.NewLoadBalancerV2(client, gophercloud.EndpointOpts{ 565 Region: os.Getenv("OS_REGION_NAME"), 566 }) 567 } 568 569 // NewMessagingV2Client returns a *ServiceClient for making calls 570 // to the OpenStack Messaging (Zaqar) v2 API. An error will be returned 571 // if authentication or client creation was not possible. 572 func NewMessagingV2Client(clientID string) (*gophercloud.ServiceClient, error) { 573 ao, err := openstack.AuthOptionsFromEnv() 574 if err != nil { 575 return nil, err 576 } 577 578 client, err := openstack.AuthenticatedClient(context.TODO(), ao) 579 if err != nil { 580 return nil, err 581 } 582 583 client = configureDebug(client) 584 585 return openstack.NewMessagingV2(client, clientID, gophercloud.EndpointOpts{ 586 Region: os.Getenv("OS_REGION_NAME"), 587 }) 588 } 589 590 // NewContainerV1Client returns a *ServiceClient for making calls 591 // to the OpenStack Container V1 API. An error will be returned 592 // if authentication or client creation was not possible. 593 func NewContainerV1Client() (*gophercloud.ServiceClient, error) { 594 ao, err := openstack.AuthOptionsFromEnv() 595 if err != nil { 596 return nil, err 597 } 598 599 client, err := openstack.AuthenticatedClient(context.TODO(), ao) 600 if err != nil { 601 return nil, err 602 } 603 604 client = configureDebug(client) 605 606 return openstack.NewContainerV1(client, gophercloud.EndpointOpts{ 607 Region: os.Getenv("OS_REGION_NAME"), 608 }) 609 } 610 611 // NewKeyManagerV1Client returns a *ServiceClient for making calls 612 // to the OpenStack Key Manager (Barbican) v1 API. An error will be 613 // returned if authentication or client creation was not possible. 614 func NewKeyManagerV1Client() (*gophercloud.ServiceClient, error) { 615 ao, err := openstack.AuthOptionsFromEnv() 616 if err != nil { 617 return nil, err 618 } 619 620 client, err := openstack.AuthenticatedClient(context.TODO(), ao) 621 if err != nil { 622 return nil, err 623 } 624 625 client = configureDebug(client) 626 627 return openstack.NewKeyManagerV1(client, gophercloud.EndpointOpts{ 628 Region: os.Getenv("OS_REGION_NAME"), 629 }) 630 } 631 632 // configureDebug will configure the provider client to print the API 633 // requests and responses if OS_DEBUG is enabled. 634 func configureDebug(client *gophercloud.ProviderClient) *gophercloud.ProviderClient { 635 if os.Getenv("OS_DEBUG") != "" { 636 client.HTTPClient = http.Client{ 637 Transport: &LogRoundTripper{ 638 Rt: &http.Transport{}, 639 }, 640 } 641 } 642 643 return client 644 } 645 646 // NewContainerInfraV1Client returns a *ServiceClient for making calls 647 // to the OpenStack Container Infra Management v1 API. An error will be returned 648 // if authentication or client creation was not possible. 649 func NewContainerInfraV1Client() (*gophercloud.ServiceClient, error) { 650 ao, err := openstack.AuthOptionsFromEnv() 651 if err != nil { 652 return nil, err 653 } 654 655 client, err := openstack.AuthenticatedClient(context.TODO(), ao) 656 if err != nil { 657 return nil, err 658 } 659 660 client = configureDebug(client) 661 662 return openstack.NewContainerInfraV1(client, gophercloud.EndpointOpts{ 663 Region: os.Getenv("OS_REGION_NAME"), 664 }) 665 } 666 667 // NewWorkflowV2Client returns a *ServiceClient for making calls 668 // to the OpenStack Workflow v2 API (Mistral). An error will be returned if 669 // authentication or client creation failed. 670 func NewWorkflowV2Client() (*gophercloud.ServiceClient, error) { 671 ao, err := openstack.AuthOptionsFromEnv() 672 if err != nil { 673 return nil, err 674 } 675 676 client, err := openstack.AuthenticatedClient(context.TODO(), ao) 677 if err != nil { 678 return nil, err 679 } 680 681 client = configureDebug(client) 682 683 return openstack.NewWorkflowV2(client, gophercloud.EndpointOpts{ 684 Region: os.Getenv("OS_REGION_NAME"), 685 }) 686 } 687 688 // NewOrchestrationV1Client returns a *ServiceClient for making calls 689 // to the OpenStack Orchestration v1 API. An error will be returned 690 // if authentication or client creation was not possible. 691 func NewOrchestrationV1Client() (*gophercloud.ServiceClient, error) { 692 ao, err := openstack.AuthOptionsFromEnv() 693 if err != nil { 694 return nil, err 695 } 696 697 client, err := openstack.AuthenticatedClient(context.TODO(), ao) 698 if err != nil { 699 return nil, err 700 } 701 702 client = configureDebug(client) 703 704 return openstack.NewOrchestrationV1(client, gophercloud.EndpointOpts{ 705 Region: os.Getenv("OS_REGION_NAME"), 706 }) 707 } 708 709 // NewPlacementV1Client returns a *ServiceClient for making calls 710 // to the OpenStack Placement API. An error will be returned 711 // if authentication or client creation was not possible. 712 func NewPlacementV1Client() (*gophercloud.ServiceClient, error) { 713 ao, err := openstack.AuthOptionsFromEnv() 714 if err != nil { 715 return nil, err 716 } 717 718 client, err := openstack.AuthenticatedClient(context.TODO(), ao) 719 if err != nil { 720 return nil, err 721 } 722 723 client = configureDebug(client) 724 725 return openstack.NewPlacementV1(client, gophercloud.EndpointOpts{ 726 Region: os.Getenv("OS_REGION_NAME"), 727 }) 728 }