def remove_right(ctx, role_name, rights, org_name): try: client = ctx.obj['client'] if org_name is not None: org_href = client.get_org_by_name(org_name).get('href') else: org_href = ctx.obj['profiles'].get('org_href') org = Org(client, href=org_href) role_record = org.get_role_record(role_name) role = Role(client, href=role_record.get('href')) role.remove_rights(list(rights)) stdout('Removed rights successfully from the role \'%s\'' % role_name, ctx) except Exception as e: stderr(e, ctx)
def remove_right(ctx, role_name, rights, org_name): try: restore_session(ctx) client = ctx.obj['client'] if org_name is not None: org_href = client.get_org_by_name(org_name).get('href') else: org_href = ctx.obj['profiles'].get('org_href') org = Org(client, href=org_href) role_record = org.get_role_record(role_name) role = Role(client, href=role_record.get('href')) role.remove_rights(list(rights)) stdout('Removed rights successfully from the role \'%s\'' % role_name, ctx) except Exception as e: stderr(e, ctx)
def test_10_remove_rights_from_role(self): org_in_use = self.config['vcd']['org_in_use'] org = Org(self.client, href=self.client.get_org_by_name(org_in_use).get('href')) role_name = self.config['vcd']['role_name'] right_name = self.config['vcd']['right_name'] role_record = org.get_role_record(role_name) role = Role(self.client, href=role_record.get('href')) updated_role_resource = role.remove_rights([right_name]) success = True if hasattr(updated_role_resource, 'RightReferences') and \ hasattr(updated_role_resource.RightReferences, 'RightReference'): for right in updated_role_resource.RightReferences.RightReference: if right.get('name') == right_name: success = False break assert success