mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-11 05:17:41 +03:00
feature #4320: CONTEXT can now be updated in poweroff related states
This commit is contained in:
parent
88a66d53f2
commit
759e645821
@ -251,7 +251,7 @@ public:
|
|||||||
*
|
*
|
||||||
* @return the value of the attribute if found, empty otherwise
|
* @return the value of the attribute if found, empty otherwise
|
||||||
*/
|
*/
|
||||||
string vector_value(const char *name) const;
|
string vector_value(const string& name) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of the given element of the VectorAttribute
|
* Returns the value of the given element of the VectorAttribute
|
||||||
@ -262,7 +262,7 @@ public:
|
|||||||
* @return 0 on success, -1 otherwise
|
* @return 0 on success, -1 otherwise
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
int vector_value(const char *name, T& value) const
|
int vector_value(const string& name, T& value) const
|
||||||
{
|
{
|
||||||
map<string,string>::const_iterator it;
|
map<string,string>::const_iterator it;
|
||||||
|
|
||||||
@ -289,9 +289,9 @@ public:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int vector_value(const char *name, string& value) const;
|
int vector_value(const string& name, string& value) const;
|
||||||
|
|
||||||
int vector_value(const char *name, bool& value) const;
|
int vector_value(const string& name, bool& value) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of the given element of the VectorAttribute
|
* Returns the value of the given element of the VectorAttribute
|
||||||
@ -303,7 +303,7 @@ public:
|
|||||||
* @return the value in string form on success, "" otherwise
|
* @return the value in string form on success, "" otherwise
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
string vector_value_str(const char *name, T& value) const
|
string vector_value_str(const string& name, T& value) const
|
||||||
{
|
{
|
||||||
map<string,string>::const_iterator it;
|
map<string,string>::const_iterator it;
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ class SqliteDB : public SqlDB
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SqliteDB(string& db_name)
|
SqliteDB(const string& db_name)
|
||||||
{
|
{
|
||||||
throw runtime_error("Aborting oned, Sqlite support not compiled!");
|
throw runtime_error("Aborting oned, Sqlite support not compiled!");
|
||||||
};
|
};
|
||||||
|
@ -997,7 +997,8 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Updates the configuration attributes based on a template, the state of
|
* Updates the configuration attributes based on a template, the state of
|
||||||
* the virtual machine is checked to assure operation consistency
|
* the virtual machine is checked to assure operation consistency
|
||||||
* @param tmpl with the new attributes include: OS, RAW, FEAUTRES, GRAPHICS
|
* @param tmpl with the new attributes include: OS, RAW, FEAUTRES,
|
||||||
|
* CONTEXT and GRAPHICS.
|
||||||
* @param err description if any
|
* @param err description if any
|
||||||
*
|
*
|
||||||
* @return 0 on success
|
* @return 0 on success
|
||||||
|
@ -362,7 +362,7 @@ EOT
|
|||||||
TEMPLATE_OPTIONS[3]]
|
TEMPLATE_OPTIONS[3]]
|
||||||
|
|
||||||
UPDATECONF_OPTIONS_VM = TEMPLATE_OPTIONS[6..15] + [TEMPLATE_OPTIONS[2],
|
UPDATECONF_OPTIONS_VM = TEMPLATE_OPTIONS[6..15] + [TEMPLATE_OPTIONS[2],
|
||||||
TEMPLATE_OPTIONS[18]]
|
TEMPLATE_OPTIONS[17], TEMPLATE_OPTIONS[18]]
|
||||||
|
|
||||||
OPTIONS = XML, NUMERIC, KILOBYTES
|
OPTIONS = XML, NUMERIC, KILOBYTES
|
||||||
|
|
||||||
|
@ -943,6 +943,10 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|||||||
|
|
||||||
onevm updateconf myvm --arch x86_64 --vnc
|
onevm updateconf myvm --arch x86_64 --vnc
|
||||||
|
|
||||||
|
- Change the DNS for ETH0 device and add PASSWORD:
|
||||||
|
|
||||||
|
onevm updateconf myvm --context "ETH0_DNS=\\"8.8.8.8\\", PASSWORD=\\"1234\\""
|
||||||
|
|
||||||
This command also accepts a template, the full list of configuration
|
This command also accepts a template, the full list of configuration
|
||||||
attributes are (not all supported via options):
|
attributes are (not all supported via options):
|
||||||
OS = ["ARCH", "MACHINE", "KERNEL", "INITRD", "BOOTLOADER", "BOOT"]
|
OS = ["ARCH", "MACHINE", "KERNEL", "INITRD", "BOOTLOADER", "BOOT"]
|
||||||
@ -950,9 +954,11 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|||||||
INPUT = ["TYPE", "BUS"]
|
INPUT = ["TYPE", "BUS"]
|
||||||
GRAPHICS = ["TYPE", "LISTEN", "PASSWD", "KEYMAP" ]
|
GRAPHICS = ["TYPE", "LISTEN", "PASSWD", "KEYMAP" ]
|
||||||
RAW = ["DATA", "DATA_VMX", "TYPE"]
|
RAW = ["DATA", "DATA_VMX", "TYPE"]
|
||||||
|
CONTEXT (any value, **no variable substitution will be made**)
|
||||||
|
|
||||||
*NOTE* Update will replace or add attributes, to remove an existing one
|
*NOTE* Update will replace or add attributes, to remove an existing one
|
||||||
add an empty value.
|
add an empty value.
|
||||||
|
|
||||||
EOT
|
EOT
|
||||||
|
|
||||||
command :updateconf, updateconf_desc, :vmid, [:file, nil], :options =>
|
command :updateconf, updateconf_desc, :vmid, [:file, nil], :options =>
|
||||||
|
@ -237,7 +237,7 @@ void VectorAttribute::remove(const string& name)
|
|||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
string VectorAttribute::vector_value(const char *name) const
|
string VectorAttribute::vector_value(const string& name) const
|
||||||
{
|
{
|
||||||
map<string,string>::const_iterator it;
|
map<string,string>::const_iterator it;
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ string VectorAttribute::vector_value(const char *name) const
|
|||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int VectorAttribute::vector_value(const char *name, string& value) const
|
int VectorAttribute::vector_value(const string& name, string& value) const
|
||||||
{
|
{
|
||||||
map<string,string>::const_iterator it;
|
map<string,string>::const_iterator it;
|
||||||
|
|
||||||
@ -275,7 +275,7 @@ int VectorAttribute::vector_value(const char *name, string& value) const
|
|||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int VectorAttribute::vector_value(const char *name, bool& value) const
|
int VectorAttribute::vector_value(const string& name, bool& value) const
|
||||||
{
|
{
|
||||||
map<string,string>::const_iterator it;
|
map<string,string>::const_iterator it;
|
||||||
|
|
||||||
|
@ -4820,20 +4820,39 @@ static void replace_vector_values(Template *old_tmpl, Template *new_tmpl,
|
|||||||
old_tmpl->set(old_attr);
|
old_tmpl->set(old_attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i < num; i++)
|
if ( num > 0 && vnames != 0 )
|
||||||
{
|
{
|
||||||
if ( new_attr->vector_value(vnames[i].c_str(), value) == -1 )
|
for (int i=0; i < num; i++)
|
||||||
{
|
{
|
||||||
continue;
|
if ( new_attr->vector_value(vnames[i], value) == -1 )
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (value.empty())
|
||||||
|
{
|
||||||
|
old_attr->remove(vnames[i]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
old_attr->replace(vnames[i], value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else //replace all
|
||||||
|
{
|
||||||
|
const map<string, string> contents = new_attr->value();
|
||||||
|
map<string, string>::const_iterator it;
|
||||||
|
|
||||||
if (value.empty())
|
for ( it = contents.begin() ; it != contents.end() ; ++it )
|
||||||
{
|
{
|
||||||
old_attr->remove(vnames[i].c_str());
|
if ( it->second.empty() )
|
||||||
}
|
{
|
||||||
else
|
old_attr->remove(it->first);
|
||||||
{
|
}
|
||||||
old_attr->replace(vnames[i].c_str(), value);
|
else
|
||||||
|
{
|
||||||
|
old_attr->replace(it->first, it->second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -4936,5 +4955,10 @@ int VirtualMachine::updateconf(VirtualMachineTemplate& tmpl, string &err)
|
|||||||
|
|
||||||
replace_vector_values(obj_template, &tmpl, "RAW", raw_names, 3);
|
replace_vector_values(obj_template, &tmpl, "RAW", raw_names, 3);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
// Update CONTEXT: any value
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
replace_vector_values(obj_template, &tmpl, "CONTEXT", 0, -1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user