Parses [TARGET_ID] [XACTION_ID|XACTION_NAME] [BUCKET]
(c *cli.Context)
| 441 | |
| 442 | // Parses [TARGET_ID] [XACTION_ID|XACTION_NAME] [BUCKET] |
| 443 | func 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 |
| 492 | func listXactions(onlyStartable bool) []string { |
no test coverage detected