Skip to content

Commit

Permalink
addressing #54
Browse files Browse the repository at this point in the history
  • Loading branch information
iannesbitt committed Jan 10, 2024
1 parent 41b6602 commit 142b6f7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mnonboard/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def run(cfg):
loc=loc,
ssh=cfg['ssh'])
time.sleep(0.5)
utils.upload_xml(ssh=ssh, server=SO_SRVR[cfg['mode']], files=files, node_id=node_id, loc=loc)
utils.upload_xml(ssh=ssh, server=CN_SRVR[cfg['mode']], files=files, node_id=node_id, loc=loc)
# create and validate the subject in the accounts service (step 16)
utils.create_subj_in_acct_svc(ssh=ssh, cert=cfg['cert_loc'], files=files, cn=cfg['cn_url'], loc=loc)
utils.validate_subj_in_acct_svc(ssh=ssh, cert=cfg['cert_loc'], names=names, cn=cfg['cn_url'], loc=loc)
Expand Down
3 changes: 3 additions & 0 deletions mnonboard/defs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os, pwd
from mnonboard import __version__

ORCID_PREFIX = 'http://orcid.org/'
Expand Down Expand Up @@ -44,6 +45,8 @@
The location of the coordinating node.
"""

USER_NAME = pwd.getpwuid(os.getuid())[0]

CN_SRVR_BASEURL = 'https://%s/cn'
"""
The URL format of the CN API.
Expand Down
10 changes: 6 additions & 4 deletions mnonboard/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import xmltodict
from pathlib import Path

from mnonboard.defs import SCHEDULES, NAMES_DICT, SUBJECT_PREFIX, SUBJECT_POSTFIX
from mnonboard.defs import SCHEDULES, NAMES_DICT, SUBJECT_PREFIX, SUBJECT_POSTFIX, USER_NAME
from mnonboard import NODE_PATH_REL, CUR_PATH_ABS, LOG_DIR, HARVEST_LOG_NAME, HM_DATE, L
from mnonboard.info_chx import cn_subj_lookup, local_subj_lookup, enter_schedule, orcid_name, set_role

Expand Down Expand Up @@ -355,7 +355,7 @@ def start_ssh(server: str, node_id, loc: str, ssh: bool=True):
L.error('%s running %s. Details: %s' % (repr(e), op, e))
return None, local_xml_dir, node_id

def upload_xml(ssh: SSHClient, files: list, node_id: str, loc: str, server: str=None):
def upload_xml(ssh: SSHClient, files: list, node_id: str, loc: str, usern: str=USER_NAME, server: str=None):
"""
Format subject XML documents and return list of names.
Expand All @@ -377,10 +377,11 @@ def upload_xml(ssh: SSHClient, files: list, node_id: str, loc: str, server: str=
scp.put(files=files, remote_path=target_dir)
else:
cmd_fn = f"{loc}/commands.sh"
write_cmd_to(fn=cmd_fn, cmd=f'## Commands to be run on the MN:')
write_cmd_to(fn=cmd_fn, cmd=f'mkdir -p {target_dir}', desc='Copy xml files from so server to cn', mode='w')
write_cmd_to(fn=cmd_fn, cmd=f'cd {target_dir}')
write_cmd_to(fn=cmd_fn, cmd=f'cd {target_dir}', desc=" ")
for f in files:
command = f"scp mnlite@{server}:{f} {target_dir}"
command = f"scp {f} {usern}@{server}:{target_dir}"
write_cmd_to(fn=cmd_fn, cmd=command)
except Exception as e:
L.error('%s running %s. Details: %s' % (repr(e), op, e))
Expand Down Expand Up @@ -409,6 +410,7 @@ def create_subj_in_acct_svc(ssh: SSHClient, cert: str, files: list, cn: str, loc
else:
L.debug(f'Command: {command}')
L.info(f'Writing cmd to {cmd_fn}: subject creation')
write_cmd_to(fn=cmd_fn, cmd="## Commands to be run on the CN:")
write_cmd_to(fn=cmd_fn, cmd=command, desc=f"Create subject: {f}")

def validate_subj_in_acct_svc(ssh: SSHClient, cert: str, names: dict, cn: str, loc: str):
Expand Down

0 comments on commit 142b6f7

Please sign in to comment.