2 * Copyright (C) 2009 Red Hat Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 /* This file makes available all entries in the libvirt NodeInfo
31 #include <libvirt/libvirt.h>
33 #include "hostinfod.h"
36 model (struct guest_description *hval,
37 const char *cmd, apr_array_header_t *args)
39 if (get_args (args, "") == -1) {
40 warning ("%s: %s: wrong number or type of arguments",
41 hval->name, __func__);
42 send_error (hval, 400);
46 send_reply (hval, 200, "%s", nodeinfo.model);
48 REGISTER_COMMAND (model)
51 memory (struct guest_description *hval,
52 const char *cmd, apr_array_header_t *args)
54 if (get_args (args, "") == -1) {
55 warning ("%s: %s: wrong number or type of arguments",
56 hval->name, __func__);
57 send_error (hval, 400);
61 send_reply (hval, 200, "%lu", nodeinfo.memory);
63 REGISTER_COMMAND (memory)
66 availcpus (struct guest_description *hval,
67 const char *cmd, apr_array_header_t *args)
69 if (get_args (args, "") == -1) {
70 warning ("%s: %s: wrong number or type of arguments",
71 hval->name, __func__);
72 send_error (hval, 400);
76 send_reply (hval, 200, "%u", nodeinfo.cpus);
78 REGISTER_COMMAND (availcpus)
81 physcpus (struct guest_description *hval,
82 const char *cmd, apr_array_header_t *args)
84 if (get_args (args, "") == -1) {
85 warning ("%s: %s: wrong number or type of arguments",
86 hval->name, __func__);
87 send_error (hval, 400);
91 send_reply (hval, 200, "%u", VIR_NODEINFO_MAXCPUS (nodeinfo));
93 REGISTER_COMMAND (physcpus)
96 mhz (struct guest_description *hval,
97 const char *cmd, apr_array_header_t *args)
99 if (get_args (args, "") == -1) {
100 warning ("%s: %s: wrong number or type of arguments",
101 hval->name, __func__);
102 send_error (hval, 400);
106 send_reply (hval, 200, "%u", nodeinfo.mhz);
108 REGISTER_COMMAND (mhz)
111 nodes (struct guest_description *hval,
112 const char *cmd, apr_array_header_t *args)
114 if (get_args (args, "") == -1) {
115 warning ("%s: %s: wrong number or type of arguments",
116 hval->name, __func__);
117 send_error (hval, 400);
121 send_reply (hval, 200, "%u", nodeinfo.nodes);
123 REGISTER_COMMAND (nodes)
126 socketspernode (struct guest_description *hval,
127 const char *cmd, apr_array_header_t *args)
129 if (get_args (args, "") == -1) {
130 warning ("%s: %s: wrong number or type of arguments",
131 hval->name, __func__);
132 send_error (hval, 400);
136 send_reply (hval, 200, "%u", nodeinfo.sockets);
138 REGISTER_COMMAND (socketspernode)
141 corespersocket (struct guest_description *hval,
142 const char *cmd, apr_array_header_t *args)
144 if (get_args (args, "") == -1) {
145 warning ("%s: %s: wrong number or type of arguments",
146 hval->name, __func__);
147 send_error (hval, 400);
151 send_reply (hval, 200, "%u", nodeinfo.cores);
153 REGISTER_COMMAND (corespersocket)
156 threadspercore (struct guest_description *hval,
157 const char *cmd, apr_array_header_t *args)
159 if (get_args (args, "") == -1) {
160 warning ("%s: %s: wrong number or type of arguments",
161 hval->name, __func__);
162 send_error (hval, 400);
166 send_reply (hval, 200, "%u", nodeinfo.threads);
168 REGISTER_COMMAND (threadspercore)