From 351013efb38e96b4a4980fdaea005cd0c1204c4d Mon Sep 17 00:00:00 2001 From: Mik Date: Thu, 26 Aug 2021 14:22:53 +0200 Subject: [PATCH 01/39] load db data from env if ALPINE --- core/*.rb | 8 ++++++-- core/connect_db_env.rb | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 core/connect_db_env.rb diff --git a/core/*.rb b/core/*.rb index f2ca44cc..7325df73 100644 --- a/core/*.rb +++ b/core/*.rb @@ -1,3 +1,7 @@ -require 'core/load_oned_conf.rb' -require 'core/connect_db.rb' +if ENV["ALPINE"] == 'true' then + require 'core/connect_db_env.rb' +else + require 'core/load_oned_conf.rb' + require 'core/connect_db.rb' +end require 'core/settings.rb' diff --git a/core/connect_db_env.rb b/core/connect_db_env.rb new file mode 100644 index 00000000..9b5deae7 --- /dev/null +++ b/core/connect_db_env.rb @@ -0,0 +1,21 @@ +db_backend = ENV['DB_BACKEND'] # mysql or postgresql +case db_backend +when "mysql" + adapter = :mysql2 +when "postgresql" + adapter = :postgres +else + STDERR.puts "OneDB backend(#{db_backend}) is not supported, exiting..." + exit 1 +end + +ops = {} +ops[:host] = ENV['DB_HOST'] +ops[:user] = ENV['DB_USER'] +ops[:password] = ENV['DB_PASSWORD'] +ops[:database] = ENV['DB_DATABASE'] + +ops.merge! adapter: adapter + +require 'sequel' +$db = Sequel.connect(**ops) From 4a02e21b23fd914221deab6554058ae576f12e86 Mon Sep 17 00:00:00 2001 From: Mik Date: Thu, 26 Aug 2021 14:23:11 +0200 Subject: [PATCH 02/39] define ALPINE and load conf from sys --- ione_server.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ione_server.rb b/ione_server.rb index 591d38ce..c8dbe762 100755 --- a/ione_server.rb +++ b/ione_server.rb @@ -3,6 +3,7 @@ # Server start-up time STARTUP_TIME = Time.now().to_i # IONe server start time INIT_IONE = true +ALPINE = ENV["ALPINE"] == 'true' # OpenNebula Ruby files location ONE_LOCATION = ENV["ONE_LOCATION"] @@ -45,7 +46,7 @@ ################# begin - $ione_conf = YAML.load_file("#{ETC_LOCATION}/ione.conf") # IONe configuration constants + $ione_conf = YAML.load_file(ALPINE ? "/ione/sys/ione.conf" : "#{ETC_LOCATION}/ione.conf") # IONe configuration constants rescue => e STDERR.puts "Error parsing config file #{ETC_LOCATION}/ione.conf: #{e.message}" exit 1 From a2452a2cfda378b00a20473a5e5910b198e61aaa Mon Sep 17 00:00:00 2001 From: Mik Date: Thu, 26 Aug 2021 14:34:43 +0200 Subject: [PATCH 03/39] deprecated --- service/log.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/service/log.rb b/service/log.rb index d4420d18..0401b1e3 100644 --- a/service/log.rb +++ b/service/log.rb @@ -3,9 +3,6 @@ module IONeLoggerKit require "#{ROOT}/service/time.rb" require "colorize" - `echo > #{LOG_ROOT}/errors.txt && chown oneadmin:oneadmin #{LOG_ROOT}/errors.txt` - `echo > #{LOG_ROOT}/sys.log && chown oneadmin:oneadmin #{LOG_ROOT}/sys.log` - $log = [] at_exit do From 422408cebab68402c74be6ec94d9e248daed9fc8 Mon Sep 17 00:00:00 2001 From: Mik Date: Thu, 26 Aug 2021 14:42:03 +0200 Subject: [PATCH 04/39] patch ETC -> ALPINE --- hooks/check_balance.rb | 6 ++++-- hooks/disk_record_crt.rb | 7 ++++--- hooks/disk_record_del.rb | 6 ++++-- hooks/record.rb | 6 ++++-- hooks/set_price.rb | 6 ++++-- hooks/user_create_networking_setup.rb | 6 ++++-- hooks/user_post_delete_clean_up.rb | 6 ++++-- hooks/vcenter/check_running_state.rb | 6 ++++-- hooks/vcenter/set_limits.rb | 6 ++++-- hooks/vn_record.rb | 6 ++++-- 10 files changed, 40 insertions(+), 21 deletions(-) diff --git a/hooks/check_balance.rb b/hooks/check_balance.rb index 58d20240..70b66d3c 100755 --- a/hooks/check_balance.rb +++ b/hooks/check_balance.rb @@ -34,8 +34,10 @@ exit 0 end -ETC_LOCATION = "/etc/one/" -ONED_CONF = ETC_LOCATION + '/oned.conf' +if ENV["ALPINE"] != "true" then + ETC_LOCATION = "/etc/one/" + ONED_CONF = ETC_LOCATION + '/oned.conf' +end $: << '/usr/lib/one/ruby' $: << '/usr/lib/one/ione' diff --git a/hooks/disk_record_crt.rb b/hooks/disk_record_crt.rb index 6eceeb53..f68a31d1 100644 --- a/hooks/disk_record_crt.rb +++ b/hooks/disk_record_crt.rb @@ -24,9 +24,10 @@ exit 0 end -RUBY_LIB_LOCATION = "/usr/lib/one/ruby" -ETC_LOCATION = "/etc/one/" - +if ENV["ALPINE"] != "true" then + ETC_LOCATION = "/etc/one/" + ONED_CONF = ETC_LOCATION + '/oned.conf' +end $: << RUBY_LIB_LOCATION $: << '/usr/lib/one/ione' diff --git a/hooks/disk_record_del.rb b/hooks/disk_record_del.rb index 771800cd..cd6eb653 100644 --- a/hooks/disk_record_del.rb +++ b/hooks/disk_record_del.rb @@ -24,8 +24,10 @@ exit 0 end -RUBY_LIB_LOCATION = "/usr/lib/one/ruby" -ETC_LOCATION = "/etc/one/" +if ENV["ALPINE"] != "true" then + ETC_LOCATION = "/etc/one/" + ONED_CONF = ETC_LOCATION + '/oned.conf' +end $: << RUBY_LIB_LOCATION $: << '/usr/lib/one/ione' diff --git a/hooks/record.rb b/hooks/record.rb index e394c9a7..aaf7eb48 100755 --- a/hooks/record.rb +++ b/hooks/record.rb @@ -15,8 +15,10 @@ # limitations under the License. # # -------------------------------------------------------------------------- # -ETC_LOCATION = "/etc/one/" -ONED_CONF = ETC_LOCATION + '/oned.conf' +if ENV["ALPINE"] != "true" then + ETC_LOCATION = "/etc/one/" + ONED_CONF = ETC_LOCATION + '/oned.conf' +end require 'yaml' require 'base64' diff --git a/hooks/set_price.rb b/hooks/set_price.rb index 8930a957..90b569e6 100755 --- a/hooks/set_price.rb +++ b/hooks/set_price.rb @@ -19,8 +19,10 @@ STARTUP_TIME = Time.now.to_f RUBY_LIB_LOCATION = "/usr/lib/one/ruby" -ETC_LOCATION = "/etc/one/" -ONED_CONF = ETC_LOCATION + "oned.conf" +if ENV["ALPINE"] != "true" then + ETC_LOCATION = "/etc/one/" + ONED_CONF = ETC_LOCATION + '/oned.conf' +end $: << '/usr/lib/one/ione' $: << RUBY_LIB_LOCATION diff --git a/hooks/user_create_networking_setup.rb b/hooks/user_create_networking_setup.rb index 1fa316c6..128c8fb8 100755 --- a/hooks/user_create_networking_setup.rb +++ b/hooks/user_create_networking_setup.rb @@ -25,8 +25,10 @@ end RUBY_LIB_LOCATION = "/usr/lib/one/ruby" -ETC_LOCATION = "/etc/one/" -ONED_CONF = ETC_LOCATION + "oned.conf" +if ENV["ALPINE"] != "true" then + ETC_LOCATION = "/etc/one/" + ONED_CONF = ETC_LOCATION + '/oned.conf' +end $: << '/usr/lib/one/ione' $: << RUBY_LIB_LOCATION diff --git a/hooks/user_post_delete_clean_up.rb b/hooks/user_post_delete_clean_up.rb index 68cafbcc..c9e68396 100755 --- a/hooks/user_post_delete_clean_up.rb +++ b/hooks/user_post_delete_clean_up.rb @@ -25,8 +25,10 @@ end RUBY_LIB_LOCATION = "/usr/lib/one/ruby" -ETC_LOCATION = "/etc/one/" -ONED_CONF = ETC_LOCATION + "oned.conf" +if ENV["ALPINE"] != "true" then + ETC_LOCATION = "/etc/one/" + ONED_CONF = ETC_LOCATION + '/oned.conf' +end $: << '/usr/lib/one/ione' $: << RUBY_LIB_LOCATION diff --git a/hooks/vcenter/check_running_state.rb b/hooks/vcenter/check_running_state.rb index ab28c966..8faa6aab 100644 --- a/hooks/vcenter/check_running_state.rb +++ b/hooks/vcenter/check_running_state.rb @@ -29,8 +29,10 @@ end RUBY_LIB_LOCATION = "/usr/lib/one/ruby" -ETC_LOCATION = "/etc/one/" -ONED_CONF = ETC_LOCATION + "oned.conf" +if ENV["ALPINE"] != "true" then + ETC_LOCATION = "/etc/one/" + ONED_CONF = ETC_LOCATION + '/oned.conf' +end $: << '/usr/lib/one/ione' $: << RUBY_LIB_LOCATION diff --git a/hooks/vcenter/set_limits.rb b/hooks/vcenter/set_limits.rb index f19a284a..035cb763 100755 --- a/hooks/vcenter/set_limits.rb +++ b/hooks/vcenter/set_limits.rb @@ -17,8 +17,10 @@ # -------------------------------------------------------------------------- # RUBY_LIB_LOCATION = "/usr/lib/one/ruby" -ETC_LOCATION = "/etc/one/" -ONED_CONF = ETC_LOCATION + "oned.conf" +if ENV["ALPINE"] != "true" then + ETC_LOCATION = "/etc/one/" + ONED_CONF = ETC_LOCATION + '/oned.conf' +end $: << '/usr/lib/one/ione' $: << RUBY_LIB_LOCATION diff --git a/hooks/vn_record.rb b/hooks/vn_record.rb index bb08001b..88f1e617 100755 --- a/hooks/vn_record.rb +++ b/hooks/vn_record.rb @@ -25,8 +25,10 @@ end RUBY_LIB_LOCATION = "/usr/lib/one/ruby" -ETC_LOCATION = "/etc/one/" -ONED_CONF = ETC_LOCATION + '/oned.conf' +if ENV["ALPINE"] != "true" then + ETC_LOCATION = "/etc/one/" + ONED_CONF = ETC_LOCATION + '/oned.conf' +end $: << '/usr/lib/one/ione' $: << RUBY_LIB_LOCATION From 000887a4fe75bbed3d6702faa0e862ff59ceb187 Mon Sep 17 00:00:00 2001 From: Mik Date: Thu, 26 Aug 2021 15:02:01 +0200 Subject: [PATCH 05/39] deprecated --- hooks/check_balance.rb | 1 - rake/set_hooks.rake | 1 - 2 files changed, 2 deletions(-) diff --git a/hooks/check_balance.rb b/hooks/check_balance.rb index 70b66d3c..a9bbeb6d 100755 --- a/hooks/check_balance.rb +++ b/hooks/check_balance.rb @@ -39,7 +39,6 @@ ONED_CONF = ETC_LOCATION + '/oned.conf' end -$: << '/usr/lib/one/ruby' $: << '/usr/lib/one/ione' require 'opennebula' diff --git a/rake/set_hooks.rake b/rake/set_hooks.rake index 813d05a8..b2647a2d 100644 --- a/rake/set_hooks.rake +++ b/rake/set_hooks.rake @@ -1,4 +1,3 @@ -$: << '/usr/lib/one/ruby' require 'opennebula' @hooks = [ From 414b46199370184a7670e149c4ebe86de909716e Mon Sep 17 00:00:00 2001 From: Mik Date: Thu, 26 Aug 2021 15:09:00 +0200 Subject: [PATCH 06/39] one more attempt of getting rid of ETC_LOCATION --- hooks/check_balance.rb | 8 +++++--- hooks/disk_record_crt.rb | 9 +++++---- hooks/disk_record_del.rb | 11 +++++------ hooks/insert_zero_traffic_record.rb | 10 ++++++++-- hooks/record.rb | 8 +++++--- hooks/set_price.rb | 8 +++++--- hooks/user_create_networking_setup.rb | 10 +++++----- hooks/user_post_delete_clean_up.rb | 10 +++++----- hooks/vcenter/check_running_state.rb | 8 +++++--- hooks/vcenter/set_limits.rb | 10 +++++----- hooks/vn_record.rb | 9 +++++---- 11 files changed, 58 insertions(+), 43 deletions(-) diff --git a/hooks/check_balance.rb b/hooks/check_balance.rb index a9bbeb6d..ba0c46fe 100755 --- a/hooks/check_balance.rb +++ b/hooks/check_balance.rb @@ -34,13 +34,15 @@ exit 0 end -if ENV["ALPINE"] != "true" then +ALPINE = ENV["ALPINE"] == "true" +if ALPINE then + $: << ENV["IONE_LOCATION"] +else ETC_LOCATION = "/etc/one/" ONED_CONF = ETC_LOCATION + '/oned.conf' + $: << '/usr/lib/one/ione' end -$: << '/usr/lib/one/ione' - require 'opennebula' include OpenNebula diff --git a/hooks/disk_record_crt.rb b/hooks/disk_record_crt.rb index f68a31d1..63c806c9 100644 --- a/hooks/disk_record_crt.rb +++ b/hooks/disk_record_crt.rb @@ -24,11 +24,14 @@ exit 0 end -if ENV["ALPINE"] != "true" then +ALPINE = ENV["ALPINE"] == "true" +if ALPINE then + $: << ENV["IONE_LOCATION"] +else ETC_LOCATION = "/etc/one/" ONED_CONF = ETC_LOCATION + '/oned.conf' + $: << '/usr/lib/one/ione' end -$: << RUBY_LIB_LOCATION $: << '/usr/lib/one/ione' vm = xml.xpath("//PARAMETER[TYPE='IN' and POSITION=2]/VALUE").text @@ -39,8 +42,6 @@ vm = VirtualMachine.new_with_id vm, Client.new vm.info! -ONED_CONF = ETC_LOCATION + '/oned.conf' - require 'core/*' require 'json' diff --git a/hooks/disk_record_del.rb b/hooks/disk_record_del.rb index cd6eb653..7f4f8fc1 100644 --- a/hooks/disk_record_del.rb +++ b/hooks/disk_record_del.rb @@ -24,14 +24,15 @@ exit 0 end -if ENV["ALPINE"] != "true" then +ALPINE = ENV["ALPINE"] == "true" +if ALPINE then + $: << ENV["IONE_LOCATION"] +else ETC_LOCATION = "/etc/one/" ONED_CONF = ETC_LOCATION + '/oned.conf' + $: << '/usr/lib/one/ione' end -$: << RUBY_LIB_LOCATION -$: << '/usr/lib/one/ione' - vm = xml.xpath("//PARAMETER[TYPE='IN' and POSITION=2]/VALUE").text require 'opennebula' @@ -40,8 +41,6 @@ vm = VirtualMachine.new_with_id vm, Client.new vm.info! -ONED_CONF = ETC_LOCATION + '/oned.conf' - require 'core/*' disks = vm.to_hash['VM']['TEMPLATE']['DISK'] diff --git a/hooks/insert_zero_traffic_record.rb b/hooks/insert_zero_traffic_record.rb index 1d3978d3..ece37b9f 100755 --- a/hooks/insert_zero_traffic_record.rb +++ b/hooks/insert_zero_traffic_record.rb @@ -35,9 +35,15 @@ end require 'yaml' -$: << '/usr/lib/one/ione' +ALPINE = ENV["ALPINE"] == "true" +if ALPINE then + $: << ENV["IONE_LOCATION"] +else + ETC_LOCATION = "/etc/one/" + ONED_CONF = ETC_LOCATION + '/oned.conf' + $: << '/usr/lib/one/ione' +end -ONED_CONF = "/etc/one/oned.conf" require 'core/*' $db[:traffic_records].insert( diff --git a/hooks/record.rb b/hooks/record.rb index aaf7eb48..77906fc0 100755 --- a/hooks/record.rb +++ b/hooks/record.rb @@ -15,16 +15,18 @@ # limitations under the License. # # -------------------------------------------------------------------------- # -if ENV["ALPINE"] != "true" then +ALPINE = ENV["ALPINE"] == "true" +if ALPINE then + $: << ENV["IONE_LOCATION"] +else ETC_LOCATION = "/etc/one/" ONED_CONF = ETC_LOCATION + '/oned.conf' + $: << '/usr/lib/one/ione' end require 'yaml' require 'base64' require 'nokogiri' - -$: << '/usr/lib/one/ione' require 'core/*' vm_template = Nokogiri::XML(Base64::decode64(ARGV.first)) diff --git a/hooks/set_price.rb b/hooks/set_price.rb index 90b569e6..0681143b 100755 --- a/hooks/set_price.rb +++ b/hooks/set_price.rb @@ -19,13 +19,15 @@ STARTUP_TIME = Time.now.to_f RUBY_LIB_LOCATION = "/usr/lib/one/ruby" -if ENV["ALPINE"] != "true" then +ALPINE = ENV["ALPINE"] == "true" +if ALPINE then + $: << ENV["IONE_LOCATION"] +else ETC_LOCATION = "/etc/one/" ONED_CONF = ETC_LOCATION + '/oned.conf' + $: << '/usr/lib/one/ione' end -$: << '/usr/lib/one/ione' -$: << RUBY_LIB_LOCATION $: << RUBY_LIB_LOCATION + '/onedb' require 'base64' diff --git a/hooks/user_create_networking_setup.rb b/hooks/user_create_networking_setup.rb index 128c8fb8..cc65fc09 100755 --- a/hooks/user_create_networking_setup.rb +++ b/hooks/user_create_networking_setup.rb @@ -24,15 +24,15 @@ exit 0 end -RUBY_LIB_LOCATION = "/usr/lib/one/ruby" -if ENV["ALPINE"] != "true" then +ALPINE = ENV["ALPINE"] == "true" +if ALPINE then + $: << ENV["IONE_LOCATION"] +else ETC_LOCATION = "/etc/one/" ONED_CONF = ETC_LOCATION + '/oned.conf' + $: << '/usr/lib/one/ione' end -$: << '/usr/lib/one/ione' -$: << RUBY_LIB_LOCATION - require 'opennebula' include OpenNebula diff --git a/hooks/user_post_delete_clean_up.rb b/hooks/user_post_delete_clean_up.rb index c9e68396..2aea1490 100755 --- a/hooks/user_post_delete_clean_up.rb +++ b/hooks/user_post_delete_clean_up.rb @@ -24,15 +24,15 @@ exit 0 end -RUBY_LIB_LOCATION = "/usr/lib/one/ruby" -if ENV["ALPINE"] != "true" then +ALPINE = ENV["ALPINE"] == "true" +if ALPINE then + $: << ENV["IONE_LOCATION"] +else ETC_LOCATION = "/etc/one/" ONED_CONF = ETC_LOCATION + '/oned.conf' + $: << '/usr/lib/one/ione' end -$: << '/usr/lib/one/ione' -$: << RUBY_LIB_LOCATION - require 'opennebula' include OpenNebula diff --git a/hooks/vcenter/check_running_state.rb b/hooks/vcenter/check_running_state.rb index 8faa6aab..a76d9527 100644 --- a/hooks/vcenter/check_running_state.rb +++ b/hooks/vcenter/check_running_state.rb @@ -29,13 +29,15 @@ end RUBY_LIB_LOCATION = "/usr/lib/one/ruby" -if ENV["ALPINE"] != "true" then +ALPINE = ENV["ALPINE"] == "true" +if ALPINE then + $: << ENV["IONE_LOCATION"] +else ETC_LOCATION = "/etc/one/" ONED_CONF = ETC_LOCATION + '/oned.conf' + $: << '/usr/lib/one/ione' end -$: << '/usr/lib/one/ione' -$: << RUBY_LIB_LOCATION $: << RUBY_LIB_LOCATION + '/onedb' require 'base64' diff --git a/hooks/vcenter/set_limits.rb b/hooks/vcenter/set_limits.rb index 035cb763..13bc452a 100755 --- a/hooks/vcenter/set_limits.rb +++ b/hooks/vcenter/set_limits.rb @@ -17,15 +17,15 @@ # -------------------------------------------------------------------------- # RUBY_LIB_LOCATION = "/usr/lib/one/ruby" -if ENV["ALPINE"] != "true" then +ALPINE = ENV["ALPINE"] == "true" +if ALPINE then + $: << ENV["IONE_LOCATION"] +else ETC_LOCATION = "/etc/one/" ONED_CONF = ETC_LOCATION + '/oned.conf' + $: << '/usr/lib/one/ione' end -$: << '/usr/lib/one/ione' -$: << RUBY_LIB_LOCATION -$: << RUBY_LIB_LOCATION + '/onedb' - require "uri" require "net/http" require "yaml" diff --git a/hooks/vn_record.rb b/hooks/vn_record.rb index 88f1e617..c03d6fb6 100755 --- a/hooks/vn_record.rb +++ b/hooks/vn_record.rb @@ -24,14 +24,15 @@ exit 0 end -RUBY_LIB_LOCATION = "/usr/lib/one/ruby" -if ENV["ALPINE"] != "true" then +ALPINE = ENV["ALPINE"] == "true" +if ALPINE then + $: << ENV["IONE_LOCATION"] +else ETC_LOCATION = "/etc/one/" ONED_CONF = ETC_LOCATION + '/oned.conf' + $: << '/usr/lib/one/ione' end -$: << '/usr/lib/one/ione' -$: << RUBY_LIB_LOCATION require 'opennebula' include OpenNebula From 8ca34b1ae4be0dbfa1261f79326125771204948e Mon Sep 17 00:00:00 2001 From: Mik Date: Thu, 26 Aug 2021 15:09:09 +0200 Subject: [PATCH 07/39] one more attempt of getting rid of ETC_LOCATION --- ione_server.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/ione_server.rb b/ione_server.rb index c8dbe762..5ee4523b 100755 --- a/ione_server.rb +++ b/ione_server.rb @@ -16,14 +16,20 @@ # OpenNebula configs location ETC_LOCATION = "/etc/one" end +if ALPINE + LOG_LOCATION ||= ENV["LOG_LOCATION"] +end # IONe source location ROOT_DIR = File.dirname(__FILE__) -$: << '/usr/lib/one/ruby' -$: << '/usr/lib/one/ruby/cloud' -$: << '/usr/lib/one/ione' -$: << '/usr/lib/one/ione/models' +if ALPINE then + $: << ROOT_DIR + $: << ROOT_DIR + '/models' +else + $: << '/usr/lib/one/ione' + $: << '/usr/lib/one/ione/models' +end ###################### # Required libraries # @@ -76,7 +82,7 @@ # Loading DB Credentials and connecting DB -ONED_CONF = ETC_LOCATION + '/oned.conf' +ONED_CONF = ETC_LOCATION + '/oned.conf' unless ALPINE require 'core/*' @@ -91,7 +97,7 @@ include OpenNebula ########################################### # OpenNebula credentials -CREDENTIALS = File.read(VAR_LOCATION + "/.one/one_auth").chomp +CREDENTIALS = ALPINE ? ENV["ONE_CREDENTIALS"] : File.read(VAR_LOCATION + "/.one/one_auth").chomp # XML_RPC endpoint where OpenNebula is listening ENDPOINT = "http://localhost:#{$oned_conf.get('PORT')}/RPC2" $client = Client.new(CREDENTIALS, ENDPOINT) # oneadmin auth-client From 53c9a480c31f994004e5620a19f910ecdd327163 Mon Sep 17 00:00:00 2001 From: Mik Date: Thu, 26 Aug 2021 16:20:23 +0200 Subject: [PATCH 08/39] tota;;y getting rid of $oned_conf --- ione_server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ione_server.rb b/ione_server.rb index 5ee4523b..214f6906 100755 --- a/ione_server.rb +++ b/ione_server.rb @@ -99,7 +99,7 @@ # OpenNebula credentials CREDENTIALS = ALPINE ? ENV["ONE_CREDENTIALS"] : File.read(VAR_LOCATION + "/.one/one_auth").chomp # XML_RPC endpoint where OpenNebula is listening -ENDPOINT = "http://localhost:#{$oned_conf.get('PORT')}/RPC2" +ENDPOINT = ALPINE ? ENV["ONE_ENDPOINT"] : "http://localhost:#{$oned_conf.get('PORT')}/RPC2" $client = Client.new(CREDENTIALS, ENDPOINT) # oneadmin auth-client puts 'Including on_helper funcs' From 7b1f5fc2654c99715b727709452de5ea9b396abc Mon Sep 17 00:00:00 2001 From: Mik Date: Thu, 26 Aug 2021 16:20:30 +0200 Subject: [PATCH 09/39] updated Gemfile --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index a7289731..95c31f80 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ gem 'mysql2' gem 'net-sftp', '3.0.0' gem 'net-ssh', '6.1.0' gem 'nori' +gem 'opennebula' gem 'sequel' gem 'sinatra-contrib' gem 'sinatra-websocket' From ccb097ec40ccf512c8b93686042dc8450fe6748d Mon Sep 17 00:00:00 2001 From: Mik Date: Thu, 26 Aug 2021 16:20:35 +0200 Subject: [PATCH 10/39] Docker files --- .dockerignore | 7 +++++++ Dockerfile | 8 ++++++++ 2 files changed, 15 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..35bf87fe --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +*.md +LICENSE +*.yml +ui +modules +*.service +nginx.* \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..8ef05255 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM ruby:2.5.5 + +ADD . /ione +WORKDIR /ione + +RUN bundle install + +ENTRYPOINT ["ruby", "/ione/ione_server.rb"] \ No newline at end of file From b5a217a64d0aab75286cc52e1cafd8a4ec1cd5f7 Mon Sep 17 00:00:00 2001 From: Mik Date: Fri, 27 Aug 2021 15:31:01 +0200 Subject: [PATCH 11/39] API bind to 0.0.0.0 if alpine --- ione_server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ione_server.rb b/ione_server.rb index 214f6906..91062c4d 100755 --- a/ione_server.rb +++ b/ione_server.rb @@ -240,7 +240,7 @@ class IONe # IONe API based on http # puts "Binding on localhost:8009" -set :bind, 'localhost' +set :bind, ALPINE ? '0.0.0.0' : 'localhost' set :port, 8009 before do From 5e1e7c107db0804d707ee65e99328f78b8585cce Mon Sep 17 00:00:00 2001 From: Mik Date: Fri, 27 Aug 2021 15:31:25 +0200 Subject: [PATCH 12/39] switch to alpine and install native extentions --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8ef05255..686b618a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,10 @@ -FROM ruby:2.5.5 +FROM ruby:2.5.5-alpine ADD . /ione WORKDIR /ione +RUN apk update && apk add --virtual build-dependencies build-base +RUN apk add augeas-dev mariadb-dev RUN bundle install ENTRYPOINT ["ruby", "/ione/ione_server.rb"] \ No newline at end of file From 19872591067480e267a00848a13d0ea5607b8516 Mon Sep 17 00:00:00 2001 From: Mik Date: Fri, 27 Aug 2021 15:31:35 +0200 Subject: [PATCH 13/39] IONe Admin UI container --- ui/.dockerignore | 1 + ui/Dockerfile | 10 ++++++++++ ui/command.sh | 5 +++++ 3 files changed, 16 insertions(+) create mode 100644 ui/.dockerignore create mode 100644 ui/Dockerfile create mode 100644 ui/command.sh diff --git a/ui/.dockerignore b/ui/.dockerignore new file mode 100644 index 00000000..b512c09d --- /dev/null +++ b/ui/.dockerignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/ui/Dockerfile b/ui/Dockerfile new file mode 100644 index 00000000..d3567927 --- /dev/null +++ b/ui/Dockerfile @@ -0,0 +1,10 @@ +FROM node:latest + +ADD . /app +WORKDIR /app + +RUN npm install +RUN npm install -g serve +RUN chmod +x command.sh + +ENTRYPOINT [ "/app/command.sh" ] \ No newline at end of file diff --git a/ui/command.sh b/ui/command.sh new file mode 100644 index 00000000..7240f69d --- /dev/null +++ b/ui/command.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +cd /app +npm run build +serve -s dist \ No newline at end of file From 677349dd4d7b04fd8a49eb1a39fcf19fec5e7a5c Mon Sep 17 00:00:00 2001 From: Mik Date: Fri, 27 Aug 2021 15:31:39 +0200 Subject: [PATCH 14/39] augeas --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index 95c31f80..338c465c 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,6 @@ source 'https://rubygems.org' +gem 'augeas' gem 'colorize' gem 'file-tail' gem 'mysql2' From 36cfbf5ff7a8e6a10fb3cad32c703d17a56a0722 Mon Sep 17 00:00:00 2001 From: Mik Date: Fri, 27 Aug 2021 15:39:51 +0200 Subject: [PATCH 15/39] use ENDPOINT while creating Client object in before hook --- ione_server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ione_server.rb b/ione_server.rb index 91062c4d..f6a3d680 100755 --- a/ione_server.rb +++ b/ione_server.rb @@ -267,7 +267,7 @@ class IONe @auth = Base64.decode64 request.env['HTTP_AUTHORIZATION'].split(' ').last end - env[:one_client] = @client = Client.new(@auth) + env[:one_client] = @client = Client.new(@auth, ENDPOINT) env[:one_user] = @one_user = User.new_with_id(-1, @client) rc = @one_user.info! if OpenNebula.is_error?(rc) From 9d0efbdb57e1c9f1b63e382856e632f4aa59e4be Mon Sep 17 00:00:00 2001 From: Mik Date: Tue, 31 Aug 2021 14:11:16 +0200 Subject: [PATCH 16/39] add retry while connecting to DB --- core/connect_db.rb | 12 +++++++++++- core/connect_db_env.rb | 11 ++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/core/connect_db.rb b/core/connect_db.rb index 9bc0e6c0..067b491a 100644 --- a/core/connect_db.rb +++ b/core/connect_db.rb @@ -23,4 +23,14 @@ ops.merge! adapter: adapter require 'sequel' -$db = Sequel.connect(**ops) +begin + puts "Connecting to DB" + $db = Sequel.connect(**ops) +rescue => e + puts "Error connecting to DB: #{e.message}" + puts "Retrying in 60 sec" + sleep 60 + puts "Retrying..." + retry +end + diff --git a/core/connect_db_env.rb b/core/connect_db_env.rb index 9b5deae7..202ba153 100644 --- a/core/connect_db_env.rb +++ b/core/connect_db_env.rb @@ -18,4 +18,13 @@ ops.merge! adapter: adapter require 'sequel' -$db = Sequel.connect(**ops) +begin + puts "Connecting to DB" + $db = Sequel.connect(**ops) +rescue => e + puts "Error connecting to DB: #{e.message}" + puts "Retrying in 60 sec" + sleep 60 + puts "Retrying..." + retry +end From 3d5c92e97d20de3b3dbde51bc7f4a25528749d5b Mon Sep 17 00:00:00 2001 From: Mik Date: Tue, 31 Aug 2021 14:16:30 +0200 Subject: [PATCH 17/39] lint --- core/connect_db.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/core/connect_db.rb b/core/connect_db.rb index 067b491a..607a7eb5 100644 --- a/core/connect_db.rb +++ b/core/connect_db.rb @@ -33,4 +33,3 @@ puts "Retrying..." retry end - From 21fb8835584e38d901abdedb181a9f1fa704737e Mon Sep 17 00:00:00 2001 From: Mik Date: Tue, 31 Aug 2021 16:06:46 +0200 Subject: [PATCH 18/39] web hook for alpine --- hooks/web_hook.rb | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 hooks/web_hook.rb diff --git a/hooks/web_hook.rb b/hooks/web_hook.rb new file mode 100644 index 00000000..c2597230 --- /dev/null +++ b/hooks/web_hook.rb @@ -0,0 +1,32 @@ +#!/usr/bin/env ruby +# -------------------------------------------------------------------------- # +# Copyright 2017-2021, IONe Cloud Project, Support.by # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +# -------------------------------------------------------------------------- # + +require 'net/http' +require 'json' + +hook, *args = ARGV +hook = hook.split('/').last + +api = URI("http://ione:8009/") +req = Net::HTTP::Post.new(api + '/hooks/' + hook) +# Reading credentials from file and using as #basic_auth(uname, passwd) +req.basic_auth(*File.read('/var/lib/one/.one/one_auth').chomp.split(':')) +req.body = JSON.generate params: args + +r = Net::HTTP.start(api.hostname, api.port) do | http | + http.request(req) +end From d75c41bb6c5ba3f68dc6b13a0f3595299017b05d Mon Sep 17 00:00:00 2001 From: Mik Date: Tue, 31 Aug 2021 16:59:56 +0200 Subject: [PATCH 19/39] OpenNebula client access credentials in hooks(in ALPINE env) --- hooks/check_balance.rb | 6 ++++-- hooks/disk_record_crt.rb | 4 +++- hooks/disk_record_del.rb | 4 +++- hooks/set_price.rb | 4 +++- hooks/user_create_networking_setup.rb | 5 +++-- hooks/user_post_delete_clean_up.rb | 9 +++++---- hooks/vcenter/check_running_state.rb | 2 +- hooks/vcenter/set_limits.rb | 2 +- hooks/vn_record.rb | 4 +++- hooks/web_hook.rb | 14 ++++++++++++++ 10 files changed, 40 insertions(+), 14 deletions(-) diff --git a/hooks/check_balance.rb b/hooks/check_balance.rb index ba0c46fe..b839f367 100755 --- a/hooks/check_balance.rb +++ b/hooks/check_balance.rb @@ -46,10 +46,12 @@ require 'opennebula' include OpenNebula -vm = VirtualMachine.new_with_id(vmid, Client.new) +client = ALPINE ? Client.new(ENV["ONE_CREDENTIALS"], ENV["ONE_ENDPOINT"]) : Client.new + +vm = VirtualMachine.new_with_id(vmid, client) vm.info! -u = User.new_with_id vm['UID'].to_i, Client.new +u = User.new_with_id vm['UID'].to_i, client u.info! exit 0 if u.groups.include? 0 diff --git a/hooks/disk_record_crt.rb b/hooks/disk_record_crt.rb index 63c806c9..b8d0e36b 100644 --- a/hooks/disk_record_crt.rb +++ b/hooks/disk_record_crt.rb @@ -39,7 +39,9 @@ require 'opennebula' include OpenNebula -vm = VirtualMachine.new_with_id vm, Client.new +client = ALPINE ? Client.new(ENV["ONE_CREDENTIALS"], ENV["ONE_ENDPOINT"]) : Client.new + +vm = VirtualMachine.new_with_id vm, client vm.info! require 'core/*' diff --git a/hooks/disk_record_del.rb b/hooks/disk_record_del.rb index 7f4f8fc1..c0f55e2b 100644 --- a/hooks/disk_record_del.rb +++ b/hooks/disk_record_del.rb @@ -38,7 +38,9 @@ require 'opennebula' include OpenNebula -vm = VirtualMachine.new_with_id vm, Client.new +client = ALPINE ? Client.new(ENV["ONE_CREDENTIALS"], ENV["ONE_ENDPOINT"]) : Client.new + +vm = VirtualMachine.new_with_id vm, client vm.info! require 'core/*' diff --git a/hooks/set_price.rb b/hooks/set_price.rb index 0681143b..2ef20d8d 100755 --- a/hooks/set_price.rb +++ b/hooks/set_price.rb @@ -47,7 +47,9 @@ exit 0 end -vm = VirtualMachine.new xml.xpath('//EXTRA/VM'), Client.new +client = ALPINE ? Client.new(ENV["ONE_CREDENTIALS"], ENV["ONE_ENDPOINT"]) : Client.new + +vm = VirtualMachine.new xml.xpath('//EXTRA/VM'), client vm.info! begin diff --git a/hooks/user_create_networking_setup.rb b/hooks/user_create_networking_setup.rb index cc65fc09..927f07fa 100755 --- a/hooks/user_create_networking_setup.rb +++ b/hooks/user_create_networking_setup.rb @@ -36,8 +36,9 @@ require 'opennebula' include OpenNebula -$client = Client.new -user = User.new xml.xpath('//EXTRA/USER'), $client +client = ALPINE ? Client.new(ENV["ONE_CREDENTIALS"], ENV["ONE_ENDPOINT"]) : Client.new + +user = User.new xml.xpath('//EXTRA/USER'), client user.info! require 'yaml' diff --git a/hooks/user_post_delete_clean_up.rb b/hooks/user_post_delete_clean_up.rb index 2aea1490..adbdfe3c 100755 --- a/hooks/user_post_delete_clean_up.rb +++ b/hooks/user_post_delete_clean_up.rb @@ -36,8 +36,9 @@ require 'opennebula' include OpenNebula -$client = Client.new -user = User.new xml.xpath('//EXTRA/USER'), $client +client = ALPINE ? Client.new(ENV["ONE_CREDENTIALS"], ENV["ONE_ENDPOINT"]) : Client.new + +user = User.new xml.xpath('//EXTRA/USER'), client require 'yaml' require 'core/*' @@ -64,12 +65,12 @@ def vn_pool id until pool(id) == [] pool(id).each do | vm | - VirtualMachine.new_with_id(vm[:oid], $client).terminate(true) + VirtualMachine.new_with_id(vm[:oid], client).terminate(true) end end vn_pool(id).each do | vnet | - vnet = VirtualNetwork.new_with_id(vnet[:oid], $client) + vnet = VirtualNetwork.new_with_id(vnet[:oid], client) vnet.delete end diff --git a/hooks/vcenter/check_running_state.rb b/hooks/vcenter/check_running_state.rb index a76d9527..1b25e351 100644 --- a/hooks/vcenter/check_running_state.rb +++ b/hooks/vcenter/check_running_state.rb @@ -55,7 +55,7 @@ require 'service/objects/host' require 'service/objects/vm' -client = Client.new +client = ALPINE ? Client.new(ENV["ONE_CREDENTIALS"], ENV["ONE_ENDPOINT"]) : Client.new xml = Nokogiri::XML(Base64::decode64(ARGV.first)) id = xml.xpath('//ID').text.to_i diff --git a/hooks/vcenter/set_limits.rb b/hooks/vcenter/set_limits.rb index 13bc452a..bc2e55cf 100755 --- a/hooks/vcenter/set_limits.rb +++ b/hooks/vcenter/set_limits.rb @@ -39,7 +39,7 @@ require 'service/objects/host' require 'service/objects/vm' -client = Client.new +client = ALPINE ? Client.new(ENV["ONE_CREDENTIALS"], ENV["ONE_ENDPOINT"]) : Client.new xml = Nokogiri::XML(Base64::decode64(ARGV.first)) id = xml.xpath('//ID').text.to_i diff --git a/hooks/vn_record.rb b/hooks/vn_record.rb index c03d6fb6..ae32fa8c 100755 --- a/hooks/vn_record.rb +++ b/hooks/vn_record.rb @@ -36,7 +36,9 @@ require 'opennebula' include OpenNebula -vnet = VirtualNetwork.new xml.xpath('//EXTRA/VNET'), Client.new +client = ALPINE ? Client.new(ENV["ONE_CREDENTIALS"], ENV["ONE_ENDPOINT"]) : Client.new + +vnet = VirtualNetwork.new xml.xpath('//EXTRA/VNET'), client vnet.info! require 'yaml' diff --git a/hooks/web_hook.rb b/hooks/web_hook.rb index c2597230..b8da481a 100644 --- a/hooks/web_hook.rb +++ b/hooks/web_hook.rb @@ -30,3 +30,17 @@ r = Net::HTTP.start(api.hostname, api.port) do | http | http.request(req) end +res = JSON.parse r.body + +case r.code.to_i +when 400 + STDERR.puts res['error'] + exit 1 +when 403 + STDERR.puts "Forbidden" + exit 1 +else + STDOUT.puts res['stdout'] + STDERR.puts res['stderr'] + exit res['status'] +end From 09f438b58ec5294265b54ae0d0dc93086eef32d8 Mon Sep 17 00:00:00 2001 From: Mik Date: Tue, 31 Aug 2021 17:09:16 +0200 Subject: [PATCH 20/39] logs --- core/connect_db.rb | 3 ++- core/connect_db_env.rb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core/connect_db.rb b/core/connect_db.rb index 607a7eb5..7d7a8b48 100644 --- a/core/connect_db.rb +++ b/core/connect_db.rb @@ -24,7 +24,7 @@ require 'sequel' begin - puts "Connecting to DB" + print "Connecting to DB... " $db = Sequel.connect(**ops) rescue => e puts "Error connecting to DB: #{e.message}" @@ -33,3 +33,4 @@ puts "Retrying..." retry end +puts "Connected" diff --git a/core/connect_db_env.rb b/core/connect_db_env.rb index 202ba153..c6cc7b05 100644 --- a/core/connect_db_env.rb +++ b/core/connect_db_env.rb @@ -19,7 +19,7 @@ require 'sequel' begin - puts "Connecting to DB" + print "Connecting to DB... " $db = Sequel.connect(**ops) rescue => e puts "Error connecting to DB: #{e.message}" @@ -28,3 +28,4 @@ puts "Retrying..." retry end +puts "Connected" From 76d803d408ac24a2c10257094bba3c8c8e2c8ece Mon Sep 17 00:00:00 2001 From: Mik Date: Tue, 31 Aug 2021 17:30:58 +0200 Subject: [PATCH 21/39] rake hooks_tp: setting hooks in container task --- rake/set_hooks.rake | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/rake/set_hooks.rake b/rake/set_hooks.rake index b2647a2d..10978eab 100644 --- a/rake/set_hooks.rake +++ b/rake/set_hooks.rake @@ -213,3 +213,48 @@ task :hooks do end end end + +desc "Setting needed hooks in Container environment" +task :hooks_tp do + + client = OpenNebula::Client.new(ENV["ONE_CREDENTIALS"], ENV["ONE_ENDPOINT"]) + + user = OpenNebula::User.new_with_id(-1, client) + begin + print "Connecting to OpenNebula XML-RPC API... " + rc = user.info! + raise if OpenNebula.is_error? rc + rescue + puts "Error!" + puts rc.message + print "Retrying in 30sec... " + sleep 30 + retry + end + + $: << ENV["IONE_LOCATION"] + require 'lib/std++/main.rb' + + @hooks << { + "NAME" => 'test-tp-hook', + "TYPE" => 'api', + "CALL" => 'one.user.allocate', + "COMMAND" => '/usr/lib/one/ione/hooks/test_tp.rb', + "ARGUMENTS" => '$API' + } + + for hook in @hooks do + print "Allocating hook #{hook['NAME']}... " + hook["ARGUMENTS"] = hook["COMMAND"] + ' ' + hook["ARGUMENTS"] + hook["COMMAND"] = '/usr/lib/one/ione/hooks/web_hook.rb' + + rc = OpenNebula::Hook.new_with_id(0, client).allocate(hook.to_one_template) + if OpenNebula.is_error? rc then + puts "Error: " + rc.message + else + puts "Success: #{rc}" + end + end + + chmod_R "+x", "#{ENV["IONE_LOCATION"]}/hooks/" +end From 284a7fc0b03641cb8a480f9b44190a88cdcabbb4 Mon Sep 17 00:00:00 2001 From: Mik Date: Tue, 31 Aug 2021 17:31:25 +0200 Subject: [PATCH 22/39] setup hooks before starting ione --- Dockerfile | 2 +- command.sh | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 command.sh diff --git a/Dockerfile b/Dockerfile index 686b618a..628fe909 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,4 +7,4 @@ RUN apk update && apk add --virtual build-dependencies build-base RUN apk add augeas-dev mariadb-dev RUN bundle install -ENTRYPOINT ["ruby", "/ione/ione_server.rb"] \ No newline at end of file +ENTRYPOINT ["sh", "command.sh"] \ No newline at end of file diff --git a/command.sh b/command.sh new file mode 100644 index 00000000..44db525c --- /dev/null +++ b/command.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +rake hooks_tp +ruby /ione/ione_server.rb \ No newline at end of file From 993c67a0518b1e2ac6d78a2bf47261deb98e137f Mon Sep 17 00:00:00 2001 From: Mik Date: Tue, 31 Aug 2021 17:31:34 +0200 Subject: [PATCH 23/39] webhook endpoint --- routes/hooks.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 routes/hooks.rb diff --git a/routes/hooks.rb b/routes/hooks.rb new file mode 100644 index 00000000..116ba65e --- /dev/null +++ b/routes/hooks.rb @@ -0,0 +1,25 @@ +# !@group Ansible Playbook Endpoints +if ALPINE then + + require 'open3' + + post '/hooks/:hook' do | hook | + unless IPAddr.new(request.env['REMOTE_ADDR']).private? then + halt 403 + end + p hook + hook = "#{ROOT_DIR}/hooks/#{hook}" + p hook + unless File.exist? hook then + halt 400, { 'Content-Type': 'application/json' }, { error: "Script doesn't exist" }.to_json + end + + p @request_hash + + stdout, stderr, status = Open3.capture3(hook + " " + @request_hash['params'].join(' ')) + p stdout, stderr, status + + json hook: hook, stdout: stdout, stderr: stderr, status: status.exitstatus + end +end +# !@endgroup From b43554a97478b1f8ff7cb413f4dbe827c759fccd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Sep 2021 01:10:11 +0000 Subject: [PATCH 24/39] fix(deps): bump ruby/setup-ruby from 1.81.0 to 1.82.0 Bumps [ruby/setup-ruby](https://github.com/ruby/setup-ruby) from 1.81.0 to 1.82.0. - [Release notes](https://github.com/ruby/setup-ruby/releases) - [Commits](https://github.com/ruby/setup-ruby/compare/v1.81.0...v1.82.0) --- updated-dependencies: - dependency-name: ruby/setup-ruby dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 1742b1d1..1029d268 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -24,7 +24,7 @@ jobs: - uses: actions/checkout@v2.3.4 - name: Setup Ruby - uses: ruby/setup-ruby@v1.81.0 + uses: ruby/setup-ruby@v1.82.0 with: ruby-version: 2.5 From 7493881dba894939c4dfda71017145aa4aaf9805 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Sep 2021 00:16:43 +0000 Subject: [PATCH 25/39] fix(deps): bump actions/setup-node from 2.4.0 to 2.4.1 Bumps [actions/setup-node](https://github.com/actions/setup-node) from 2.4.0 to 2.4.1. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/v2.4.0...v2.4.1) --- updated-dependencies: - dependency-name: actions/setup-node dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/cd.yml | 2 +- .github/workflows/check_ui.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 53721bd6..03c2d023 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -19,7 +19,7 @@ jobs: steps: - uses: actions/checkout@v2.3.4 - - uses: actions/setup-node@v2.4.0 + - uses: actions/setup-node@v2.4.1 - name: Dependencies run: npm install diff --git a/.github/workflows/check_ui.yml b/.github/workflows/check_ui.yml index 5f0f230c..dcc345d8 100644 --- a/.github/workflows/check_ui.yml +++ b/.github/workflows/check_ui.yml @@ -27,7 +27,7 @@ jobs: steps: - uses: actions/checkout@v2.3.4 - - uses: actions/setup-node@v2.4.0 + - uses: actions/setup-node@v2.4.1 - name: Dependencies run: npm install From 6a896e8c6bcb3acf498832a5e085a6e6d813b6e7 Mon Sep 17 00:00:00 2001 From: Mik Date: Thu, 30 Sep 2021 13:32:40 +0200 Subject: [PATCH 26/39] CI/CD --- .github/workflows/docker.yml | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000..c6b7de66 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,42 @@ +name: Create and publish a Docker images + +on: + push: + branches: ['ione-tp', 'master'] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + ione: + runs-on: ubuntu-latest + environment: ione + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file From 0c36b28cb1892792bc5e0ebb521e358c770fd2c0 Mon Sep 17 00:00:00 2001 From: Mik Date: Thu, 30 Sep 2021 13:39:10 +0200 Subject: [PATCH 27/39] add ione-admin to CI/CD --- .github/workflows/docker.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c6b7de66..f7c2183d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -16,6 +16,38 @@ jobs: contents: read packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + ione-admin: + runs-on: ubuntu-latest + environment: ione-admin + permissions: + contents: read + packages: write + steps: - name: Checkout repository uses: actions/checkout@v2 From 2108942c61f5f38895574809d26893e147a7bb20 Mon Sep 17 00:00:00 2001 From: Mik Date: Thu, 30 Sep 2021 13:44:45 +0200 Subject: [PATCH 28/39] basic docker-compose --- docker-compose.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..8f5442e5 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,29 @@ +version: '3.7' +services: + ione: + image: ghcr.io/support-pl/ione:latest + network_mode: host + environment: + ALPINE: "true" + IONE_LOCATION: /ione + ONE_LOCATION: /ione/sys + LOG_LOCATION: /log + ONE_CREDENTIALS: "oneadmin:password" + DB_BACKEND: mysql + DB_HOST: localhost + DB_USER: oneadmin + DB_PASSWORD: DBpassword + DB_DATABASE: opennebula + ONE_ENDPOINT: "http://localhost:2633/RPC2" + ports: + - 8009:8009 + volumes: + - ./sys:/ione/sys + - /var/log/one:/log + ione-admin: + image: ghcr.io/support-pl/ione-admin:latest + network_mode: host + environment: + VUE_APP_IONE_API_BASE_URL: http://localhost:8009 + ports: + - 5000:5000 \ No newline at end of file From 0066df55a981917d0256393bece6267043590b97 Mon Sep 17 00:00:00 2001 From: Mik Date: Thu, 30 Sep 2021 13:47:25 +0200 Subject: [PATCH 29/39] readme table of contents --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 298cc1e6..385b69f3 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,13 @@ Creators: [Support.pl](https://support.pl) [slnt_opp](https://slnt-opp.xyz) -## Main additional features +## Table of Contents + +- [System requirements](#system-requirements) +- [Installation classic](#install) +- [Notes](#important-notes) + +## Main features - Transparent showback - Balance From e1db45195eb71ff959100ee7704e6567f3eb487c Mon Sep 17 00:00:00 2001 From: Mik Date: Thu, 30 Sep 2021 13:52:13 +0200 Subject: [PATCH 30/39] format --- sys/ione.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/ione.conf b/sys/ione.conf index 29543b01..41e79037 100644 --- a/sys/ione.conf +++ b/sys/ione.conf @@ -19,4 +19,4 @@ SnapshotController: check-period: 3600 # Snapshots check frequency in seconds TrafficRecorder: - check-period: 3600 \ No newline at end of file + check-period: 3600 From 1eafbdf83b34a4e63fbf6a9f7238e2145e724aae Mon Sep 17 00:00:00 2001 From: Mik Date: Thu, 30 Sep 2021 13:52:59 +0200 Subject: [PATCH 31/39] trafficrecorder conf comments --- sys/ione.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/ione.conf b/sys/ione.conf index 41e79037..46237240 100644 --- a/sys/ione.conf +++ b/sys/ione.conf @@ -19,4 +19,4 @@ SnapshotController: check-period: 3600 # Snapshots check frequency in seconds TrafficRecorder: - check-period: 3600 + check-period: 3600 # Compute Traffic frequency in seconds From f8337dd6ae031254090ec7c82d3a46c40a7ef391 Mon Sep 17 00:00:00 2001 From: Mik Date: Thu, 30 Sep 2021 14:08:23 +0200 Subject: [PATCH 32/39] updated CI/CD images tags --- .github/workflows/docker.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f7c2183d..32dae720 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -6,7 +6,6 @@ on: env: REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} jobs: ione: @@ -31,7 +30,7 @@ jobs: id: meta uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + images: ${{ env.REGISTRY }}/ione - name: Build and push Docker image uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc @@ -63,7 +62,7 @@ jobs: id: meta uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + images: ${{ env.REGISTRY }}/ione-admin - name: Build and push Docker image uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc From d6905d8fd584a4fcd53e91bc6c07af8305c2cfe5 Mon Sep 17 00:00:00 2001 From: Mik Date: Thu, 30 Sep 2021 14:08:58 +0200 Subject: [PATCH 33/39] Running in docker manual --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 385b69f3..16e70d1d 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Creators: - [System requirements](#system-requirements) - [Installation classic](#install) +- [Running in Docker](#running-in-docker) - [Notes](#important-notes) ## Main features @@ -199,6 +200,20 @@ Environment=GEM_PATH=/usr/local/rvm/gems/ruby-2.5.8:/usr/local/rvm/gems/ruby-2.5 --------------------------------------------------------------------------------------------------------- +## Running in Docker + +1. Download needed files using: + + ```shell + mkdir ione && cd ione && \ + wget https://raw.githubusercontent.com/Support-pl/ione/master/sys/ione.conf && \ + wget https://raw.githubusercontent.com/Support-pl/ione/ione-tp/docker-compose.yml + ``` + +2. Pre-configure IONe in `ione.conf` if needed +3. Configure credentials and endpoints in `docker-compose.yml` +4. Start IONe using `docker-compose up -d` + Thanks for choosing us, contacts for support are in "Contacts" section at the beginning of this `README` ## Important Notes From e06cd3c68a3a9923e0093d2406f802a652d1abf9 Mon Sep 17 00:00:00 2001 From: Mik Date: Thu, 30 Sep 2021 14:13:46 +0200 Subject: [PATCH 34/39] fix tag names --- .github/workflows/docker.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 32dae720..0faca108 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -30,7 +30,7 @@ jobs: id: meta uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 with: - images: ${{ env.REGISTRY }}/ione + images: ${{ env.REGISTRY }}/support-pl/ione - name: Build and push Docker image uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc @@ -62,12 +62,12 @@ jobs: id: meta uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 with: - images: ${{ env.REGISTRY }}/ione-admin + images: ${{ env.REGISTRY }}/support-pl/ione-admin - name: Build and push Docker image uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc with: - context: . + context: ui push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file From 3a256fc183d96a5362707c596976ae8cd3c4968f Mon Sep 17 00:00:00 2001 From: Mik Date: Thu, 30 Sep 2021 14:25:44 +0200 Subject: [PATCH 35/39] actions versions --- .github/workflows/docker.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 0faca108..dbe8f2e9 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -2,7 +2,7 @@ name: Create and publish a Docker images on: push: - branches: ['ione-tp', 'master'] + branches: ['master'] env: REGISTRY: ghcr.io @@ -52,7 +52,7 @@ jobs: uses: actions/checkout@v2 - name: Log in to the Container registry - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + uses: docker/login-action@v1.10.0 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} @@ -60,12 +60,12 @@ jobs: - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + uses: docker/metadata-action@v3.5.0 with: images: ${{ env.REGISTRY }}/support-pl/ione-admin - name: Build and push Docker image - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + uses: docker/build-push-action@2.7.0 with: context: ui push: true From ed95fceb12cd2c27d9d9a9c632d448d756352067 Mon Sep 17 00:00:00 2001 From: Mik Date: Thu, 30 Sep 2021 14:36:16 +0200 Subject: [PATCH 36/39] actions versions --- .github/workflows/docker.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index dbe8f2e9..4c6a51bb 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -20,7 +20,7 @@ jobs: uses: actions/checkout@v2 - name: Log in to the Container registry - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + uses: docker/login-action@v1.10.0 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} @@ -28,12 +28,12 @@ jobs: - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + uses: docker/metadata-action@v3.5.0 with: images: ${{ env.REGISTRY }}/support-pl/ione - name: Build and push Docker image - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + uses: docker/build-push-action@2.7.0 with: context: . push: true From b1d28c3b633a87d028e991b014209796e52f98ac Mon Sep 17 00:00:00 2001 From: Mik Date: Thu, 30 Sep 2021 14:38:16 +0200 Subject: [PATCH 37/39] README --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 16e70d1d..300f308f 100644 --- a/README.md +++ b/README.md @@ -212,6 +212,9 @@ Environment=GEM_PATH=/usr/local/rvm/gems/ruby-2.5.8:/usr/local/rvm/gems/ruby-2.5 2. Pre-configure IONe in `ione.conf` if needed 3. Configure credentials and endpoints in `docker-compose.yml` + + 3.1 You may need to change tags to anything else from `latest` sometimes. Check [Github packages](https://github.com/orgs/Support-pl/packages?repo_name=ione) to see latest published versions + 4. Start IONe using `docker-compose up -d` Thanks for choosing us, contacts for support are in "Contacts" section at the beginning of this `README` From 40b0bf4bd0828a782cf20c526fa63dab1a480306 Mon Sep 17 00:00:00 2001 From: Mik Date: Thu, 30 Sep 2021 14:41:19 +0200 Subject: [PATCH 38/39] env vars reference --- README.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 300f308f..1c08ea3c 100644 --- a/README.md +++ b/README.md @@ -211,12 +211,30 @@ Environment=GEM_PATH=/usr/local/rvm/gems/ruby-2.5.8:/usr/local/rvm/gems/ruby-2.5 ``` 2. Pre-configure IONe in `ione.conf` if needed -3. Configure credentials and endpoints in `docker-compose.yml` +3. Configure credentials and endpoints in `docker-compose.yml` ([reference below](#docker-environment-variables-reference)) 3.1 You may need to change tags to anything else from `latest` sometimes. Check [Github packages](https://github.com/orgs/Support-pl/packages?repo_name=ione) to see latest published versions 4. Start IONe using `docker-compose up -d` +### Docker environment variables reference + +```shell +ALPINE=true # just required to make IONe reading data from env instead of default ONe files +IONE_LOCATION=/ione # IONe root dir in container +ONE_LOCATION=/ione/sys # IONe configs dir path +LOG_LOCATION=/log # Path to dir to write IONe logs in +ONE_CREDENTIALS="oneadmin:passwd" # oneadmin or other ONe admin(!) user credentials +ONE_ENDPOINT="http://localhost:2633/RPC2" # ONe XML-RPC API endpoint + +# Database connection(must be same DB with ONe and have at least READ access to ONe tables) +DB_BACKEND=mysql +DB_HOST=10.6.6.6 +DB_USER=oneadmin +DB_PASSWORD:passwd +DB_DATABASE=opennebula +``` + Thanks for choosing us, contacts for support are in "Contacts" section at the beginning of this `README` ## Important Notes From 5506528a9f60ae480571adf85ac10419ff50f820 Mon Sep 17 00:00:00 2001 From: Mik Date: Thu, 30 Sep 2021 14:42:25 +0200 Subject: [PATCH 39/39] CI/CD hook --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 4c6a51bb..2cbab771 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -2,7 +2,7 @@ name: Create and publish a Docker images on: push: - branches: ['master'] + branches: ['master', 'release'] env: REGISTRY: ghcr.io