本文整理汇总了Golang中github.com/rackspace/gophercloud/openstack/networking/v2/subnets.UpdateOpts类的典型用法代码示例。如果您正苦于以下问题:Golang UpdateOpts类的具体用法?Golang UpdateOpts怎么用?Golang UpdateOpts使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UpdateOpts类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: resourceNetworkingSubnetV2Update
func resourceNetworkingSubnetV2Update(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := config.networkingV2Client(d.Get("region").(string))
if err != nil {
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
}
// Check if both gateway_ip and no_gateway are set
if _, ok := d.GetOk("gateway_ip"); ok {
if _, ok2 := d.GetOk("no_gateway"); ok2 {
return fmt.Errorf("Both gateway_ip and no_gateway cannot be set.")
}
}
var updateOpts subnets.UpdateOpts
if d.HasChange("name") {
updateOpts.Name = d.Get("name").(string)
}
if d.HasChange("gateway_ip") {
updateOpts.GatewayIP = d.Get("gateway_ip").(string)
}
if d.HasChange("no_gateway") {
updateOpts.NoGateway = d.Get("no_gateway").(bool)
}
if d.HasChange("dns_nameservers") {
updateOpts.DNSNameservers = resourceSubnetDNSNameserversV2(d)
}
if d.HasChange("host_routes") {
updateOpts.HostRoutes = resourceSubnetHostRoutesV2(d)
}
if d.HasChange("enable_dhcp") {
v := d.Get("enable_dhcp").(bool)
updateOpts.EnableDHCP = &v
}
log.Printf("[DEBUG] Updating Subnet %s with options: %+v", d.Id(), updateOpts)
_, err = subnets.Update(networkingClient, d.Id(), updateOpts).Extract()
if err != nil {
return fmt.Errorf("Error updating OpenStack Neutron Subnet: %s", err)
}
return resourceNetworkingSubnetV2Read(d, meta)
}
开发者ID:Originate,项目名称:terraform,代码行数:50,代码来源:resource_openstack_networking_subnet_v2.go
示例2: resourceNetworkingSubnetV2Update
func resourceNetworkingSubnetV2Update(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := config.networkingV2Client(d.Get("region").(string))
if err != nil {
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
}
var updateOpts subnets.UpdateOpts
if d.HasChange("name") {
updateOpts.Name = d.Get("name").(string)
}
if d.HasChange("gateway_ip") {
updateOpts.GatewayIP = d.Get("gateway_ip").(string)
}
if d.HasChange("dns_nameservers") {
updateOpts.DNSNameservers = resourceSubnetDNSNameserversV2(d)
}
if d.HasChange("host_routes") {
updateOpts.HostRoutes = resourceSubnetHostRoutesV2(d)
}
if d.HasChange("enable_dhcp") {
edRaw := d.Get("enable_dhcp").(string)
if edRaw != "" {
ed, err := strconv.ParseBool(edRaw)
if err != nil {
return fmt.Errorf("enable_dhcp, if provided, must be either 'true' or 'false'")
}
updateOpts.EnableDHCP = &ed
}
}
log.Printf("[DEBUG] Updating Subnet %s with options: %+v", d.Id(), updateOpts)
_, err = subnets.Update(networkingClient, d.Id(), updateOpts).Extract()
if err != nil {
return fmt.Errorf("Error updating OpenStack Neutron Subnet: %s", err)
}
return resourceNetworkingSubnetV2Read(d, meta)
}
开发者ID:jrperritt,项目名称:terraform,代码行数:45,代码来源:resource_openstack_networking_subnet_v2.go
注:本文中的github.com/rackspace/gophercloud/openstack/networking/v2/subnets.UpdateOpts类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论