Statistics
| Branch: | Tag: | Revision:

one / include / IPAMRequest.h @ 1772a358

History | View | Annotate | Download (2.96 KB)

1
/* -------------------------------------------------------------------------- */
2
/* Copyright 2002-2015, OpenNebula Project, OpenNebula Systems                */
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 IPAM_REQUEST_H_
18
#define IPAM_REQUEST_H_
19

    
20
#include "SyncRequest.h"
21
#include "NebulaUtil.h"
22

    
23
/**
24
 *  The IPAMRequest class represents a request for the IPAM driver. The request
25
 *  is in the form
26
 *  request to the AuthManager. The result of the request will be stored
27
 *  in the result and message attributes of this class.
28
 */
29
class IPAMRequest : public SyncRequest
30
{
31
public:
32
    /* ---------------------------------------------------------------------- */
33
    /* IPAM Request constructors                                              */
34
    /* ---------------------------------------------------------------------- */
35
    IPAMRequest(const std::string& _ar_xml) :
36
        ar_xml(_ar_xml), address_xml("<ADDRESS></MAC></IP></IP6_GLOBAL>"
37
                "</IP6_ULA></SIZE></ADDRESS>"){};
38

    
39
    IPAMRequest(const std::string& _ar_xml, const std::string& _address_xml) :
40
        ar_xml(_ar_xml), address_xml(_address_xml){};
41

    
42
    virtual ~IPAMRequest(){};
43

    
44
    /* ---------------------------------------------------------------------- */
45
    /* Driver message formatting and processing                               */
46
    /* ---------------------------------------------------------------------- */
47
    std::string& to_xml64(std::string& action_data) const
48
    {
49
        std::ostringstream oss;
50
        std::string * aux_str;
51

    
52
        oss << "<IPAM_DRIVER_ACTION_DATA>"
53
            << ar_xml
54
            << address_xml
55
            << "</IPAM_DRIVER_ACTION_DATA>";
56

    
57
        aux_str     = one_util::base64_encode(oss.str());
58
        action_data = *aux_str;
59

    
60
        free(aux_str);
61

    
62
        return action_data;
63
    }
64

    
65
private:
66
    /**
67
     *  XML representation for this request <AR>...</AR>
68
     */
69
    string ar_xml;
70

    
71
    /**
72
     * Address request representation
73
     */
74
    string address_xml;
75
};
76

    
77
#endif