Revision d0973401

View differences:

include/VMTemplate.h
102 102
        obj_template->set(disks);
103 103
    }
104 104

  
105
    /**
106
    *  This method check if sched_action is malformed or not
107
	*
108
    *    @return false if the attribute is malformed
109
    */
110
    bool parse_sched_action()
111
    {
112
        bool malformed = false;
113
        string action = "";
114
        VectorAttribute *attr = nullptr;
115
        vector<const VectorAttribute *> _sched_actions;
116
        obj_template->get("SCHED_ACTION",_sched_actions);
117

  
118
        for (vector<const VectorAttribute *>::const_iterator i = _sched_actions.begin();
119
				i != _sched_actions.end() && !malformed ; ++i)
120
		{
121
		    attr = new VectorAttribute(*i);
122
            if ( attr->vector_value("DONE") != "" || attr->vector_value("MESSAGE") != "" )
123
            {
124
                malformed = true;
125
            }
126
		}
127
        return !malformed;
128
    }
129

  
105 130
    // ------------------------------------------------------------------------
106 131
    // Virtual Router
107 132
    // ------------------------------------------------------------------------
......
142 167
    int insert_replace(SqlDB *db, bool replace, string& error_str);
143 168

  
144 169
    /**
170
     *  Execute this method after update the template.
171
     *    @param error Returns the error reason, if any
172
     *    @return 0 one success
173
     */
174
    int post_update_template(string& error);
175

  
176
    /**
145 177
     *  Bootstraps the database table(s) associated to the VMTemplate
146 178
     *    @return 0 on success
147 179
     */
src/vm_template/VMTemplate.cc
167 167
    return -1;
168 168
}
169 169

  
170
/* ------------------------------------------------------------------------ */
171
/* ------------------------------------------------------------------------ */
172

  
173
int VMTemplate::post_update_template(string& error)
174
{
175
    if ( !parse_sched_action() )
176
    {
177
       error = "Error parsing sched_action, malformed.";
178
       return -1;
179
    }
180
    return 0;
181
}
182

  
170 183
/* ************************************************************************ */
171 184
/* VMTemplate :: Misc                                                       */
172 185
/* ************************************************************************ */

Also available in: Unified diff