skd——ssh
【摘要】 # coding: utf-8from huaweicloudsdkcore.auth.credentials import BasicCredentialsfrom huaweicloudsdkkps.v3.region.kps_region import KpsRegionfrom huaweicloudsdkcore.exceptions import exceptionsfrom h...
# coding: utf-8
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkkps.v3.region.kps_region import KpsRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkkps.v3 import *
import time
def get_token():
ak = ""
sk = ""
credentials = BasicCredentials(ak, sk) \
client = KpsClient.new_builder() \
.with_credentials(credentials) \
.with_region(KpsRegion.value_of("cn-north-4")) \
.build()
return client
class ssh:
def __init__(self,client):
self.client=client
def create(self):
client=self.client
request = CreateKeypairRequest()
keypairbody = CreateKeypairAction(
name="chinaskills_keypair"
)
request.body = CreateKeypairRequestBody(
keypair=keypairbody
)
response = client.create_keypair(request)
def get(self,name):
request = ListKeypairDetailRequest()
request.keypair_name = name
response = client.list_keypair_detail(request)
print(response)
def delete(self,name):
request = DeleteKeypairRequest()
request.keypair_name = name
response = client.delete_keypair(request)
if __name__ == "__main__":
client=get_token()
a=ssh(client)
a.delete('chinaskills_keypair')
#time.sleep(3)
#a.create()
#time.sleep(3)
#a.get('chinaskills_keypair')
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)