mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-22 22:03:39 +03:00
Feature #4215: Use VROUTER=YES to differentiate vr templates
This commit is contained in:
parent
8b648b3bad
commit
74f5f38276
@ -70,6 +70,16 @@ public:
|
||||
*(static_cast<VirtualMachineTemplate *>(obj_template)));
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Virtual Router
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns true if this Template is a Virtual Router Template
|
||||
* @return true if this Template is a Virtual Router Template
|
||||
*/
|
||||
bool is_vrouter();
|
||||
|
||||
private:
|
||||
// -------------------------------------------------------------------------
|
||||
// Friends
|
||||
|
@ -36,7 +36,25 @@ void VMTemplateInstantiate::request_execute(xmlrpc_c::paramList const& paramList
|
||||
str_uattrs = xmlrpc_c::value_string(paramList.getString(4));
|
||||
}
|
||||
|
||||
// TODO: if Template has VROUTER = YES, do not allow to instantiate here
|
||||
VMTemplate * tmpl = static_cast<VMTemplatePool* > (pool)->get(id,true);
|
||||
|
||||
if ( tmpl == 0 )
|
||||
{
|
||||
att.resp_id = id;
|
||||
failure_response(NO_EXISTS, att);
|
||||
return;
|
||||
}
|
||||
|
||||
bool is_vrouter = tmpl->is_vrouter();
|
||||
|
||||
tmpl->unlock();
|
||||
|
||||
if (is_vrouter)
|
||||
{
|
||||
att.resp_msg = "Templates with VROUTER=YES cannot be instantiated as stand-alone VMs";
|
||||
failure_response(ACTION, att);
|
||||
return;
|
||||
}
|
||||
|
||||
int vid;
|
||||
ErrorCode ec;
|
||||
|
@ -38,6 +38,7 @@ void VirtualRouterInstantiate::request_execute(
|
||||
VirtualRouterPool* vrpool = nd.get_vrouterpool();
|
||||
VirtualRouter * vr;
|
||||
DispatchManager* dm = nd.get_dm();
|
||||
VMTemplatePool* tpool = nd.get_tpool();
|
||||
|
||||
PoolObjectAuth vr_perms;
|
||||
Template* extra_attrs;
|
||||
@ -92,6 +93,27 @@ void VirtualRouterInstantiate::request_execute(
|
||||
return;
|
||||
}
|
||||
|
||||
VMTemplate * tmpl = tpool->get(tmpl_id,true);
|
||||
|
||||
if ( tmpl == 0 )
|
||||
{
|
||||
att.resp_id = tmpl_id;
|
||||
att.resp_obj = PoolObjectSQL::TEMPLATE;
|
||||
failure_response(NO_EXISTS, att);
|
||||
return;
|
||||
}
|
||||
|
||||
bool is_vrouter = tmpl->is_vrouter();
|
||||
|
||||
tmpl->unlock();
|
||||
|
||||
if (!is_vrouter)
|
||||
{
|
||||
att.resp_msg = "Only Templates with VROUTER=YES are allowed";
|
||||
failure_response(ACTION, att);
|
||||
return;
|
||||
}
|
||||
|
||||
if (name.empty())
|
||||
{
|
||||
name = "vr-" + vr_name + "-%i";
|
||||
|
@ -78,7 +78,13 @@ define(function(require) {
|
||||
"select_resource": Locale.tr("Please select a Template from the list"),
|
||||
"you_selected": Locale.tr("You selected the following Template:"),
|
||||
"select_resource_multiple": Locale.tr("Please select one or more Templates from the list"),
|
||||
"you_selected_multiple": Locale.tr("You selected the following Templates:")
|
||||
"you_selected_multiple": Locale.tr("You selected the following Templates:"),
|
||||
|
||||
// By default the filter is set to return all VM Templates that
|
||||
// are NOT virtual router templates
|
||||
"filter_fn": function(tmpl){
|
||||
return (tmpl.TEMPLATE.VROUTER == undefined || tmpl.TEMPLATE.VROUTER.toUpperCase() != "YES");
|
||||
}
|
||||
};
|
||||
|
||||
this.labels = [];
|
||||
|
@ -131,3 +131,12 @@
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<input type="checkbox" wizard_field="VROUTER" id="VROUTER" value="YES"/>
|
||||
<label for="VROUTER">
|
||||
{{tr "Make this template available for Virtual Router machines only"}}
|
||||
{{{tip (tr "Virtual Routers create Virtual Machines from a source Template. This checkbox makes this template available to be selected in the New Virtual Router wizard")}}}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
@ -63,7 +63,15 @@ define(function(require) {
|
||||
}
|
||||
};
|
||||
|
||||
this.templatesTable = new TemplatesTable('vr_create', {'select': true});
|
||||
this.templatesTable = new TemplatesTable(
|
||||
'vr_create',
|
||||
{ 'select': true,
|
||||
'selectOptions': {
|
||||
'filter_fn': function(tmpl){
|
||||
return (tmpl.TEMPLATE.VROUTER != undefined && tmpl.TEMPLATE.VROUTER.toUpperCase() == "YES");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
BaseFormPanel.call(this);
|
||||
}
|
||||
|
@ -248,3 +248,12 @@ int VMTemplate::from_xml(const string& xml)
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
bool VMTemplate::is_vrouter()
|
||||
{
|
||||
bool vr;
|
||||
|
||||
get_template_attribute("VROUTER", vr);
|
||||
|
||||
return vr;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user