cp_oraclecloud 0.1.11 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/cp_oraclecloud/admin.js +2 -0
  3. data/app/assets/stylesheets/cp_oraclecloud/admin.css +4 -0
  4. data/app/controllers/cp_oraclecloud/admin_controller.rb +31 -0
  5. data/app/controllers/cp_oraclecloud/images_controller.rb +70 -0
  6. data/app/controllers/cp_oraclecloud/ssh_keys_controller.rb +16 -14
  7. data/app/helpers/cp_oraclecloud/admin_helper.rb +2 -0
  8. data/app/models/cp_oraclecloud/compute_instance.rb +5 -1
  9. data/app/models/cp_oraclecloud/database_component.rb +1 -1
  10. data/app/models/cp_oraclecloud/database_instance.rb +15 -3
  11. data/app/models/cp_oraclecloud/image.rb +77 -0
  12. data/app/models/cp_oraclecloud/java_instance.rb +7 -4
  13. data/app/models/cp_oraclecloud/soa_instance.rb +5 -1
  14. data/app/models/cp_oraclecloud/ssh_key.rb +31 -14
  15. data/app/policies/cp_oraclecloud/image_policy.rb +26 -0
  16. data/app/views/cp_oraclecloud/admin/dashboard.html.erb +178 -0
  17. data/app/views/cp_oraclecloud/database_instances/_show.html.erb +149 -107
  18. data/app/views/cp_oraclecloud/java_components/_fields.html.erb +8 -6
  19. data/app/views/cp_oraclecloud/java_instances/_show.html.erb +82 -34
  20. data/app/views/cp_oraclecloud/ssh_keys/_form.html.erb +1 -1
  21. data/app/views/cp_oraclecloud/ssh_keys/edit.html.erb +19 -4
  22. data/app/views/cp_oraclecloud/ssh_keys/new.html.erb +19 -4
  23. data/app/views/products/_cp_oraclecloud_component_menu.html.erb +18 -6
  24. data/config/initializers/fog.rb +3 -0
  25. data/config/routes.rb +2 -0
  26. data/lib/cp_oraclecloud.rb +4 -0
  27. data/lib/cp_oraclecloud/compute_mixin.rb +2 -1
  28. data/lib/cp_oraclecloud/database_mixin.rb +5 -4
  29. data/lib/cp_oraclecloud/engine.rb +2 -3
  30. data/lib/cp_oraclecloud/java_mixin.rb +6 -5
  31. data/lib/cp_oraclecloud/soa_mixin.rb +4 -3
  32. data/lib/cp_oraclecloud/version.rb +1 -1
  33. metadata +38 -15
@@ -0,0 +1,26 @@
1
+ module CpOraclecloud
2
+ class ImagePolicy < ApplicationPolicy
3
+
4
+ def create?
5
+ user.has_role? :admin
6
+ end
7
+
8
+ def update?
9
+ user.has_role? :admin
10
+ end
11
+
12
+ def destroy?
13
+ user.has_role? :admin
14
+ end
15
+
16
+ def index?
17
+ user.has_role? :admin
18
+ end
19
+
20
+ class Scope < Scope
21
+ def resolve
22
+ scope.all
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,178 @@
1
+ <ol class="breadcrumb">
2
+ <li class="breadcrumb-item"><%= link_to "Home",root_path %></li>
3
+ <li class="breadcrumb-item active">Oracle Cloud Plugin</li>
4
+ </ol>
5
+ <div class="card">
6
+ <div class="card-block">
7
+ <div class="row">
8
+ <div class="col-xs-5">
9
+ <h4 class="card-title">Oracle Cloud Plugin Administration</h4>
10
+ </div>
11
+ </div>
12
+ </div>
13
+ </div>
14
+ <div class="row">
15
+ <div class="col-lg-8">
16
+ <div class="row">
17
+ <div class="col-md-3 col-sm-6">
18
+ <div class="social-box primary">
19
+ <i class="fa fa-database"></i>
20
+ <ul>
21
+ <li>
22
+ <strong><%= @totals[:database][:total] %></strong>
23
+ <span>Services</span>
24
+ </li>
25
+ <li>
26
+ <strong><%= number_to_currency(@totals[:database][:cost]) %></strong>
27
+ <span>Total Cost</span>
28
+ </li>
29
+ </ul>
30
+ </div>
31
+ </div>
32
+ <div class="col-md-3 col-sm-6">
33
+ <div class="social-box info">
34
+ <i class="fa fae-java"></i>
35
+ <ul>
36
+ <li>
37
+ <strong><%= @totals[:java][:total] %></strong>
38
+ <span>Services</span>
39
+ </li>
40
+ <li>
41
+ <strong><%= number_to_currency(@totals[:java][:cost]) %></strong>
42
+ <span>Total Cost</span>
43
+ </li>
44
+ </ul>
45
+ </div>
46
+ </div>
47
+ <div class="col-md-3 col-sm-6">
48
+ <div class="social-box warning">
49
+ <i class="fa fa-code-fork"></i>
50
+ <ul>
51
+ <li>
52
+ <strong><%= @totals[:soa][:total] %></strong>
53
+ <span>Services</span>
54
+ </li>
55
+ <li>
56
+ <strong><%= number_to_currency(@totals[:soa][:cost]) %></strong>
57
+ <span>Total Cost</span>
58
+ </li>
59
+ </ul>
60
+ </div>
61
+ </div>
62
+ <div class="col-md-3 col-sm-6">
63
+ <div class="social-box danger">
64
+ <i class="fa fa-desktop"></i>
65
+ <ul>
66
+ <li>
67
+ <strong><%= @totals[:compute][:total] %></strong>
68
+ <span>Services</span>
69
+ </li>
70
+ <li>
71
+ <strong><%= number_to_currency(@totals[:compute][:cost]) %></strong>
72
+ <span>Total Cost</span>
73
+ </li>
74
+ </ul>
75
+ </div>
76
+ </div>
77
+ </div>
78
+ <div class="row">
79
+ <div class="col-xs-12">
80
+ <div class="card">
81
+ <div class="card-header">Instances</div>
82
+ <div class="card-block">
83
+ <table class="table table-hover table-outline mb-0 hidden-sm-down">
84
+ <thead class="thead-default">
85
+ <tr>
86
+ <th></th>
87
+ <th>Name</th>
88
+ <th>Status</th>
89
+ <th>Project</th>
90
+ <th>Start</th>
91
+ <th>End</th>
92
+ <th>Monthly Cost</th>
93
+ </tr>
94
+ </thead>
95
+ <tbody>
96
+ <% @instances.each do |i| %>
97
+ <tr>
98
+ <td><i class="fa <%= i.icon %>"></i></td>
99
+ <td>
100
+ <div><%= i.name %></div>
101
+ <div class="small text-muted">
102
+ <%= i.cloud_type %>
103
+ </div>
104
+ </td>
105
+ <td><%= i.status %></td>
106
+ <td><%= link_to i.environment.project.name, i.environment.project %> - <%= link_to i.environment.name, [i.environment.project, i.environment] %></td>
107
+ <td><%= i.environment.start_date %></td>
108
+ <td><%= i.environment.end_date %></td>
109
+ <td><%= number_to_currency(i.month_cost) %></td>
110
+ </tr>
111
+ <% end %>
112
+ </tbody>
113
+ </table>
114
+ <p class="text-muted">Note: This only includes instances in the Oracle Cloud that are managed by Cloud Portal. There may be other instances in your account not listed here</p>
115
+
116
+ </div>
117
+ </div>
118
+ </div>
119
+ </div>
120
+ </div>
121
+ <div class="col-lg-4">
122
+ <div class="row">
123
+ <div class="col-xs-12">
124
+ <div class="card">
125
+ <div class="card-header">SSH Keys
126
+ <div class="card-actions">
127
+ <%= link_to new_cp_oraclecloud_ssh_key_path do %>
128
+ <i class="fa fa-plus"></i>
129
+ <% end %>
130
+ </div>
131
+ </div>
132
+ <div class="card-block">
133
+ <ul class="icons-list">
134
+ <% @ssh_keys.each do |ssh_key| %>
135
+ <li>
136
+ <span class="title"><%= ssh_key %></span>
137
+ <div class="pull-right">
138
+ <%= link_to "", [:edit, ssh_key],
139
+ class: "edit" %>
140
+ <%= link_to "", ssh_key, method: :delete,
141
+ data: { confirm: "Are you sure you want to delete this SSH Key?"},
142
+ class: "delete" %>
143
+
144
+ </div>
145
+ </li>
146
+ <% end %>
147
+ </ul>
148
+ </div>
149
+ </div>
150
+ </div>
151
+ <div class="col-xs-12">
152
+ <div class="card">
153
+ <div class="card-header">Images
154
+ <div class="card-actions">
155
+
156
+ </div>
157
+ </div>
158
+ <div class="card-block">
159
+ <ul class="icons-list">
160
+ <% @images.each do |image| %>
161
+ <li>
162
+ <span class="title"><%= image %></span>
163
+ <div class="pull-right">
164
+ <%= link_to "", [:edit, image],
165
+ class: "edit" %>
166
+ <%= link_to "", image, method: :delete,
167
+ data: { confirm: "Are you sure you want to delete this Image?"},
168
+ class: "delete" %>
169
+ </div>
170
+ </li>
171
+ <% end %>
172
+ </ul>
173
+ </div>
174
+ </div>
175
+ </div>
176
+ </div>
177
+ </div>
178
+ </div>
@@ -1,113 +1,155 @@
1
- <dl class="dl-horizontal">
2
- <% ['description', 'status', 'shape', 'level', 'edition', 'sid', 'pdbName', 'em_url', 'service_uri'].each { |a| %>
3
- <% if instance.attr_get(a).present? then %>
4
- <dt><%= a.titleize() %></dt>
5
- <dd><%= instance.attr_get(a) %></dd>
6
- <% end %>
7
- <% } %>
8
- </dl>
9
-
10
- <ul class="nav nav-tabs">
11
- <li role="presentation" class="active"><a href="#servers" data-toggle="tab">Servers</a></li>
12
- <li role="presentation"><a href="#backups" data-toggle="tab">Backups</a></li>
13
- <li role="presentation"><a href="#patches" data-toggle="tab">Patches</a></li>
14
- </ul>
1
+ </div>
2
+ </div>
3
+ <div class="row">
4
+ <div class="col-md-8">
5
+ <div class="row">
6
+ <div class="col-xs-6 col-lg-4">
7
+ <div class="card">
8
+ <div class="card-block p-a-0 clearfix">
9
+ <i class="fa fa-dollar bg-primary p-a-2 font-2xl m-r-1 pull-left"></i>
10
+ <div class="h5 text-primary m-b-0 p-t-1"><%= number_to_currency(instance.month_cost) %></div>
11
+ <div class="text-muted text-uppercase font-weight-bold font-xs">Cost Per Month</div>
12
+ </div>
13
+ </div>
14
+ </div>
15
+ <div class="col-xs-6 col-lg-4">
16
+ <div class="card">
17
+ <div class="card-block p-a-0 clearfix">
18
+ <i class="fa fa-heartbeat bg-<%= instance.attr_get('status') == 'Running' ? 'success' : 'danger' %> p-a-2 font-2xl m-r-1 pull-left"></i>
19
+ <div class="h5 text-<%= instance.attr_get('status') == 'Running' ? 'success' : 'danger' %> m-b-0 p-t-1"><%= instance.attr_get('status') %></div>
20
+ <div class="text-muted text-uppercase font-weight-bold font-xs">Status</div>
21
+ </div>
22
+ </div>
23
+ </div>
24
+ <div class="col-xs-6 col-lg-4">
25
+ <div class="card">
26
+ <div class="card-block p-a-0 clearfix">
27
+ <i class="fa fa-list-alt bg-info p-a-2 font-2xl m-r-1 pull-left"></i>
28
+ <div class="h5 text-info m-b-0 p-t-1"><%= instance.attr_get('shape').upcase %> - <%= instance.attr_get('edition') %></div>
29
+ <div class="text-muted text-uppercase font-weight-bold font-xs">Type</div>
30
+ </div>
31
+ </div>
32
+ </div>
33
+ </div>
34
+ <div class="card">
35
+ <div class="card-block">
36
+ <div class="row">
37
+ <ul class="nav nav-tabs">
38
+ <li role="presentation" class="nav-item active"><a href="#servers" data-toggle="tab" class="nav-link">Servers</a></li>
39
+ <li role="presentation" class="nav-item"><a href="#backups" data-toggle="tab" class="nav-link">Backups</a></li>
40
+ <li role="presentation" class="nav-item"><a href="#patches" data-toggle="tab" class="nav-link">Patches</a></li>
41
+ </ul>
15
42
 
16
- <div class="tab-content ">
17
- <div class="tab-pane active" id="servers">
18
- <table class="table table-striped table-hover">
19
- <thead>
20
- <tr>
21
- <th>Hostname</th>
22
- <th>Status</th>
23
- <th>Shape</th>
24
- <th></th>
25
- </tr>
26
- </thead>
27
- <tbody>
28
- <% instance.fog.servers.each {|i| %>
29
- <tr>
30
- <td><%= i.hostname %></td>
31
- <td><%= i.status %></td>
32
- <td><%= i.shape %></td>
33
- <td></td>
34
- </tr>
35
- <% } %>
36
- </tbody>
37
- </table>
43
+ <div class="tab-content ">
44
+ <div class="tab-pane active" id="servers">
45
+ <table class="table table-striped table-hover">
46
+ <thead>
47
+ <tr>
48
+ <th>Hostname</th>
49
+ <th>Status</th>
50
+ <th>Shape</th>
51
+ <th></th>
52
+ </tr>
53
+ </thead>
54
+ <tbody>
55
+ <% instance.fog.servers.each {|i| %>
56
+ <tr>
57
+ <td><%= i.hostname %></td>
58
+ <td><%= i.status %></td>
59
+ <td><%= i.shape %></td>
60
+ <td></td>
61
+ </tr>
62
+ <% } %>
63
+ </tbody>
64
+ </table>
65
+ </div>
66
+ <div class="tab-pane" id="backups">
67
+ <div class="row">
68
+ <div class="col-xs-6">
69
+ <h4>Backups</h4>
70
+ <table class="table table-striped table-hover">
71
+ <thead>
72
+ <tr>
73
+ <th>Tag</th>
74
+ <th>Status</th>
75
+ <th>Date</th>
76
+ <th></th>
77
+ </tr>
78
+ </thead>
79
+ <tbody>
80
+ <% instance.fog.backups.each {|i| %>
81
+ <tr>
82
+ <td><%= i.db_tag %></td>
83
+ <td><%= i.status %></td>
84
+ <td><%= i.backup_complete_date %></td>
85
+ <td></td>
86
+ </tr>
87
+ <% } %>
88
+ </tbody>
89
+ </table>
90
+ </div>
91
+ <div class="col-xs-6">
92
+ <h3>Restores</h3>
93
+ <table class="table table-striped table-hover">
94
+ <thead>
95
+ <tr>
96
+ <th>Tag</th>
97
+ <th>Status</th>
98
+ <th>Date</th>
99
+ <th></th>
100
+ </tr>
101
+ </thead>
102
+ <tbody>
103
+ <% instance.fog.recoveries.each {|i| %>
104
+ <tr>
105
+ <td><%= i.db_tag %></td>
106
+ <td><%= i.status %></td>
107
+ <td><%= i.recovery_complete_date %></td>
108
+ <td></td>
109
+ </tr>
110
+ <% } %>
111
+ </tbody>
112
+ </table>
113
+ </div>
114
+ </div>
115
+ </div>
116
+ <div class="tab-pane" id="patches">
117
+ <h4>Patches</h4>
118
+ <table class="table table-striped table-hover">
119
+ <thead>
120
+ <tr>
121
+ <th>Id</th>
122
+ <th>Category</th>
123
+ <th>URL</th>
124
+ <th></th>
125
+ </tr>
126
+ </thead>
127
+ <tbody>
128
+ <% instance.fog.patches.each {|i| %>
129
+ <tr>
130
+ <td><%= i.id %></td>
131
+ <td><%= i.category %></td>
132
+ <td><a href="<%= i.release_url %>"><%= i.release_url %></a></td>
133
+ <td></td>
134
+ </tr>
135
+ <% } %>
136
+ </tbody>
137
+ </table>
138
+ </div>
139
+ </div>
140
+ </div>
141
+ </div>
142
+ </div>
38
143
  </div>
39
- <div class="tab-pane" id="backups">
40
- <p></p>
41
- <div class="btn-group" role="group">
42
- <%= link_to "Backup", cp_oraclecloud_database_instance_backup_path(instance), method: :put, class: 'btn btn-default' %>
144
+ <div class="col-md-4">
145
+ <div class="card">
146
+ <div class="card-header">Actions</div>
147
+ <div class="card-block">
148
+ <%= link_to "Backup", cp_oraclecloud_database_instance_backup_path(instance), method: :put, class: 'btn btn-outline-primary btn-lg btn-block' %>
43
149
 
44
- <button type="button" class="btn btn-default">Restore</button>
150
+ <button type="button" class="btn btn-outline-primary btn-lg btn-block">Restore</button>
151
+
152
+ </div>
45
153
  </div>
46
- <h3>Backups</h3>
47
- <table class="table table-striped table-hover">
48
- <thead>
49
- <tr>
50
- <th>Tag</th>
51
- <th>Status</th>
52
- <th>Date</th>
53
- <th></th>
54
- </tr>
55
- </thead>
56
- <tbody>
57
- <% instance.fog.backups.each {|i| %>
58
- <tr>
59
- <td><%= i.db_tag %></td>
60
- <td><%= i.status %></td>
61
- <td><%= i.backup_complete_date %></td>
62
- <td></td>
63
- </tr>
64
- <% } %>
65
- </tbody>
66
- </table>
67
- <h3>Restores</h3>
68
- <table class="table table-striped table-hover">
69
- <thead>
70
- <tr>
71
- <th>Tag</th>
72
- <th>Status</th>
73
- <th>Date</th>
74
- <th></th>
75
- </tr>
76
- </thead>
77
- <tbody>
78
- <% instance.fog.recoveries.each {|i| %>
79
- <tr>
80
- <td><%= i.db_tag %></td>
81
- <td><%= i.status %></td>
82
- <td><%= i.recovery_complete_date %></td>
83
- <td></td>
84
- </tr>
85
- <% } %>
86
- </tbody>
87
- </table>
88
- </div>
89
- <div class="tab-pane" id="patches">
90
- <h3>Patches</h3>
91
- <table class="table table-striped table-hover">
92
- <thead>
93
- <tr>
94
- <th>Id</th>
95
- <th>Category</th>
96
- <th>URL</th>
97
- <th></th>
98
- </tr>
99
- </thead>
100
- <tbody>
101
- <% instance.fog.patches.each {|i| %>
102
- <tr>
103
- <td><%= i.id %></td>
104
- <td><%= i.category %></td>
105
- <td><a href="<%= i.release_url %>"><%= i.release_url %></a></td>
106
- <td></td>
107
- </tr>
108
- <% } %>
109
- </tbody>
110
- </table>
111
154
  </div>
112
-
113
155
  </div>