Statistics
| Branch: | Tag: | Revision:

one / include / RequestManagerVirtualMachine.h @ af3eed60

History | View | Annotate | Download (4.97 KB)

1
/* -------------------------------------------------------------------------- */
2
/* Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org)             */
3
/*                                                                            */
4
/* Licensed under the Apache License, Version 2.0 (the "License"); you may    */
5
/* not use this file except in compliance with the License. You may obtain    */
6
/* a copy of the License at                                                   */
7
/*                                                                            */
8
/* http://www.apache.org/licenses/LICENSE-2.0                                 */
9
/*                                                                            */
10
/* Unless required by applicable law or agreed to in writing, software        */
11
/* distributed under the License is distributed on an "AS IS" BASIS,          */
12
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   */
13
/* See the License for the specific language governing permissions and        */
14
/* limitations under the License.                                             */
15
/* -------------------------------------------------------------------------- */
16

    
17
#ifndef REQUEST_MANAGER_VIRTUAL_MACHINE_H_
18
#define REQUEST_MANAGER_VIRTUAL_MACHINE_H
19

    
20
#include "Request.h"
21
#include "Nebula.h"
22

    
23
using namespace std;
24

    
25
/* ------------------------------------------------------------------------- */
26
/* ------------------------------------------------------------------------- */
27
/* ------------------------------------------------------------------------- */
28

    
29
class RequestManagerVirtualMachine: public Request
30
{
31
protected:
32
    RequestManagerVirtualMachine(const string& method_name,
33
                       const string& help,
34
                       const string& params)
35
        :Request(method_name,params,help)
36
    {
37
        Nebula& nd  = Nebula::instance();
38
        pool        = nd.get_vmpool();
39

    
40
        auth_object = AuthRequest::VM;
41
        auth_op = AuthRequest::MANAGE;
42
    };
43

    
44
    ~RequestManagerVirtualMachine(){};
45

    
46
    /* -------------------------------------------------------------------- */
47

    
48
    virtual void request_execute(xmlrpc_c::paramList const& _paramList) = 0;
49

    
50
    bool vm_authorization(int id, int hid, ImageTemplate *tmpl);
51

    
52
    int get_host_information(int hid, string& name, string& vmm, string& tm);
53

    
54
    int add_history(VirtualMachine * vm,
55
                    int              hid,
56
                    const string&    hostname,
57
                    const string&    vmm_mad,
58
                    const string&    tm_mad);
59

    
60
    VirtualMachine * get_vm(int id);
61
};
62

    
63
/* ------------------------------------------------------------------------- */
64
/* ------------------------------------------------------------------------- */
65

    
66
class VirtualMachineAction : public RequestManagerVirtualMachine
67
{
68
public:
69
    VirtualMachineAction():
70
        RequestManagerVirtualMachine("VirtualMachineAction",
71
                                     "Performs an action on a virtual machine",
72
                                     "A:ssi"){};
73
    ~VirtualMachineAction(){};
74

    
75
    void request_execute(xmlrpc_c::paramList const& _paramList);
76
};
77

    
78
/* ------------------------------------------------------------------------- */
79
/* ------------------------------------------------------------------------- */
80

    
81
class VirtualMachineDeploy : public RequestManagerVirtualMachine
82
{
83
public:
84
    VirtualMachineDeploy():
85
        RequestManagerVirtualMachine("VirtualMachineDeploy",
86
                                     "Deploys a virtual machine",
87
                                     "A:sii"){};
88

    
89
    ~VirtualMachineDeploy(){};
90

    
91
    void request_execute(xmlrpc_c::paramList const& _paramList);
92
};
93

    
94
/* ------------------------------------------------------------------------- */
95
/* ------------------------------------------------------------------------- */
96

    
97
class VirtualMachineMigrate : public RequestManagerVirtualMachine
98
{
99
public:
100
    VirtualMachineMigrate():
101
        RequestManagerVirtualMachine("VirtualMachineDeploy",
102
                                     "Migrates a virtual machine",
103
                                     "A:siib"){};
104

    
105
    ~VirtualMachineMigrate(){};
106

    
107
    void request_execute(xmlrpc_c::paramList const& _paramList);
108
};
109

    
110
/* ------------------------------------------------------------------------- */
111
/* ------------------------------------------------------------------------- */
112

    
113
class VirtualMachineSaveDisk : public RequestManagerVirtualMachine
114
{
115
public:
116
    VirtualMachineSaveDisk():
117
        RequestManagerVirtualMachine("VirtualMachineSaveDisk",
118
                           "Saves a disk from virtual machine as a new image",
119
                           "A:siis"){};
120

    
121
    ~VirtualMachineSaveDisk(){};
122

    
123
    void request_execute(xmlrpc_c::paramList const& _paramList);
124
};
125

    
126
/* -------------------------------------------------------------------------- */
127
/* -------------------------------------------------------------------------- */
128
/* -------------------------------------------------------------------------- */
129

    
130
#endif