github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/compute/v2/extensions/attachinterfaces/doc.go (about) 1 /* 2 Package attachinterfaces provides the ability to retrieve and manage network 3 interfaces through Nova. 4 5 Example of Listing a Server's Interfaces 6 7 serverID := "b07e7a3b-d951-4efc-a4f9-ac9f001afb7f" 8 allPages, err := attachinterfaces.List(computeClient, serverID).AllPages() 9 if err != nil { 10 panic(err) 11 } 12 13 allInterfaces, err := attachinterfaces.ExtractInterfaces(allPages) 14 if err != nil { 15 panic(err) 16 } 17 18 for _, interface := range allInterfaces { 19 fmt.Printf("%+v\n", interface) 20 } 21 22 Example to Get a Server's Interface 23 24 portID = "0dde1598-b374-474e-986f-5b8dd1df1d4e" 25 serverID := "b07e7a3b-d951-4efc-a4f9-ac9f001afb7f" 26 interface, err := attachinterfaces.Get(computeClient, serverID, portID).Extract() 27 if err != nil { 28 panic(err) 29 } 30 31 Example to Create a new Interface attachment on the Server 32 33 networkID := "8a5fe506-7e9f-4091-899b-96336909d93c" 34 serverID := "b07e7a3b-d951-4efc-a4f9-ac9f001afb7f" 35 attachOpts := attachinterfaces.CreateOpts{ 36 NetworkID: networkID, 37 } 38 interface, err := attachinterfaces.Create(computeClient, serverID, attachOpts).Extract() 39 if err != nil { 40 panic(err) 41 } 42 43 Example to Delete an Interface attachment from the Server 44 45 portID = "0dde1598-b374-474e-986f-5b8dd1df1d4e" 46 serverID := "b07e7a3b-d951-4efc-a4f9-ac9f001afb7f" 47 err := attachinterfaces.Delete(computeClient, serverID, portID).ExtractErr() 48 if err != nil { 49 panic(err) 50 } 51 */ 52 package attachinterfaces