Revision 0a132883

View differences:

include/RequestManagerAllocate.h
48 48

  
49 49
    void request_execute(xmlrpc_c::paramList const& _paramList);
50 50

  
51
    bool allocate_authorization(Template * obj_template);
51
    virtual bool allocate_authorization(Template * obj_template);
52 52

  
53 53
    string allocate_error (char *error);
54 54

  
......
67 67
    bool do_template;
68 68
};
69 69

  
70

  
71
/* ------------------------------------------------------------------------- */
72
/* ------------------------------------------------------------------------- */
73

  
74
class VirtualMachineAllocate: public RequestManagerAllocate
75
{
76
public:
77
    VirtualMachineAllocate():
78
        RequestManagerAllocate("VirtualMachineAllocate",
79
                               "Allocates a new virtual machine",
80
                               "A:ss",
81
                               true)
82
    {    
83
        Nebula& nd = Nebula::instance();
84
        pool       = nd.get_vmpool();
85
        auth_object = AuthRequest::VM;
86
    };
87

  
88
    ~VirtualMachineAllocate(){};
89
    /* --------------------------------------------------------------------- */
90

  
91
    Template * get_object_template() 
92
    { 
93
        return new VirtualMachineTemplate; 
94
    };
95

  
96
    int pool_allocate(xmlrpc_c::paramList const& _paramList, 
97
                      Template * tmpl,
98
                      int& id, 
99
                      string& error_str);
100

  
101
    bool allocate_authorization(Template * obj_template);
102
};
103

  
70 104
/* ------------------------------------------------------------------------- */
71 105
/* ------------------------------------------------------------------------- */
72 106

  
......
163 197
                      string& error_str);
164 198
};
165 199

  
166

  
167 200
/* ------------------------------------------------------------------------- */
168 201
/* ------------------------------------------------------------------------- */
169 202

  
......
246 279
{
247 280
public:
248 281
    GroupAllocate():
249
        RequestManagerAllocate("GroupInfo",
282
        RequestManagerAllocate("GroupAllocate",
250 283
                               "Allocates a new group",
251 284
                               "A:ss",
252 285
                               false)
src/rm/Request.cc
69 69

  
70 70
        if ( object == 0 )
71 71
        {
72
            failure_response(NO_EXISTS, get_error("USER",oid)); //TODO
72
            failure_response(NO_EXISTS, get_error(object_name(auth_object),oid)); 
73 73
            return false;
74 74
        }
75 75

  
......
86 86
   if (UserPool::authorize(ar) == -1)
87 87
   {
88 88
        failure_response(AUTHORIZATION, //TODO
89
                 authorization_error("INFO","USER",oid,-1));
89
                 authorization_error("INFO",object_name(auth_object),oid,-1));
90 90

  
91 91
        return false;
92 92
    }
src/rm/RequestManagerAllocate.cc
96 96
/* -------------------------------------------------------------------------- */
97 97
/* -------------------------------------------------------------------------- */
98 98

  
99
bool VirtualMachineAllocate::allocate_authorization(Template * tmpl)
100
{
101
    if ( uid == 0 )
102
    {
103
        return true;
104
    }
105

  
106
    AuthRequest ar(uid);
107
    string      t64;
108

  
109
    VirtualMachineTemplate * ttmpl = static_cast<VirtualMachineTemplate *>(tmpl);
110

  
111
    ar.add_auth(auth_object,tmpl->to_xml(t64),auth_op,uid,false);
112

  
113
    VirtualMachine::set_auth_request(uid, ar, ttmpl);
114

  
115
   if (UserPool::authorize(ar) == -1)
116
   {
117
        failure_response(AUTHORIZATION, //TODO
118
                 authorization_error("INFO","USER",uid,-1));
119

  
120
        return false;
121
    }
122

  
123
    return true;
124
}
125

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

  
99 129
void RequestManagerAllocate::request_execute(xmlrpc_c::paramList const& params)
100 130
{
101 131
    Template * tmpl = 0;
......
140 170
/* -------------------------------------------------------------------------- */
141 171
/* -------------------------------------------------------------------------- */
142 172

  
173
int VirtualMachineAllocate::pool_allocate(xmlrpc_c::paramList const& paramList, 
174
                                          Template * tmpl,
175
                                          int& id, 
176
                                          string& error_str)
177
{
178
    VirtualMachineTemplate * ttmpl = static_cast<VirtualMachineTemplate *>(tmpl);
179
    VirtualMachinePool * vmpool    = static_cast<VirtualMachinePool *>(pool);
180

  
181
    return vmpool->allocate(uid, gid, ttmpl, &id, error_str, false);
182
}
183

  
184

  
185
/* -------------------------------------------------------------------------- */
186
/* -------------------------------------------------------------------------- */
187

  
143 188
int VirtualNetworkAllocate::pool_allocate(xmlrpc_c::paramList const& _paramList, 
144 189
                                          Template * tmpl,
145 190
                                          int& id, 

Also available in: Unified diff