mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-16 09:43:18 +09:00
Merge branch 'master' of git.opennebula.org:one
This commit is contained in:
commit
4f00cbac3d
7 files changed
+31
-23
No files matched your search
@@ -37,6 +37,7 @@ public:
|
||||
HostPool * _hpool,
|
||||
time_t _timer_period,
|
||||
time_t _poll_period,
|
||||
bool _do_vm_poll,
|
||||
int _vm_limit,
|
||||
vector<const Attribute*>& _mads);
|
||||
|
||||
@@ -131,6 +132,11 @@ private:
|
||||
*/
|
||||
time_t poll_period;
|
||||
|
||||
/**
|
||||
* Perform pro-active VM monitoring
|
||||
*/
|
||||
bool do_vm_poll;
|
||||
|
||||
/**
|
||||
* Virtual Machine polling limit
|
||||
*/
|
||||
|
||||
@@ -165,7 +165,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
OpenNebulaHelper.rname_to_id(arg, "USER")
|
||||
end
|
||||
|
||||
set :format, :template_id, Service.rname_to_id_desc("SERVICE TEMPLATE") do |arg|
|
||||
set :format, :templateid, Service.rname_to_id_desc("SERVICE TEMPLATE") do |arg|
|
||||
Service.rname_to_id(arg, "SERVICE TEMPLATE")
|
||||
end
|
||||
|
||||
@@ -266,7 +266,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
Show detailed information of a given Service Template
|
||||
EOT
|
||||
|
||||
command :show, show_desc, :template_id, :options => Service::JSON_FORMAT do
|
||||
command :show, show_desc, :templateid, :options => Service::JSON_FORMAT do
|
||||
client = Service::Client.new(
|
||||
:username => options[:username],
|
||||
:password => options[:password],
|
||||
@@ -304,7 +304,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
Instantiate a Service Template
|
||||
EOT
|
||||
|
||||
command :instantiate, instantiate_desc, :template_id, [:file, nil],
|
||||
command :instantiate, instantiate_desc, :templateid, [:file, nil],
|
||||
:options => [Service::JSON_FORMAT, Service::TOP] do
|
||||
client = Service::Client.new(
|
||||
:username => options[:username],
|
||||
|
||||
@@ -238,6 +238,14 @@ module OpenNebula
|
||||
|
||||
@body['last_vmname'] ||= 0
|
||||
|
||||
extra_template = @body['vm_template_contents']
|
||||
|
||||
extra_template = "" if extra_template.nil?
|
||||
|
||||
extra_template <<
|
||||
"\nSERVICE_ID = #{@service.id()}" <<
|
||||
"\nROLE_NAME = \"#{@body['name']}\""
|
||||
|
||||
n_nodes.times { |i|
|
||||
vm_name = @@vm_name_template.
|
||||
gsub("$SERVICE_ID", @service.id().to_s).
|
||||
@@ -254,9 +262,6 @@ module OpenNebula
|
||||
|
||||
template = OpenNebula::Template.new_with_id(template_id, @service.client)
|
||||
|
||||
extra_template = "SERVICE_ID = #{@service.id()}\n"\
|
||||
"ROLE_NAME = \"#{@body['name']}\""
|
||||
|
||||
vm_id = template.instantiate(vm_name, false, extra_template)
|
||||
|
||||
if OpenNebula.is_error?(vm_id)
|
||||
|
||||
@@ -35,6 +35,10 @@ module OpenNebula
|
||||
:type => :integer,
|
||||
:required => true
|
||||
},
|
||||
'vm_template_contents' => {
|
||||
:type => :string,
|
||||
:required => false
|
||||
},
|
||||
'parents' => {
|
||||
:type => :array,
|
||||
:items => {
|
||||
@@ -171,7 +175,7 @@ module OpenNebula
|
||||
def allocate(template_json)
|
||||
template = JSON.parse(template_json)
|
||||
|
||||
validate(template)
|
||||
ServiceTemplate.validate(template)
|
||||
|
||||
super(template.to_json, template['name'])
|
||||
end
|
||||
@@ -186,7 +190,7 @@ module OpenNebula
|
||||
def update(template_json)
|
||||
template = JSON.parse(template_json)
|
||||
|
||||
validator(template)
|
||||
ServiceTemplate.validate(template)
|
||||
|
||||
super(template.to_json)
|
||||
end
|
||||
|
||||
@@ -408,6 +408,7 @@ post '/service_template/:id/action' do
|
||||
action = JSON.parse(request.body.read)['action']
|
||||
|
||||
opts = action['params']
|
||||
opts = {} if opts.nil?
|
||||
|
||||
rc = case action['perform']
|
||||
when 'instantiate'
|
||||
|
||||
@@ -563,16 +563,14 @@ void Nebula::start(bool bootstrap_only)
|
||||
|
||||
nebula_configuration->get("VM_INDIVIDUAL_MONITORING", do_poll);
|
||||
|
||||
if (do_poll)
|
||||
{
|
||||
poll_period = monitor_period * 2.5;
|
||||
}
|
||||
poll_period = monitor_period * 2.5;
|
||||
|
||||
vmm = new VirtualMachineManager(
|
||||
vmpool,
|
||||
hpool,
|
||||
timer_period,
|
||||
poll_period,
|
||||
do_poll,
|
||||
vm_limit,
|
||||
vmm_mads);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ VirtualMachineManager::VirtualMachineManager(
|
||||
HostPool * _hpool,
|
||||
time_t _timer_period,
|
||||
time_t _poll_period,
|
||||
bool _do_vm_poll,
|
||||
int _vm_limit,
|
||||
vector<const Attribute*>& _mads):
|
||||
MadManager(_mads),
|
||||
@@ -41,6 +42,7 @@ VirtualMachineManager::VirtualMachineManager(
|
||||
hpool(_hpool),
|
||||
timer_period(_timer_period),
|
||||
poll_period(_poll_period),
|
||||
do_vm_poll(_do_vm_poll),
|
||||
vm_limit(_vm_limit)
|
||||
{
|
||||
am.addListener(this);
|
||||
@@ -63,15 +65,7 @@ extern "C" void * vmm_action_loop(void *arg)
|
||||
|
||||
NebulaLog::log("VMM",Log::INFO,"Virtual Machine Manager started.");
|
||||
|
||||
if ( vmm->poll_period == 0 )
|
||||
{
|
||||
vmm->am.loop(0,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
NebulaLog::log("VMM",Log::INFO,"VM monitoring is enabled.");
|
||||
vmm->am.loop(vmm->timer_period,0);
|
||||
}
|
||||
vmm->am.loop(vmm->timer_period, 0);
|
||||
|
||||
NebulaLog::log("VMM",Log::INFO,"Virtual Machine Manager stopped.");
|
||||
|
||||
@@ -1507,8 +1501,8 @@ void VirtualMachineManager::timer_action()
|
||||
vmpool->clean_expired_monitoring();
|
||||
|
||||
// Skip monitoring the first poll_period to allow the Host monitoring to
|
||||
// gather the VM info
|
||||
if ( timer_start + poll_period > thetime )
|
||||
// gather the VM info (or if it is disabled)
|
||||
if ( timer_start + poll_period > thetime || !do_vm_poll)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user