github.com/vnpaycloud-console/gophercloud/v2@v2.0.5/internal/acceptance/openstack/networking/v2/extensions/bgpvpns/bgpvpns.go (about)

     1  package bgpvpns
     2  
     3  import (
     4  	"context"
     5  	"testing"
     6  
     7  	"github.com/vnpaycloud-console/gophercloud/v2"
     8  	"github.com/vnpaycloud-console/gophercloud/v2/internal/acceptance/tools"
     9  	"github.com/vnpaycloud-console/gophercloud/v2/openstack/networking/v2/extensions/bgpvpns"
    10  	th "github.com/vnpaycloud-console/gophercloud/v2/testhelper"
    11  )
    12  
    13  func CreateBGPVPN(t *testing.T, client *gophercloud.ServiceClient) (*bgpvpns.BGPVPN, error) {
    14  	opts := bgpvpns.CreateOpts{
    15  		Name: tools.RandomString("TESTACC-BGPVPN-", 10),
    16  	}
    17  
    18  	t.Logf("Attempting to create BGP VPN: %s", opts.Name)
    19  	bgpVpn, err := bgpvpns.Create(context.TODO(), client, opts).Extract()
    20  	if err != nil {
    21  		return bgpVpn, err
    22  	}
    23  
    24  	th.AssertEquals(t, bgpVpn.Name, opts.Name)
    25  	t.Logf("Successfully created BGP VPN")
    26  	tools.PrintResource(t, bgpVpn)
    27  	return bgpVpn, err
    28  }