jellyfish-manageiq 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +202 -0
  3. data/README.md +109 -0
  4. data/Rakefile +25 -0
  5. data/app/assets/images/jellyfish_manageiq/products/apache.png +0 -0
  6. data/app/assets/images/jellyfish_manageiq/products/aws_ec2.png +0 -0
  7. data/app/assets/images/jellyfish_manageiq/products/aws_rds.png +0 -0
  8. data/app/assets/images/jellyfish_manageiq/products/aws_s3.png +0 -0
  9. data/app/assets/images/jellyfish_manageiq/products/bugzilla.png +0 -0
  10. data/app/assets/images/jellyfish_manageiq/products/confluence.png +0 -0
  11. data/app/assets/images/jellyfish_manageiq/products/database.png +0 -0
  12. data/app/assets/images/jellyfish_manageiq/products/dna.png +0 -0
  13. data/app/assets/images/jellyfish_manageiq/products/exchange.png +0 -0
  14. data/app/assets/images/jellyfish_manageiq/products/f5.png +0 -0
  15. data/app/assets/images/jellyfish_manageiq/products/firewall.png +0 -0
  16. data/app/assets/images/jellyfish_manageiq/products/hadoop.png +0 -0
  17. data/app/assets/images/jellyfish_manageiq/products/java.png +0 -0
  18. data/app/assets/images/jellyfish_manageiq/products/jira.png +0 -0
  19. data/app/assets/images/jellyfish_manageiq/products/kb.png +0 -0
  20. data/app/assets/images/jellyfish_manageiq/products/man.png +0 -0
  21. data/app/assets/images/jellyfish_manageiq/products/mean.png +0 -0
  22. data/app/assets/images/jellyfish_manageiq/products/mssql.png +0 -0
  23. data/app/assets/images/jellyfish_manageiq/products/netapp.png +0 -0
  24. data/app/assets/images/jellyfish_manageiq/products/oracle.png +0 -0
  25. data/app/assets/images/jellyfish_manageiq/products/php.png +0 -0
  26. data/app/assets/images/jellyfish_manageiq/products/postgresql.png +0 -0
  27. data/app/assets/images/jellyfish_manageiq/products/rails.png +0 -0
  28. data/app/assets/images/jellyfish_manageiq/products/redhat.png +0 -0
  29. data/app/assets/images/jellyfish_manageiq/products/teradata.png +0 -0
  30. data/app/assets/images/jellyfish_manageiq/products/ubuntu.png +0 -0
  31. data/app/assets/images/jellyfish_manageiq/products/windows.png +0 -0
  32. data/app/assets/images/jellyfish_manageiq/products/woman.png +0 -0
  33. data/app/assets/javascripts/jellyfish_manageiq/application.js +13 -0
  34. data/app/assets/javascripts/jellyfish_manageiq/products_admin_controller.js +63 -0
  35. data/app/assets/stylesheets/jellyfish_manageiq/application.css +15 -0
  36. data/app/controllers/manageiq/automate_controller.rb +61 -0
  37. data/app/controllers/manageiq/order_items_controller.rb +64 -0
  38. data/app/helpers/application_helper.rb +2 -0
  39. data/app/models/manage_iq_client.rb +12 -0
  40. data/app/models/manage_iq_client/base.rb +61 -0
  41. data/app/models/manage_iq_client/cluster.rb +9 -0
  42. data/app/models/manage_iq_client/datastore.rb +9 -0
  43. data/app/models/manage_iq_client/host.rb +9 -0
  44. data/app/models/manage_iq_client/policy.rb +9 -0
  45. data/app/models/manage_iq_client/policy_profile.rb +9 -0
  46. data/app/models/manage_iq_client/provider.rb +9 -0
  47. data/app/models/manage_iq_client/resource.rb +82 -0
  48. data/app/models/manage_iq_client/resource_pool.rb +9 -0
  49. data/app/models/manage_iq_client/server.rb +34 -0
  50. data/app/models/manage_iq_client/service.rb +9 -0
  51. data/app/models/manage_iq_client/service_catalog.rb +9 -0
  52. data/app/models/manage_iq_client/service_template.rb +9 -0
  53. data/app/models/manage_iq_client/template.rb +25 -0
  54. data/app/models/manage_iq_client/virtual_machine.rb +27 -0
  55. data/app/models/manage_iq_client/zone.rb +9 -0
  56. data/app/policies/manageiq/order_item_policy.rb +16 -0
  57. data/app/views/manageiq/automate/catalog_item_initialization.html.erb +0 -0
  58. data/app/views/manageiq/automate/create_chef_node.html.erb +97 -0
  59. data/app/views/manageiq/automate/create_ec2.html.erb +140 -0
  60. data/app/views/manageiq/automate/create_rds.html.erb +146 -0
  61. data/app/views/manageiq/automate/create_s3.html.erb +100 -0
  62. data/app/views/manageiq/automate/create_ses.html.erb +114 -0
  63. data/app/views/manageiq/automate/create_vmware_vm.html.erb +102 -0
  64. data/app/views/manageiq/automate/provision_rds.html.erb +130 -0
  65. data/app/views/manageiq/automate/retire_ec2.html.erb +96 -0
  66. data/app/views/manageiq/automate/retire_rds.html.erb +117 -0
  67. data/app/views/manageiq/automate/retire_s3.html.erb +93 -0
  68. data/app/views/manageiq/automate/retire_ses.html.erb +98 -0
  69. data/app/views/manageiq/automate/retire_vmware_vm.html.erb +70 -0
  70. data/app/views/manageiq/automate/update_servicemix_and_chef.html.erb +364 -0
  71. data/config/initializers/manage_iq_client.rb +9 -0
  72. data/config/initializers/product_types.rb +6 -0
  73. data/config/initializers/provisioners.rb +9 -0
  74. data/config/initializers/task_scheduler.rb +12 -0
  75. data/config/product_questions/big_data.json +50 -0
  76. data/config/product_questions/database.json +79 -0
  77. data/config/product_questions/infrastructure.json +49 -0
  78. data/config/product_questions/storage.json +57 -0
  79. data/config/provisioners.json +6 -0
  80. data/config/routes.rb +38 -0
  81. data/db/migrate/20150513221625_create_jellyfish_manageiq_database_products.rb +16 -0
  82. data/db/migrate/20150513221938_create_jellyfish_manageiq_big_data_products.rb +14 -0
  83. data/db/migrate/20150513222020_create_jellyfish_manageiq_infrastructure_products.rb +13 -0
  84. data/db/migrate/20150513222056_create_jellyfish_manageiq_storage_products.rb +13 -0
  85. data/lib/jellyfish/manageiq.rb +34 -0
  86. data/lib/jellyfish/manageiq/big_data.rb +6 -0
  87. data/lib/jellyfish/manageiq/databases.rb +6 -0
  88. data/lib/jellyfish/manageiq/engine.rb +19 -0
  89. data/lib/jellyfish/manageiq/infrastructure.rb +6 -0
  90. data/lib/jellyfish/manageiq/provisioner.rb +115 -0
  91. data/lib/jellyfish/manageiq/storage.rb +6 -0
  92. data/lib/jellyfish/manageiq/version.rb +5 -0
  93. data/lib/tasks/pollvms.rake +42 -0
  94. metadata +360 -0
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,61 @@
1
+ module Manageiq
2
+ # Display automate code for ManageIQ / CloudForms
3
+ class AutomateController < ::ApplicationController
4
+ layout false
5
+ def catalog_item_initialization
6
+ render 'manageiq/automate/catalog_item_initialization.html.erb', content_type: :plain
7
+ end
8
+
9
+ def update_servicemix_and_chef
10
+ render 'manageiq/automate/update_servicemix_and_chef.html.erb', content_type: :plain
11
+ end
12
+
13
+ def create_rds
14
+ render 'manageiq/automate/create_rds.html.erb', content_type: :plain
15
+ end
16
+
17
+ def provision_rds
18
+ render 'manageiq/automate/provision_rds.html.erb', content_type: :plain
19
+ end
20
+
21
+ def create_ec2
22
+ render 'manageiq/automate/create_ec2.html.erb', content_type: :plain
23
+ end
24
+
25
+ def create_s3
26
+ render 'manageiq/automate/create_s3.html.erb', content_type: :plain
27
+ end
28
+
29
+ def create_ses
30
+ render 'manageiq/automate/create_ses.html.erb', content_type: :plain
31
+ end
32
+
33
+ def retire_ec2
34
+ render 'manageiq/automate/retire_ec2.html.erb', content_type: :plain
35
+ end
36
+
37
+ def retire_rds
38
+ render 'manageiq/automate/retire_rds.html.erb', content_type: :plain
39
+ end
40
+
41
+ def retire_s3
42
+ render 'manageiq/automate/retire_s3.html.erb', content_type: :plain
43
+ end
44
+
45
+ def retire_ses
46
+ render 'manageiq/automate/retire_ses.html.erb', content_type: :plain
47
+ end
48
+
49
+ def create_vmware_vm
50
+ render 'manageiq/automate/create_vmware_vm.html.erb', content_type: :plain
51
+ end
52
+
53
+ def retire_vmware_vm
54
+ render 'manageiq/automate/retire_vmware_vm.html.erb', content_type: :plain
55
+ end
56
+
57
+ def create_chef_node
58
+ render 'manageiq/automate/create_chef_node.html.erb', content_type: :plain
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,64 @@
1
+ module Manageiq
2
+ class OrderItemsController < ::ApplicationController
3
+ after_action :verify_authorized
4
+
5
+ before_action :load_order_item, only: [:start_service, :stop_service]
6
+ before_action :load_order_item_for_update, only: :provision_update
7
+
8
+ api :PUT, '/manageiq/order_items/:order_item_id/start_service', 'Starts service for a provisioned order item'
9
+ param :id, :number, required: true
10
+
11
+ def start_service
12
+ authorize OrderItem
13
+ # TODO: Direct ManageIQ to pass along a start request
14
+ render nothing: true, status: :ok
15
+ end
16
+
17
+ api :PUT, '/manageiq/order_items/:id/stop_service', 'Stops service for a provisioned order item'
18
+ param :id, :number, required: true
19
+
20
+ def stop_service
21
+ authorize OrderItem
22
+ # TODO: Direct ManageIQ to pass along a stop request
23
+ render nothing: true, status: :ok
24
+ end
25
+
26
+ api :PUT, '/manageiq/order_items/:id/provision_update', 'Updates a provisioned order item from ManageIQ'
27
+ param :id, :number, required: true, desc: 'Order Item ID'
28
+ param :status, String, required: true, desc: 'Status of the provision request'
29
+ param :message, String, required: true, desc: 'Any messages from ManageIQ'
30
+ param :info, Hash, required: true, desc: 'Informational payload from ManageIQ' do
31
+ param :uuid, String, required: true, desc: 'V4 UUID Generated for order item upon creation'
32
+ param :provision_status, String, required: true, desc: 'Status of the provision request'
33
+ param :miq_id, :number, required: false, desc: 'The unique ID from ManageIQ'
34
+ end
35
+
36
+ error code: 404, desc: MissingRecordDetection::Messages.not_found
37
+ error code: 422, desc: ParameterValidation::Messages.missing
38
+
39
+ def provision_update
40
+ authorize @order_item
41
+
42
+ @order_item.update_attributes order_item_params_for_update
43
+ respond_with @order_item
44
+ end
45
+
46
+ private
47
+
48
+ def order_item_params
49
+ params.permit(:uuid)
50
+ end
51
+
52
+ def load_order_item
53
+ @order_item = OrderItem.find params.require(:id)
54
+ end
55
+
56
+ def order_item_params_for_update
57
+ params.require(:info).permit(:miq_id, :provision_status).merge(payload_response: ActionController::Parameters.new(JSON.parse(request.body.read)))
58
+ end
59
+
60
+ def load_order_item_for_update
61
+ @order_item = OrderItem.where(id: params.require(:id), uuid: params.require(:info)[:uuid]).first!
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,12 @@
1
+ module ManageIQClient
2
+ mattr_accessor :host
3
+ mattr_accessor :verify_ssl
4
+ mattr_accessor :auth_token
5
+
6
+ self.verify_ssl ||= true
7
+
8
+ def self.credentials=(credentials)
9
+ ManageIQClient::Base.user = credentials[:user]
10
+ ManageIQClient::Base.password = credentials[:password]
11
+ end
12
+ end
@@ -0,0 +1,61 @@
1
+ require 'rest-client'
2
+
3
+ module ManageIQClient
4
+ class Base
5
+ DEFAULT_HEADERS = { accept: :json, content_type: :json }
6
+ attr_accessor :client
7
+ cattr_accessor :user, :password
8
+
9
+ delegate :[], to: :client
10
+
11
+ def initialize
12
+ setup_args = [ManageIQClient.host]
13
+ setup_hash = { verify_ssl: ManageIQClient.verify_ssl }
14
+ setup_hash.merge! user: self.class.user, password: self.class.password unless ManageIQClient.auth_token
15
+ setup_args += [setup_hash]
16
+ @client = RestClient::Resource.new(*setup_args)
17
+ end
18
+
19
+ def headers
20
+ headers = DEFAULT_HEADERS
21
+ headers.merge! 'X-Auth-Token' => ManageIQClient.auth_token if ManageIQClient.auth_token
22
+ headers
23
+ end
24
+
25
+ def save(resource)
26
+ path = resource.class.collection_path
27
+ payload = resource.to_payload
28
+ payload.merge! files: resource.files if resource.respond_to?(:files) && resource.files
29
+ send_payload path, 'add', payload
30
+ end
31
+
32
+ def update(resource)
33
+ path = resource.resource_pathh
34
+ payload = resource.to_payload
35
+ payload.merge! files: resource.files if resource.respond_to?(:files) && resource.files
36
+ send_payload path, 'edit', payload
37
+ end
38
+
39
+ def destroy(resource)
40
+ client[resource.path].delete headers
41
+ end
42
+
43
+ def find(path, params = {})
44
+ ActiveSupport::JSON.decode(client[path_and_params path, params].get headers)
45
+ end
46
+
47
+ def path_and_params(path, params)
48
+ params.nil? ? path : [path, params.to_param].join('?')
49
+ end
50
+
51
+ private
52
+
53
+ def send_payload(path, action, payload)
54
+ msg = { action: action, resource: payload }
55
+ case action
56
+ when 'add', 'create', 'edit'
57
+ client[path].post msg, headers
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,9 @@
1
+ module ManageIQClient
2
+ class Cluster
3
+ include ManageIQClient::Resource
4
+
5
+ self.path = '/api/clusters'
6
+
7
+ attribute :id, Integer
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module ManageIQClient
2
+ class Datastore
3
+ include ManageIQClient::Resource
4
+
5
+ self.path = '/api/datastores'
6
+
7
+ attribute :id, Integer
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module ManageIQClient
2
+ class Host
3
+ include ManageIQClient::Resource
4
+
5
+ self.path = '/api/hosts'
6
+
7
+ attribute :id, Integer
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module ManageIQClient
2
+ class Policy
3
+ include ManageIQClient::Resource
4
+
5
+ self.path = '/api/policies'
6
+
7
+ attribute :id, Integer
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module ManageIQClient
2
+ class PolicyProfile
3
+ include ManageIQClient::Resource
4
+
5
+ self.path = '/api/policy_profiles'
6
+
7
+ attribute :id, Integer
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module ManageIQClient
2
+ class Provider
3
+ include ManageIQClient::Resource
4
+
5
+ self.path = '/api/providers'
6
+
7
+ attribute :id, Integer
8
+ end
9
+ end
@@ -0,0 +1,82 @@
1
+ require 'virtus'
2
+
3
+ module ManageIQClient
4
+ module Resource
5
+ include ManageIQClient
6
+
7
+ def self.included(base)
8
+ base.include Virtus.model
9
+ base.extend ClassMethods
10
+ base.cattr_accessor :path
11
+ base.send(:attr_accessor, :errors)
12
+ base.send(:attr_accessor, :id)
13
+ end
14
+
15
+ module ClassMethods
16
+ def list(params = {})
17
+ client.find collection_path, params
18
+ end
19
+
20
+ def find(id, params = {})
21
+ new(client.find resource_path(id), params)
22
+ end
23
+
24
+ def client
25
+ @client ||= ManageIQClient::Base.new
26
+ end
27
+
28
+ def collection_path
29
+ path
30
+ end
31
+
32
+ def resource_path(id)
33
+ "#{path}/#{id}"
34
+ end
35
+ end
36
+
37
+ def initialize
38
+ @errors = []
39
+ end
40
+
41
+ def _id
42
+ id.split(path + '/')[-1].to_i
43
+ rescue
44
+ id
45
+ end
46
+
47
+ # TODO: ManageIQ uses a non RESTful message format
48
+ # def save
49
+ # res = client.save self
50
+ # self.id = ActiveSupport::JSON.decode(res)[resource_name]['id'] unless res.blank?
51
+ # true
52
+ # rescue RestClient::UnprocessableEntity => e
53
+ # self.errors = ActiveSupport::JSON.decode(e.response)
54
+ # false
55
+ # end
56
+
57
+ def client
58
+ self.class.client
59
+ end
60
+
61
+ def to_payload
62
+ attributes
63
+ # { resource_name => attributes }
64
+ end
65
+
66
+ def destroy
67
+ client.destroy self
68
+ end
69
+
70
+ def resource_name
71
+ self.class.to_s.demodulize.underscore
72
+ end
73
+
74
+ def to_json
75
+ { resource_name => attributes }.to_json
76
+ end
77
+
78
+ def path
79
+ [self.class.path, id].join '/'
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,9 @@
1
+ module ManageIQClient
2
+ class ResourcePool
3
+ include ManageIQClient::Resource
4
+
5
+ self.path = '/api/resource_pools'
6
+
7
+ attribute :id, Integer
8
+ end
9
+ end
@@ -0,0 +1,34 @@
1
+ module ManageIQClient
2
+ class Server
3
+ include ManageIQClient::Resource
4
+
5
+ self.path = '/api/servers'
6
+
7
+ attribute :id, String
8
+ attribute :name, String
9
+ attribute :guid, String
10
+ attribute :status, String
11
+ attribute :pid, Integer
12
+ attribute :started_on, DateTime
13
+ attribute :build, String
14
+ attribute :percent_memory, Float
15
+ attribute :percent_cpu, Float
16
+ attribute :cpu_time, Float
17
+ attribute :capabilities, Hash
18
+ attribute :last_heartbeat, DateTime
19
+ attribute :os_priority, Integer
20
+ attribute :is_master, Boolean
21
+ attribute :version, String
22
+ attribute :zone_id, String
23
+ attribute :memory_usage, Integer
24
+ attribute :memory_size, Integer
25
+ attribute :hostname, String
26
+ attribute :ipaddress, String
27
+ attribute :drb_uri, String
28
+ attribute :mac_address, String
29
+ attribute :has_active_userinterface, Boolean
30
+ attribute :has_active_webservices, Boolean
31
+ attribute :sql_spid, Integer
32
+ attribute :rhn_mirror, Boolean
33
+ end
34
+ end
@@ -0,0 +1,9 @@
1
+ module ManageIQClient
2
+ class Service
3
+ include ManageIQClient::Resource
4
+
5
+ self.path = '/api/services'
6
+
7
+ attribute :id, Integer
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module ManageIQClient
2
+ class ServiceCatalog
3
+ include ManageIQClient::Resource
4
+
5
+ self.path = '/api/service_catalogs'
6
+
7
+ attribute :id, Integer
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module ManageIQClient
2
+ class ServiceTemplate
3
+ include ManageIQClient::Resource
4
+
5
+ self.path = '/api/service_templates'
6
+
7
+ attribute :id, Integer
8
+ end
9
+ end