jellyfish-aws 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +201 -0
- data/README.rdoc +3 -0
- data/Rakefile +25 -0
- data/app/controllers/jellyfish_aws/application_controller.rb +12 -0
- data/app/controllers/jellyfish_aws/providers_controller.rb +31 -0
- data/app/models/product_type/ec2.rb +41 -0
- data/app/models/provider/aws.rb +148 -0
- data/app/models/registered_provider/aws.rb +33 -0
- data/app/models/service/ec2.rb +37 -0
- data/app/policies/aws_policy.rb +17 -0
- data/config/routes.rb +10 -0
- data/lib/jellyfish-aws.rb +1 -0
- data/lib/jellyfish_aws/engine.rb +76 -0
- data/lib/jellyfish_aws/version.rb +3 -0
- data/lib/jellyfish_aws.rb +6 -0
- data/lib/tasks/jellyfish_aws_tasks.rake +4 -0
- data/spec/rails_helper.rb +52 -0
- data/spec/spec_helper.rb +92 -0
- data/spec/test_app/README.rdoc +28 -0
- data/spec/test_app/Rakefile +6 -0
- data/spec/test_app/app/controllers/application_controller.rb +2 -0
- data/spec/test_app/bin/bundle +3 -0
- data/spec/test_app/bin/rails +4 -0
- data/spec/test_app/bin/rake +4 -0
- data/spec/test_app/bin/setup +29 -0
- data/spec/test_app/config/application.rb +29 -0
- data/spec/test_app/config/boot.rb +5 -0
- data/spec/test_app/config/environment.rb +5 -0
- data/spec/test_app/config/environments/development.rb +38 -0
- data/spec/test_app/config/environments/production.rb +76 -0
- data/spec/test_app/config/environments/test.rb +42 -0
- data/spec/test_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/test_app/config/initializers/secret_token.rb +19 -0
- data/spec/test_app/config/initializers/wrap_parameters.rb +9 -0
- data/spec/test_app/config/locales/en.yml +23 -0
- data/spec/test_app/config/routes.rb +4 -0
- data/spec/test_app/config/secrets.yml +22 -0
- data/spec/test_app/config.ru +4 -0
- data/spec/test_app/public/404.html +67 -0
- data/spec/test_app/public/422.html +67 -0
- data/spec/test_app/public/500.html +66 -0
- data/spec/test_app/public/favicon.ico +0 -0
- metadata +210 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 214593e74b3789aa930667c7cda874336497c913
|
4
|
+
data.tar.gz: b94385d164bc924ad79a71b8eae3e7054f431558
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 62e34849187eaf445e89281d9f27413992d923090fd0a2e61ffa1c641b0af109f4b24a6645c4c84a419a637083e2fce324a5db6d0b1bdccc25e3d06272005fa0
|
7
|
+
data.tar.gz: 7cdbd479c0cfb5f12b7442e15b10352232d0d885bd53c756ea49735c78a6b5fe25b607a77f73c4332d460439cc3c9cd5aae3a3339faed4b6ea770b2a9e4cfd54
|
data/LICENSE
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright {yyyy} {name of copyright owner}
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'JellyfishAws'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
load 'rails/tasks/statistics.rake'
|
18
|
+
Bundler::GemHelper.install_tasks
|
19
|
+
|
20
|
+
require 'rspec/core'
|
21
|
+
require 'rspec/core/rake_task'
|
22
|
+
|
23
|
+
desc 'Run all specs in spec directory'
|
24
|
+
RSpec::Core::RakeTask.new(:spec)
|
25
|
+
task default: :spec
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module JellyfishAws
|
2
|
+
class ApplicationController < ::ApplicationController
|
3
|
+
rescue_from Fog::Compute::AWS::Error, with: :aws_error
|
4
|
+
|
5
|
+
protected
|
6
|
+
|
7
|
+
def aws_error(ex)
|
8
|
+
message, type = ex.message.split(' => ').reverse
|
9
|
+
render json: {type: type, error: message}, status: :bad_request
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module JellyfishAws
|
2
|
+
class ProvidersController < JellyfishAws::ApplicationController
|
3
|
+
after_action :verify_authorized
|
4
|
+
|
5
|
+
def ec2_flavors
|
6
|
+
authorize :aws
|
7
|
+
render json: provider.ec2_flavors
|
8
|
+
end
|
9
|
+
|
10
|
+
def ec2_images
|
11
|
+
authorize :aws
|
12
|
+
render json: provider.ec2_images
|
13
|
+
end
|
14
|
+
|
15
|
+
def subnets
|
16
|
+
authorize :aws
|
17
|
+
render json: provider.subnets
|
18
|
+
end
|
19
|
+
|
20
|
+
def availability_zones
|
21
|
+
authorize :aws
|
22
|
+
render json: provider.availability_zones
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def provider
|
28
|
+
@provider ||= Provider.find params[:id]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
class ProductType
|
2
|
+
class Ec2 < ProductType
|
3
|
+
def self.load_product_types
|
4
|
+
return unless super
|
5
|
+
|
6
|
+
transaction do
|
7
|
+
[
|
8
|
+
set('EC2 Instance', 'd16d5017-6d6b-4775-958f-535f68b4cf04', provider_type: 'Provider::Aws')
|
9
|
+
].each do |s|
|
10
|
+
create! s.merge!(type: 'ProductType::Ec2')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def description
|
16
|
+
'Amazon Web Services Elastic Compute Cloud Instance'
|
17
|
+
end
|
18
|
+
|
19
|
+
def tags
|
20
|
+
['ec2', 'server']
|
21
|
+
end
|
22
|
+
|
23
|
+
def product_questions
|
24
|
+
[
|
25
|
+
{ name: :flavor_id, value_type: :string, field: :aws_ec2_flavors, required: true },
|
26
|
+
{ name: :image_id, value_type: :string, field: :aws_ec2_images, required: true },
|
27
|
+
{ name: :subnet_id, value_type: :string, field: :aws_subnets, required: true }
|
28
|
+
]
|
29
|
+
end
|
30
|
+
|
31
|
+
def order_questions
|
32
|
+
[
|
33
|
+
{ name: :zone_id, value_type: :string, field: :aws_zones, required: true }
|
34
|
+
]
|
35
|
+
end
|
36
|
+
|
37
|
+
def service_class
|
38
|
+
'Service::Ec2'.constantize
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,148 @@
|
|
1
|
+
class Provider
|
2
|
+
class Aws < Provider
|
3
|
+
def ec2_flavors
|
4
|
+
client.flavors.map do |f|
|
5
|
+
{
|
6
|
+
id: f.id, name: f.name, bits: f.bits, cores: f.cores, ram: f.ram,
|
7
|
+
label: [f.name, f.id].join(' - '), value: f.id
|
8
|
+
}
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def ec2_images
|
13
|
+
case settings[:region]
|
14
|
+
when 'us-east-1'
|
15
|
+
[
|
16
|
+
{ label: 'Amazon Linux AMI 2015.03 (HVM), SSD Volume Type', value: 'ami-1ecae776' },
|
17
|
+
{ label: 'Red Hat Enterprise Linux 7.1 (HVM), SSD Volume Type', value: 'ami-12663b7a' },
|
18
|
+
{ label: 'SUSE Linux Enterprise Server 12 (HVM), SSD Volume Type', value: 'ami-aeb532c6' },
|
19
|
+
{ label: 'Ubuntu Server 14.04 LTS (HVM), SSD Volume Type', value: 'ami-d05e75b8' },
|
20
|
+
{ label: 'Microsoft Windows Server 2012 R2 Base', value: 'ami-f70cdd9c' },
|
21
|
+
{ label: 'Amazon Linux AMI 2015.03 (PV)', value: 'ami-1ccae774' },
|
22
|
+
{ label: 'SUSE Linux Enterprise Server 11 SP3 (PV), SSD Volume Type', value: 'ami-c08fcba8' },
|
23
|
+
{ label: 'Ubuntu Server 14.04 LTS (PV), SSD Volume Type', value: 'ami-d85e75b0' }
|
24
|
+
]
|
25
|
+
when 'us-west-1'
|
26
|
+
[
|
27
|
+
{ label: 'Amazon Linux AMI 2015.03 (HVM), SSD Volume Type', value: 'ami-e7527ed7' },
|
28
|
+
{ label: 'Red Hat Enterprise Linux 7.1 (HVM), SSD Volume Type', value: 'ami-4dbf9e7d' },
|
29
|
+
{ label: 'SUSE Linux Enterprise Server 12 (HVM), SSD Volume Type', value: 'ami-d7450be7' },
|
30
|
+
{ label: 'Ubuntu Server 14.04 LTS (HVM), SSD Volume Type', value: 'ami-5189a661' },
|
31
|
+
{ label: 'Microsoft Windows Server 2012 R2 Base', value: 'ami-c3b3b1f3' },
|
32
|
+
{ label: 'Amazon Linux AMI 2015.03 (PV)', value: 'ami-ff527ecf' },
|
33
|
+
{ label: 'SUSE Linux Enterprise Server 11 SP3 (PV), SSD Volume Type', value: 'ami-5df2ab6d' },
|
34
|
+
{ label: 'Ubuntu Server 14.04 LTS (PV), SSD Volume Type', value: 'ami-6989a659' }
|
35
|
+
]
|
36
|
+
when 'us-west-1'
|
37
|
+
[
|
38
|
+
{ label: 'Amazon Linux AMI 2015.03 (HVM), SSD Volume Type', value: 'ami-d114f295' },
|
39
|
+
{ label: 'Red Hat Enterprise Linux 7.1 (HVM), SSD Volume Type', value: 'ami-a540a5e1' },
|
40
|
+
{ label: 'SUSE Linux Enterprise Server 12 (HVM), SSD Volume Type', value: 'ami-b95b4ffc' },
|
41
|
+
{ label: 'Ubuntu Server 14.04 LTS (HVM), SSD Volume Type', value: 'ami-df6a8b9b' },
|
42
|
+
{ label: 'Microsoft Windows Server 2012 R2 Base', value: 'ami-3bee1c7f' },
|
43
|
+
{ label: 'Amazon Linux AMI 2015.03 (PV)', value: 'ami-d514f291' },
|
44
|
+
{ label: 'SUSE Linux Enterprise Server 11 SP3 (PV), SSD Volume Type', value: 'ami-fe8891bb' },
|
45
|
+
{ label: 'Ubuntu Server 14.04 LTS (PV), SSD Volume Type', value: 'ami-d16a8b95' }
|
46
|
+
]
|
47
|
+
when 'eu-west-1'
|
48
|
+
[
|
49
|
+
{ label: 'Amazon Linux AMI 2015.03 (HVM), SSD Volume Type', value: 'ami-a10897d6' },
|
50
|
+
{ label: 'Red Hat Enterprise Linux 7.1 (HVM), SSD Volume Type', value: 'ami-25158352' },
|
51
|
+
{ label: 'SUSE Linux Enterprise Server 12 (HVM), SSD Volume Type', value: 'ami-e801af9f' },
|
52
|
+
{ label: 'Ubuntu Server 14.04 LTS (HVM), SSD Volume Type', value: 'ami-47a23a30' },
|
53
|
+
{ label: 'Microsoft Windows Server 2012 R2 Base', value: 'ami-68347d1f' },
|
54
|
+
{ label: 'Amazon Linux AMI 2015.03 (PV)', value: 'ami-bf0897c8' },
|
55
|
+
{ label: 'SUSE Linux Enterprise Server 11 SP3 (PV), SSD Volume Type', value: 'ami-17c44860' },
|
56
|
+
{ label: 'Ubuntu Server 14.04 LTS (PV), SSD Volume Type', value: 'ami-5da23a2a' }
|
57
|
+
]
|
58
|
+
when 'eu-central-1'
|
59
|
+
[
|
60
|
+
{ label: 'Amazon Linux AMI 2015.03 (HVM), SSD Volume Type', value: 'ami-a8221fb5' },
|
61
|
+
{ label: 'Red Hat Enterprise Linux 7.1 (HVM), SSD Volume Type', value: 'ami-dafdcfc7' },
|
62
|
+
{ label: 'SUSE Linux Enterprise Server 12 (HVM), SSD Volume Type', value: 'ami-a22610bf' },
|
63
|
+
{ label: 'Ubuntu Server 14.04 LTS (HVM), SSD Volume Type', value: 'ami-accff2b1' },
|
64
|
+
{ label: 'Microsoft Windows Server 2012 R2 Base', value: 'ami-f64540eb' },
|
65
|
+
{ label: 'Amazon Linux AMI 2015.03 (PV)', value: 'ami-ac221fb1' },
|
66
|
+
{ label: 'SUSE Linux Enterprise Server 11 SP3 (PV), SSD Volume Type', value: 'ami-fc0033e1' },
|
67
|
+
{ label: 'Ubuntu Server 14.04 LTS (PV), SSD Volume Type', value: 'ami-b6cff2ab' }
|
68
|
+
]
|
69
|
+
when 'ap-southeast-1'
|
70
|
+
[
|
71
|
+
{ label: 'Amazon Linux AMI 2015.03 (HVM), SSD Volume Type', value: 'ami-68d8e93a' },
|
72
|
+
{ label: 'Red Hat Enterprise Linux 7.1 (HVM), SSD Volume Type', value: 'ami-dc1c2b8e' },
|
73
|
+
{ label: 'SUSE Linux Enterprise Server 12 (HVM), SSD Volume Type', value: 'ami-84b392d6' },
|
74
|
+
{ label: 'Ubuntu Server 14.04 LTS (HVM), SSD Volume Type', value: 'ami-96f1c1c4' },
|
75
|
+
{ label: 'Microsoft Windows Server 2012 R2 Base', value: 'ami-b89093ea' },
|
76
|
+
{ label: 'Amazon Linux AMI 2015.03 (PV)', value: 'ami-acd9e8fe' },
|
77
|
+
{ label: 'SUSE Linux Enterprise Server 11 SP3 (PV), SSD Volume Type', value: 'ami-3cbe956e' },
|
78
|
+
{ label: 'Ubuntu Server 14.04 LTS (PV), SSD Volume Type', value: 'ami-e8f1c1ba' }
|
79
|
+
]
|
80
|
+
when 'ap-northeast-1'
|
81
|
+
[
|
82
|
+
{ label: 'Amazon Linux AMI 2015.03 (HVM), SSD Volume Type', value: 'ami-cbf90ecb' },
|
83
|
+
{ label: 'Red Hat Enterprise Linux 7.1 (HVM), SSD Volume Type', value: 'ami-b1b458b1' },
|
84
|
+
{ label: 'SUSE Linux Enterprise Server 12 (HVM), SSD Volume Type', value: 'ami-d54a79d4' },
|
85
|
+
{ label: 'Ubuntu Server 14.04 LTS (HVM), SSD Volume Type', value: 'ami-936d9d93' },
|
86
|
+
{ label: 'Microsoft Windows Server 2012 R2 Base', value: 'ami-e69520e6' },
|
87
|
+
{ label: 'Amazon Linux AMI 2015.03 (PV)', value: 'ami-27f90e27' },
|
88
|
+
{ label: 'SUSE Linux Enterprise Server 11 SP3 (PV), SSD Volume Type', value: 'ami-5cb8a65d' },
|
89
|
+
{ label: 'Ubuntu Server 14.04 LTS (PV), SSD Volume Type', value: 'ami-8d6d9d8d' }
|
90
|
+
]
|
91
|
+
when 'ap-southeast-2'
|
92
|
+
[
|
93
|
+
{ label: 'Amazon Linux AMI 2015.03 (HVM), SSD Volume Type', value: 'ami-fd9cecc7' },
|
94
|
+
{ label: 'Red Hat Enterprise Linux 7.1 (HVM), SSD Volume Type', value: 'ami-d3daace9' },
|
95
|
+
{ label: 'SUSE Linux Enterprise Server 12 (HVM), SSD Volume Type', value: 'ami-b90e6283' },
|
96
|
+
{ label: 'Ubuntu Server 14.04 LTS (HVM), SSD Volume Type', value: 'ami-69631053' },
|
97
|
+
{ label: 'Microsoft Windows Server 2012 R2 Base', value: 'ami-2d2d6b17' },
|
98
|
+
{ label: 'Amazon Linux AMI 2015.03 (PV)', value: 'ami-ff9cecc5' },
|
99
|
+
{ label: 'SUSE Linux Enterprise Server 11 SP3 (PV), SSD Volume Type', value: 'ami-ad0d7997' },
|
100
|
+
{ label: 'Ubuntu Server 14.04 LTS (PV), SSD Volume Type', value: 'ami-7163104b' }
|
101
|
+
]
|
102
|
+
when 'sa-east-1'
|
103
|
+
[
|
104
|
+
{ label: 'Amazon Linux AMI 2015.03 (HVM), SSD Volume Type', value: 'ami-b52890a8' },
|
105
|
+
{ label: 'Red Hat Enterprise Linux 7.1 (HVM), SSD Volume Type', value: 'ami-09e25b14' },
|
106
|
+
{ label: 'SUSE Linux Enterprise Server 12 (HVM), SSD Volume Type', value: 'ami-f102b6ec' },
|
107
|
+
{ label: 'Ubuntu Server 14.04 LTS (HVM), SSD Volume Type', value: 'ami-4d883350' },
|
108
|
+
{ label: 'Microsoft Windows Server 2012 R2 Base', value: 'ami-87f8779a' },
|
109
|
+
{ label: 'Amazon Linux AMI 2015.03 (PV', value: 'ami-bb2890a6' },
|
110
|
+
{ label: 'SUSE Linux Enterprise Server 11 SP3 (PV), SSD Volume Type', value: 'ami-23912d3e' },
|
111
|
+
{ label: 'Ubuntu Server 14.04 LTS (PV), SSD Volume Type', value: 'ami-55883348' }
|
112
|
+
]
|
113
|
+
else
|
114
|
+
[]
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def subnets
|
119
|
+
client.subnets.map do |s|
|
120
|
+
{
|
121
|
+
id: s.subnet_id, name: s.cidr_block, cidr: s.cidr_block, vpc_id: s.vpc_id,
|
122
|
+
label: s.cidr_block, value: s.subnet_id
|
123
|
+
}
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def availability_zones
|
128
|
+
client.describe_availability_zones.body['availabilityZoneInfo'].map do |az|
|
129
|
+
next unless client.region == az['regionName']
|
130
|
+
{ label: az['zoneName'], value: az['zoneName'] }
|
131
|
+
end.compact
|
132
|
+
end
|
133
|
+
|
134
|
+
private
|
135
|
+
|
136
|
+
def client
|
137
|
+
@client ||= begin
|
138
|
+
credentials = {
|
139
|
+
provider: 'AWS',
|
140
|
+
aws_access_key_id: settings[:access_id],
|
141
|
+
aws_secret_access_key: settings[:secret_key],
|
142
|
+
region: settings[:region]
|
143
|
+
}
|
144
|
+
Fog::Compute.new credentials
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class RegisteredProvider
|
2
|
+
class Aws < RegisteredProvider
|
3
|
+
def self.load_registered_providers
|
4
|
+
return unless super
|
5
|
+
|
6
|
+
transaction do
|
7
|
+
[
|
8
|
+
set('AWS', '1072ddc9-e04f-4d43-929b-8866ce7e6d3a')
|
9
|
+
].each { |s| create! s.merge!(type: 'RegisteredProvider::Aws') }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def provider_class
|
14
|
+
'Provider::Aws'.constantize
|
15
|
+
end
|
16
|
+
|
17
|
+
def description
|
18
|
+
'Amazon Web Services'
|
19
|
+
end
|
20
|
+
|
21
|
+
def tags
|
22
|
+
['aws']
|
23
|
+
end
|
24
|
+
|
25
|
+
def questions
|
26
|
+
[
|
27
|
+
{ name: :access_id, value_type: :string, field: :text, label: 'Access ID', required: true },
|
28
|
+
{ name: :secret_key, value_type: :password, field: :password, label: 'Secret Key', required: :if_new },
|
29
|
+
{ name: :region, value_type: :string, field: :aws_regions, required: true }
|
30
|
+
]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class Service
|
2
|
+
class Ec2 < Service::Compute
|
3
|
+
def actions
|
4
|
+
actions = super.merge :terminate
|
5
|
+
|
6
|
+
# determine if action is available
|
7
|
+
|
8
|
+
actions
|
9
|
+
end
|
10
|
+
|
11
|
+
def provision
|
12
|
+
=begin
|
13
|
+
create key_pair name: service.uuid
|
14
|
+
create security group (one per project) name: project-{id}
|
15
|
+
create vpc (one per project) name: project-{id}
|
16
|
+
=end
|
17
|
+
end
|
18
|
+
|
19
|
+
def start
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
def stop
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def terminate
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def client
|
34
|
+
@client ||= provider.settings
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/config/routes.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/jellyfish_aws'
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module JellyfishAws
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace JellyfishAws
|
4
|
+
|
5
|
+
config.generators do |g|
|
6
|
+
g.test_framework :rspec, fixture: false
|
7
|
+
g.fixture_replacement :factory_girl, dir: 'spec/factories'
|
8
|
+
g.assets false
|
9
|
+
g.helper false
|
10
|
+
end
|
11
|
+
|
12
|
+
initializer :append_migrations do |app|
|
13
|
+
unless app.root.to_s.match root.to_s
|
14
|
+
config.paths['db/migrate'].expanded.each do |expanded_path|
|
15
|
+
app.config.paths['db/migrate'] << expanded_path
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Initializer to combine this engines static assets with the static assets of the hosting site.
|
21
|
+
initializer 'static assets' do |app|
|
22
|
+
app.middleware.insert_before(::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public")
|
23
|
+
end
|
24
|
+
|
25
|
+
initializer 'jellyfish_aws.load_default_settings', :before => :load_config_initializers do
|
26
|
+
begin
|
27
|
+
if Setting.table_exists?
|
28
|
+
Dir[File.expand_path '../../../app/models/setting/*.rb', __FILE__].each do |file|
|
29
|
+
require_dependency file
|
30
|
+
end
|
31
|
+
end
|
32
|
+
rescue
|
33
|
+
#ignored
|
34
|
+
nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
initializer 'jellyfish_aws.load_product_types', :before => :load_config_initializers do
|
39
|
+
begin
|
40
|
+
if ProductType.table_exists?
|
41
|
+
Dir[File.expand_path '../../../app/models/product_type/*.rb', __FILE__].each do |file|
|
42
|
+
require_dependency file
|
43
|
+
end
|
44
|
+
end
|
45
|
+
rescue
|
46
|
+
#ignored
|
47
|
+
nil
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
initializer 'jellyfish_aws.load_registered_providers', :before => :load_config_initializers do
|
52
|
+
begin
|
53
|
+
if RegisteredProvider.table_exists?
|
54
|
+
Dir[File.expand_path '../../../app/models/registered_provider/*', __FILE__].each do |file|
|
55
|
+
require_dependency file
|
56
|
+
end
|
57
|
+
end
|
58
|
+
rescue
|
59
|
+
#ignored
|
60
|
+
nil
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
initializer 'jellyfish_aws.register_extension', :after => :finisher_hook do |app|
|
65
|
+
Jellyfish::Extension.register 'jellyfish-aws' do
|
66
|
+
requires_jellyfish '>= 4.0.0'
|
67
|
+
|
68
|
+
load_scripts 'extensions/aws/components/forms/fields.config.js',
|
69
|
+
'extensions/aws/resources/aws-data.factory.js'
|
70
|
+
|
71
|
+
mount_extension JellyfishAws::Engine, at: :aws
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|