wco_hosting 0.0.0.20 → 0.0.0.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/README.txt +26 -0
  3. data/app/assets/stylesheets/wco_hosting/main.scss +8 -0
  4. data/app/controllers/wco_hosting/appliance_tmpls_controller.rb +117 -3
  5. data/app/controllers/wco_hosting/appliances_controller.rb +15 -0
  6. data/app/controllers/wco_hosting/environments_controller.rb +0 -0
  7. data/app/controllers/wco_hosting/files_controller.rb +61 -0
  8. data/app/controllers/wco_hosting/serverhosts_controller.rb +7 -0
  9. data/app/controllers/wco_hosting/task_tmpls_controller.rb +49 -0
  10. data/app/controllers/wco_hosting/tasks_controller.rb +38 -0
  11. data/app/views/wco_hosting/_main_header.haml +14 -1
  12. data/app/views/wco_hosting/appliance_tmpls/_form.haml +39 -9
  13. data/app/views/wco_hosting/appliance_tmpls/_header.haml +7 -0
  14. data/app/views/wco_hosting/appliance_tmpls/edit.haml +2 -1
  15. data/app/views/wco_hosting/appliance_tmpls/index.haml +2 -4
  16. data/app/views/wco_hosting/appliance_tmpls/show.haml +9 -0
  17. data/app/views/wco_hosting/appliances/_form.haml +11 -0
  18. data/app/views/wco_hosting/appliances/index.haml +5 -3
  19. data/app/views/wco_hosting/appliances/new.haml +7 -0
  20. data/app/views/wco_hosting/appliances/show.haml +36 -14
  21. data/app/views/wco_hosting/files/_form.haml +18 -0
  22. data/app/views/wco_hosting/files/_table.haml +13 -0
  23. data/app/views/wco_hosting/files/edit.haml +9 -0
  24. data/app/views/wco_hosting/files/index.haml +6 -0
  25. data/app/views/wco_hosting/files/new.haml +5 -0
  26. data/app/views/wco_hosting/files/show.haml +11 -0
  27. data/app/views/wco_hosting/serverhosts/index.haml +1 -1
  28. data/app/views/wco_hosting/serverhosts/show.haml +14 -0
  29. data/app/views/wco_hosting/task_tmpls/_form.haml +8 -0
  30. data/app/views/wco_hosting/task_tmpls/index.haml +13 -0
  31. data/app/views/wco_hosting/task_tmpls/new.haml +2 -0
  32. data/app/views/wco_hosting/tasks/index.haml +6 -0
  33. data/config/routes.rb +11 -0
  34. metadata +21 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac6eb4fd2ae0707eebe481069a4cf6d26f7531c03705c9a9c4fb1f4790ed0414
4
- data.tar.gz: d54c3c68e27996aefad4ac0059d325f60a848968cc3c6bc128b1dd5c5d972b8c
3
+ metadata.gz: 9e55beb39ff6f9757777e7c9c3816152e461fd9c650c5a6f0e85717c3c0374af
4
+ data.tar.gz: 24ab8fc95d20316353140d76e655fbf65abf3a162be641e552ea0925a0b4eb91
5
5
  SHA512:
6
- metadata.gz: d955a2c7785c6f76e5606f55239b87a40064f55ead21f3fe7628d04fe5b7adc1e7933d8e2e442123355495ac1e5b13fc344eddd668ece086e860db98f1b67f12
7
- data.tar.gz: 63342f69a1a709338aa5401daec2e5117c2214c211c2d806b519c227be496a0662b562fab68ec2af3a3f2838dcf521eb74659b44f6561ac2964a800e907112d2
6
+ metadata.gz: ef58967b90d1ef1aa68404d4bf468c934f48edc9dc47639812197e24d06dcddfeb50676e49803aabc14ee45d0482eb0d38861d548ed0620b5175e71a8337b970
7
+ data.tar.gz: 5da64e84acca5cedbe1c0d1e0f66009f02c24327a3721f9fca75e79992e058bd00884167d8f2779e9b8afcd6215d48440b53a37477efb336385a87a785a601da
data/README.txt CHANGED
@@ -0,0 +1,26 @@
1
+
2
+
3
+
4
+ aws ecs execute-command \
5
+ --region us-east-2 \
6
+ --cluster fragile-cluster \
7
+ --task bb72734046164681bf4b2cec286c00c6 \
8
+ --container demmitv \
9
+ --command "/bin/bash" \
10
+ --interactive \
11
+ --profile ecs_driver_1
12
+
13
+ aws ecs describe-services \
14
+ --cluster fragile-cluster \
15
+ --services demmitv \
16
+ --profile ecs_driver_1
17
+
18
+ aws ecs list-tasks \
19
+ --cluster fragile-cluster \
20
+ --service demmitv \
21
+ --profile ecs_driver_1
22
+
23
+ aws ecs describe-tasks --cluster fragile-cluster \
24
+ --tasks arn:aws:ecs:us-east-2:831556125887:task/fragile-cluster/6653805b531c463eb6e6e9d13424ae93 \
25
+ --profile ecs_driver_1
26
+
@@ -20,3 +20,11 @@ table.bordered {
20
20
  .flex-row {
21
21
  display: flex;
22
22
  }
23
+
24
+ .Logs {
25
+ .descr {
26
+ max-height: 300px;
27
+ overflow: auto;
28
+ }
29
+ }
30
+
@@ -3,6 +3,18 @@ class WcoHosting::ApplianceTmplsController < WcoHosting::ApplicationController
3
3
 
4
4
  before_action :set_lists
5
5
 
6
+ def add_task_tmpl
7
+ @appliance_tmpl = WcoHosting::ApplianceTmpl.find params[:id]
8
+ authorize! :edit, @appliance_tmpl
9
+ @appliance_tmpl.task_tmpls.push WcoHosting::TaskTmpl.find( params[:task_tmpl_id] )
10
+ if @appliance_tmpl.save
11
+ flash_notice @appliance_tmpl
12
+ else
13
+ flash_alert @appliance_tmpl
14
+ end
15
+ redirect_to request.referrer
16
+ end
17
+
6
18
  def create
7
19
  # params[:tmpl][:leadset_ids].delete ''
8
20
 
@@ -12,11 +24,11 @@ class WcoHosting::ApplianceTmplsController < WcoHosting::ApplicationController
12
24
  flag = @appliance_tmpl.save
13
25
  if flag
14
26
  flash[:notice] = 'Success.'
15
- redirect_to action: :index
16
27
  else
17
28
  flash[:alert] = "Cannot create appliance tmplate: #{@appliance_tmpl.errors.full_messages.join(', ')}."
18
- redirect_to action: :index
19
29
  end
30
+
31
+ redirect_to appliance_tmpls_path
20
32
  end
21
33
 
22
34
  def destroy
@@ -32,13 +44,16 @@ class WcoHosting::ApplianceTmplsController < WcoHosting::ApplicationController
32
44
  end
33
45
 
34
46
  def edit
35
- @appliance_tmpl = WcoHosting::ApplianceTmpl.find params[:id]
47
+ @appliance_tmpl = WcoHosting::ApplianceTmpl.unscoped.find params[:id]
36
48
  authorize! :edit, @appliance_tmpl
37
49
  end
38
50
 
39
51
  def index
40
52
  authorize! :index, WcoHosting::ApplianceTmpl
41
53
  @appliance_tmpls = WcoHosting::ApplianceTmpl.all
54
+ if params[:deleted]
55
+ @appliance_tmpls = WcoHosting::ApplianceTmpl.unscoped.deleted
56
+ end
42
57
  end
43
58
 
44
59
  def new
@@ -46,6 +61,104 @@ class WcoHosting::ApplianceTmplsController < WcoHosting::ApplicationController
46
61
  @appliance_tmpl = WcoHosting::ApplianceTmpl.new
47
62
  end
48
63
 
64
+ def run_task
65
+ @appliance_tmpl = WcoHosting::ApplianceTmpl.find params[:id]
66
+ @tmpl = @appliance_tmpl
67
+ authorize! :run_task, @appliance_tmpl
68
+
69
+ @appliance = WcoHosting::Appliance.where( id: params[:appliance_id] ).first
70
+ rc_json = JSON.parse @appliance.rc_json
71
+
72
+ case params[:task]
73
+ when WcoHosting::Runner::TASK_REDEPLOY_ECS_TASK_DEFINITION
74
+
75
+ template = ERB.new( @appliance_tmpl.ecs_task_definition_erb )
76
+ file = Tempfile.new('prefix')
77
+ rendered_str = template.result(binding)
78
+ puts! rendered_str, 'rendered_str'
79
+ file.write rendered_str
80
+ file.close
81
+ out = WcoHosting::Runner.do_exec <<~AOL
82
+ aws ecs register-task-definition \
83
+ --cli-input-json file:///#{file.path} \
84
+ --profile ecs_driver_1
85
+ AOL
86
+
87
+ if out[:stdout].present?
88
+ Wco::Log.puts! out[:stdout], 'stdout', obj: @appliance_tmpl
89
+ end
90
+ if out[:stderr].present?
91
+ Wco::Log.puts! out[:stderr], 'stderr', obj: @appliance_tmpl
92
+ end
93
+
94
+ when WcoHosting::Runner::TASK_REDEPLOY_ECS_TASK
95
+
96
+ out = WcoHosting::Runner.do_exec <<~AOL
97
+ aws ecs update-service --service #{@appliance_tmpl.kind} \
98
+ --task-definition #{@appliance_tmpl.kind} \
99
+ --cluster fragile-cluster \
100
+ --enable-execute-command \
101
+ --force-new-deployment \
102
+ --profile ecs_driver_1
103
+ AOL
104
+
105
+ if out[:stdout].present?
106
+ Wco::Log.puts! out[:stdout], 'stdout', obj: @appliance
107
+ end
108
+ if out[:stderr].present?
109
+ Wco::Log.puts! out[:stderr], 'stderr', obj: @appliance
110
+ end
111
+
112
+ when WcoHosting::Runner::TASK_SYNC_ECS_TASK
113
+
114
+ out = WcoHosting::Runner.do_exec <<~AOL
115
+ aws ecs list-tasks \
116
+ --cluster fragile-cluster \
117
+ --service #{@appliance_tmpl.kind} \
118
+ --profile ecs_driver_1
119
+ AOL
120
+ out = JSON.parse out[:stdout]
121
+ task_id = out['taskArns'][0].split('/').last
122
+ puts! task_id, 'task_id'
123
+ rc_json[:task_id] = task_id
124
+
125
+ out = WcoHosting::Runner.do_exec <<~AOL
126
+ aws ecs describe-tasks --cluster fragile-cluster \
127
+ --tasks arn:aws:ecs:us-east-2:831556125887:task/fragile-cluster/#{task_id} \
128
+ --profile ecs_driver_1
129
+ AOL
130
+ out = JSON.parse out[:stdout]
131
+ eni_id = out['tasks'][0]['attachments'][0]['details'].select { |d|
132
+ d['name'] == 'networkInterfaceId'
133
+ }[0]['value']
134
+ puts! eni_id, 'eni_id'
135
+ rc_json[:eni_id] = eni_id
136
+
137
+ out = WcoHosting::Runner.do_exec <<~AOL
138
+ aws ec2 describe-network-interfaces \
139
+ --network-interface-id #{eni_id} \
140
+ --profile ecs_driver_1
141
+ AOL
142
+ out = JSON.parse out[:stdout]
143
+ public_ip = out['NetworkInterfaces'][0]['Association']['PublicIp']
144
+ puts! public_ip, 'public_ip'
145
+ rc_json[:public_ip] = public_ip
146
+ rc_json[:ip_addr] = out['NetworkInterfaces'][0]['PrivateIpAddress']
147
+
148
+ @appliance.update({ rc_json: rc_json })
149
+
150
+ end
151
+
152
+
153
+ flash[:notice] = "Status: #{out[:status]}"
154
+ redirect_to request.referrer
155
+ end
156
+
157
+ def show
158
+ @appliance_tmpl = WcoHosting::ApplianceTmpl.find params[:id]
159
+ authorize! :show, @appliance_tmpl
160
+ end
161
+
49
162
  def update
50
163
  # params[:tmpl][:leadset_ids].delete ''
51
164
 
@@ -77,6 +190,7 @@ class WcoHosting::ApplianceTmplsController < WcoHosting::ApplicationController
77
190
  @leadsets = Wco::Leadset.all
78
191
  @leadsets_list = Wco::Leadset.list
79
192
  @new_appliance_tmpl = WcoHosting::ApplianceTmpl.new
193
+ @task_tmpls_list = WcoHosting::TaskTmpl.list
80
194
  # @profiles_list = Wco::Profile.list
81
195
  end
82
196
 
@@ -11,6 +11,11 @@ class WcoHosting::AppliancesController < WcoHosting::ApplicationController
11
11
  authorize! :edit, @appliance
12
12
  end
13
13
 
14
+ def new
15
+
16
+ authorize! :new, @new_appliance
17
+ end
18
+
14
19
  def show
15
20
  @appliance = WcoHosting::Appliance.find params[:id]
16
21
  authorize! :show, @appliance
@@ -27,5 +32,15 @@ class WcoHosting::AppliancesController < WcoHosting::ApplicationController
27
32
  # redirect_to action: :index
28
33
  # end
29
34
 
35
+ ##
36
+ ## private
37
+ ##
38
+ private
39
+
40
+ def set_lists
41
+ @appliance_tmpls_list = WcoHosting::ApplianceTmpl.list
42
+ @environments_list = WcoHosting::Environment.list
43
+ @new_appliance = WcoHosting::Appliance.new
44
+ end
30
45
 
31
46
  end
@@ -0,0 +1,61 @@
1
+
2
+ class WcoHosting::FilesController < WcoHosting::ApplicationController
3
+
4
+ def create
5
+ @file = WcoHosting::File.new params[:file].permit!
6
+ authorize! :create, @file
7
+
8
+ flag = @file.save
9
+ if flag
10
+ flash[:notice] = 'Success.'
11
+ redirect_to action: :index
12
+ else
13
+ flash[:alert] = "Cannot create file: #{@file.errors.full_messages.join(', ')}."
14
+ render action: :index
15
+ end
16
+ end
17
+
18
+ def edit
19
+ @file = WcoHosting::File.find params[:id]
20
+ authorize! :edit, @file
21
+
22
+ @serverhost = @file.serverhost
23
+ end
24
+
25
+ def index
26
+ authorize! :index, WcoHosting::File
27
+ @files = WcoHosting::File.all
28
+ @new_file = WcoHosting::File.new
29
+ end
30
+
31
+ def new
32
+ authorize! :index, WcoHosting::File
33
+ @new_file = WcoHosting::File.new
34
+ end
35
+
36
+ def show
37
+ @file = WcoHosting::File.find params[:id]
38
+ authorize! :show, @file
39
+ end
40
+
41
+ def update
42
+ @file = WcoHosting::File.find params[:id]
43
+ authorize! :update, @file
44
+ if @file.update_attributes( params[:file].permit! )
45
+ flash_notice @file
46
+ else
47
+ flash_alert @file
48
+ end
49
+ redirect_to request.referrer
50
+ end
51
+
52
+ ##
53
+ ## private
54
+ ##
55
+ private
56
+
57
+ def set_lists
58
+ @appliances_list = WcoHosting::Appliance.list
59
+ end
60
+
61
+ end
@@ -31,6 +31,13 @@ class WcoHosting::ServerhostsController < WcoHosting::ApplicationController
31
31
  @new_serverhost = WcoHosting::Serverhost.new
32
32
  end
33
33
 
34
+ def show
35
+ @serverhost = WcoHosting::Serverhost.find params[:id]
36
+ authorize! :show, @serverhost
37
+
38
+ @files = @serverhost.files
39
+ end
40
+
34
41
  def update
35
42
  @serverhost = WcoHosting::Serverhost.find params[:id]
36
43
  authorize! :update, @serverhost
@@ -0,0 +1,49 @@
1
+
2
+ class WcoHosting::TaskTmplsController < WcoHosting::ApplicationController
3
+
4
+ def create
5
+ @tmpl = WcoHosting::TaskTmpl.new params[:task_tmpl].permit!
6
+ authorize! :create, WcoHosting::TaskTmpl
7
+
8
+ if @tmpl.save
9
+ flash_notice @tmpl
10
+ else
11
+ flash_alert @tmpl
12
+ end
13
+
14
+ redirect_to request.referrer
15
+ end
16
+
17
+ def destroy
18
+ end
19
+
20
+ def edit
21
+ end
22
+
23
+ def index
24
+ authorize! :index, WcoHosting::TaskTmpl
25
+ @task_tmpls = WcoHosting::TaskTmpl.all
26
+ end
27
+
28
+ def new
29
+ authorize! :new, WcoHosting::TaskTmpl
30
+
31
+ end
32
+
33
+ def show
34
+ end
35
+
36
+ def update
37
+ end
38
+
39
+ ##
40
+ ## private
41
+ ##
42
+ private
43
+
44
+ def set_lists
45
+ @new_task_tmpl = WcoHosting::TaskTmpl.new
46
+ end
47
+
48
+ end
49
+
@@ -0,0 +1,38 @@
1
+
2
+ class WcoHosting::TasksController < WcoHosting::ApplicationController
3
+
4
+ def create
5
+ end
6
+
7
+ def destroy
8
+ end
9
+
10
+ def edit
11
+ end
12
+
13
+ def index
14
+ authorize! :index, WcoHosting::Task
15
+ end
16
+
17
+ def new
18
+ authorize! :new, WcoHosting::Task
19
+
20
+ end
21
+
22
+ def show
23
+ end
24
+
25
+ def update
26
+ end
27
+
28
+ ##
29
+ ## private
30
+ ##
31
+ private
32
+
33
+ def set_lists
34
+ @new_task_ = WcoHosting::Task.new
35
+ end
36
+
37
+ end
38
+
@@ -5,8 +5,21 @@
5
5
  Wco Hosting
6
6
  .flex-row
7
7
  %ul
8
- %li= link_to 'ApplianceTmpl`s', appliance_tmpls_path
8
+ %li
9
+ = render '/wco_hosting/appliance_tmpls/header'
9
10
  %li= link_to 'Appliances', appliances_path
11
+ %li
12
+ = link_to 'Environments', environments_path
13
+ &nbsp;
14
+ = link_to '[+]', new_environment_path
15
+ %li
16
+ = link_to 'Task Tmpls', task_tmpls_path
17
+ &nbsp;
18
+ = link_to '[+]', new_task_tmpl_path
19
+ %li
20
+ = link_to 'Tasks/Agents', tasks_path
21
+ &nbsp;
22
+ = link_to '[+]', new_task_path
10
23
  %li= link_to 'Domains', domains_path
11
24
  %li= link_to 'Serverhosts', serverhosts_path
12
25
 
@@ -2,23 +2,53 @@
2
2
  - url = appliance_tmpl.new_record? ? appliance_tmpls_path : appliance_tmpl_path( appliance_tmpl )
3
3
 
4
4
  .appliance-tmpls--form
5
+ .row
6
+ .col-md-6
7
+ &nbsp;
8
+ .col-md-6
9
+ .field
10
+ %label Depends on
11
+ - appliance_tmpl.task_tmpls.each do |task_tmpl|
12
+ .a
13
+ = link_to task_tmpl, task_tmpl_path(task_tmpl)
14
+ = link_to '[~]', edit_task_tmpl_path(task_tmpl)
15
+ -# .gray.mini= task_tmpl.inspect
16
+ = form_tag add_appliance_tmpl_task_tmpl_path do
17
+ = hidden_field_tag :id, appliance_tmpl.id
18
+ = select_tag :task_tmpl_id, options_for_select(@task_tmpls_list), class: 'select2'
19
+ = submit_tag 'Add'
20
+
5
21
  = form_for appliance_tmpl, as: :tmpl, url: url do |f|
6
22
  .actions
7
- = f.submit 'Submit'
23
+ = f.submit 'Go'
8
24
  .d-flex
9
- = f.label :kind
25
+ %label kind (name)
10
26
  = f.text_field :kind, style: 'flex-grow: 1'
11
-
12
- = f.label :version
27
+ %label version
13
28
  = f.text_field :version
29
+ .row
30
+ .col-md-6
31
+ .field
32
+ = f.label :descr
33
+ = f.text_area :descr
14
34
  .field
15
- = f.label :descr
16
- = f.text_area :descr
35
+ %label :ecs_task_definition_erb
36
+ = f.text_area :ecs_task_definition_erb
37
+
38
+
17
39
  .field
18
40
  = f.label :image
19
41
  = f.text_field :image, class: 'w-100'
42
+
43
+ .field
44
+ %label volume_zip_url
45
+ = f.text_field :volume_zip_url, class: 'w-100'
46
+ .field
47
+ %label volume_zip_exe
48
+ = f.text_field :volume_zip_exe, class: 'w-100'
49
+
20
50
  .field
21
- %label volume_zip
22
- = f.text_field :volume_zip, class: 'w-100'
51
+ %label deleted_at
52
+ = f.text_field :deleted_at
23
53
  .actions
24
- = f.submit 'Submit'
54
+ = f.submit 'Go'
@@ -0,0 +1,7 @@
1
+
2
+ .header
3
+ .title
4
+ = link_to "ApplianceTmpl's", appliance_tmpls_path
5
+ = link_to '[del]', deleted_appliance_tmpls_path
6
+ = link_to '[+]', new_appliance_tmpl_path
7
+
@@ -1,6 +1,7 @@
1
1
 
2
2
  .appliance-tmpls-edit.maxwidth
3
- %h5 Edit ApplianceTmpl `#{@appliance_tmpl}`
3
+ %h5
4
+ Edit ApplianceTmpl `#{link_to @appliance_tmpl, appliance_tmpl_path(@appliance_tmpl)}`&nbsp;
4
5
 
5
6
 
6
7
 
@@ -1,8 +1,6 @@
1
1
 
2
2
  .appliance-tmpls-index.maxwidth
3
- %h5
4
- ApplianceTmpl's
5
- = link_to '[+]', new_appliance_tmpl_path
3
+ = render '/wco_hosting/appliance_tmpls/header'
6
4
 
7
5
  %table.bordered
8
6
  %tr
@@ -19,7 +17,7 @@
19
17
  .d-flex
20
18
  = link_to '[~]', edit_appliance_tmpl_path(tmpl)
21
19
  = button_to 'x', appliance_tmpl_path(tmpl), method: :delete, data: { confirm: 'Are you sure?' }
22
- %td= tmpl.kind
20
+ %td= link_to tmpl.kind, appliance_tmpl_path(tmpl)
23
21
  %td= tmpl.version
24
22
  %td= tmpl.image
25
23
  %td= tmpl.volume_zip
@@ -0,0 +1,9 @@
1
+
2
+ .appliance_tmpls-show.maxwidth
3
+ .header
4
+ %h5.title
5
+ Viewing `#{@appliance_tmpl.kind}`&nbsp;
6
+ = link_to '[~]', edit_appliance_tmpl_path(@appliance_tmpl)
7
+
8
+ %ul
9
+ %li= button_to 'redeply ecs task definition', appliance_tmpl_run_task_path(@appliance_tmpl.id, WcoHosting::Runner::TASK_REDEPLOY_ECS_TASK_DEFINITION ), data: { confirm: 'Are you sure?' }
@@ -0,0 +1,11 @@
1
+
2
+ .appliances--form
3
+ = form_for appliance do |f|
4
+ .d-flex
5
+ %label tmpl
6
+ = f.select :appliance_tmpl_id, options_for_select( @appliance_tmpls_list, selected: appliance.appliance_tmpl_id ), {}, { class: 'select2' }
7
+ .d-flex
8
+ %label environment
9
+ = f.select :environment_id, options_for_select( @environments_list, selected: appliance.environment_id ), {}, { class: 'select2' }
10
+ .actions
11
+ = f.submit 'Go'
@@ -1,6 +1,8 @@
1
1
 
2
2
  .appliances-index.maxwidth
3
- %h5 Appliances
3
+ %h5
4
+ Appliances
5
+ = link_to '[+]', new_appliance_path
4
6
 
5
7
  %table.bordered.data-table
6
8
  %thead
@@ -8,7 +10,7 @@
8
10
  %td created_at
9
11
  %td tmpl
10
12
  %td host
11
- %td service_name
13
+ -# %td service_name
12
14
  %td port
13
15
 
14
16
  - @appliances.each do |app|
@@ -21,7 +23,7 @@
21
23
  = app.created_at
22
24
  %td= app.tmpl
23
25
  %td= app.host
24
- %td= app.service_name
26
+ -# %td= app.service_name
25
27
  %td= app.port
26
28
 
27
29
 
@@ -0,0 +1,7 @@
1
+
2
+ .appliances-new.maxwidth
3
+ .header
4
+ %h5.title
5
+ New Appliance
6
+
7
+ = render 'form', appliance: @new_appliance
@@ -1,27 +1,49 @@
1
1
 
2
2
  .appliances-edit.maxwidth
3
- %h5 Appliance `#{@appliance}`
3
+ .header
4
+ %h5.title
5
+ Appliance `#{@appliance}`&nbsp;
6
+ = link_to '[~]', edit_appliance_path(@appliance)
4
7
 
5
- %ul
6
- %li
7
- %label.bold Leadset:
8
- = link_to @appliance.leadset, wco.leadset_path(@appliance.leadset)
9
- %li
10
- %label.bold Env:
11
- = @appliance.environment
12
- %li
13
- %label.bold Tmpl:
14
- = @appliance.appliance_tmpl
8
+ %ul
9
+ %li.d-flex
10
+ = button_to 'redeploy', appliance_tmpl_run_task_path(@appliance.tmpl.id, WcoHosting::Runner::TASK_REDEPLOY_ECS_TASK, appliance_id: @appliance.id ), data: { confirm: 'Are you sure?' }
11
+ .gray.mini WcoHosting::Runner::TASK_REDEPLOY_ECS_TASK
12
+ %li.d-flex
13
+ = button_to 'sync', appliance_tmpl_run_task_path(@appliance.tmpl.id, WcoHosting::Runner::TASK_SYNC_ECS_TASK, appliance_id: @appliance.id ), data: { confirm: 'Are you sure?' }
14
+ .gray.mini WcoHosting::Runner::TASK_SYNC_ECS_TASK
15
+
16
+ .row
17
+ .col-md-6
18
+ %ul
19
+ %li
20
+ %label.bold Leadset:
21
+ = link_to @appliance.leadset, wco.leadset_path(@appliance.leadset)
22
+ %li
23
+ %label.bold Env:
24
+ = link_to @appliance.environment, environment_path(@appliance.environment)
25
+ %li
26
+ %label.bold Tmpl:
27
+ = link_to @appliance.appliance_tmpl, appliance_tmpl_path(@appliance.tmpl)
28
+ .col-md-6
29
+ %h5 rc_json
30
+ .descr
31
+ %pre= JSON.pretty_generate( @appliance.rc_json )
15
32
 
16
- .logs
33
+ %hr
34
+ .Logs
17
35
  %h5 Logs
18
36
  %ul
19
37
  - @appliance.logs.each do |log|
20
38
  %li
21
- = log.created_at
22
- %b= log.label
39
+ .d-flex.collapse-expand{id: "log_#{log.id}" }
40
+ = log.created_at
41
+ &nbsp;
42
+ %b= log.label
23
43
  %pre.descr= log.message
24
44
 
45
+ %hr
46
+ %h5 inspect
25
47
  = @appliance.inspect
26
48
 
27
49
 
@@ -0,0 +1,18 @@
1
+
2
+ .files--form
3
+ = form_for file do |f|
4
+ = hidden_field_tag 'file[serverhost_id]', params[:serverhost_id] if params[:serverhost_id]
5
+
6
+ .field
7
+ %label Appliance
8
+ = f.select :appliance_id, options_for_select(@appliances_list, selected: file.appliance_id), class: 'select2'
9
+ .d-flex
10
+ = f.label :path
11
+ = f.text_field :path, class: 'flex-grow-1'
12
+
13
+ .field
14
+ = f.label :template_erb
15
+ = f.text_area :template_erb
16
+
17
+ .actions
18
+ = f.submit
@@ -0,0 +1,13 @@
1
+
2
+ .files--table
3
+ %table.bordered
4
+ %tr
5
+ %th name
6
+ -# %td &nbsp;
7
+ - files.each do |ser|
8
+ %tr
9
+ %td
10
+ = link_to '[~]', edit_file_path(ser)
11
+ = link_to ser.path, file_path(ser)
12
+ -# %td= ser.inspect
13
+
@@ -0,0 +1,9 @@
1
+
2
+ .files-edit.maxwidth
3
+ .header
4
+ %h5.title
5
+ .gray.mini Serverhost&nbsp;
6
+ = link_to @serverhost.name, serverhost_path(@serverhost)
7
+ .gray.mini &nbspFile&nbsp;
8
+ = @file.path
9
+ = render 'form', file: @file
@@ -0,0 +1,6 @@
1
+
2
+ .files-index.maxwidth
3
+ %h5
4
+ Files
5
+ = link_to '[+]', new_file_path
6
+ = render 'table', files: @files
@@ -0,0 +1,5 @@
1
+
2
+ .files-new.maxwidth
3
+ .header
4
+ %h5.title New File
5
+ = render 'form', file: @new_file
@@ -0,0 +1,11 @@
1
+
2
+ .files-show.maxwidth
3
+
4
+ .header
5
+ %h5.title
6
+ Files&nbsp;
7
+ = link_to '[+]', wco_hosting.new_file_path({ file_id: @file.id })
8
+
9
+ %ul
10
+ - @file.files.each do |file|
11
+ %li= file.inspect
@@ -15,7 +15,7 @@
15
15
  %tr
16
16
  %td
17
17
  = link_to '[~]', edit_serverhost_path(ser)
18
- = ser.name
18
+ = link_to ser.name, serverhost_path(ser)
19
19
  %td= ser.ssh_host
20
20
  %td= ser.public_ip
21
21
  %td= ser.next_port
@@ -0,0 +1,14 @@
1
+
2
+ .serverhosts-show.maxwidth
3
+
4
+ .header
5
+ %h5.title
6
+ Serverhost `#{@serverhost.name}`&nbsp;
7
+ = link_to '[~]', edit_serverhost_path(@serverhost)
8
+
9
+
10
+ %h5.title
11
+ Files&nbsp;
12
+ = link_to '[+]', wco_hosting.new_file_path({ serverhost_id: @serverhost.id })
13
+ = render 'wco_hosting/files/table', files: @serverhost.files
14
+
@@ -0,0 +1,8 @@
1
+
2
+ = form_for task_tmpl do |f|
3
+ .field
4
+ %label slug
5
+ = f.text_field :slug
6
+
7
+ .actions
8
+ = f.submit 'Go'
@@ -0,0 +1,13 @@
1
+
2
+ .task-tmpls-index.maxwidth
3
+ .header
4
+ %h5.title
5
+ Task Tmpl`s&nbsp;
6
+ = link_to '[+]', new_task_tmpl_path
7
+
8
+ %ul
9
+ - @task_tmpls.each do |tmpl|
10
+ %li
11
+ = tmpl.slug
12
+ .mini.gray
13
+ = tmpl.inspect
@@ -0,0 +1,2 @@
1
+
2
+ = render 'form', task_tmpl: @new_task_tmpl
@@ -0,0 +1,6 @@
1
+
2
+ .tasks-index.maxwidth
3
+ .header
4
+ %h5.title
5
+ Tasks&nbsp;
6
+ = link_to '[+]', new_task_path
data/config/routes.rb CHANGED
@@ -2,11 +2,19 @@
2
2
  WcoHosting::Engine.routes.draw do
3
3
  root to: '/wco_hosting/application#home'
4
4
 
5
+ post 'appliance_tmpls/add-tmpl-task', to: 'appliance_tmpls#add_task_tmpl', as: :add_appliance_tmpl_task_tmpl
6
+ get 'appliance_tmpls/deleted', to: 'appliance_tmpls#index', defaults: { deleted: true }, as: :deleted_appliance_tmpls
7
+ get 'appliance_tmpls', to: 'appliance_tmpls#index', defaults: { deleted: false }, as: :appliance_tmpls
8
+ post 'appliance_tmpls/run-task/:id/:task', to: 'appliance_tmpls#run_task', as: :appliance_tmpl_run_task
5
9
  resources :appliance_tmpls
6
10
  resources :appliances
7
11
 
8
12
  resources :domains
9
13
 
14
+ resources :environments
15
+
16
+ resources :files
17
+
10
18
  # get 'email_conversations/in/:tagname', to: '/wco/email_conversations#index', as: :email_conversations_in
11
19
  # get 'email_conversations/not-in/:tagname_not', to: '/wco/email_conversations#index', as: :email_conversations_in_not
12
20
  # resources :email_conversations
@@ -15,4 +23,7 @@ WcoHosting::Engine.routes.draw do
15
23
 
16
24
  resources :serverhosts
17
25
 
26
+ resources :task_tmpls
27
+ resources :tasks
28
+
18
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wco_hosting
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0.20
4
+ version: 0.0.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-26 00:00:00.000000000 Z
11
+ date: 2024-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cancancan
@@ -237,24 +237,38 @@ files:
237
237
  - app/controllers/wco_hosting/appliances_controller.rb
238
238
  - app/controllers/wco_hosting/application_controller.rb
239
239
  - app/controllers/wco_hosting/domains_controller.rb
240
+ - app/controllers/wco_hosting/environments_controller.rb
241
+ - app/controllers/wco_hosting/files_controller.rb
240
242
  - app/controllers/wco_hosting/serverhosts_controller.rb
241
243
  - app/controllers/wco_hosting/subscriptions_controller.rb
244
+ - app/controllers/wco_hosting/task_tmpls_controller.rb
245
+ - app/controllers/wco_hosting/tasks_controller.rb
242
246
  - app/helpers/wco_hosting/application_helper.rb
243
247
  - app/mailers/wco_hosting/application_mailer.rb
244
248
  - app/views/layouts/wco_hosting/application.haml
245
249
  - app/views/wco_hosting/_main_header.haml
246
250
  - app/views/wco_hosting/appliance_tmpls/_form.haml
251
+ - app/views/wco_hosting/appliance_tmpls/_header.haml
247
252
  - app/views/wco_hosting/appliance_tmpls/edit.haml
248
253
  - app/views/wco_hosting/appliance_tmpls/index.haml
249
254
  - app/views/wco_hosting/appliance_tmpls/new.haml
255
+ - app/views/wco_hosting/appliance_tmpls/show.haml
256
+ - app/views/wco_hosting/appliances/_form.haml
250
257
  - app/views/wco_hosting/appliances/edit.haml
251
258
  - app/views/wco_hosting/appliances/index.haml
259
+ - app/views/wco_hosting/appliances/new.haml
252
260
  - app/views/wco_hosting/appliances/show.haml
253
261
  - app/views/wco_hosting/application/home.haml
254
262
  - app/views/wco_hosting/domains/_form.haml
255
263
  - app/views/wco_hosting/domains/edit.haml
256
264
  - app/views/wco_hosting/domains/index.haml
257
265
  - app/views/wco_hosting/domains/show.haml
266
+ - app/views/wco_hosting/files/_form.haml
267
+ - app/views/wco_hosting/files/_table.haml
268
+ - app/views/wco_hosting/files/edit.haml
269
+ - app/views/wco_hosting/files/index.haml
270
+ - app/views/wco_hosting/files/new.haml
271
+ - app/views/wco_hosting/files/show.haml
258
272
  - app/views/wco_hosting/leadsets/_form.haml
259
273
  - app/views/wco_hosting/leadsets/index.haml
260
274
  - app/views/wco_hosting/leadsets/show.haml
@@ -262,6 +276,11 @@ files:
262
276
  - app/views/wco_hosting/serverhosts/edit.haml
263
277
  - app/views/wco_hosting/serverhosts/index.haml
264
278
  - app/views/wco_hosting/serverhosts/new.haml
279
+ - app/views/wco_hosting/serverhosts/show.haml
280
+ - app/views/wco_hosting/task_tmpls/_form.haml
281
+ - app/views/wco_hosting/task_tmpls/index.haml
282
+ - app/views/wco_hosting/task_tmpls/new.haml
283
+ - app/views/wco_hosting/tasks/index.haml
265
284
  - config/initializers/assets.rb
266
285
  - config/routes.rb
267
286
  - lib/tasks/wco_hosting_tasks.rake