mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-23 17:33:56 +03:00
Feature #4215: Add keepalived_id/password
This commit is contained in:
parent
546301463c
commit
c41d43f09a
@ -1988,6 +1988,13 @@ private:
|
||||
*/
|
||||
int parse_vrouter(string& error_str);
|
||||
|
||||
/**
|
||||
* Known Virtual Router attributes, to be moved from the user template
|
||||
* to the template
|
||||
*/
|
||||
static const char* VROUTER_ATTRIBUTES[];
|
||||
static const int NUM_VROUTER_ATTRIBUTES;
|
||||
|
||||
/**
|
||||
* Known attributes for network contextualization rendered as:
|
||||
* ETH_<nicid>_<context[0]> = $NETWORK[context[1], vnet_name]
|
||||
|
@ -20,7 +20,7 @@
|
||||
<div class="row">
|
||||
<div class="medium-6 columns">
|
||||
<label for="name" >
|
||||
{{tr "Name"}}:
|
||||
{{tr "Name"}}
|
||||
</label>
|
||||
<input type="text" wizard_field="NAME" required name="name" id="name"/>
|
||||
</div>
|
||||
@ -34,6 +34,22 @@
|
||||
<textarea type="text" wizard_field="DESCRIPTION" id="DESCRIPTION" name="DESCRIPTION"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="medium-6 columns">
|
||||
<label for="keepalived_id" >
|
||||
{{tr "Keepalived ID"}}
|
||||
<span class="tip">{{tr "Optional. Sets keepalived configuration parameter 'virtual_router_id'"}}</span>
|
||||
</label>
|
||||
<input type="text" wizard_field="KEEPALIVED_ID" name="keepalived_id" id="keepalived_id"/>
|
||||
</div>
|
||||
<div class="medium-6 columns">
|
||||
<label for="keepalived_password" >
|
||||
{{tr "Keepalived password"}}
|
||||
<span class="tip">{{tr "Optional. Sets keepalived configuration parameter 'authentication/auth_pass'"}}</span>
|
||||
</label>
|
||||
<input type="text" wizard_field="KEEPALIVED_PASSWORD" name="keepalived_password" id="keepalived_password"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="large-12 columns nicsContext">
|
||||
|
@ -157,6 +157,12 @@ const char* VirtualMachine::NETWORK6_CONTEXT[][2] = {
|
||||
|
||||
const int VirtualMachine::NUM_NETWORK6_CONTEXT = 4;
|
||||
|
||||
const char* VirtualMachine::VROUTER_ATTRIBUTES[] = {
|
||||
"VROUTER_ID",
|
||||
"VROUTER_KEEPALIVED_ID",
|
||||
"VROUTER_KEEPALIVED_PASSWORD"};
|
||||
const int VirtualMachine::NUM_VROUTER_ATTRIBUTES = 3;
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
@ -845,14 +851,17 @@ int VirtualMachine::parse_vrouter(string& error_str)
|
||||
{
|
||||
string st;
|
||||
|
||||
user_obj_template->get("VROUTER_ID", st);
|
||||
|
||||
if (!st.empty())
|
||||
for (int i = 0; i < NUM_VROUTER_ATTRIBUTES; i++)
|
||||
{
|
||||
obj_template->replace("VROUTER_ID", st);
|
||||
}
|
||||
user_obj_template->get(VROUTER_ATTRIBUTES[i], st);
|
||||
|
||||
user_obj_template->erase("VROUTER_ID");
|
||||
if (!st.empty())
|
||||
{
|
||||
obj_template->replace(VROUTER_ATTRIBUTES[i], st);
|
||||
}
|
||||
|
||||
user_obj_template->erase(VROUTER_ATTRIBUTES[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -907,6 +916,7 @@ int VirtualMachine::parse_context(string& error_str)
|
||||
string parsed;
|
||||
string files_ds;
|
||||
string files_ds_parsed;
|
||||
string st;
|
||||
|
||||
ostringstream oss_parsed;
|
||||
|
||||
@ -1098,6 +1108,20 @@ int VirtualMachine::parse_context(string& error_str)
|
||||
add_template_attribute("CREATED_BY", uid);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Virtual Router attributes
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
for (int i = 0; i < NUM_VROUTER_ATTRIBUTES; i++)
|
||||
{
|
||||
obj_template->get(VROUTER_ATTRIBUTES[i], st);
|
||||
|
||||
if (!st.empty())
|
||||
{
|
||||
context_parsed->replace(VROUTER_ATTRIBUTES[i], st);
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
||||
error_cleanup:
|
||||
|
@ -453,6 +453,8 @@ Template * VirtualRouter::get_vm_template() const
|
||||
bool floating;
|
||||
vector<Attribute * > nics;
|
||||
VectorAttribute * nic;
|
||||
int keepalived_id;
|
||||
string st;
|
||||
|
||||
num_nics = obj_template->get("NIC",nics);
|
||||
|
||||
@ -487,6 +489,20 @@ Template * VirtualRouter::get_vm_template() const
|
||||
|
||||
tmpl->replace("VROUTER_ID", oid);
|
||||
|
||||
if (!obj_template->get("KEEPALIVED_ID", keepalived_id))
|
||||
{
|
||||
keepalived_id = (oid & 0xFF);
|
||||
}
|
||||
|
||||
tmpl->replace("VROUTER_KEEPALIVED_ID", keepalived_id);
|
||||
|
||||
obj_template->get("KEEPALIVED_PASSWORD", st);
|
||||
|
||||
if (!st.empty())
|
||||
{
|
||||
tmpl->replace("VROUTER_KEEPALIVED_PASSWORD", st);
|
||||
}
|
||||
|
||||
return tmpl;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user