| 3549 | } |
| 3550 | |
| 3551 | int process_pg_map_command( |
| 3552 | const string& orig_prefix, |
| 3553 | const cmdmap_t& orig_cmdmap, |
| 3554 | const PGMap& pg_map, |
| 3555 | const OSDMap& osdmap, |
| 3556 | ceph::Formatter *f, |
| 3557 | stringstream *ss, |
| 3558 | bufferlist *odata) |
| 3559 | { |
| 3560 | string prefix = orig_prefix; |
| 3561 | auto cmdmap = orig_cmdmap; |
| 3562 | |
| 3563 | string omap_stats_note = |
| 3564 | "\n* NOTE: Omap statistics are gathered during deep scrub and " |
| 3565 | "may be inaccurate soon afterwards depending on utilization. See " |
| 3566 | "http://docs.ceph.com/en/latest/dev/placement-group/#omap-statistics " |
| 3567 | "for further details.\n"; |
| 3568 | bool omap_stats_note_required = false; |
| 3569 | |
| 3570 | // perhaps these would be better in the parsing, but it's weird |
| 3571 | bool primary = false; |
| 3572 | if (prefix == "pg dump_json") { |
| 3573 | vector<string> v; |
| 3574 | v.push_back(string("all")); |
| 3575 | cmd_putval(g_ceph_context, cmdmap, "dumpcontents", v); |
| 3576 | prefix = "pg dump"; |
| 3577 | } else if (prefix == "pg dump_pools_json") { |
| 3578 | vector<string> v; |
| 3579 | v.push_back(string("pools")); |
| 3580 | cmd_putval(g_ceph_context, cmdmap, "dumpcontents", v); |
| 3581 | prefix = "pg dump"; |
| 3582 | } else if (prefix == "pg ls-by-primary") { |
| 3583 | primary = true; |
| 3584 | prefix = "pg ls"; |
| 3585 | } else if (prefix == "pg ls-by-osd") { |
| 3586 | prefix = "pg ls"; |
| 3587 | } else if (prefix == "pg ls-by-pool") { |
| 3588 | prefix = "pg ls"; |
| 3589 | string poolstr; |
| 3590 | cmd_getval(cmdmap, "poolstr", poolstr); |
| 3591 | int64_t pool = osdmap.lookup_pg_pool_name(poolstr.c_str()); |
| 3592 | if (pool < 0) { |
| 3593 | *ss << "pool " << poolstr << " does not exist"; |
| 3594 | return -ENOENT; |
| 3595 | } |
| 3596 | cmd_putval(g_ceph_context, cmdmap, "pool", pool); |
| 3597 | } |
| 3598 | |
| 3599 | stringstream ds; |
| 3600 | if (prefix == "pg stat") { |
| 3601 | if (f) { |
| 3602 | f->open_object_section("pg_summary"); |
| 3603 | pg_map.print_oneline_summary(f, NULL); |
| 3604 | f->close_section(); |
| 3605 | f->flush(ds); |
| 3606 | } else { |
| 3607 | ds << pg_map; |
| 3608 | } |
no test coverage detected