當前位置: 首頁>>代碼示例>>Golang>>正文


Golang loadbalancers.Get函數代碼示例

本文整理匯總了Golang中github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas_v2/loadbalancers.Get函數的典型用法代碼示例。如果您正苦於以下問題:Golang Get函數的具體用法?Golang Get怎麽用?Golang Get使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Get函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: waitForLoadBalancerDelete

func waitForLoadBalancerDelete(networkingClient *gophercloud.ServiceClient, lbID string) resource.StateRefreshFunc {
	return func() (interface{}, string, error) {
		log.Printf("[DEBUG] Attempting to delete OpenStack LoadBalancerV2 %s", lbID)

		lb, err := loadbalancers.Get(networkingClient, lbID).Extract()
		if err != nil {
			errCode, ok := err.(*gophercloud.UnexpectedResponseCodeError)
			if !ok {
				return lb, "ACTIVE", err
			}
			if errCode.Actual == 404 {
				log.Printf("[DEBUG] Successfully deleted OpenStack LoadBalancerV2 %s", lbID)
				return lb, "DELETED", nil
			}
		}

		log.Printf("[DEBUG] Openstack LoadBalancerV2: %+v", lb)
		err = loadbalancers.Delete(networkingClient, lbID).ExtractErr()
		if err != nil {
			errCode, ok := err.(*gophercloud.UnexpectedResponseCodeError)
			if !ok {
				return lb, "ACTIVE", err
			}
			if errCode.Actual == 404 {
				log.Printf("[DEBUG] Successfully deleted OpenStack LoadBalancerV2 %s", lbID)
				return lb, "DELETED", nil
			}
		}

		log.Printf("[DEBUG] OpenStack LoadBalancerV2 %s still active.", lbID)
		return lb, "ACTIVE", nil
	}
}
開發者ID:RezaDKhan,項目名稱:terraform,代碼行數:33,代碼來源:resource_openstack_lb_loadbalancer_v2.go

示例2: resourceLoadBalancerV2Read

func resourceLoadBalancerV2Read(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)
	}

	lb, err := loadbalancers.Get(networkingClient, d.Id()).Extract()
	if err != nil {
		return CheckDeleted(d, err, "LoadBalancerV2")
	}

	log.Printf("[DEBUG] Retreived OpenStack LoadBalancerV2 %s: %+v", d.Id(), lb)

	d.Set("name", lb.Name)
	d.Set("description", lb.Description)
	d.Set("vip_subnet_id", lb.VipSubnetID)
	d.Set("tenant_id", lb.TenantID)
	d.Set("vip_address", lb.VipAddress)
	d.Set("admin_state_up", lb.AdminStateUp)
	d.Set("flavor", lb.Flavor)
	d.Set("provider", lb.Provider)

	return nil
}
開發者ID:RezaDKhan,項目名稱:terraform,代碼行數:25,代碼來源:resource_openstack_lb_loadbalancer_v2.go

示例3: testAccCheckLBV2LoadBalancerExists

func testAccCheckLBV2LoadBalancerExists(t *testing.T, n string, lb *loadbalancers.LoadBalancer) 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("(testAccCheckLBV2LoadBalancerExists) Error creating OpenStack networking client: %s", err)
		}

		found, err := loadbalancers.Get(networkingClient, rs.Primary.ID).Extract()
		if err != nil {
			return err
		}

		if found.ID != rs.Primary.ID {
			return fmt.Errorf("Member not found")
		}

		*lb = *found

		return nil
	}
}
開發者ID:Originate,項目名稱:terraform,代碼行數:31,代碼來源:resource_openstack_lb_loadbalancer_v2_test.go

示例4: waitForLoadBalancerActive

func waitForLoadBalancerActive(networkingClient *gophercloud.ServiceClient, lbID string) resource.StateRefreshFunc {
	return func() (interface{}, string, error) {
		lb, err := loadbalancers.Get(networkingClient, lbID).Extract()
		if err != nil {
			return nil, "", err
		}

		log.Printf("[DEBUG] OpenStack LoadBalancer: %+v", lb)
		if lb.ProvisioningStatus == "ACTIVE" {
			return lb, "ACTIVE", nil
		}

		return lb, lb.ProvisioningStatus, nil
	}
}
開發者ID:RezaDKhan,項目名稱:terraform,代碼行數:15,代碼來源:resource_openstack_lb_loadbalancer_v2.go

示例5: getLoadbalancerWaitActive

func getLoadbalancerWaitActive(t *testing.T, loadbalancerID string) {
	start := time.Now().Second()
	for {
		time.Sleep(1 * time.Second)

		if time.Now().Second()-start >= loadbalancerActiveTimeoutSeconds {
			t.Errorf("Loadbalancer failed to go into ACTIVE provisioning status")
			return
		}

		loadbalancer, err := loadbalancers.Get(base.Client, loadbalancerID).Extract()
		th.AssertNoErr(t, err)
		if loadbalancer.ProvisioningStatus == "ACTIVE" {
			t.Logf("Retrieved Loadbalancer, ID [%s]: OperatingStatus [%s]", loadbalancer.ID, loadbalancer.ProvisioningStatus)
			return
		}
	}
}
開發者ID:sstrato,項目名稱:gophercloud,代碼行數:18,代碼來源:loadbalancer_test.go

示例6: waitLoadbalancerActiveProvisioningStatus

func waitLoadbalancerActiveProvisioningStatus(client *gophercloud.ServiceClient, loadbalancerID string) error {
	start := time.Now().Second()
	for {
		loadbalancer, err := loadbalancers.Get(client, loadbalancerID).Extract()
		if err != nil {
			return err
		}
		if loadbalancer.ProvisioningStatus == "ACTIVE" {
			return nil
		}

		time.Sleep(1 * time.Second)

		if time.Now().Second()-start >= loadbalancerActiveTimeoutSeconds {
			return fmt.Errorf("Loadbalancer failed to go into ACTIVE provisioning status within alloted time")

		}
	}
}
開發者ID:RyanBinfeng,項目名稱:kubernetes,代碼行數:19,代碼來源:openstack_loadbalancer.go

示例7: waitLoadbalancerDeleted

func waitLoadbalancerDeleted(client *gophercloud.ServiceClient, loadbalancerID string) error {
	start := time.Now().Second()
	for {
		_, err := loadbalancers.Get(client, loadbalancerID).Extract()
		if err != nil {
			if err == ErrNotFound {
				return nil
			} else {
				return err
			}
		}

		time.Sleep(1 * time.Second)

		if time.Now().Second()-start >= loadbalancerDeleteTimeoutSeconds {
			return fmt.Errorf("Loadbalancer failed to delete within the alloted time")
		}

	}
}
開發者ID:nak3,項目名稱:kubernetes,代碼行數:20,代碼來源:openstack_loadbalancer.go

示例8: getLoadbalancerWaitDeleted

func getLoadbalancerWaitDeleted(t *testing.T, loadbalancerID string) {
	start := time.Now().Second()
	for {
		time.Sleep(1 * time.Second)

		if time.Now().Second()-start >= loadbalancerDeleteTimeoutSeconds {
			t.Errorf("Loadbalancer failed to delete")
			return
		}

		_, err := loadbalancers.Get(base.Client, loadbalancerID).Extract()
		if err != nil {
			if errData, ok := err.(*(gophercloud.UnexpectedResponseCodeError)); ok {
				if errData.Actual == 404 {
					return
				}
			} else {
				th.AssertNoErr(t, err)
			}
		}
	}
}
開發者ID:sstrato,項目名稱:gophercloud,代碼行數:22,代碼來源:loadbalancer_test.go

示例9: testAccCheckLBV2LoadBalancerDestroy

func testAccCheckLBV2LoadBalancerDestroy(s *terraform.State) error {
	config := testAccProvider.Meta().(*Config)
	networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
	if err != nil {
		return fmt.Errorf("(testAccCheckLBV2LoadBalancerDestroy) Error creating OpenStack networking client: %s", err)
	}

	for _, rs := range s.RootModule().Resources {
		log.Printf("[FINDME] rs TYPE is: %#v", rs.Type)

		if rs.Type != "openstack_lb_loadbalancer_v2" {
			continue
		}

		_, err := loadbalancers.Get(networkingClient, rs.Primary.ID).Extract()
		if err == nil {
			return fmt.Errorf("LoadBalancer still exists: %s", rs.Primary.ID)
		}
	}

	return nil
}
開發者ID:Originate,項目名稱:terraform,代碼行數:22,代碼來源:resource_openstack_lb_loadbalancer_v2_test.go


注:本文中的github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas_v2/loadbalancers.Get函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。