本文整理汇总了Golang中github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/vips.Get函数的典型用法代码示例。如果您正苦于以下问题:Golang Get函数的具体用法?Golang Get怎么用?Golang Get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Get函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: testAccCheckLBV1VIPExists
func testAccCheckLBV1VIPExists(t *testing.T, n string, vip *vips.VirtualIP) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Not found: %s", n)
}
if rs.Primary.ID == "" {
return fmt.Errorf("No ID is set")
}
config := testAccProvider.Meta().(*Config)
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
if err != nil {
return fmt.Errorf("(testAccCheckLBV1VIPExists) Error creating OpenStack networking client: %s", err)
}
found, err := vips.Get(networkingClient, rs.Primary.ID).Extract()
if err != nil {
return err
}
if found.ID != rs.Primary.ID {
return fmt.Errorf("VIP not found")
}
*vip = *found
return nil
}
}
示例2: waitForLBVIPDelete
func waitForLBVIPDelete(networkingClient *gophercloud.ServiceClient, vipId string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
log.Printf("[DEBUG] Attempting to delete OpenStack LB VIP %s", vipId)
p, err := vips.Get(networkingClient, vipId).Extract()
if err != nil {
errCode, ok := err.(*gophercloud.UnexpectedResponseCodeError)
if !ok {
return p, "ACTIVE", err
}
if errCode.Actual == 404 {
log.Printf("[DEBUG] Successfully deleted OpenStack LB VIP %s", vipId)
return p, "DELETED", nil
}
}
log.Printf("[DEBUG] OpenStack LB VIP: %+v", p)
err = vips.Delete(networkingClient, vipId).ExtractErr()
if err != nil {
errCode, ok := err.(*gophercloud.UnexpectedResponseCodeError)
if !ok {
return p, "ACTIVE", err
}
if errCode.Actual == 404 {
log.Printf("[DEBUG] Successfully deleted OpenStack LB VIP %s", vipId)
return p, "DELETED", nil
}
}
log.Printf("[DEBUG] OpenStack LB VIP %s still active.", vipId)
return p, "ACTIVE", nil
}
}
示例3: resourceLBVipV1Read
func resourceLBVipV1Read(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)
}
p, err := vips.Get(networkingClient, d.Id()).Extract()
if err != nil {
return CheckDeleted(d, err, "LB VIP")
}
log.Printf("[DEBUG] Retreived OpenStack LB VIP %s: %+v", d.Id(), p)
d.Set("name", p.Name)
d.Set("subnet_id", p.SubnetID)
d.Set("protocol", p.Protocol)
d.Set("port", p.ProtocolPort)
d.Set("pool_id", p.PoolID)
d.Set("port_id", p.PortID)
d.Set("tenant_id", p.TenantID)
d.Set("address", p.Address)
d.Set("description", p.Description)
d.Set("conn_limit", p.ConnLimit)
d.Set("admin_state_up", p.AdminStateUp)
return nil
}
示例4: waitForLBVIPActive
func waitForLBVIPActive(networkingClient *gophercloud.ServiceClient, vipId string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
p, err := vips.Get(networkingClient, vipId).Extract()
if err != nil {
return nil, "", err
}
log.Printf("[DEBUG] OpenStack LB VIP: %+v", p)
if p.Status == "ACTIVE" {
return p, "ACTIVE", nil
}
return p, p.Status, nil
}
}
示例5: testAccCheckLBV1VIPDestroy
func testAccCheckLBV1VIPDestroy(s *terraform.State) error {
config := testAccProvider.Meta().(*Config)
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
if err != nil {
return fmt.Errorf("(testAccCheckLBV1VIPDestroy) Error creating OpenStack networking client: %s", err)
}
for _, rs := range s.RootModule().Resources {
if rs.Type != "openstack_lb_vip_v1" {
continue
}
_, err := vips.Get(networkingClient, rs.Primary.ID).Extract()
if err == nil {
return fmt.Errorf("LB VIP still exists")
}
}
return nil
}