avm-tools 0.114.1 → 0.116.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/tools/version.rb +1 -1
  3. data/sub/avm/lib/avm/instances/base/auto_values/database.rb +2 -2
  4. data/sub/avm/lib/avm/instances/entry_keys.rb +2 -1
  5. data/sub/avm/lib/avm/self/instance.rb +0 -1
  6. data/sub/avm/lib/avm/sources/base/instance.rb +28 -0
  7. data/sub/avm/lib/avm/version.rb +1 -1
  8. data/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/assert.rb +77 -0
  9. data/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance.rb +23 -12
  10. data/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/version.rb +1 -1
  11. data/sub/avm-eac_rails_base0/avm-eac_rails_base0.gemspec +1 -1
  12. data/sub/avm-eac_rails_base0/lib/avm/eac_rails_base0/deploy.rb +1 -1
  13. data/sub/avm-eac_rails_base0/lib/avm/eac_rails_base0/version.rb +1 -1
  14. data/sub/avm-eac_rails_base1/avm-eac_rails_base1.gemspec +1 -1
  15. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner/tasks_scheduler/systemd_unit.rb +46 -0
  16. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/runner/tasks_scheduler.rb +17 -0
  17. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/systemd_unit/service.rb +70 -0
  18. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/systemd_unit/tasks_scheduler_command.rb +29 -0
  19. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/systemd_unit.rb +57 -0
  20. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/version.rb +1 -1
  21. data/sub/avm-eac_rails_base1/template/avm/eac_rails_base1/systemd_unit/tasks_scheduler.service +12 -0
  22. data/sub/avm-eac_rails_base1/template/avm/eac_rails_base1/systemd_unit/tasks_scheduler_command.sh +6 -0
  23. data/sub/avm-eac_redmine_base0/avm-eac_redmine_base0.gemspec +2 -1
  24. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/data_unit.rb +6 -10
  25. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instance.rb +20 -0
  26. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/rest_api.rb +11 -0
  27. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/version.rb +1 -1
  28. data/sub/avm-eac_redmine_base0/template/avm/eac_redmine_base0/deploy/config/install.sh.template +3 -3
  29. data/sub/avm-eac_ubuntu_base0/lib/avm/eac_ubuntu_base0/instances/base.rb +6 -0
  30. data/sub/avm-eac_ubuntu_base0/lib/avm/eac_ubuntu_base0/version.rb +1 -1
  31. data/sub/avm-eac_webapp_base0/avm-eac_webapp_base0.gemspec +1 -1
  32. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instance.rb +7 -0
  33. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/version.rb +1 -1
  34. data/sub/eac_cli/lib/eac_cli/runner/context.rb +4 -0
  35. data/sub/eac_cli/lib/eac_cli/runner/instance_methods.rb +10 -0
  36. data/sub/eac_cli/lib/eac_cli/runner_with/subcommands.rb +1 -1
  37. data/sub/eac_cli/lib/eac_cli/version.rb +1 -1
  38. data/sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb +6 -1
  39. data/sub/eac_fs/lib/eac_fs/version.rb +1 -1
  40. data/sub/eac_rest/Gemfile +5 -0
  41. data/sub/eac_rest/eac_rest.gemspec +18 -0
  42. data/sub/eac_rest/lib/eac_rest/api.rb +39 -0
  43. data/sub/eac_rest/lib/eac_rest/entity.rb +16 -0
  44. data/sub/eac_rest/lib/eac_rest/request.rb +74 -0
  45. data/sub/eac_rest/lib/eac_rest/response.rb +72 -0
  46. data/sub/eac_rest/lib/eac_rest/version.rb +5 -0
  47. data/sub/eac_rest/lib/eac_rest.rb +7 -0
  48. data/sub/eac_rest/spec/rubocop_spec.rb +3 -0
  49. data/sub/eac_rest/spec/spec_helper.rb +4 -0
  50. data/sub/eac_ruby_utils/lib/eac_ruby_utils/bit.rb +46 -0
  51. data/sub/eac_ruby_utils/lib/eac_ruby_utils/bit_array.rb +81 -0
  52. data/sub/eac_ruby_utils/lib/eac_ruby_utils/byte.rb +105 -0
  53. data/sub/eac_ruby_utils/lib/eac_ruby_utils/byte_array.rb +36 -0
  54. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/process.rb +12 -4
  55. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/asserts.rb +11 -0
  56. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/basename_noext.rb +10 -0
  57. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/reqdir_glob.rb +13 -0
  58. data/sub/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  59. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/bit_array_spec.rb +22 -0
  60. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/byte_spec.rb +54 -0
  61. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/pathname/basename_noext_spec.rb +26 -0
  62. metadata +41 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2c54ac1c77f2c1db81cb6e2fa45e97ff5bd9ffad83054e33d8baeb94ff682dea
4
- data.tar.gz: 842806c80c5fa0fa93f1b6207f498831e833a94147ad9015e2717ebf9e3ec01b
3
+ metadata.gz: 27716dd4266fe2074f32cc46de1d3d4b0a83612a50e4794f9948523d3ed6bad5
4
+ data.tar.gz: 97d712f91c0adbeacedd67674ae108d9f48fd2db800df50696625a7d81bd95f3
5
5
  SHA512:
6
- metadata.gz: 7d026169d9ce0ef808fb38cad55a307eabdd023f7585dd42a6d61e6aa66ca1b7cb203a75aeaa25675e24c4267564dbc4d423dba6902be83d279b3234f6514459
7
- data.tar.gz: ebc64d8a3e11ab4eee57147b797b2f69fa7816be26d8621383822d1180f7f6ea8c4d9570d19ef21dbb844c25aa41ee3ef4cca0a48efcb30483114d092978810a
6
+ metadata.gz: ba1854580f3fd1cbda82b94422e8feffde990f8f8ec4ec5e789f7e565536502f581a9e6da694a2eb04c76da27916b6bbd8504dc6663e8a540aae7e8517941256
7
+ data.tar.gz: fc5000e7db1db0c41cda3768665ce4bd08846a81ba7c7f8d5b8c8e014d79fc28bf99a6d0fa5ba75d7b2d8b3be360c2dd13d18321cdb0b1789972f84e89616d60
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.114.1'
5
+ VERSION = '0.116.0'
6
6
  end
7
7
  end
@@ -37,7 +37,7 @@ module Avm
37
37
  end
38
38
 
39
39
  def auto_database_password
40
- database_auto_common('password')
40
+ database_auto_common('password') || id
41
41
  end
42
42
 
43
43
  def auto_database_port
@@ -45,7 +45,7 @@ module Avm
45
45
  end
46
46
 
47
47
  def auto_database_username
48
- database_auto_common('username')
48
+ database_auto_common('username') || id
49
49
  end
50
50
 
51
51
  def auto_database_system
@@ -47,7 +47,8 @@ module Avm
47
47
  docker: %w[registry],
48
48
  mailer: {
49
49
  '' => %w[id from reply_to],
50
- smtp: %w[address port domain username password authentication starttls_auto]
50
+ smtp: %w[address port domain username password authentication openssl_verify_mode
51
+ starttls_auto tls]
51
52
  },
52
53
  ssh: %w[hostname port url username],
53
54
  web: %w[authority hostname path port scheme url userinfo]
@@ -3,7 +3,6 @@
3
3
  require 'avm/instances/base'
4
4
  require 'avm/self/docker_image'
5
5
  require 'avm/self/instance/entry_keys'
6
- require 'avm/eac_ubuntu_base0/docker_image'
7
6
 
8
7
  module Avm
9
8
  module Self
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/instances/application'
4
+ require 'avm/instances/base'
5
+
6
+ module Avm
7
+ module Sources
8
+ class Base
9
+ module Instance
10
+ DEFAULT_INSTANCE_SUFFIX = 'dev'
11
+
12
+ def instance_suffix
13
+ DEFAULT_INSTANCE_SUFFIX
14
+ end
15
+
16
+ private
17
+
18
+ def application_uncached
19
+ ::Avm::Instances::Application.new(path.basename)
20
+ end
21
+
22
+ def instance_uncached
23
+ ::Avm::Instances::Base.new(application, DEFAULT_INSTANCE_SUFFIX)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Avm
4
- VERSION = '0.15.0'
4
+ VERSION = '0.17.0'
5
5
  end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacPostgresqlBase0
7
+ class Instance
8
+ class Assert
9
+ common_constructor :instance
10
+ delegate :name, :password, :user, to: :instance
11
+
12
+ def perform
13
+ create_user unless user_exist?
14
+ change_password unless password_ok?
15
+ create_database unless database_exist?
16
+ change_owner unless user_owner?
17
+ end
18
+
19
+ def change_owner
20
+ root_execute("ALTER DaTABASE \"#{name}\" OWNER TO \"#{user}\"")
21
+ end
22
+
23
+ def change_password
24
+ root_execute("ALTER USER \"#{user}\" WITH PASSWORD '#{password}'")
25
+ end
26
+
27
+ def create_user
28
+ root_execute("CREATE USER \"#{user}\" WITH PASSWORD '#{password}'")
29
+ end
30
+
31
+ def current_owner
32
+ root_query(<<~SQL
33
+ SELECT pg_catalog.pg_get_userbyid(datdba)
34
+ FROM pg_catalog.pg_database
35
+ WHERE datname = '#{name}'
36
+ SQL
37
+ )
38
+ end
39
+
40
+ def database_exist?
41
+ root_boolean_query("FROM pg_database WHERE datname='#{name}'")
42
+ end
43
+
44
+ def password_ok?
45
+ instance.psql_command_command('SELECT 1', false)
46
+ .execute!(exit_outputs: { 512 => 'login_failed' }).strip == '1'
47
+ end
48
+
49
+ def user_exist?
50
+ root_boolean_query("FROM pg_roles WHERE rolname='#{user}'")
51
+ end
52
+
53
+ def user_owner?
54
+ user == current_owner
55
+ end
56
+
57
+ def create_database
58
+ root_execute("CREATE DATABASE \"#{name}\" WITH OWNER \"#{user}\"")
59
+ end
60
+
61
+ private
62
+
63
+ def root_boolean_query(sql_after_projection)
64
+ root_query("SELECT 1 #{sql_after_projection}") == '1'
65
+ end
66
+
67
+ def root_execute(sql)
68
+ instance.root_psql_command(sql).execute!
69
+ end
70
+
71
+ def root_query(sql)
72
+ root_execute(sql).strip
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -1,13 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/eac_postgresql_base0/instance/data_unit'
4
+ require 'eac_ruby_utils/core_ext'
4
5
 
5
6
  module Avm
6
7
  module EacPostgresqlBase0
7
8
  class Instance
8
- def initialize(env, connection_params)
9
- @env = env
10
- @connection_params = connection_params.with_indifferent_access
9
+ require_sub __FILE__
10
+
11
+ MAINTENANCE_DATABASE = 'postgres'
12
+
13
+ common_constructor :env, :connection_params do
14
+ self.connection_params = connection_params.with_indifferent_access
15
+ end
16
+
17
+ def assert
18
+ ::Avm::EacPostgresqlBase0::Instance::Assert.new(self).perform
11
19
  end
12
20
 
13
21
  def data_unit
@@ -23,20 +31,23 @@ module Avm
23
31
  dump_command.append(['@ESC_|', 'gzip', '-9', '-c'])
24
32
  end
25
33
 
26
- def psql_command
27
- env.command("@ESC_PGPASSWORD=#{password}", 'psql', *common_command_args)
34
+ def psql_command(database = true)
35
+ env.command("@ESC_PGPASSWORD=#{password}", 'psql', *common_command_args(database))
28
36
  end
29
37
 
30
- def psql_command_command(sql)
31
- psql_command.append(['--quiet', '--tuples-only', '--command', sql])
38
+ def psql_command_command(sql, database = true)
39
+ psql_command(database).append(['--quiet', '--tuples-only', '--command', sql])
32
40
  end
33
41
 
34
- private
35
-
36
- attr_reader :env, :connection_params
42
+ def root_psql_command(sql = nil)
43
+ args = ['sudo', '-u', 'postgres', 'psql']
44
+ args += ['--quiet', '--tuples-only', '--command', sql] if sql.present?
45
+ env.command(*args)
46
+ end
37
47
 
38
- def common_command_args
39
- ['--host', host, '--username', user, '--port', port, name]
48
+ def common_command_args(database = true)
49
+ ['--host', host, '--username', user, '--port', port,
50
+ (database ? name : MAINTENANCE_DATABASE)]
40
51
  end
41
52
 
42
53
  def host
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacPostgresqlBase0
5
- VERSION = '0.1.0'
5
+ VERSION = '0.2.0'
6
6
  end
7
7
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.files = Dir['{lib,template}/**/*']
14
14
 
15
- s.add_dependency 'avm-eac_rails_base1', '~> 0.1', '>= 0.1.3'
15
+ s.add_dependency 'avm-eac_rails_base1', '~> 0.2'
16
16
  s.add_dependency 'eac_ruby_utils', '~> 0.80', '>= 0.80.2'
17
17
 
18
18
  s.add_development_dependency 'eac_ruby_gem_support', '~> 0.4'
@@ -18,7 +18,7 @@ module Avm
18
18
 
19
19
  def assert_database
20
20
  infom 'Asserting database...'
21
- instance.rake('db:create').system!
21
+ instance.pg.assert
22
22
  end
23
23
 
24
24
  def bundle_install
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacRailsBase0
5
- VERSION = '0.1.3'
5
+ VERSION = '0.3.0'
6
6
  end
7
7
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.files = Dir['{lib}/**/*']
14
14
 
15
- s.add_dependency 'avm-eac_webapp_base0', '~> 0.2', '>= 0.2.1'
15
+ s.add_dependency 'avm-eac_webapp_base0', '~> 0.3'
16
16
  s.add_dependency 'eac_ruby_gems_utils', '~> 0.9', '>= 0.9.9'
17
17
  s.add_dependency 'eac_ruby_utils', '~> 0.68'
18
18
 
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_rails_base1/systemd_unit'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module EacRailsBase1
8
+ class Runner < ::Avm::EacWebappBase0::Runner
9
+ class TasksScheduler
10
+ class SystemdUnit
11
+ DEFAULT_RESTART = 'on-failure'
12
+
13
+ runner_with :help do
14
+ desc 'Configure Systemd unit for instace\'s tasks scheduler daemon (Reference: ' \
15
+ 'https://www.freedesktop.org/software/systemd/man/systemd.service.html).'
16
+ bool_opt '-e', '--exec-run', 'Run daemon with "run" instead of "start"/"stop".'
17
+ arg_opt '-r', '--restart', 'Value for systemd.service, Restart=.',
18
+ default: DEFAULT_RESTART
19
+ end
20
+
21
+ delegate :restart, to: :parsed
22
+
23
+ def run
24
+ if result.error?
25
+ fatal_error result.to_s
26
+ else
27
+ infov 'Result', result.label
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def systemd_unit_uncached
34
+ ::Avm::EacRailsBase1::SystemdUnit.new(runner_context.call(:instance),
35
+ restart: parsed.restart,
36
+ exec_run: parsed.exec_run?)
37
+ end
38
+
39
+ def result_uncached
40
+ systemd_unit.run
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacRailsBase1
7
+ class Runner < ::Avm::EacWebappBase0::Runner
8
+ class TasksScheduler
9
+ require_sub __FILE__
10
+
11
+ runner_with :help, :subcommands do
12
+ subcommands
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacRailsBase1
7
+ class SystemdUnit
8
+ module Service
9
+ def service_content
10
+ template.child('tasks_scheduler.service').apply(variables_source)
11
+ end
12
+
13
+ def service_exec_lines
14
+ service_exec_operations
15
+ .map { |k, v| "#{k}=#{tasks_scheduler_command_path} #{v}" }
16
+ .join("\n")
17
+ end
18
+
19
+ def service_path
20
+ ::Pathname.new('/etc/systemd/system').join(unit_name)
21
+ end
22
+
23
+ def service_link_path
24
+ ::Pathname.new('/etc/systemd/system/multi-user.target.wants').join(unit_name)
25
+ end
26
+
27
+ def verify_service
28
+ sudo_system!('systemd-analyze', 'verify', service_path)
29
+ end
30
+
31
+ private
32
+
33
+ def enable_service
34
+ systemctl('enable', unit_name)
35
+ end
36
+
37
+ def link_service
38
+ sudo_execute!('rm', '-f', service_link_path)
39
+ sudo_execute!('ln', '-s', service_path, service_link_path)
40
+ end
41
+
42
+ def reload_systemd
43
+ systemctl('daemon-reload')
44
+ end
45
+
46
+ # @return [Hash<String, String>]
47
+ def service_exec_operations
48
+ if exec_run?
49
+ { 'ExecStart' => 'run' }
50
+ else
51
+ { 'ExecStart' => 'start', 'ExecStop' => 'stop' }
52
+ end
53
+ end
54
+
55
+ def start_service
56
+ systemctl('start', unit_name)
57
+ end
58
+
59
+ def systemctl(*args)
60
+ sudo_system!('systemctl', *args)
61
+ end
62
+
63
+ def write_service
64
+ infom 'Writing service\'s unit file...'
65
+ platform_instance.file_sudo_write(service_path, service_content)
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacRailsBase1
7
+ class SystemdUnit
8
+ module TasksSchedulerCommand
9
+ def tasks_scheduler_command_content
10
+ template.child('tasks_scheduler_command.sh').apply(variables_source)
11
+ end
12
+
13
+ def tasks_scheduler_command_path
14
+ "/opt/aux/#{instance.id}/tasks_scheduler.sh"
15
+ end
16
+
17
+ private
18
+
19
+ def write_tasks_scheduler_command
20
+ infom 'Writing tasks scheduler\'s command...'
21
+ sudo_execute!('mkdir', '-p', ::File.dirname(tasks_scheduler_command_path))
22
+ platform_instance.file_sudo_write(tasks_scheduler_command_path,
23
+ tasks_scheduler_command_content)
24
+ sudo_execute!('chmod', '+x', tasks_scheduler_command_path)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/jobs/base'
4
+ require 'avm/eac_ubuntu_base0/apache'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avm
8
+ module EacRailsBase1
9
+ class SystemdUnit
10
+ JOBS = %w[write_tasks_scheduler_command write_service link_service verify_service
11
+ reload_systemd enable_service start_service].freeze
12
+
13
+ include ::Avm::Jobs::Base
14
+ require_sub __FILE__, include_modules: true
15
+ delegate :platform_instance, to: :instance
16
+
17
+ enable_listable
18
+ lists.add_symbol :option, :exec_run, :restart
19
+
20
+ def description
21
+ "#{instance.id} Tasks Scheduler"
22
+ end
23
+
24
+ def exec_run?
25
+ options[OPTION_EXEC_RUN]
26
+ end
27
+
28
+ def option_list
29
+ self.class.lists.option
30
+ end
31
+
32
+ def restart
33
+ options[OPTION_RESTART]
34
+ end
35
+
36
+ def unit_name
37
+ "#{instance.id}_tasks_scheduler.service"
38
+ end
39
+
40
+ def user
41
+ instance.ssh_username
42
+ end
43
+
44
+ private
45
+
46
+ def sudo_execute!(*args)
47
+ platform_instance.host_env.command(['sudo'] + args).execute!
48
+ end
49
+
50
+ def sudo_system!(*args)
51
+ command_args = ['sudo'] + args
52
+ infom "Running \"#{::Shellwords.join(command_args)}\"..."
53
+ platform_instance.host_env.command(command_args).system!
54
+ end
55
+ end
56
+ end
57
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacRailsBase1
5
- VERSION = '0.1.4'
5
+ VERSION = '0.2.0'
6
6
  end
7
7
  end
@@ -0,0 +1,12 @@
1
+ [Unit]
2
+ Description='%%description%%'
3
+ After=postgresql.service
4
+
5
+ [Service]
6
+ Type=forking
7
+ %%service_exec_lines%%
8
+ Restart=%%restart%%
9
+ User=%%user%%
10
+
11
+ [Install]
12
+ WantedBy=multi-user.target
@@ -0,0 +1,6 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ source "$HOME/.rvm/scripts/rvm"
6
+ ( cd '%%fs_path%%'; bundle exec tasks_scheduler "$@" )
@@ -12,10 +12,11 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.files = Dir['{lib,template}/**/*']
14
14
 
15
- s.add_dependency 'avm-eac_rails_base1', '~> 0.1'
15
+ s.add_dependency 'avm-eac_rails_base1', '~> 0.2'
16
16
  s.add_dependency 'avm-eac_ubuntu_base0', '~> 0.2'
17
17
  s.add_dependency 'curb', '~> 0.9.10'
18
18
  s.add_dependency 'eac_fs', '~> 0.4'
19
+ s.add_dependency 'eac_rest', '~> 0.4'
19
20
  s.add_dependency 'eac_ruby_utils', '~> 0.68'
20
21
 
21
22
  s.add_development_dependency 'eac_ruby_gem_support', '~> 0.4'
@@ -10,11 +10,13 @@ module Avm
10
10
  class DataUnit < ::Avm::Data::Instance::Unit
11
11
  common_constructor :instance
12
12
 
13
+ EXPORT_PATH = '/backup/export'
13
14
  EXTENSION = '.tar'
15
+ IMPORT_PATH = '/backup/import.json'
14
16
 
15
17
  def do_dump(data_path)
16
18
  ::File.open(data_path, 'wb') do |file|
17
- file << URI.parse(export_url).read
19
+ file << export_request.response.body_data_or_raise
18
20
  end
19
21
  end
20
22
 
@@ -37,18 +39,12 @@ module Avm
37
39
  true
38
40
  end
39
41
 
40
- def export_url
41
- url('/backup/export')
42
+ def export_request
43
+ instance.rest_api.request(EXPORT_PATH)
42
44
  end
43
45
 
44
46
  def import_url
45
- url('/backup/import.json')
46
- end
47
-
48
- def url(path)
49
- uri = ::Addressable::URI.parse(instance.read_entry('web.url')) + path
50
- uri.query_values = { key: instance.read_entry('admin.api_key') }
51
- uri.to_s
47
+ instance.rest_api.build_service_url(IMPORT_PATH).to_s
52
48
  end
53
49
  end
54
50
  end
@@ -1,13 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'addressable/uri'
3
4
  require 'avm/eac_redmine_base0/data_unit'
4
5
  require 'avm/eac_redmine_base0/instances/docker_image'
6
+ require 'avm/eac_redmine_base0/rest_api'
5
7
  require 'avm/eac_webapp_base0/instance'
6
8
  require 'avm/eac_rails_base1/instance'
7
9
 
8
10
  module Avm
9
11
  module EacRedmineBase0
10
12
  class Instance < ::Avm::EacRailsBase1::Instance
13
+ enable_simple_cache
14
+
11
15
  FILES_UNITS = { files: 'files' }.freeze
12
16
 
13
17
  def docker_image_class
@@ -32,6 +36,22 @@ module Avm
32
36
  }
33
37
  )
34
38
  end
39
+
40
+ # @return [Addressable::URI]
41
+ def root_url
42
+ r = ::Addressable::URI.parse(read_entry(::Avm::Instances::EntryKeys::WEB_URL))
43
+ r.query_values = nil
44
+ r
45
+ end
46
+
47
+ private
48
+
49
+ # @return [Avm::EacRedmineBase0::RestApi]
50
+ def rest_api_uncached
51
+ url = root_url
52
+ url.query_values = { key: read_entry('api.key') }
53
+ ::Avm::EacRedmineBase0::RestApi.new(url)
54
+ end
35
55
  end
36
56
  end
37
57
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_rest/api'
5
+
6
+ module Avm
7
+ module EacRedmineBase0
8
+ class RestApi < ::EacRest::Api
9
+ end
10
+ end
11
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacRedmineBase0
5
- VERSION = '0.3.1'
5
+ VERSION = '0.5.0'
6
6
  end
7
7
  end
@@ -18,9 +18,9 @@ export git_repositories_hierarchical_organisation=false
18
18
  export smtp_server='%%MAILER.SMTP.ADDRESS%%'
19
19
  export smtp_port='%%MAILER.SMTP.PORT%%'
20
20
  export smtp_domain='%%MAILER.SMTP.DOMAIN%%'
21
- export smtp_tls='%%MAILER_SMTP_TLS%%'
22
- export smtp_enable_starttls_auto='%%MAILER_SMTP_STARTTLS_AUTO%%'
23
- export smtp_openssl_verify_mode='%%MAILER_SMTP_OPENSSL_VERIFY_MODE%%'
21
+ export smtp_tls='%%MAILER.SMTP.TLS%%'
22
+ export smtp_enable_starttls_auto='%%MAILER.SMTP.STARTTLS_AUTO%%'
23
+ export smtp_openssl_verify_mode='%%MAILER.SMTP.OPENSSL_VERIFY_MODE%%'
24
24
  export smtp_authentication='%%MAILER.SMTP.AUTHENTICATION%%'
25
25
  export smtp_username='%%MAILER.SMTP.USERNAME%%'
26
26
  export smtp_password='%%MAILER.SMTP.PASSWORD%%'