1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-23 17:33:56 +03:00

B #5103: Improve state transition flag system (#884)

This commit is contained in:
Daniel Clavijo Coca 2021-02-26 08:35:31 -06:00 committed by GitHub
parent cff5f1807e
commit 6930839e87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 19 deletions

View File

@ -129,8 +129,7 @@ class Container
# Create a container without a base image
def create(wait: true, timeout: '')
@lxc['source'] = { 'type' => 'none' }
transition_start # not ready to report status yet
@lxc['config']['user.one_status'] = '0' # not ready to report status yet
wait?(@client.post(CONTAINERS, @lxc), wait, timeout)
@ -253,16 +252,10 @@ class Container
# Extended reboot required for OpenNebula execution flow
def reboot(force)
if transient?
start
transition_end # container reached the final state of rebooting
update
else
transition_start # container will be started later
update
if check_status == 'Running'
check_stop(force)
else
start
end
end
@ -476,14 +469,16 @@ class Container
end
# Flags a container indicating current status not definitive
# Stalls monitoring status query. Requires updating the container
def transition_start
# Stalls monitoring status query.
def avoid_monitoring
@lxc['config']['user.one_status'] = '0'
update
end
# Removes transient state flag. Requires updating the container.
def transition_end
# Removes transient state flag.
def allow_monitoring
@lxc['config'].delete('user.one_status')
update
end
# Helper method for querying transition phase
@ -534,6 +529,8 @@ class Container
def change_state(action, options)
options.update(:action => action)
avoid_monitoring
response = @client.put("#{CONTAINERS}/#{name}/state", options)
status = wait?(response, options[:wait], options[:timeout])

View File

@ -84,9 +84,6 @@ end
# Updates container configuration with the OpenNebulaVM description
# ------------------------------------------------------------------------------
container.save_xml(xml)
container.transition_end unless container.wild?
container.update
container.vnc('start')
puts container.name
container.allow_monitoring

View File

@ -49,3 +49,4 @@ force = false
force = true if ARGV[-1] == '-f'
container.reboot(force)
container.allow_monitoring