本文整理汇总了Golang中github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups.Get函数的典型用法代码示例。如果您正苦于以下问题:Golang Get函数的具体用法?Golang Get怎么用?Golang Get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Get函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: resourceComputeSecGroupV2Read
func resourceComputeSecGroupV2Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
computeClient, err := config.computeV2Client(d.Get("region").(string))
if err != nil {
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
}
sg, err := secgroups.Get(computeClient, d.Id()).Extract()
if err != nil {
return CheckDeleted(d, err, "security group")
}
d.Set("name", sg.Name)
d.Set("description", sg.Description)
rtm := rulesToMap(sg.Rules)
for _, v := range rtm {
if v["group"] == d.Get("name") {
v["self"] = "1"
} else {
v["self"] = "0"
}
}
log.Printf("[DEBUG] rulesToMap(sg.Rules): %+v", rtm)
d.Set("rule", rtm)
return nil
}
示例2: testAccCheckComputeV2SecGroupExists
func testAccCheckComputeV2SecGroupExists(t *testing.T, n string, secgroup *secgroups.SecurityGroup) 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)
computeClient, err := config.computeV2Client(OS_REGION_NAME)
if err != nil {
return fmt.Errorf("(testAccCheckComputeV2SecGroupExists) Error creating OpenStack compute client: %s", err)
}
found, err := secgroups.Get(computeClient, rs.Primary.ID).Extract()
if err != nil {
return err
}
if found.ID != rs.Primary.ID {
return fmt.Errorf("Security group not found")
}
*secgroup = *found
return nil
}
}
示例3: testAccCheckComputeV2SecGroupDestroy
func testAccCheckComputeV2SecGroupDestroy(s *terraform.State) error {
config := testAccProvider.Meta().(*Config)
computeClient, err := config.computeV2Client(OS_REGION_NAME)
if err != nil {
return fmt.Errorf("(testAccCheckComputeV2SecGroupDestroy) Error creating OpenStack compute client: %s", err)
}
for _, rs := range s.RootModule().Resources {
if rs.Type != "openstack_compute_secgroup_v2" {
continue
}
_, err := secgroups.Get(computeClient, rs.Primary.ID).Extract()
if err == nil {
return fmt.Errorf("Security group still exists")
}
}
return nil
}
示例4: SecGroupV2StateRefreshFunc
func SecGroupV2StateRefreshFunc(computeClient *gophercloud.ServiceClient, d *schema.ResourceData) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
log.Printf("[DEBUG] Attempting to delete Security Group %s.\n", d.Id())
err := secgroups.Delete(computeClient, d.Id()).ExtractErr()
if err != nil {
return nil, "", err
}
s, err := secgroups.Get(computeClient, d.Id()).Extract()
if err != nil {
err = CheckDeleted(d, err, "Security Group")
if err != nil {
return s, "", err
} else {
log.Printf("[DEBUG] Successfully deleted Security Group %s", d.Id())
return s, "DELETED", nil
}
}
log.Printf("[DEBUG] Security Group %s still active.\n", d.Id())
return s, "ACTIVE", nil
}
}
示例5: getSecGroup
func getSecGroup(t *testing.T, client *gophercloud.ServiceClient, id string) {
group, err := secgroups.Get(client, id).Extract()
th.AssertNoErr(t, err)
t.Logf("Getting %s: %#v", id, group)
}