MCPcopy
hub / github.com/NVIDIA/aistore / parseXactionFromArgs

Function parseXactionFromArgs

cmd/cli/commands/utils.go:443–489  ·  view source on GitHub ↗

Parses [TARGET_ID] [XACTION_ID|XACTION_NAME] [BUCKET]

(c *cli.Context)

Source from the content-addressed store, hash-verified

441
442// Parses [TARGET_ID] [XACTION_ID|XACTION_NAME] [BUCKET]
443func parseXactionFromArgs(c *cli.Context) (nodeID, xactID, xactKind string, bck cmn.Bck, err error) {
444 var smap *cluster.Smap
445 smap, err = api.GetClusterMap(defaultAPIParams)
446 if err != nil {
447 return
448 }
449 shift := 0
450 xactKind = argDaemonID(c)
451 if node := smap.GetProxy(xactKind); node != nil {
452 return "", "", "", bck, fmt.Errorf("daemon %q is a proxy", xactKind)
453 }
454 if node := smap.GetTarget(xactKind); node != nil {
455 nodeID = xactKind
456 xactKind = c.Args().Get(1)
457 shift++
458 }
459
460 uri := c.Args().Get(1 + shift)
461 if !xact.IsValidKind(xactKind) {
462 xactID = xactKind
463 xactKind = ""
464 uri = c.Args().Get(1 + shift)
465 } else if strings.Contains(xactKind, apc.BckProviderSeparator) {
466 uri = xactKind
467 xactKind = ""
468 }
469 if uri != "" {
470 switch xact.Table[xactKind].Scope {
471 case xact.ScopeBck:
472 // Bucket is optional.
473 if uri := c.Args().Get(1); uri != "" {
474 if bck, err = parseBckURI(c, uri); err != nil {
475 return "", "", "", bck, err
476 }
477 if _, err = headBucket(bck); err != nil {
478 return "", "", "", bck, err
479 }
480 }
481 default:
482 if c.NArg() > 1 {
483 fmt.Fprintf(c.App.ErrWriter,
484 "Warning: %q is a non bucket-scope xaction, ignoring bucket name\n", xactKind)
485 }
486 }
487 }
488 return
489}
490
491// Get list of xactions
492func listXactions(onlyStartable bool) []string {

Callers 4

stopXactionHandlerFunction · 0.85
waitXactionHandlerFunction · 0.85
showXactionHandlerFunction · 0.85

Calls 10

GetProxyMethod · 0.95
GetTargetMethod · 0.95
GetClusterMapFunction · 0.92
IsValidKindFunction · 0.92
argDaemonIDFunction · 0.85
parseBckURIFunction · 0.85
headBucketFunction · 0.85
ArgsMethod · 0.80
GetMethod · 0.65
ContainsMethod · 0.45

Tested by

no test coverage detected