本文整理汇总了Golang中github.com/rackspace/gophercloud/openstack/compute/v2/extensions/keypairs.Delete函数的典型用法代码示例。如果您正苦于以下问题:Golang Delete函数的具体用法?Golang Delete怎么用?Golang Delete使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Delete函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Cleanup
func (s *StepKeyPair) Cleanup(state multistep.StateBag) {
// If we used an SSH private key file, do not go about deleting
// keypairs
if s.PrivateKeyFile != "" {
return
}
// If no key name is set, then we never created it, so just return
if s.keyName == "" {
return
}
config := state.Get("config").(Config)
ui := state.Get("ui").(packer.Ui)
// We need the v2 compute client
computeClient, err := config.computeV2Client()
if err != nil {
ui.Error(fmt.Sprintf(
"Error cleaning up keypair. Please delete the key manually: %s", s.keyName))
return
}
ui.Say("Deleting temporary keypair...")
err = keypairs.Delete(computeClient, s.keyName).ExtractErr()
if err != nil {
ui.Error(fmt.Sprintf(
"Error cleaning up keypair. Please delete the key manually: %s", s.keyName))
}
}
开发者ID:rodm,项目名称:packer,代码行数:29,代码来源:step_key_pair.go
示例2: TestCreateServerWithKeyPair
func TestCreateServerWithKeyPair(t *testing.T) {
client, err := newClient()
th.AssertNoErr(t, err)
if testing.Short() {
t.Skip("Skipping test that requires server creation in short mode.")
}
privateKey, err := rsa.GenerateKey(rand.Reader, 2048)
publicKey := privateKey.PublicKey
pub, err := ssh.NewPublicKey(&publicKey)
th.AssertNoErr(t, err)
pubBytes := ssh.MarshalAuthorizedKey(pub)
pk := string(pubBytes)
kp, err := keypairs.Create(client, keypairs.CreateOpts{
Name: keyName,
PublicKey: pk,
}).Extract()
th.AssertNoErr(t, err)
t.Logf("Created key pair: %s\n", kp)
choices, err := ComputeChoicesFromEnv()
th.AssertNoErr(t, err)
name := tools.RandomString("Gophercloud-", 8)
t.Logf("Creating server [%s] with key pair.", name)
serverCreateOpts := servers.CreateOpts{
Name: name,
FlavorRef: choices.FlavorID,
ImageRef: choices.ImageID,
}
server, err := servers.Create(client, keypairs.CreateOptsExt{
serverCreateOpts,
keyName,
}).Extract()
th.AssertNoErr(t, err)
defer servers.Delete(client, server.ID)
if err = waitForStatus(client, server, "ACTIVE"); err != nil {
t.Fatalf("Unable to wait for server: %v", err)
}
server, err = servers.Get(client, server.ID).Extract()
t.Logf("Created server: %+v\n", server)
th.AssertNoErr(t, err)
th.AssertEquals(t, server.KeyName, keyName)
t.Logf("Deleting key pair [%s]...", kp.Name)
err = keypairs.Delete(client, keyName).ExtractErr()
th.AssertNoErr(t, err)
t.Logf("Deleting server [%s]...", name)
}
开发者ID:cdosso,项目名称:machine,代码行数:55,代码来源:keypairs_test.go
示例3: resourceComputeKeypairV2Delete
func resourceComputeKeypairV2Delete(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)
}
err = keypairs.Delete(computeClient, d.Id()).ExtractErr()
if err != nil {
return fmt.Errorf("Error deleting OpenStack keypair: %s", err)
}
d.SetId("")
return nil
}
开发者ID:pyhrus,项目名称:terraform,代码行数:14,代码来源:resource_openstack_compute_keypair_v2.go
示例4: resourceComputeKeypairDelete
func resourceComputeKeypairDelete(d *schema.ResourceData, meta interface{}) error {
computeClient, err := meta.(*Config).computeClient()
if err != nil {
return fmt.Errorf("Error creating ConoHa compute client: %s", err)
}
err = keypairs.Delete(computeClient, d.Id()).ExtractErr()
if err != nil {
return fmt.Errorf("Error deleting ConoHa keypair: %s", err)
}
d.SetId("")
return nil
}
开发者ID:hanazuki,项目名称:terraform-provider-conoha,代码行数:15,代码来源:resource_compute_keypair.go
示例5: DeleteKeyPair
func (c *GenericClient) DeleteKeyPair(d *Driver, name string) error {
if result := keypairs.Delete(c.Compute, name); result.Err != nil {
return result.Err
}
return nil
}
开发者ID:rhendric,项目名称:machine,代码行数:6,代码来源:client.go
示例6: Delete
// Delete requests the deletion of a previous stored KeyPair from the server.
func Delete(client *gophercloud.ServiceClient, name string) os.DeleteResult {
return os.Delete(client, name)
}
开发者ID:Clarifai,项目名称:kubernetes,代码行数:4,代码来源:delegate.go
注:本文中的github.com/rackspace/gophercloud/openstack/compute/v2/extensions/keypairs.Delete函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论