github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/networking/v2/extensions/extradhcpopts/doc.go (about)

     1  /*
     2  Package extradhcpopts allow to work with extra DHCP functionality of Neutron ports.
     3  
     4  Example to Get a Port with Extra DHCP Options
     5  
     6  	portID := "46d4bfb9-b26e-41f3-bd2e-e6dcc1ccedb2"
     7  	var s struct {
     8  		ports.Port
     9  		extradhcpopts.ExtraDHCPOptsExt
    10  	}
    11  
    12  	err := ports.Get(networkClient, portID).ExtractInto(&s)
    13  	if err != nil {
    14  		panic(err)
    15  	}
    16  
    17  Example to Create a Port with Extra DHCP Options
    18  
    19  	var s struct {
    20  		ports.Port
    21  		extradhcpopts.ExtraDHCPOptsExt
    22  	}
    23  
    24  	adminStateUp := true
    25  	portCreateOpts := ports.CreateOpts{
    26  		Name:         "dhcp-conf-port",
    27  		AdminStateUp: &adminStateUp,
    28  		NetworkID:    "a87cc70a-3e15-4acf-8205-9b711a3531b7",
    29  		FixedIPs: []ports.IP{
    30  			{SubnetID: "a0304c3a-4f08-4c43-88af-d796509c97d2", IPAddress: "10.0.0.2"},
    31  		},
    32  	}
    33  
    34  	createOpts := extradhcpopts.CreateOptsExt{
    35  		CreateOptsBuilder: portCreateOpts,
    36  		ExtraDHCPOpts: []extradhcpopts.CreateExtraDHCPOpt{
    37  			{
    38  				OptName:  "optionA",
    39  				OptValue: "valueA",
    40  			},
    41  		},
    42  	}
    43  
    44  	err := ports.Create(networkClient, createOpts).ExtractInto(&s)
    45  	if err != nil {
    46  		panic(err)
    47  	}
    48  
    49  Example to Update a Port with Extra DHCP Options
    50  
    51  	var s struct {
    52  		ports.Port
    53  		extradhcpopts.ExtraDHCPOptsExt
    54  	}
    55  
    56  	portUpdateOpts := ports.UpdateOpts{
    57  		Name: "updated-dhcp-conf-port",
    58  		FixedIPs: []ports.IP{
    59  			{SubnetID: "a0304c3a-4f08-4c43-88af-d796509c97d2", IPAddress: "10.0.0.3"},
    60  		},
    61  	}
    62  
    63  	value := "valueB"
    64  	updateOpts := extradhcpopts.UpdateOptsExt{
    65  		UpdateOptsBuilder: portUpdateOpts,
    66  		ExtraDHCPOpts: []extradhcpopts.UpdateExtraDHCPOpt{
    67  			{
    68  				OptName:  "optionB",
    69  				OptValue: &value,
    70  			},
    71  		},
    72  	}
    73  
    74  	portID := "46d4bfb9-b26e-41f3-bd2e-e6dcc1ccedb2"
    75  	err := ports.Update(networkClient, portID, updateOpts).ExtractInto(&s)
    76  	if err != nil {
    77  		panic(err)
    78  	}
    79  */
    80  package extradhcpopts