jellyfish-fog 0.0.3 → 0.0.4

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: cd1297e817ca5f4ddce3854889f32c32321b9f5d
4
- data.tar.gz: 16e7a0922d310bb17aa44c277c57f5e28a342e15
3
+ metadata.gz: d04e61608cc847611bbdbc2b46cc2ab0e225d4f1
4
+ data.tar.gz: 4fe07b73bbe512316d6c235918ea7fb67e6c03b2
5
5
  SHA512:
6
- metadata.gz: 4e16e0b451153d8dadee20a8fabbf05ddfc8831a9e9bbc803588b60f2fbfa45447736344447adddd24210f0481004867f2e45c7d0a6420ddc1b3efe02f01ad30
7
- data.tar.gz: 6c0cf4fe767f19fdf05aae4e8c605db2634af32491df27cdf75d3e2fc9a7a91fc1bbeeff38ee7da70e3964e9e0bfb1e5873dcf0515ba3480f4595aa9c0ba2464
6
+ metadata.gz: 1237e4605d6390e0aa705607099cd4003ac5b3e445b2fc66b628eac76cf5a5369afa421f9953ff059481cb09a08e4c5ff51da994f53498f8120a2eceef188570
7
+ data.tar.gz: a70b5bbc020d18b39a9463e545c48ff535b8109f4e64ff54e93fc094184e1be4fac8087ef93ac0d9be6217f8bd4669d2fcc660f0d2aad7c741eae64a03fa4718
@@ -0,0 +1,8 @@
1
+ require 'azure'
2
+
3
+ Azure.configure do |config|
4
+ # Configure these 3 properties to use Storage
5
+ config.management_certificate = ENV['JELLYFISH_AZURE_PEM_PATH']
6
+ config.subscription_id = ENV['JELLYFISH_AZURE_SUB_ID']
7
+ config.management_endpoint = ENV['JELLYFISH_AZURE_API_URL']
8
+ end
@@ -7,7 +7,7 @@
7
7
  "image" :{
8
8
  "title": "Image ID",
9
9
  "type": "string",
10
- "default": "jellyfish-20150519-359159-os-2015-05-19"
10
+ "default": "a699494373c04fc0bc8f2bb1389d6106__Win2K8R2SP1-Datacenter-201504.01-en.us-127GB.vhd"
11
11
  },
12
12
  "location" : {
13
13
  "title": "Location",
@@ -17,12 +17,12 @@
17
17
  "vm_name" :{
18
18
  "title": "VM Name",
19
19
  "type": "string",
20
- "default": "fog-server"
20
+ "default": "fogvmclone"
21
21
  },
22
22
  "vm_user" :{
23
23
  "title": "VM User",
24
24
  "type": "string",
25
- "default": "foguser"
25
+ "default": "jellyfish"
26
26
  },
27
27
 
28
28
  "password" :{
@@ -33,7 +33,7 @@
33
33
  "storage_account_name" :{
34
34
  "title": "Storage Account Name",
35
35
  "type": "string",
36
- "default": "fogstorage"
36
+ "default": "fogvmclonestorage"
37
37
  }
38
38
  }
39
39
  }
@@ -10,7 +10,7 @@ module Jellyfish
10
10
  end
11
11
 
12
12
  server['new_vm'] = server['new_vm'].except('parent')
13
- @order_item.provision_status = 'ok'
13
+ @order_item.provision_status = :ok
14
14
  @order_item.payload_response = server.to_json
15
15
  end
16
16
 
@@ -31,7 +31,7 @@ module Jellyfish
31
31
  server = connection.servers.create(details).tap { |s| s.wait_for { ready? } }
32
32
  end
33
33
 
34
- @order_item.provision_status = 'ok'
34
+ @order_item.provision_status = :ok
35
35
  @order_item.payload_response = server.to_json
36
36
  end
37
37
 
@@ -39,7 +39,7 @@ module Jellyfish
39
39
  handle_errors do
40
40
  connection.servers.delete(server_identifier)
41
41
  end
42
- @order_item.provision_status = 'retired'
42
+ @order_item.provision_status = :retired
43
43
  end
44
44
 
45
45
  private
@@ -58,20 +58,41 @@ module Jellyfish
58
58
  class Infrastructure < Jellyfish::Provisioner
59
59
  def provision
60
60
  server = nil
61
+ current_vm = nil
61
62
 
62
63
  handle_errors do
64
+ # CREATE THE AZURE VM CLONE
63
65
  server = connection.servers.create(details)
66
+
67
+ # LOOK UP VMS ASSOCIATED WITH AZURE SUBSCRIPTION
68
+ azure_vmms = ::Azure::VirtualMachineManagementService.new
69
+ vms = azure_vmms.list_virtual_machines
70
+
71
+ # LOCATE THE VM JUST CREATED
72
+ # vms.each { |vm| current_vm = vm if vm.vm_name == details['vm_name'] }
73
+ vms.each do |vm|
74
+ current_vm = vm if vm.vm_name == details[:vm_name]
75
+ end
64
76
  end
65
77
 
66
- order_item.provision_status = :ok
67
- order_item.payload_response = server.attributes
78
+ # POPULATE PAYLOAD RESPONSE TEMPLATE
79
+ payload_response = payload_response_template
80
+ payload_response[:raw] = server.attributes
81
+
82
+ # INCLUDE IPADDRESS AND HOSTANME IF THEY EXIST
83
+ payload_response[:defaults][:ip_address] = current_vm.ipaddress unless current_vm.ipaddress.nil?
84
+ payload_response[:defaults][:hostname] = current_vm.hostname unless current_vm.hostname.nil?
85
+
86
+ # UPDATE ORDER ITEM - SET STATUS TO CRITICAL IF CANNOT LOCATE IPADDRESS
87
+ @order_item.provision_status = current_vm.ipaddress.nil? ? :warning : :ok
88
+ @order_item.payload_response = payload_response
68
89
  end
69
90
 
70
91
  def retire
71
92
  handle_errors do
72
- connection.delete_virtual_machine(server_attributes[:vm_name], server_attributes[:cloud_service_name])
93
+ connection.delete_virtual_machine(server_attributes['vm_name'], server_attributes['cloud_service_name'])
73
94
  end
74
- order_item.provision_status = :retired
95
+ @order_item.provision_status = :retired
75
96
  end
76
97
 
77
98
  private
@@ -81,7 +102,7 @@ module Jellyfish
81
102
  end
82
103
 
83
104
  def server_attributes
84
- order_item.payload_response
105
+ @order_item.payload_response['raw']
85
106
  end
86
107
  end
87
108
  end
@@ -18,6 +18,10 @@ module Jellyfish
18
18
  order_item.answers
19
19
  end
20
20
 
21
+ def payload_response_template
22
+ { defaults: { ip_address: '127.0.0.1', hostname: 'TBD', total: '0.0' }, raw: nil }
23
+ end
24
+
21
25
  def self.perform(order_item_id, error_method)
22
26
  order_item = OrderItem.find(order_item_id)
23
27
  yield order_item
@@ -1,5 +1,5 @@
1
1
  module Jellyfish
2
2
  module Fog
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
  end
5
5
  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.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - mafernando
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-27 00:00:00.000000000 Z
11
+ date: 2015-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -132,13 +132,14 @@ files:
132
132
  - LICENSE
133
133
  - README.md
134
134
  - Rakefile
135
+ - config/initializers/azure.rb
135
136
  - config/initializers/fog.rb
136
137
  - config/initializers/product_types.rb
137
138
  - config/initializers/provisioners.rb
139
+ - config/product_questions/aws_database.json
140
+ - config/product_questions/aws_infrastructure.json
141
+ - config/product_questions/aws_storage.json
138
142
  - config/product_questions/azure_infrastructure.json
139
- - config/product_questions/database.json
140
- - config/product_questions/infrastructure.json
141
- - config/product_questions/storage.json
142
143
  - config/product_questions/vmware_infrastructure.json
143
144
  - config/provisioners.json
144
145
  - lib/jellyfish-fog.rb