Revision c9d0df87 src/host/HostHook.cc

View differences:

src/host/HostHook.cc
20 20

  
21 21
// -----------------------------------------------------------------------------
22 22
// -----------------------------------------------------------------------------
23
static void parse_host_arguments(Host *host, string& parsed)
24
{
25
    size_t  found;
26

  
27
    found = parsed.find("$HID");
28

  
29
    if ( found !=string::npos )
30
    {
31
        ostringstream oss;
32
        oss << host->get_oid();
33

  
34
        parsed.replace(found,4,oss.str());
35
    }
36

  
37
    found = parsed.find("$TEMPLATE");
38

  
39
    if ( found != string::npos )
40
    {
41
        string templ;
42
        parsed.replace(found,9,host->to_xml64(templ));
43
    }
44
}
45
// -----------------------------------------------------------------------------
46
// -----------------------------------------------------------------------------
23 47

  
24 48
void HostAllocateHook::do_hook(void *arg)
25 49
{
26 50
    Host *  host;
27 51

  
28 52
    string  parsed_args = args;
29
    size_t  found;
30 53

  
31 54
    host = static_cast<Host *>(arg);
32 55

  
......
34 57
    {
35 58
        return;
36 59
    }
37

  
38
    found = args.find("$HID");
39

  
40
    if ( found !=string::npos )
41
    {
42
        ostringstream oss;
43
        oss << host->get_oid();
44

  
45
        parsed_args.replace(found,4,oss.str());
46
    }
60
    
61
    parse_host_arguments(host,parsed_args);
47 62

  
48 63
    Nebula& ne                    = Nebula::instance();
49 64
    HookManager * hm              = ne.get_hm();
......
156 171
    if ( cur_state == this->state )
157 172
    {
158 173
        string  parsed_args = args;
159
        size_t  found;
160

  
161
        found = args.find("$HID");
162 174

  
163
        if ( found !=string::npos )
164
        {
165
            ostringstream oss;
166
            oss << host->get_oid();
167

  
168
            parsed_args.replace(found,4,oss.str());
169
        }
175
        parse_host_arguments(host,parsed_args);
170 176

  
171 177
        Nebula& ne        = Nebula::instance();
172 178
        HookManager * hm  = ne.get_hm();

Also available in: Unified diff