Skip to content

Commit

Permalink
flux-ion-resource: add support for ns-info
Browse files Browse the repository at this point in the history
Add a subcommand into flux-ion-resource:
ns-info Rank Type Id to get to help invoke ns-info
RPC within sched-fluxion-resource.
  • Loading branch information
dongahn committed Dec 2, 2020
1 parent 848233a commit aec3170
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions t/scripts/flux-ion-resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ def rpc_find (self, criteria, find_format=None):

def rpc_status (self):
return self.f.rpc ("sched-fluxion-resource.status").get ()

def rpc_namespace_info (self, rank, type_name, identity):
payload = {'rank' : rank, 'type-name' : type_name, 'id' : identity}
return self.f.rpc ("sched-fluxion-resource.ns-info", payload).get ()


"""
Expand Down Expand Up @@ -220,6 +224,14 @@ def status_action (args):
print ('MATCHED RESOURCES:')
print (json.dumps (resp))

"""
Action for ns-info sub-command
"""
def namespace_info_action (args):
r = ResourceModuleInterface ()
resp = r.rpc_namespace_info (args.rank, args.type, args.Id)
print (resp['id'])

"""
Main entry point
"""
Expand Down Expand Up @@ -250,6 +262,7 @@ def main ():
ststr = "Display resource status"
pstr = "Set property-key=value for specified resource."
gstr = "Get value for specified resource and property-key."
nstr = "Get remapped ID given raw ID seen by the selected reader."
parser_m = subpar.add_parser ('match', help=mstr, description=mstr)
parser_u = subpar.add_parser ('update', help=ustr, description=ustr)
parser_i = subpar.add_parser ('info', help=istr, description=istr)
Expand All @@ -259,6 +272,7 @@ def main ():
parser_st = subpar.add_parser ('status', help=ststr, description=ststr)
parser_sp = subpar.add_parser ('set-property', help=pstr, description=pstr)
parser_gp = subpar.add_parser ('get-property', help=gstr, description=gstr)
parser_n = subpar.add_parser ('ns-info', help=nstr, description=nstr)

#
# Add subparser for the match sub-command
Expand Down Expand Up @@ -353,6 +367,16 @@ def main ():
help='get-property resource_path property-key')
parser_gp.set_defaults (func=get_property_action)

# Positional argument for ns-info sub-command
#
parser_n.add_argument ('rank', metavar='Rank', type=int,
help='execution target')
parser_n.add_argument ('type', metavar='Type', type=str,
help='type: e.g., core, gpu, or rank')
parser_n.add_argument ('Id', metavar='Id', type=int,
help='raw Id seen by the reader')
parser_n.set_defaults (func=namespace_info_action)

#
# Parse the args and call an action routine as part of that
#
Expand Down

0 comments on commit aec3170

Please sign in to comment.