github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/acceptance/openstack/networking/v2/routes/route.go (about) 1 package routes 2 3 import ( 4 "testing" 5 6 "github.com/huaweicloud/golangsdk" 7 "github.com/huaweicloud/golangsdk/openstack/networking/v2/peerings" 8 "github.com/huaweicloud/golangsdk/openstack/networking/v2/routes" 9 ) 10 11 func CreateRoute(t *testing.T, clientV2 *golangsdk.ServiceClient, peeringConn *peerings.Peering) (*routes.Route, error) { 12 13 createRouteOpts := routes.CreateOpts{ 14 NextHop: peeringConn.ID, 15 Destination: "192.168.0.0/16", 16 VPC_ID: peeringConn.RequestVpcInfo.VpcId, 17 Type: "peering", 18 } 19 20 t.Logf("Attempting to create route") 21 22 route, err := routes.Create(clientV2, createRouteOpts).Extract() 23 if err != nil { 24 return route, err 25 } 26 t.Logf("Created route: %s", route) 27 28 return route, nil 29 } 30 31 func DeleteRoute(t *testing.T, clientV2 *golangsdk.ServiceClient, routeID string) { 32 t.Logf("Attempting to delete route: %s", routeID) 33 34 err := routes.Delete(clientV2, routeID).ExtractErr() 35 if err != nil { 36 t.Fatalf("Error deleting route: %v", err) 37 } 38 39 t.Logf("Deleted route: %s", routeID) 40 }