Revision 20deae85

View differences:

include/Image.h
191 191
        return (persistent_img == 1);
192 192
    };
193 193

  
194
    bool is_managed() const
195
    {
196
        bool one_managed;
197

  
198
        if (get_template_attribute("OPENNEBULA_MANAGED", one_managed) == false)
199
        {
200
            one_managed = true;
201
        }
202

  
203
        return one_managed;
204
    }
205

  
194 206
    /**
195 207
     *  Check the PERSISTENT attribute in an image Template, if not set the
196 208
     *  DEFAULT_IMAGE_PERSISTENT and DEFAULT_IMAGE_PERSISTENT_NEW are check in
include/VirtualMachineDisk.h
52 52
        return is_flag("PERSISTENT");
53 53
    }
54 54

  
55
    bool is_managed() const
56
    {
57
        bool one_managed;
58

  
59
        if (vector_value("OPENNEBULA_MANAGED", one_managed) == -1)
60
        {
61
            one_managed = true;
62
        }
63

  
64
        return one_managed;
65
    }
66

  
55 67
    void set_attach()
56 68
    {
57 69
        set_flag("ATTACH");
src/rm/RequestManagerClone.cc
198 198
                goto error_images;
199 199
            }
200 200

  
201
            ec = img_persistent.request_execute(new_img_id, true, img_att);
202

  
203
            if (ec != SUCCESS)
201
            if ( (*disk)->is_managed() )
204 202
            {
205
                NebulaLog::log("ReM", Log::ERROR, failure_message(ec, img_att));
203
                ec = img_persistent.request_execute(new_img_id, true, img_att);
206 204

  
207
                img_delete.request_execute(img_id, img_att);
205
                if (ec != SUCCESS)
206
                {
207
                    NebulaLog::log("ReM",Log::ERROR,failure_message(ec,img_att));
208 208

  
209
                att.resp_msg = "Failed to clone images: " + img_att.resp_msg;
209
                    img_delete.request_execute(img_id, img_att);
210 210

  
211
                goto error_images;
211
                    att.resp_msg = "Failed to clone images: " + img_att.resp_msg;
212

  
213
                    goto error_images;
214
                }
212 215
            }
213 216

  
214 217
            (*disk)->remove("IMAGE");
src/rm/RequestManagerImage.cc
118 118

  
119 119
    ds_id = image->get_ds_id();
120 120

  
121
    if ( !image->is_managed() )
122
    {
123
        att.resp_msg = "Cannot change persistent state for non-managed images";
124

  
125
        image->unlock();
126

  
127
        return ACTION;
128
    }
129

  
121 130
    image->unlock();
122 131

  
123 132
    ds = dspool->get(ds_id, true);

Also available in: Unified diff