本文整理汇总了Golang中github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers.UpdateOpts.Name方法的典型用法代码示例。如果您正苦于以下问题:Golang UpdateOpts.Name方法的具体用法?Golang UpdateOpts.Name怎么用?Golang UpdateOpts.Name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers.UpdateOpts
的用法示例。
在下文中一共展示了UpdateOpts.Name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: resourceNetworkingRouterV2Update
func resourceNetworkingRouterV2Update(d *schema.ResourceData, meta interface{}) error {
routerId := d.Id()
osMutexKV.Lock(routerId)
defer osMutexKV.Unlock(routerId)
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 routers.UpdateOpts
if d.HasChange("name") {
updateOpts.Name = d.Get("name").(string)
}
if d.HasChange("admin_state_up") {
asu := d.Get("admin_state_up").(bool)
updateOpts.AdminStateUp = &asu
}
log.Printf("[DEBUG] Updating Router %s with options: %+v", d.Id(), updateOpts)
_, err = routers.Update(networkingClient, d.Id(), updateOpts).Extract()
if err != nil {
return fmt.Errorf("Error updating OpenStack Neutron Router: %s", err)
}
return resourceNetworkingRouterV2Read(d, meta)
}
示例2: resourceNetworkingRouterV2Update
func resourceNetworkingRouterV2Update(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 routers.UpdateOpts
if d.HasChange("name") {
updateOpts.Name = d.Get("name").(string)
}
if d.HasChange("admin_state_up") {
asuRaw := d.Get("admin_state_up").(string)
if asuRaw != "" {
asu, err := strconv.ParseBool(asuRaw)
if err != nil {
return fmt.Errorf("admin_state_up, if provided, must be either 'true' or 'false'")
}
updateOpts.AdminStateUp = &asu
}
}
log.Printf("[DEBUG] Updating Router %s with options: %+v", d.Id(), updateOpts)
_, err = routers.Update(networkingClient, d.Id(), updateOpts).Extract()
if err != nil {
return fmt.Errorf("Error updating OpenStack Neutron Router: %s", err)
}
return resourceNetworkingRouterV2Read(d, meta)
}