~ubuntu-branches/ubuntu/precise/ceph/precise-proposed

« back to all changes in this revision

Viewing changes to src/tools/gceph.cc

  • Committer: Bazaar Package Importer
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2011-04-25 10:09:05 UTC
  • mfrom: (1.1.3 upstream) (0.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110425100905-exm7dfvi2v5ick02
Tags: 0.27-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 
2
// vim: ts=8 sw=2 smarttab
 
3
/*
 
4
 * Ceph - scalable distributed file system
 
5
 *
 
6
 * Copyright (C) 2004-2010 Sage Weil <sage@newdream.net>
 
7
 * Copyright (C) 2010 Dreamhost
 
8
 *
 
9
 * This is free software; you can redistribute it and/or
 
10
 * modify it under the terms of the GNU Lesser General Public
 
11
 * License version 2.1, as published by the Free Software
 
12
 * Foundation.  See file COPYING.
 
13
 *
 
14
 */
 
15
 
 
16
#include "common/common_init.h"
 
17
#include "common/ceph_argparse.h"
 
18
#include "common/config.h"
 
19
#include "tools/common.h"
 
20
 
 
21
#include <iostream>
 
22
#include <sstream>
 
23
#include <vector>
 
24
 
 
25
// tool/gui.cc
 
26
int run_gui(int argc, char **argv);
 
27
 
 
28
using std::vector;
 
29
 
 
30
static std::ostringstream gss;
 
31
 
 
32
static void usage()
 
33
{
 
34
  derr << "usage: gceph [options]" << dendl;
 
35
  derr << dendl;
 
36
  derr << "Runs the ceph graphical monitor" << dendl;
 
37
  generic_client_usage(); // Will exit()
 
38
}
 
39
 
 
40
static void parse_gceph_args(const vector<const char*> &args)
 
41
{
 
42
  DEFINE_CONF_VARS(usage);
 
43
  FOR_EACH_ARG(args) {
 
44
    if (CEPH_ARGPARSE_EQ("help", 'h')) {
 
45
      usage();
 
46
    }
 
47
  }
 
48
}
 
49
 
 
50
static int cephtool_run_gui(int argc, const char **argv)
 
51
{
 
52
  g.log = &gss;
 
53
  g.slog = &gss;
 
54
 
 
55
  // TODO: make sure that we capture the log this generates in the GUI
 
56
  g.lock.Lock();
 
57
  send_observe_requests();
 
58
  g.lock.Unlock();
 
59
 
 
60
  return run_gui(argc, (char **)argv);
 
61
}
 
62
 
 
63
void ceph_tool_common_shutdown_wrapper()
 
64
{
 
65
  ceph_tool_messenger_shutdown();
 
66
  ceph_tool_common_shutdown();
 
67
}
 
68
 
 
69
int main(int argc, const char **argv)
 
70
{
 
71
  int ret = 0;
 
72
 
 
73
  DEFINE_CONF_VARS(usage);
 
74
  vector<const char*> args;
 
75
  argv_to_vec(argc, argv, args);
 
76
  env_to_vec(args);
 
77
 
 
78
  common_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
 
79
  keyring_init(&g_conf);
 
80
 
 
81
  vec_to_argv(args, argc, argv);
 
82
 
 
83
  parse_gceph_args(args);
 
84
 
 
85
  if (ceph_tool_common_init(CEPH_TOOL_MODE_GUI)) {
 
86
    derr << "cephtool_common_init failed." << dendl;
 
87
    return 1;
 
88
  }
 
89
 
 
90
  atexit(ceph_tool_common_shutdown_wrapper);
 
91
 
 
92
  if (cephtool_run_gui(argc, argv))
 
93
    ret = 1;
 
94
 
 
95
  if (ceph_tool_messenger_shutdown())
 
96
    ret = 1;
 
97
 
 
98
  return ret;
 
99
}