1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-02-05 21:57:24 +03:00

Merge branch 'master' into f-3951

This commit is contained in:
Tino Vazquez 2021-01-22 12:31:54 +01:00
commit 22bbbbc6a9
No known key found for this signature in database
GPG Key ID: 14201E424D02047E
14 changed files with 95 additions and 87 deletions

View File

@ -352,12 +352,14 @@ VAR_DIRS="$VAR_LOCATION/remotes \
$VAR_LOCATION/remotes/im/lxd-probes.d/host/system \
$VAR_LOCATION/remotes/im/lxd-probes.d/vm/monitor \
$VAR_LOCATION/remotes/im/lxd-probes.d/vm/status \
$VAR_LOCATION/remotes/im/lxd-probes.d/vm/snapshot \
$VAR_LOCATION/remotes/im/firecracker.d \
$VAR_LOCATION/remotes/im/firecracker-probes.d/host/beacon \
$VAR_LOCATION/remotes/im/firecracker-probes.d/host/monitor \
$VAR_LOCATION/remotes/im/firecracker-probes.d/host/system \
$VAR_LOCATION/remotes/im/firecracker-probes.d/vm/monitor \
$VAR_LOCATION/remotes/im/firecracker-probes.d/vm/status \
$VAR_LOCATION/remotes/im/firecracker-probes.d/vm/snapshot \
$VAR_LOCATION/remotes/im/vcenter.d \
$VAR_LOCATION/remotes/im/ec2.d \
$VAR_LOCATION/remotes/im/ec2-probes.d/host/beacon \
@ -2382,7 +2384,7 @@ ONEPROVISION_CONF_FILES="src/cli/etc/oneprovision.yaml \
ONEPROVISION_ANSIBLE_FILES="share/oneprovision/ansible"
ONEPROVISION_TEMPLATES_FILES="share/oneprovision/provisions"
ONEPROVISION_TEMPLATES_FILES="share/oneprovision/provisions/"
ONEPROVISION_LIB_FILES="src/oneprovision/lib/oneprovision.rb \
src/oneprovision/lib/provision_element.rb"

View File

@ -450,9 +450,8 @@ class OneProvisionHelper < OpenNebulaHelper::OneHelper
#
# @param host [OpenNebula::Host]
# @param operation [String] Operation to perform
# @param options [Hash] User CLI options
# @param args [Array] Operation arguments
def host_operation(host, operation, options, args)
def host_operation(host, operation, args)
p_id = host['TEMPLATE/PROVISION/ID']
return OpenNebula::Error.new('No provision ID found') unless p_id
@ -471,7 +470,7 @@ class OneProvisionHelper < OpenNebulaHelper::OneHelper
when 'delete'
provision.update_objects('hosts', :remove, host.one['ID'])
when 'configure'
host.configure((options.key? :force))
host.configure
when 'ssh'
host.ssh(args)
end
@ -503,7 +502,7 @@ class OneProvisionHelper < OpenNebulaHelper::OneHelper
case type
when 'HOSTS'
host_operation(obj, operation, options, args[1])
host_operation(obj, operation, args[1])
else
msg = "Deleting #{type} #{obj['ID']}"

View File

@ -42,6 +42,9 @@ require 'one_helper/onemarketapp_helper'
require 'one_helper/onemarket_helper'
require 'one_helper/onedatastore_helper'
require 'vcenter_driver'
CONFIG = VCenterConf.new
CommandParser::CmdParser.new(ARGV) do
usage '`onemarket` <command> [<args>] [<options>]'
version OpenNebulaHelper::ONE_VERSION
@ -101,6 +104,13 @@ CommandParser::CmdParser.new(ARGV) do
end
}
TEMPLATE = {
:name => 'template',
:large => '--template template_id ',
:description => 'Associate with VM template',
:format => Integer,
}
MARKET = {
:name => 'market',
:large => '--market market_id',
@ -123,7 +133,8 @@ CommandParser::CmdParser.new(ARGV) do
OneDatastoreHelper::FILE_DATASTORE,
OneMarketPlaceAppHelper::VMNAME,
TAG,
NO]
NO,
TEMPLATE]
IMPORT_OPTIONS = [YES, NO, MARKET, OneMarketPlaceAppHelper::VMNAME]
########################################################################
@ -272,7 +283,9 @@ CommandParser::CmdParser.new(ARGV) do
:name => args[1],
:vmtemplate_name => options[:vmname],
:url_args => tag,
:notemplate => options[:no] == 'no'
:notemplate => options[:no] == 'no',
:template => options[:template],
:default_template => CONFIG[:default_template],
)
if OpenNebula.is_error?(rc)

View File

@ -123,6 +123,9 @@ CommandParser::CmdParser.new(ARGV) do
if OpenNebula.is_error?(rc)
STDERR.puts rc.message
exit(-1)
elsif rc < 0
puts "ID: #{rc}"
rc
else
puts "ID: #{rc}"
0
@ -261,8 +264,7 @@ CommandParser::CmdParser.new(ARGV) do
command [:host, :configure],
host_configure_desc,
[:range, :hostid_list],
:options => [OneProvisionHelper::MODES,
OneProvisionHelper::FORCE] do
:options => [OneProvisionHelper::MODES] do
operation = { :operation => 'configure', :message => 'enabled' }
rc = helper.resources_operation(args, operation, options, 'HOSTS')

View File

@ -2,8 +2,7 @@
"env": {
"browser": true,
"es2021": true,
"node": true,
"cypress/globals": true
"node": true
},
"extends": [
"plugin:react/recommended",
@ -16,12 +15,8 @@
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["react", "cypress"],
"plugins": ["react"],
"rules": {
"cypress/no-assigning-return-values": "error",
"cypress/no-unnecessary-waiting": "error",
"cypress/assertion-before-screenshot": "warn",
"cypress/no-async-tests": "error",
"import/no-extraneous-dependencies": [
"error",
{

View File

@ -1,17 +0,0 @@
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}

View File

@ -1,20 +0,0 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands'
// Alternatively you can use CommonJS syntax:
// require('./commands')

View File

@ -27,7 +27,6 @@
"opennebula"
],
"devDependencies": {
"cypress": "^6.2.1",
"eslint": "^7.11.0",
"eslint-config-prettier": "^6.11.0",
"eslint-config-standard": "^14.1.1",

View File

@ -772,7 +772,7 @@ class ServiceLCM
next unless role.nodes.find {|n| n['deploy_id'] == node }
# just update if the cardinality is positive
set_cardinality(role, cardinality, false) if cardinality >= 0
set_cardinality(role, cardinality, true) if cardinality >= 0
role.nodes.delete_if {|n| n['deploy_id'] == node }

View File

@ -89,12 +89,14 @@ module OpenNebula::MarketPlaceAppExt
private
# Exports an OpenNebula Image from this marketplace app
# @param optoins to export the image
# @param options to export the image
# :vmtemplate_name [String] name of new image and template
# :url_args [String] optional URL arguments
# :dsid [String] Datastore id to create the image
# :f_dsid [String] Files Datastore id
# :notemplate [Bool] if true do not create vm_template (if any)
# :template [Integer] Template id to use with image
# :default_template [String] Default template id for vCenter
# @return [Hash]
# :image [Array] of the new image
# :image_type [String] of the new image (CONTEXT, KERNEL, CDROM)
@ -181,19 +183,41 @@ module OpenNebula::MarketPlaceAppExt
return rc_info
end
tmpl = Base64.decode64(self['TEMPLATE/VMTEMPLATE64'])
tmpl << <<-EOT
if !options[:template].nil?
template_id = options[:template]
NAME = "#{options[:vmtemplate_name] || options[:name]}"
DISK = [ IMAGE_ID = "#{image.id}" ]
EOT
template_id = options[:default_template] if template_id == -1
vmtpl = Template.new(Template.build_xml, @client)
template = Template.new_with_id(template_id, @client)
rc = vmtpl.allocate(tmpl)
rc = vmtpl.id unless OpenNebula.is_error?(rc)
vmtpl_id = template.clone(options[:vmtemplate_name] || options[:name])
rc_info[:vmtemplate] = [rc]
tmpl << <<-EOT
NAME = "#{options[:vmtemplate_name] || options[:name]}"
DISK = [ IMAGE_ID = "#{image.id}" ]
EOT
template = Template.new_with_id(vmtpl_id, @client)
template.update(tmpl, true)
rc_info[:vmtemplate] = [vmtpl_id]
else
tmpl = Base64.decode64(self['TEMPLATE/VMTEMPLATE64'])
tmpl << <<-EOT
NAME = "#{options[:vmtemplate_name] || options[:name]}"
DISK = [ IMAGE_ID = "#{image.id}" ]
EOT
vmtpl = Template.new(Template.build_xml, @client)
rc = vmtpl.allocate(tmpl)
rc = vmtpl.id unless OpenNebula.is_error?(rc)
rc_info[:vmtemplate] = [rc]
end
rc_info
end
@ -218,7 +242,7 @@ module OpenNebula::MarketPlaceAppExt
unless OpenNebula.is_error?(vmtmpl[0])
rc[:image] += vmtmpl[1]
rc[:vmtemplate] += vmtmpl[2]
rc[:vmtemplate] += vmtmpl[2] unless options[:notemplate]
end
rc

View File

@ -83,7 +83,7 @@ module OneProvision
# @param hosts [OpenNebula::Datastore array] Datastores for vars
# @param provision [OpenNebula::Provision] Provision info
# @param ping [Boolean] True to check ping to hosts
def configure(hosts, datastores, provision = nil, ping = true)
def configure(hosts, datastores = nil, provision = nil, ping = true)
return if hosts.nil? || hosts.empty?
Driver.retry_loop('Failed to configure hosts', provision) do

View File

@ -317,7 +317,7 @@ module OneProvision
end
if skip == :none
configure
configure_resources
else
info_objects('hosts', true) {|h| h.enable }
end
@ -351,19 +351,7 @@ module OneProvision
return OpenNebula::Error.new('Provision already configured')
end
self.state = STATE['CONFIGURING']
update
rc = Ansible.configure(hosts, datastores, self)
if rc == 0
self.state = STATE['RUNNING']
else
self.state = STATE['ERROR']
end
update
configure_resources
end
# Deletes provision objects
@ -371,6 +359,8 @@ module OneProvision
# @param cleanup [Boolean] True to delete running VMs and images
# @param timeout [Integer] Timeout for deleting running VMs
def delete(cleanup, timeout)
exist = true
if running_vms? && !cleanup
Utils.fail('Provision with running VMs can\'t be deleted')
end
@ -416,9 +406,13 @@ module OneProvision
rc = super()
exist = false
return rc if OpenNebula.is_error?(rc)
0
ensure
unlock if exist
end
# Updates provision objects
@ -691,6 +685,23 @@ module OneProvision
end
end
# Configures provision resources
def configure_resources
self.state = STATE['CONFIGURING']
update
rc = Ansible.configure(hosts, datastores, self)
if rc == 0
self.state = STATE['RUNNING']
else
self.state = STATE['ERROR']
end
update
end
# Updates provision hosts with new name
#
# @param ips [Array] IPs for each host

View File

@ -204,11 +204,8 @@ module OneProvision
end
# Configures the HOST
#
# @param force [Boolean] Force the configuration if the HOST
# is already configured
def configure(force)
Ansible.configure([{ 'id' => @one['ID'] }], force)
def configure
Ansible.configure([{ 'id' => @one['ID'] }])
end
# Checks that the HOST is a baremetal HOST

View File

@ -35,4 +35,7 @@
:memory_dumps: true
# Cache expiration for monitoring
:cache_expire: 120
:cache_expire: 120
# Default template when import from MarketPlace
:default_template: -1