f580883ebd5ab871e4230b715f07688842b4f23e
[handlervirt.git] / handler_virt.h
blobf580883ebd5ab871e4230b715f07688842b4f23e
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 /* Cherokee
5 * Authors:
6 * Alvaro Lopez Ortega <alvaro@alobbs.com>
7 * Stefan de Konink <stefan@konink.de>
9 * Copyright (C) 2001-2008 Alvaro Lopez Ortega
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of version 2 of the GNU General Public
13 * License as published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
26 #ifndef CHEROKEE_HANDLER_VIRT_H
27 #define CHEROKEE_HANDLER_VIRT_H
30 #include "common.h"
31 #include "buffer.h"
32 #include "handler.h"
33 #include "connection.h"
34 #include "plugin_loader.h"
37 #include <libvirt/libvirt.h>
38 #include <cherokee/cherokee.h>
39 #include "handler_clusterstats.h"
41 /* Data types
43 typedef struct {
44 cherokee_handler_clusterstats_t base;
46 /* Configuration parameters */
47 cherokee_boolean_t authenticate;
48 cherokee_boolean_t read_only;
49 cherokee_buffer_t xsl;
50 cherokee_buffer_t virt;
51 } cherokee_handler_virt_props_t;
53 typedef struct {
54 cherokee_handler_t base;
55 cherokee_buffer_t buffer;
56 cherokee_buffer_t user;
57 cherokee_buffer_t vm;
58 enum {
59 not_authenticated = -2,
60 not_implemented = -1,
61 nothing = 0,
62 domainAttachDevice,
63 domainAttachDevice_args,
64 domainDetachDevice,
65 domainGetID,
66 domainGetMaxMemory,
67 domainGetMaxVcpus,
68 domainGetName,
69 domainGetOSType,
70 domainGetSchedulerParameters,
71 domainGetSchedulerType,
72 domainGetUUID,
73 domainGetUUIDString,
74 domainGetVcpus,
75 domainCreate,
76 domainDestroy,
77 domainReboot,
78 domainRestore,
79 domainSave,
80 domainShutdown,
81 domainInterfaceStats,
82 domainUndefine,
83 storageVolCreateXML,
84 storageVolCreateXML_args,
85 storageVolCloneXML_args,
86 storageVolCloneStatus_args,
87 storageVolDelete_args,
88 storageVolSetPassword_args,
89 graph,
90 graphLoad_args,
91 graphInterface_args,
92 xml,
93 domainDefineXML_args,
94 domainDefineXML,
95 domainGetXMLDesc,
96 domainGetXMLSnapshots,
97 storageVolGetXMLDesc_args,
98 showall,
99 showuservms
100 } action;
101 } cherokee_handler_virt_t;
103 typedef struct {
104 const char *name;
105 char *dom;
106 float cost;
107 } tender_t;
109 #define HDL_VIRT(x) ((cherokee_handler_virt_t *)(x))
110 #define PROP_VIRT(x) ((cherokee_handler_virt_props_t *)(x))
111 #define HDL_VIRT_PROPS(x) (PROP_VIRT(MODULE(x)->props))
113 /* Library init function
115 void PLUGIN_INIT_NAME(virt) (cherokee_plugin_loader_t *loader);
116 ret_t cherokee_handler_virt_new (cherokee_handler_t **hdl, cherokee_connection_t *cnt, cherokee_module_props_t *props);
118 /* virtual methods implementation
120 ret_t cherokee_handler_virt_init (cherokee_handler_virt_t *hdl);
122 static ret_t virt_build_page (cherokee_handler_virt_t *hdl);
124 static virStorageVolPtr virt_get_vol_by_args(cherokee_handler_virt_t *hdl, virConnectPtr virConn, unsigned short int prefix);
126 static ret_t load_xml(cherokee_handler_virt_t *hdl, cherokee_buffer_t *xmlDesc);
127 static ret_t save_xml(cherokee_handler_virt_t *hdl, virDomainPtr result, cherokee_buffer_t *buf);
129 #endif /* CHEROKEE_HANDLER_VIRT_H */