本文整理汇总了Python中katello.client.api.user_role.UserRoleAPI类的典型用法代码示例。如果您正苦于以下问题:Python UserRoleAPI类的具体用法?Python UserRoleAPI怎么用?Python UserRoleAPI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UserRoleAPI类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UserRoleAction
class UserRoleAction(BaseAction):
def __init__(self):
super(UserRoleAction, self).__init__()
self.api = UserRoleAPI()
def get_role(self, name):
role = self.api.role_by_name(name)
if role == None:
system_exit(os.EX_DATAERR, _("Cannot find user role '%s'") % name )
return role
示例2: PermissionAction
class PermissionAction(Action):
def __init__(self):
super(PermissionAction, self).__init__()
self.user_role_api = UserRoleAPI()
self.api = PermissionAPI()
def getAvailablePermissions(self, orgName, scope=None):
data = self.user_role_api.available_verbs(orgName)
if scope == None:
return data
elif scope in data:
return {scope: data[scope]}
else:
return {}
示例3: AssignRole
class AssignRole(UserAction):
@property
def description(self):
if self.__assign:
return _('assign role to a user')
else:
return _('unassign role to a user')
def assign(self):
return self.__assign
def __init__(self, assign = True):
super(AssignRole, self).__init__()
self.role_api = UserRoleAPI()
self.__assign = assign
def setup_parser(self):
self.parser.add_option('--username', dest='username', help=_("user name (required)"))
self.parser.add_option('--role', dest='role', help=_("user role (required)"))
def check_options(self):
self.require_option('username')
self.require_option('role')
def run(self):
userName = self.get_option('username')
roleName = self.get_option('role')
user = get_user(userName)
if user == None:
return os.EX_DATAERR
role = self.role_api.role_by_name(roleName)
if role == None:
print _("Role [ %s ] not found" % roleName)
return os.EX_DATAERR
msg = self.update_role(user['id'], role['id'])
print msg
return os.EX_OK
def update_role(self, userId, roleId):
if self.assign():
return self.api.assign_role(userId, roleId)
else:
return self.api.unassign_role(userId, roleId)
示例4: __init__
def __init__(self):
self.orgapi = OrganizationAPI()
self.systemapi = SystemAPI()
self.userapi = UserAPI()
self.envapi = EnvironmentAPI()
self.rolesapi = UserRoleAPI()
self.permissionapi = PermissionAPI()
self.distributorapi = DistributorAPI()
self.provapi = ProviderAPI()
self.infoapi = CustomInfoAPI()
s = server.KatelloServer(CONFIG.get("katello", "hostname"),
CONFIG.get("katello", "port"),
CONFIG.get("katello", "proto"),
CONFIG.get("katello", "api_url"))
s.set_auth_method(BasicAuthentication(CONFIG.get("katello", "admin_user"), CONFIG.get("katello", "admin_pass")))
server.set_active_server(s)
示例5: __init__
def __init__(self):
super(PermissionAction, self).__init__()
self.user_role_api = UserRoleAPI()
self.api = PermissionAPI()
示例6: __init__
def __init__(self, assign = True):
super(AssignRole, self).__init__()
self.role_api = UserRoleAPI()
self.__assign = assign
示例7: KatelloConnection
class KatelloConnection():
def __init__(self):
self.orgapi = OrganizationAPI()
self.systemapi = SystemAPI()
self.userapi = UserAPI()
self.envapi = EnvironmentAPI()
self.rolesapi = UserRoleAPI()
self.permissionapi = PermissionAPI()
self.distributorapi = DistributorAPI()
self.provapi = ProviderAPI()
self.infoapi = CustomInfoAPI()
s = server.KatelloServer(CONFIG.get("katello", "hostname"),
CONFIG.get("katello", "port"),
CONFIG.get("katello", "proto"),
CONFIG.get("katello", "api_url"))
s.set_auth_method(BasicAuthentication(CONFIG.get("katello", "admin_user"), CONFIG.get("katello", "admin_pass")))
server.set_active_server(s)
def get_owners(self):
return self.orgapi.organizations()
def create_distributor(self, name, root_org):
return self.distributorapi.create(name=name, org=root_org, environment_id=None)
def delete_distributor(self, name, root_org):
dist_uuid = self.distributorapi.distributor_by_name(distName=name, orgName=root_org)['uuid']
return self.distributorapi.delete(distributor_uuid=dist_uuid)
def update_distributor(self, name, root_org, params):
dist_uuid = self.distributorapi.distributor_by_name(
distName=name, orgName=root_org)['uuid']
return self.distributorapi.update(dist_uuid, params)
def export_manifest(self, dist_uuid):
return self.distributorapi.export_manifest(distributor_uuid=dist_uuid)
def import_manifest(self, prov_id, file):
return self.provapi.import_manifest(provId=prov_id, manifestFile=file)
def get_redhat_provider(self, org):
return self.provapi.provider_by_name(orgName=org, provName="Red Hat")
def get_entitlements(self, system_id):
return self.systemapi.subscriptions(system_id=system_id)['entitlements']
def get_subscription_status(self, system_uuid):
return self.systemapi.subscription_status(system_id=system_uuid)
def create_owner(self, label, name):
return self.orgapi.create(name, label, "no description")
def delete_owner(self, name):
# todo: error handling, not sure if orgapi will handle it
self.orgapi.delete(name)
def update_owner(self, name, params):
return self.orgapi.update(name, params)
def get_users(self):
return self.userapi.users()
def create_user(self, username, email):
return self.userapi.create(name=username, pw="CHANGEME", email=email, disabled=False, default_environment=None)
def delete_user(self, user_id):
return self.userapi.delete(user_id=user_id)
def get_spacewalk_id(self, object_id):
# this wants an object ID
info_list = self.infoapi.get_custom_info(informable_type='system', informable_id=object_id)
for info in info_list:
if info['keyname'] == 'spacewalk-id':
return info['value']
def find_by_spacewalk_id(self, org, spacewalk_id):
result = self.systemapi.find_by_custom_info(org, 'spacewalk-id', spacewalk_id)
if len(result) > 1:
raise Exception("more than one record found for spacewalk ID %s in org %s!" % (spacewalk_id, org))
# we're guaranteed at this point to have zero or one records
if result:
return result[0]
return
def create_consumer(self, name, facts, installed_products, last_checkin, sw_uuid=None, owner=None):
# there are four calls here! we need to work with katello to send all this stuff up at once
consumer = self.systemapi.register(name=name, org='satellite-' + owner, environment_id=None,
facts=facts, activation_keys=None, cp_type='system',
installed_products=installed_products)
#TODO: get rid of this extra call!
facts = consumer['facts']
if 'virt.is_guest' in facts:
facts['virt.uuid'] = consumer['uuid']
self.updateConsumer(name=consumer['name'], cp_uuid=consumer['uuid'], facts=facts)
self.systemapi.checkin(consumer['uuid'], self._convert_date(last_checkin))
self.systemapi.refresh_subscriptions(consumer['uuid'])
#.........这里部分代码省略.........
示例8: KatelloConnection
class KatelloConnection():
def __init__(self):
self.orgapi = OrganizationAPI()
self.systemapi = SystemAPI()
self.userapi = UserAPI()
self.envapi = EnvironmentAPI()
self.rolesapi = UserRoleAPI()
self.permissionapi = PermissionAPI()
self.distributorapi = DistributorAPI()
self.provapi = ProviderAPI()
self.infoapi = CustomInfoAPI()
s = server.KatelloServer(CONFIG.get("katello", "hostname"),
CONFIG.get("katello", "port"),
CONFIG.get("katello", "proto"),
CONFIG.get("katello", "api_url"))
s.set_auth_method(BasicAuthentication(CONFIG.get("katello", "admin_user"), CONFIG.get("katello", "admin_pass")))
server.set_active_server(s)
def get_owners(self):
return self.orgapi.organizations()
def refresh_subs(self, org_label):
_LOG.debug("entering async task to refresh systems in %s" % org_label)
return self.orgapi.attach_all_systems(org_label)
def create_distributor(self, name, root_org):
return self.distributorapi.create(name=name, org=root_org, environment_id=None)
def delete_distributor(self, name, root_org):
dist_uuid = self.distributorapi.distributor_by_name(distName=name, orgName=root_org)['uuid']
return self.distributorapi.delete(distributor_uuid=dist_uuid)
def update_distributor(self, name, root_org, params):
dist_uuid = self.distributorapi.distributor_by_name(
distName=name, orgName=root_org)['uuid']
return self.distributorapi.update(dist_uuid, params)
def export_manifest(self, dist_uuid):
return self.distributorapi.export_manifest(distributor_uuid=dist_uuid)
def import_manifest(self, prov_id, file):
return self.provapi.import_manifest(provId=prov_id, manifestFile=file)
def get_redhat_provider(self, org):
return self.provapi.provider_by_name(orgName=org, provName="Red Hat")
def get_entitlements(self, system_id):
return self.systemapi.subscriptions(system_id=system_id)['entitlements']
def get_subscription_status(self, system_uuid):
return self.systemapi.subscription_status(system_id=system_uuid)
def create_owner(self, label, name):
return self.orgapi.create(name, label, "no description")
def delete_owner(self, name):
# todo: error handling, not sure if orgapi will handle it
self.orgapi.delete(name)
def update_owner(self, name, params):
return self.orgapi.update(name, params)
def get_users(self):
return self.userapi.users()
def create_user(self, username, email):
return self.userapi.create(name=username, pw="CHANGEME", email=email, disabled=False, default_environment=None)
def delete_user(self, user_id):
return self.userapi.delete(user_id=user_id)
def get_spacewalk_id(self, object_id):
# this wants an object ID
info_list = self.infoapi.get_custom_info(informable_type='system', informable_id=object_id)
for info in info_list:
if info['keyname'] == 'spacewalk-id':
return info['value']
def find_by_spacewalk_id(self, org, spacewalk_id):
result = self.systemapi.find_by_custom_info(org, 'spacewalk-id', spacewalk_id)
if len(result) > 1:
raise Exception("more than one record found for spacewalk ID %s in org %s!" % (spacewalk_id, org))
# we're guaranteed at this point to have zero or one records
if result:
return result[0]
return
def create_consumer(self, name, facts, installed_products, last_checkin, sw_uuid=None, owner=None):
# there are four calls here! we need to work with katello to send all this stuff up at once
consumer = self.systemapi.register(name=name, org='satellite-' + owner, environment_id=None,
facts=facts, activation_keys=None, cp_type='system',
installed_products=installed_products, last_checkin=self._convert_date(last_checkin).isoformat())
# we want this to happen ASAP. Ideally, it would be in the same transaction as the above call.
self.infoapi.add_custom_info(informable_type='system', informable_id=consumer['id'],
keyname='spacewalk-id', value=sw_uuid)
# TODO: get rid of this extra call!
#.........这里部分代码省略.........
示例9: __init__
def __init__(self):
super(UserRoleAction, self).__init__()
self.api = UserRoleAPI()
示例10: get_role
def get_role(name):
user_role_api = UserRoleAPI()
role = user_role_api.role_by_name(name)
if role == None:
raise ApiDataError(_("Cannot find user role [ %s ]") % (name))
return role
示例11: get_role
def get_role(name):
user_role_api = UserRoleAPI()
role = user_role_api.role_by_name(name)
if role == None:
print _("Cannot find user role [ %s ]") % (name)
return role