Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 14 additions & 47 deletions opensciencegrid/access-amie/lib/CLI.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from amieclient.packet import NotifyPersonIDs

from AMIE import AMIE
from OSGConnect import OSGConnect

log_config = {
"version": 1,
Expand Down Expand Up @@ -50,32 +49,34 @@ def main():
config = configparser.ConfigParser()
config.read('/opt/access-amie/etc/access-amie.conf')
amie = AMIE(config)
connect = OSGConnect(config)

parser = argparse.ArgumentParser(prog='access-amie')
# parser.add_argument('--foo', action='store_true', help='foo help')
subparsers = parser.add_subparsers(help='sub-command help')

# create the parser for the "project-created" command
parser_pcreated = subparsers.add_parser('project-created',
help='Use this when a ACCESS requested project and PI has been set up in OSGConnect')
help='Use this when a ACCESS requested project and PI has been set up in OSPool')
parser_pcreated.add_argument('--project', required=True, help='Project in the form of TG-XXXXXXXX')
parser_pcreated.add_argument('--pi-username', required=True, help='OSGConnect username of the PI')
parser_pcreated.add_argument('--pi-username', required=True, help='OSPool username of the PI')
parser_pcreated.add_argument('--pi-uid', required=True, help='OSPool uid of the PI')
parser_pcreated.set_defaults(func=project_created)

# create the parser for the "account-created" command
parser_acreated = subparsers.add_parser('account-created',
help='Use this when a ACCESS requested user account been set up in OSGConnect')
help='Use this when a ACCESS requested user account been set up in OSPool')
parser_acreated.add_argument('--global-id', required=True, help='ACCESS Global ID')
parser_acreated.add_argument('--project', required=True, help='Project in the form of TG-XXXXXXXX')
parser_acreated.add_argument('--username', required=True, help='OSGConnect username')
parser_acreated.add_argument('--ospool-username', required=True, help='OSPool username')
parser_acreated.add_argument('--ospool-uid', required=True, help='OSPool uid')
parser_acreated.set_defaults(func=account_created)

# create the parser for the "account-move" command
parser_amove = subparsers.add_parser('account-move',
help='Move an existing account to a new OSGConnect uid/username')
help='Move an existing account to a new OSPool uid/username')
parser_amove.add_argument('--access-person-id', required=True, help='ACCESS global person id')
parser_amove.add_argument('--connect-username', required=True, help='Target user in OSGConnect')
parser_amove.add_argument('--ospool-username', required=True, help='Target user in OSPool')
parser_amove.add_argument('--ospool-uid', required=True, help='Target uid in OSPool')
parser_amove.set_defaults(func=account_move)

# create the parser for the "account-park" command
Expand All @@ -91,19 +92,6 @@ def main():


def project_created(args):
# Ensure that the project and user exists in OSGConnect, we have
# a corresponding parked AMIE rpc packet, and if so send the
# notify_project_create package to AMIE

try:
project = connect.project(args.project)
pi = connect.user(args.pi_username)
uid = pi['unix_id']
# for testing - how should we switch to this?
# uid = re.sub('foo', '', args.pi_username)
except Exception as e:
log.exception(e)
sys.exit(1)

# find the parked packet
rpc = None
Expand All @@ -118,7 +106,7 @@ def project_created(args):
# construct a NotifyProjectCreate(NPC) packet.
npc = rpc.reply_packet()
npc.ProjectID = args.project # local project ID
npc.PiPersonID = uid # local person ID for the pi
npc.PiPersonID = args.pi_uid # local person ID for the pi
npc.PiRemoteSiteLogin = args.pi_username # local username

# send the NPC
Expand All @@ -129,19 +117,6 @@ def project_created(args):


def account_created(args):
# Ensure that the user exists in OSGConnect, we have
# a corresponding parked AMIE rac packet, and if so send the
# notify_account_create package to AMIE

try:
project = connect.project(args.project)
pi = connect.user(args.username)
uid = pi['unix_id']
# for testing - how should we switch to this?
# uid = re.sub('foo', '', args.username)
except Exception as e:
log.exception(e)
sys.exit(1)

# find the parked packet
rac = None
Expand All @@ -162,8 +137,8 @@ def account_created(args):
# construct a NotifyAccountCreate(NAC) packet.
nac = rac.reply_packet()
nac.ProjectID = args.project # local project ID
nac.UserPersonID = uid # local person ID for the pi
nac.UserRemoteSiteLogin = args.username # local username
nac.UserPersonID = args.ospool_uid # local person ID for the pi
nac.UserRemoteSiteLogin = args.ospool_username # local username

# send the NPC
amie.send_packet(nac)
Expand All @@ -173,22 +148,14 @@ def account_created(args):


def account_move(args):
# Ensure the new uid/username exist in OSGConnect. No verification
# on the old uid.

try:
user = connect.user(args.connect_username)
except Exception as e:
log.exception(e)
sys.exit(1)

# construct a NotifyPersonIDs packet.
npi = NotifyPersonIDs(
originating_site_name="OSG"
)
npi.PersonID = args.access_person_id
npi.PrimaryPersonID = user['unix_id']
npi.PersonIdList = [user['unix_id']]
npi.PrimaryPersonID = args.ospool_uid
npi.PersonIdList = [args.ospool_uid]
# remove old ones
npi.RemoveResourceList = ['grid1.osg.xsede']
npi.ResourceLogin = [{
Expand Down
82 changes: 40 additions & 42 deletions opensciencegrid/access-amie/lib/Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
class Main():
config = None
amie = None
connect = None
freshdesk = None

def __init__(self):
Expand Down Expand Up @@ -93,23 +92,22 @@ def request_project_create(self, packet):

subject = f'OSG/ACCESS - create PI account to activate your allocation TG-{grant_number}'
body = f'''<p>Thank you for your interest in using OSPool resources via an ACCESS allocation.
When you are ready to use your OSPool allocation, you (the allocation PI) need an account
with the OSG Connect service.</p>
When you are ready to use your OSPool allocation, you (the allocation PI) need an OSPool account.</p>

<br>
<p>
<b>If you already have an OSG Connect user profile:</b><br>
You can check by trying to ‘Log In’ via the osgconnect.net website using your institutional
identity. If you are able to view your user Profile and are ready to charge OSPool usage against
your ACCESS allocation, please send an email to [email protected], to request that your
<b>If you already have an OSPool account:</b><br>
You can check by trying to ‘Log In’ to https://registry.cilogon.org/registry/co_dashboards/dashboard/co:7
using your institutional identity. If you are able to view your user Profile and are ready to charge
OSPool usage against your ACCESS allocation, please send an email to [email protected], to request that your
user account be associated with the appropriate allocation charge code (e.g. TG-{grant_number}).
</p>

<br>
<p>
<b>If you do not yet have an OSG Connect user profile:</b><br>
Please ‘Sign Up’ for an account at https://connect.osg-htc.org/signup using your institutional
identity, and copy the below into the Comments field before submitting your Sign Up request.
<b>If you do not yet have an OSPool account:</b><br>
Please ‘Sign Up’ for an account at https://portal.osg-htc.org/application , and copy the below into
the additional information field before submitting your request.
</p>

<br>
Expand Down Expand Up @@ -187,41 +185,41 @@ def request_account_create(self, packet):
project_id = packet.ProjectID

# RACs are also used to reactivate accounts, so if the account already exists, just set it active
if user_person_id and len(user_person_id) > 1:
try:
user = self.connect.user(user_person_id)

# ensure emails match
if user_email == user['email']:
# construct a NotifyAccountCreate(NAC) packet.
nac = packet.reply_packet()
nac.UserRemoteSiteLogin = user['unix_name'] # local login for the User on the resource
nac.UserPersonID = user_person_id # local person ID for the User
self.amie.send_packet(nac)
return
except Exception:
# unable to find/process the user - fall back to facilitators
pass

subject = f'OSG/ACCESS - create an account on OSG Connect'
#if user_person_id and len(user_person_id) > 1:
# try:
# user = self.connect.user(user_person_id)
#
# # ensure emails match
# if user_email == user['email']:
# # construct a NotifyAccountCreate(NAC) packet.
# nac = packet.reply_packet()
# nac.UserRemoteSiteLogin = user['unix_name'] # local login for the User on the resource
# nac.UserPersonID = user_person_id # local person ID for the User
# self.amie.send_packet(nac)
# return
# except Exception:
# # unable to find/process the user - fall back to facilitators
# pass

subject = f'OSG/ACCESS - create an OSPool account'
body = f'''<p>Thank you for your application for an OSG account via an ACCESS allocation. When you
are ready to use your allocation, you will need an account with the OSG Connect service.
are ready to use your allocation, you will need an OSPool account.
</p>

<br>
<p>
<b>If you already have an OSG Connect user profile:</b><br>
You can double check by trying to ‘Log In’ via the https://connect.osg-htc.org/ website using your institutional identity.
If you are able to view your user Profile without needing to ‘Sign Up’ and are ready to charge OSPool usage
against your ACCESS allocation, please send an email to [email protected], to request that your
user account be associated with the appropriate allocation charge code (e.g. {project_id}).
<b>If you already have an OSPool account:</b><br>
You can double check by trying to ‘Log In’ to https://registry.cilogon.org/registry/co_dashboards/dashboard/co:7
using your institutional identity. If you are able to view your user Profile without needing to ‘Sign Up’ and
are ready to charge OSPool usage against your ACCESS allocation, please send an email to [email protected],
to request that your user account be associated with the appropriate allocation charge code (e.g. {project_id}).
</p>

<br>
<p>
<b>If you do not yet have an OSG Connect user profile:</b><br>
Please ‘Sign Up’ for an account at https://connect.osg-htc.org/signup using your institutional identity, and
copy the below into the Comments field before submitting your ‘Sign Up’ request:
<b>If you do not yet have an OSPool account:</b><br>
Please ‘Sign Up’ for an account at https://portal.osg-htc.org/application , and copy the below into
the additional information field before submitting your request.
</p>

<br>
Expand Down Expand Up @@ -309,12 +307,12 @@ def request_project_inactivate(self, packet):
resource = packet.ResourceList[0]
project_id = packet.ProjectID

log.info('Deactivating {}'.format(project_id))
try:
self.connect.remove_all_users(project_id)
except:
# project might not exist
pass
#log.info('Deactivating {}'.format(project_id))
#try:
# self.connect.remove_all_users(project_id)
#except:
# # project might not exist
# pass

nai = packet.reply_packet()
self.amie.send_packet(nai)
Expand Down
117 changes: 0 additions & 117 deletions opensciencegrid/access-amie/lib/OSGConnect.py

This file was deleted.

Loading