jellyfish-fog 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d04e61608cc847611bbdbc2b46cc2ab0e225d4f1
4
- data.tar.gz: 4fe07b73bbe512316d6c235918ea7fb67e6c03b2
3
+ metadata.gz: 5d38b47d38c5b70280e9033193a6d3eceb17c539
4
+ data.tar.gz: fd1ff2ac3530d6187b0e105c6f12d77f29d68050
5
5
  SHA512:
6
- metadata.gz: 1237e4605d6390e0aa705607099cd4003ac5b3e445b2fc66b628eac76cf5a5369afa421f9953ff059481cb09a08e4c5ff51da994f53498f8120a2eceef188570
7
- data.tar.gz: a70b5bbc020d18b39a9463e545c48ff535b8109f4e64ff54e93fc094184e1be4fac8087ef93ac0d9be6217f8bd4669d2fcc660f0d2aad7c741eae64a03fa4718
6
+ metadata.gz: e8d5140434682bce5f8d466f6536a4900558f96ccb0472c23a35b9d0bb89c97dc0022750b23d45d8c5a97e901ba497853bec764b6b15ec8f637b506ee69ca78a
7
+ data.tar.gz: 06c8b686f287daf8d7e21af8bb127c3fc26762cfe4bd4c5b4adb7386a4b71204f61c9252a30649ae0c56605f010de35f9daeed89cbe4edde4233cfd64d6da756
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "object",
3
- "title": "AWS Fog Databases",
4
- "description": "AWS Fog Databases",
3
+ "title": "AWS Fog Database",
4
+ "description": "AWS Fog Database",
5
5
  "required": ["DBInstanceClass", "Engine", "AllocatedStorage"],
6
6
  "properties": {
7
7
  "DBInstanceClass": {
@@ -0,0 +1,19 @@
1
+ {
2
+ "type": "object",
3
+ "title": "AWS Fog EBS",
4
+ "description": "AWS Fog EBS",
5
+ "required": [],
6
+ "properties": {
7
+ "size": {
8
+ "title": "Size",
9
+ "type": "string",
10
+ "default": "5"
11
+ },
12
+ "availability_zone": {
13
+ "title": "Availability Zone",
14
+ "type": "string",
15
+ "default": "us-east-1a"
16
+ }
17
+ }
18
+ }
19
+
@@ -2,15 +2,15 @@
2
2
  "type": "object",
3
3
  "title": "AWS Fog Infrastructure",
4
4
  "description": "AWS Fog Infrastructure",
5
- "required": ["ami_id", "instance_size", "disk_size"],
5
+ "required": ["ami_id", "flavor_id", "disk_size"],
6
6
  "properties": {
7
7
  "ami_id": {
8
8
  "title": "AMI ID",
9
9
  "type": "string",
10
10
  "default": "ami-1ccae774"
11
11
  },
12
- "instance_size": {
13
- "title": "Instance Size",
12
+ "flavor_id": {
13
+ "title": "Flavor Id",
14
14
  "type": "string",
15
15
  "enum": [
16
16
  "t2.micro",
@@ -23,6 +23,21 @@
23
23
  "title": "Disk Size",
24
24
  "type": "string",
25
25
  "default": "40"
26
+ },
27
+ "vpc_id": {
28
+ "title": "VPC ID",
29
+ "type": "string",
30
+ "default": ""
31
+ },
32
+ "subnet_id": {
33
+ "title": "Subnet ID",
34
+ "type": "string",
35
+ "default": ""
36
+ },
37
+ "security_group_ids": {
38
+ "title": "Security Group IDs",
39
+ "type": "string",
40
+ "default": ""
26
41
  }
27
42
  }
28
43
  }
@@ -0,0 +1,24 @@
1
+ {
2
+ "type": "object",
3
+ "title": "AWS Fog Security Group",
4
+ "description": "AWS Fog Security Group",
5
+ "required": [],
6
+ "properties": {
7
+ "name": {
8
+ "title": "Name",
9
+ "type": "string",
10
+ "default": "jellyfish"
11
+ },
12
+ "description": {
13
+ "title": "Description",
14
+ "type": "string",
15
+ "default": "jellyfish users"
16
+ },
17
+ "vpc_id": {
18
+ "title": "VPC ID",
19
+ "type": "string",
20
+ "default": ""
21
+ }
22
+ }
23
+ }
24
+
@@ -2,30 +2,12 @@
2
2
  "type": "object",
3
3
  "title": "AWS Fog Storage",
4
4
  "description": "AWS Fog Storage",
5
- "required": ["availability", "region"],
5
+ "required": [],
6
6
  "properties": {
7
- "availability": {
8
- "title": "Storage Redundancy",
7
+ "name": {
8
+ "title": "S3 Bucket Name",
9
9
  "type": "string",
10
- "enum": [
11
- "normal",
12
- "reduced"
13
- ],
14
- "default": "normal"
15
- },
16
- "region": {
17
- "title": "DB Engine",
18
- "type": "string",
19
- "enum": [
20
- "",
21
- "us-west-1",
22
- "us-west-2",
23
- "EU",
24
- "ap-northeast-1",
25
- "ap-southeast-1",
26
- "ap-southeast-2"
27
- ],
28
- "default": ""
10
+ "default": "jellyfish"
29
11
  }
30
12
  }
31
13
  }
@@ -0,0 +1,19 @@
1
+ {
2
+ "type": "object",
3
+ "title": "AWS Fog Subnet",
4
+ "description": "AWS Fog Subnet",
5
+ "required": [],
6
+ "properties": {
7
+ "vpc_id": {
8
+ "title": "VPC ID",
9
+ "type": "string",
10
+ "default": "vpc-885fc5ed"
11
+ },
12
+ "cidr_block": {
13
+ "title": "CIDR Block",
14
+ "type": "string",
15
+ "default": "172.31.247.0/24"
16
+ }
17
+ }
18
+ }
19
+
@@ -0,0 +1,14 @@
1
+ {
2
+ "type": "object",
3
+ "title": "AWS Fog VPC",
4
+ "description": "AWS Fog VPC",
5
+ "required": [],
6
+ "properties": {
7
+ "cidr_block": {
8
+ "title": "Cidr Block",
9
+ "type": "string",
10
+ "default": "10.0.0.0/16"
11
+ }
12
+ }
13
+ }
14
+
@@ -1,7 +1,11 @@
1
1
  {
2
- "AWS Fog Databases": "Jellyfish::Fog::AWS::Databases",
2
+ "AWS Fog Database": "Jellyfish::Fog::AWS::Database",
3
3
  "AWS Fog Storage": "Jellyfish::Fog::AWS::Storage",
4
4
  "AWS Fog Infrastructure": "Jellyfish::Fog::AWS::Infrastructure",
5
+ "AWS Fog VPC": "Jellyfish::Fog::AWS::VPC",
6
+ "AWS Fog Subnet": "Jellyfish::Fog::AWS::Subnet",
7
+ "AWS Fog Security Group": "Jellyfish::Fog::AWS::SecurityGroup",
8
+ "AWS Fog EBS": "Jellyfish::Fog::AWS::EBS",
5
9
  "Azure Fog Infrastructure": "Jellyfish::Fog::Azure::Infrastructure",
6
10
  "VMWare Fog Infrastructure": "Jellyfish::Fog::VMWare::Infrastructure"
7
11
  }
@@ -6,8 +6,12 @@ require 'bcrypt'
6
6
  require 'jellyfish_fog/engine'
7
7
  require 'jellyfish_fog/provisioner'
8
8
  require 'jellyfish_fog/infrastructure'
9
- require 'jellyfish_fog/databases'
9
+ require 'jellyfish_fog/security_group'
10
+ require 'jellyfish_fog/database'
10
11
  require 'jellyfish_fog/storage'
12
+ require 'jellyfish_fog/subnet'
13
+ require 'jellyfish_fog/vpc'
14
+ require 'jellyfish_fog/ebs'
11
15
 
12
16
  module Jellyfish
13
17
  module Fog
@@ -0,0 +1,60 @@
1
+ require 'bcrypt'
2
+
3
+ module Jellyfish
4
+ module Fog
5
+ module AWS
6
+ class Database < Jellyfish::Provisioner
7
+ def provision
8
+ db = nil
9
+ handle_errors do
10
+ # GENERATE PASSWORD AND INSTANCE ID
11
+ @password = SecureRandom.hex(5)
12
+ db_instance_id = "id-#{@order_item.uuid[0..9]}"
13
+
14
+ # CREATE DB INSTANCE
15
+ db = connection.create_db_instance(db_instance_id, details)
16
+
17
+ # POPULATE PAYLOAD RESPONSE TEMPLATE
18
+ payload_response = payload_response_template
19
+ payload_response[:raw] = db
20
+
21
+ # INCLUDE IPADDRESS IF PRESENT
22
+ payload_response[:defaults][:ip_address] = db.local_address unless db.local_address.nil?
23
+
24
+ @order_item.provision_status = :ok
25
+ @order_item.payload_response = payload_response
26
+ end
27
+ end
28
+
29
+ def retire(skip_final_snap_shot = true)
30
+ handle_errors do
31
+ snapshot_id = skip_final_snap_shot ? '' : snapshot
32
+ connection.delete_db_instance(identifier, snapshot_id, skip_final_snap_shot)
33
+ end
34
+ @order_item.provision_status = :retired
35
+ end
36
+
37
+ private
38
+
39
+ def details
40
+ @order_item.answers.merge(
41
+ 'MasterUserPassword' => @password,
42
+ 'MasterUsername' => 'admin'
43
+ )
44
+ end
45
+
46
+ def connection
47
+ ::Fog::AWS::RDS.new(Jellyfish::Fog::AWS.settings.except(:provider))
48
+ end
49
+
50
+ def identifier
51
+ @order_item.payload_response['raw']['data']['body']['CreateDBInstanceResult']['DBInstance']['DBInstanceIdentifier']
52
+ end
53
+
54
+ def snapshot
55
+ "snapshot-#{@order_item.uuid[0..5]}"
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,40 @@
1
+ module Jellyfish
2
+ module Fog
3
+ module AWS
4
+ class EBS < Jellyfish::Provisioner
5
+ def provision
6
+ server = nil
7
+
8
+ handle_errors do
9
+ server = connection.volumes.new(details)
10
+ server.save
11
+ end
12
+
13
+ # POPULATE PAYLOAD RESPONSE TEMPLATE
14
+ payload_response = payload_response_template
15
+ payload_response[:raw] = JSON.parse(server.to_json)
16
+
17
+ @order_item.provision_status = :ok
18
+ @order_item.payload_response = payload_response
19
+ end
20
+
21
+ def retire
22
+ handle_errors do
23
+ connection.volumes.get(server_identifier).destroy
24
+ end
25
+ @order_item.provision_status = :retired
26
+ end
27
+
28
+ private
29
+
30
+ def connection
31
+ ::Fog::Compute.new(Jellyfish::Fog::AWS.settings)
32
+ end
33
+
34
+ def server_identifier
35
+ @order_item.payload_response['raw']['id']
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -28,16 +28,26 @@ module Jellyfish
28
28
  server = nil
29
29
 
30
30
  handle_errors do
31
+ details['vpc_id'] = nil if details['vpc_id'].blank?
32
+ details['subnet_id'] = nil if details['subnet_id'].blank?
33
+ details['security_group_ids'] = nil if details['security_group_ids'].blank?
31
34
  server = connection.servers.create(details).tap { |s| s.wait_for { ready? } }
32
35
  end
33
36
 
37
+ # POPULATE PAYLOAD RESPONSE TEMPLATE
38
+ payload_response = payload_response_template
39
+ payload_response[:raw] = JSON.parse(server.to_json)
40
+
41
+ # INCLUDE IPADDRESS IF PRESENT
42
+ payload_response[:defaults][:ip_address] = server.public_ip_address unless server.public_ip_address.nil?
43
+
34
44
  @order_item.provision_status = :ok
35
- @order_item.payload_response = server.to_json
45
+ @order_item.payload_response = payload_response
36
46
  end
37
47
 
38
48
  def retire
39
49
  handle_errors do
40
- connection.servers.delete(server_identifier)
50
+ connection.servers.get(server_identifier).destroy
41
51
  end
42
52
  @order_item.provision_status = :retired
43
53
  end
@@ -49,7 +59,7 @@ module Jellyfish
49
59
  end
50
60
 
51
61
  def server_identifier
52
- @order_item.payload_response['id']
62
+ @order_item.payload_response['raw']['id']
53
63
  end
54
64
  end
55
65
  end
@@ -0,0 +1,45 @@
1
+ module Jellyfish
2
+ module Fog
3
+ module AWS
4
+ class SecurityGroup < Jellyfish::Provisioner
5
+ def provision
6
+ server = nil
7
+
8
+ handle_errors do
9
+ # create_security_group(name, description, vpc_id = nil)
10
+ details['vpc_id'] = nil if details['vpc_id'].blank?
11
+ server = connection.create_security_group(details['name'], details['description'], details['vpc_id'])
12
+ end
13
+
14
+ # POPULATE PAYLOAD RESPONSE TEMPLATE
15
+ payload_response = payload_response_template
16
+ payload_response[:raw] = server
17
+
18
+ # INCLUDE IPADDRESS IF PRESENT
19
+ payload_response[:defaults][:ip_address] = server.local_address unless server.local_address.nil?
20
+
21
+ @order_item.provision_status = :ok
22
+ @order_item.payload_response = payload_response
23
+ end
24
+
25
+ def retire
26
+ handle_errors do
27
+ security_group_name = nil
28
+ connection.delete_security_group(security_group_name, server_identifier)
29
+ end
30
+ @order_item.provision_status = :retired
31
+ end
32
+
33
+ private
34
+
35
+ def connection
36
+ ::Fog::Compute.new(Jellyfish::Fog::AWS.settings)
37
+ end
38
+
39
+ def server_identifier
40
+ @order_item.payload_response['raw']['data']['body']['groupId']
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -3,22 +3,26 @@ module Jellyfish
3
3
  module AWS
4
4
  class Storage < Jellyfish::Provisioner
5
5
  def provision
6
- instance_name = "id-#{order_item.uuid[0..9]}"
7
- begin
8
- storage = connection.directories.create(key: instance_name, public: true)
9
- rescue Excon::Errors::BadRequest, Excon::Errors::Forbidden => e
10
- raise e, 'Bad request. Check for valid credentials and proper permissions.', e.backtrace
6
+ storage = nil
7
+
8
+ handle_errors do
9
+ storage_name = "id-#{order_item.uuid[0..9]}"
10
+ storage = connection.directories.create(key: storage_name)
11
11
  end
12
12
 
13
- order_item.payload_response = storage.to_json
14
- order_item.provision_status = 'ok'
13
+ # POPULATE PAYLOAD RESPONSE TEMPLATE
14
+ payload_response = payload_response_template
15
+ payload_response[:raw] = JSON.parse(storage.to_json)
16
+
17
+ @order_item.provision_status = :ok
18
+ @order_item.payload_response = payload_response
15
19
  end
16
20
 
17
21
  def retire
18
- connection.delete_bucket(storage_key)
19
- order_item.provision_status = 'retired'
20
- rescue Excon::Errors::BadRequest, Excon::Errors::Forbidden => e
21
- raise e, 'Bad request. Check for valid credentials and proper permissions.', e.backtrace
22
+ handle_errors do
23
+ connection.delete_bucket(identifier)
24
+ end
25
+ order_item.provision_status = :retired
22
26
  end
23
27
 
24
28
  private
@@ -27,8 +31,8 @@ module Jellyfish
27
31
  ::Fog::Storage.new(Jellyfish::Fog::AWS.settings)
28
32
  end
29
33
 
30
- def storage_key
31
- order_item.payload_response['key']
34
+ def identifier
35
+ @order_item.payload_response['raw']['key']
32
36
  end
33
37
  end
34
38
  end
@@ -0,0 +1,42 @@
1
+ module Jellyfish
2
+ module Fog
3
+ module AWS
4
+ class Subnet < Jellyfish::Provisioner
5
+ def provision
6
+ server = nil
7
+
8
+ handle_errors do
9
+ server = connection.create_subnet(details['vpc_id'], details['cidr_block'])
10
+ end
11
+
12
+ # POPULATE PAYLOAD RESPONSE TEMPLATE
13
+ payload_response = payload_response_template
14
+ payload_response[:raw] = server
15
+
16
+ # INCLUDE IP_ADDRESS IF PRESENT
17
+ payload_response[:defaults][:ip_address] = server.local_address unless server.local_address.nil?
18
+
19
+ @order_item.provision_status = :ok
20
+ @order_item.payload_response = payload_response
21
+ end
22
+
23
+ def retire
24
+ handle_errors do
25
+ connection.delete_subnet(server_identifier)
26
+ end
27
+ @order_item.provision_status = :retired
28
+ end
29
+
30
+ private
31
+
32
+ def connection
33
+ ::Fog::Compute.new(Jellyfish::Fog::AWS.settings)
34
+ end
35
+
36
+ def server_identifier
37
+ @order_item.payload_response['raw']['data']['body']['subnet']['subnetId']
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,5 +1,5 @@
1
1
  module Jellyfish
2
2
  module Fog
3
- VERSION = '0.0.4'
3
+ VERSION = '0.0.5'
4
4
  end
5
5
  end
@@ -0,0 +1,42 @@
1
+ module Jellyfish
2
+ module Fog
3
+ module AWS
4
+ class VPC < Jellyfish::Provisioner
5
+ def provision
6
+ server = nil
7
+
8
+ handle_errors do
9
+ server = connection.create_vpc(details['cidr_block'])
10
+ end
11
+
12
+ # POPULATE PAYLOAD RESPONSE TEMPLATE
13
+ payload_response = payload_response_template
14
+ payload_response[:raw] = server
15
+
16
+ # INCLUDE IPADDRESS IF PRESENT
17
+ payload_response[:defaults][:ip_address] = server.local_address unless server.local_address.nil?
18
+
19
+ @order_item.provision_status = :ok
20
+ @order_item.payload_response = payload_response
21
+ end
22
+
23
+ def retire
24
+ handle_errors do
25
+ connection.delete_vpc(server_identifier)
26
+ end
27
+ @order_item.provision_status = :retired
28
+ end
29
+
30
+ private
31
+
32
+ def connection
33
+ ::Fog::Compute.new(Jellyfish::Fog::AWS.settings)
34
+ end
35
+
36
+ def server_identifier
37
+ @order_item.payload_response['raw']['data']['body']['vpcSet'][0]['vpcId']
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jellyfish-fog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - mafernando
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-01 00:00:00.000000000 Z
11
+ date: 2015-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -137,19 +137,27 @@ files:
137
137
  - config/initializers/product_types.rb
138
138
  - config/initializers/provisioners.rb
139
139
  - config/product_questions/aws_database.json
140
+ - config/product_questions/aws_ebs.json
140
141
  - config/product_questions/aws_infrastructure.json
142
+ - config/product_questions/aws_security_group.json
141
143
  - config/product_questions/aws_storage.json
144
+ - config/product_questions/aws_subnet.json
145
+ - config/product_questions/aws_vpc.json
142
146
  - config/product_questions/azure_infrastructure.json
143
147
  - config/product_questions/vmware_infrastructure.json
144
148
  - config/provisioners.json
145
149
  - lib/jellyfish-fog.rb
146
150
  - lib/jellyfish_fog.rb
147
- - lib/jellyfish_fog/databases.rb
151
+ - lib/jellyfish_fog/database.rb
152
+ - lib/jellyfish_fog/ebs.rb
148
153
  - lib/jellyfish_fog/engine.rb
149
154
  - lib/jellyfish_fog/infrastructure.rb
150
155
  - lib/jellyfish_fog/provisioner.rb
156
+ - lib/jellyfish_fog/security_group.rb
151
157
  - lib/jellyfish_fog/storage.rb
158
+ - lib/jellyfish_fog/subnet.rb
152
159
  - lib/jellyfish_fog/version.rb
160
+ - lib/jellyfish_fog/vpc.rb
153
161
  - lib/tasks/jellyfish_fog_tasks.rake
154
162
  homepage: http://www.projectjellyfish.org/
155
163
  licenses:
@@ -1,47 +0,0 @@
1
- require 'bcrypt'
2
-
3
- module Jellyfish
4
- module Fog
5
- module AWS
6
- class Databases < Jellyfish::Provisioner
7
- def provision
8
- @password = SecureRandom.hex(5)
9
- db_instance_id = "id-#{@order_item.uuid[0..9]}"
10
- handle_errors do
11
- db = connection.create_db_instance(db_instance_id, details)
12
- @order_item.payload_response = db.to_json
13
- @order_item.provision_status = 'ok'
14
- end
15
- end
16
-
17
- def retire
18
- connection.delete_db_instance(identifier, snapshot, false)
19
- @order_item.provision_status = 'retired'
20
- rescue Excon::Errors::BadRequest, Excon::Errors::Forbidden => e
21
- raise e, 'Bad request. Check for valid credentials and proper permissions.', e.backtrace
22
- end
23
-
24
- private
25
-
26
- def details
27
- @order_item.answers.merge(
28
- 'MasterUserPassword' => @password,
29
- 'MasterUsername' => 'admin'
30
- )
31
- end
32
-
33
- def connection
34
- ::Fog::AWS::RDS.new(Jellyfish::Fog::AWS.settings.except(:provider))
35
- end
36
-
37
- def identifier
38
- @order_item.payload_response['data']['body']['CreateDBInstanceResult']['DBInstance']['DBInstanceIdentifier']
39
- end
40
-
41
- def snapshot
42
- "snapshot-#{@order_item.uuid[0..5]}"
43
- end
44
- end
45
- end
46
- end
47
- end