Statistics
| Branch: | Tag: | Revision:

one / src / rm / RequestManagerGroupPoolInfo.cc @ ae53d437

History | View | Annotate | Download (3.3 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
#include "RequestManager.h"
18
#include "NebulaLog.h"
19

    
20
#include "AuthManager.h"
21

    
22
/* -------------------------------------------------------------------------- */
23
/* -------------------------------------------------------------------------- */
24

    
25
void RequestManager::GroupPoolInfo::execute(
26
    xmlrpc_c::paramList const& paramList,
27
    xmlrpc_c::value *   const  retval)
28
{
29
    string        session;
30
    ostringstream oss;
31
    int           rc;
32

    
33
    const string  method_name = "GroupPoolInfo";
34

    
35
    /*   -- RPC specific vars --  */
36
    vector<xmlrpc_c::value> arrayData;
37
    xmlrpc_c::value_array * arrayresult;
38

    
39
    NebulaLog::log("ReM",Log::DEBUG,"GroupPoolInfo method invoked");
40

    
41
    // Get the parameters
42
    session = xmlrpc_c::value_string(paramList.getString(0));
43

    
44
    //Authenticate the user
45
    rc = GroupPoolInfo::upool->authenticate(session);
46

    
47
    if ( rc == -1 )
48
    {
49
        goto error_authenticate;
50
    }
51

    
52
    // TODO: perform authorization with INFO?
53
    // Add flags, like "groups I belong to", "groups I own"
54

    
55
    // Dump the pool
56
    rc = GroupPoolInfo::gpool->dump(oss, "");
57

    
58
    if ( rc != 0 )
59
    {
60
        goto error_dump;
61
    }
62

    
63
    //All nice, return the info to the client
64
    arrayData.push_back(xmlrpc_c::value_boolean(true)); // SUCCESS
65
    arrayData.push_back(xmlrpc_c::value_string(oss.str()));
66

    
67
    arrayresult = new xmlrpc_c::value_array(arrayData);
68

    
69
    // Copy arrayresult into retval mem space
70
    *retval = *arrayresult;
71

    
72
    // and get rid of the original
73
    delete arrayresult;
74

    
75
    return;
76

    
77
error_authenticate:
78
    oss.str(authenticate_error(method_name));
79
    goto error_common;
80

    
81
error_dump:
82
    oss.str(get_error(method_name, "GROUP", -1));
83
    goto error_common;
84

    
85
error_common:
86

    
87
    arrayData.push_back(xmlrpc_c::value_boolean(false)); // FAILURE
88
    arrayData.push_back(xmlrpc_c::value_string(oss.str()));
89

    
90
    NebulaLog::log("ReM",Log::ERROR,oss);
91

    
92
    xmlrpc_c::value_array arrayresult_error(arrayData);
93

    
94
    *retval = arrayresult_error;
95

    
96
    return;
97
}
98

    
99
/* -------------------------------------------------------------------------- */
100
/* -------------------------------------------------------------------------- */