本文整理汇总了Python中pyvcloud.vcd.org.Org.delete_user方法的典型用法代码示例。如果您正苦于以下问题:Python Org.delete_user方法的具体用法?Python Org.delete_user怎么用?Python Org.delete_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvcloud.vcd.org.Org
的用法示例。
在下文中一共展示了Org.delete_user方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete
# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import delete_user [as 别名]
def delete(ctx, user_name):
try:
restore_session(ctx)
client = ctx.obj['client']
in_use_org_href = ctx.obj['profiles'].get('org_href')
org = Org(client, in_use_org_href)
org.delete_user(user_name)
stdout('User \'%s\' has been successfully deleted.' % user_name, ctx)
except Exception as e:
stderr(e, ctx)
示例2: delete
# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import delete_user [as 别名]
def delete(self):
logging.info("__INIT__delete[User]")
res = user_pb2.DeleteUserResult()
res.deleted = False
context = self.context
logged_in_org = self.client.get_org()
org = Org(self.client, resource=logged_in_org)
try:
result = org.delete_user(self.name)
res.deleted = True
except Exception as e:
res.deleted = False
error_message = '__ERROR_delete[user] failed for user {0}. __ErrorMessage__ {1}'.format(
self.name, str(e))
logging.warn(error_message)
context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
context.set_details(error_message)
return res
logging.info("__DONE__delete[User]")
return res
示例3: delete_user
# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import delete_user [as 别名]
def delete_user(self, user_name):
logged_in_org = self.client.get_org()
org = Org(self.client, resource=logged_in_org)
org.delete_user(user_name)
示例4: User
# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import delete_user [as 别名]
class User(VcdAnsibleModule):
def __init__(self, **kwargs):
super(User, self).__init__(**kwargs)
logged_in_org = self.client.get_org()
self.org = Org(self.client, resource=logged_in_org)
def manage_states(self):
state = self.params.get('state')
if state == "present":
return self.create()
if state == "absent":
return self.delete()
if state == "update":
return self.update()
def create(self):
params = self.params
role = self.org.get_role_record(params.get('role_name'))
role_href = role.get('href')
username = params.get('username')
userpassword = params.get('userpassword')
full_username = params.get('full_username')
description = params.get('description')
email = params.get('email')
telephone = params.get('telephone')
im = params.get('im')
alert_email = params.get('alert_email')
alert_email_prefix = params.get('alert_email_prefix')
stored_vm_quota = params.get('stored_vm_quota')
deployed_vm_quota = params.get('deployed_vm_quota')
is_group_role = params.get('is_group_role')
is_default_cached = params.get('is_default_cached')
is_external = params.get('is_external')
is_alert_enabled = params.get('is_alert_enabled')
is_enabled = params.get('is_enabled')
response = dict()
response['changed'] = False
try:
self.org.get_user(username)
except EntityNotFoundException:
self.org.create_user(
username, userpassword, role_href, full_username, description,
email, telephone, im, alert_email, alert_email_prefix,
stored_vm_quota, deployed_vm_quota, is_group_role,
is_default_cached, is_external, is_alert_enabled,
is_enabled)
response['msg'] = "User {} has been created.".format(username)
response['changed'] = True
else:
response['warnings'] = "User {} is already present.".format(username)
return response
def delete(self):
username = self.params.get('username')
response = dict()
response['changed'] = False
try:
self.org.get_user(username)
except EntityNotFoundException:
response['warnings'] = "User {} is not present.".format(username)
else:
self.org.delete_user(username)
response['msg'] = "User {} has been deleted.".format(username)
response['changed'] = True
return response
def update(self):
username = self.params.get('username')
enabled = self.params.get('is_enabled')
response = dict()
response['changed'] = False
self.org.get_user(username)
self.org.update_user(username, enabled)
response['msg'] = "User {} has been updated".format(username)
response['changed'] = True
return response