本文整理汇总了Golang中github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/monitors.CreateOpts类的典型用法代码示例。如果您正苦于以下问题:Golang CreateOpts类的具体用法?Golang CreateOpts怎么用?Golang CreateOpts使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CreateOpts类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: resourceLBMonitorV1Create
func resourceLBMonitorV1Create(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)
}
createOpts := monitors.CreateOpts{
TenantID: d.Get("tenant_id").(string),
Type: d.Get("type").(string),
Delay: d.Get("delay").(int),
Timeout: d.Get("timeout").(int),
MaxRetries: d.Get("max_retries").(int),
URLPath: d.Get("url_path").(string),
ExpectedCodes: d.Get("expected_codes").(string),
HTTPMethod: d.Get("http_method").(string),
}
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'")
}
createOpts.AdminStateUp = &asu
}
log.Printf("[DEBUG] Create Options: %#v", createOpts)
m, err := monitors.Create(networkingClient, createOpts).Extract()
if err != nil {
return fmt.Errorf("Error creating OpenStack LB Monitor: %s", err)
}
log.Printf("[INFO] LB Monitor ID: %s", m.ID)
log.Printf("[DEBUG] Waiting for OpenStack LB Monitor (%s) to become available.", m.ID)
stateConf := &resource.StateChangeConf{
Pending: []string{"PENDING"},
Target: "ACTIVE",
Refresh: waitForLBMonitorActive(networkingClient, m.ID),
Timeout: 2 * time.Minute,
Delay: 5 * time.Second,
MinTimeout: 3 * time.Second,
}
_, err = stateConf.WaitForState()
if err != nil {
return err
}
d.SetId(m.ID)
return resourceLBMonitorV1Read(d, meta)
}
开发者ID:AssertSelenium,项目名称:terraform,代码行数:54,代码来源:resource_openstack_lb_monitor_v1.go
示例2: resourceLBMonitorV1Create
func resourceLBMonitorV1Create(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)
}
createOpts := monitors.CreateOpts{
TenantID: d.Get("tenant_id").(string),
Type: d.Get("type").(string),
Delay: d.Get("delay").(int),
Timeout: d.Get("timeout").(int),
MaxRetries: d.Get("max_retries").(int),
URLPath: d.Get("url_path").(string),
ExpectedCodes: d.Get("expected_codes").(string),
HTTPMethod: d.Get("http_method").(string),
}
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'")
}
createOpts.AdminStateUp = &asu
}
log.Printf("[DEBUG] Create Options: %#v", createOpts)
m, err := monitors.Create(networkingClient, createOpts).Extract()
if err != nil {
return fmt.Errorf("Error creating OpenStack LB Monitor: %s", err)
}
log.Printf("[INFO] LB Monitor ID: %s", m.ID)
d.SetId(m.ID)
return resourceLBMonitorV1Read(d, meta)
}
开发者ID:semarj,项目名称:terraform,代码行数:38,代码来源:resource_openstack_lb_monitor_v1.go
注:本文中的github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/monitors.CreateOpts类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论