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,9 @@
1
+ if ENV['MIQ_URL']
2
+ ManageIQClient.host = ENV['MIQ_URL']
3
+
4
+ ManageIQClient.verify_ssl = (::Rails.env.development? && ::OpenSSL::SSL::VERIFY_NONE) || ENV.fetch('MIQ_SSL', ::OpenSSL::SSL::VERIFY_PEER)
5
+
6
+ if ENV['MIQ_USERNAME'] && ENV['MIQ_PASSWORD']
7
+ ManageIQClient.credentials = { user: ENV['MIQ_USERNAME'], password: ENV['MIQ_PASSWORD'] }
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+ Dir.glob(Jellyfish::ManageIQ::Engine.root.join('config', 'product_questions', '*.json')) do |filename|
2
+ product_type = JSON.parse(File.read(filename))
3
+ Rails.application.config.x.product_types.merge!(
4
+ product_type['title'] => product_type
5
+ )
6
+ end
@@ -0,0 +1,9 @@
1
+ require 'jellyfish/manageiq/storage'
2
+ require 'jellyfish/manageiq/big_data'
3
+ require 'jellyfish/manageiq/databases'
4
+ require 'jellyfish/manageiq/infrastructure'
5
+
6
+ Rails.application.config.x.provisioners.merge!(
7
+ JSON.parse(File.read(Jellyfish::ManageIQ::Engine.root.join('config', 'provisioners.json')))
8
+ .map { |product_type, provisioner| [product_type, provisioner.constantize] }.to_h
9
+ )
@@ -0,0 +1,12 @@
1
+ # Use this file to easily define all of your cron jobs.
2
+
3
+ # Learn more: http://github.com/jmettraux/rufus-scheduler
4
+
5
+ require 'rufus-scheduler'
6
+ require 'rake'
7
+
8
+ scheduler = Rufus::Scheduler.new
9
+
10
+ scheduler.every '15m' do
11
+ Rake::Task['jellyfish:manageiq:pollvms']
12
+ end
@@ -0,0 +1,50 @@
1
+ {
2
+ "type": "object",
3
+ "title": "ManageIQ Big Data",
4
+ "description": "ManageIQ Big Data",
5
+ "required": ["CloudProvider", "ServiceCatalogId", "ServiceTemplateId", "CpuCount", "DiskSize", "RamSize"],
6
+ "properties": {
7
+ "CloudProvider": {
8
+ "title": "Cloud Provider",
9
+ "type": "string",
10
+ "enum": [
11
+ "OpenStack",
12
+ "Google",
13
+ "VMware",
14
+ "Rackspace",
15
+ "Azure",
16
+ "AWS",
17
+ "Other"
18
+ ],
19
+ "default": "AWS"
20
+ },
21
+ "ChefRole": {
22
+ "title": "Chef Role",
23
+ "type": "string"
24
+ },
25
+ "ServiceCatalogId": {
26
+ "title": "ManageIQ Service Catalog ID",
27
+ "type": "string"
28
+ },
29
+ "ServiceTemplateId": {
30
+ "title": "ManageIQ Service Template ID",
31
+ "type": "string"
32
+ },
33
+ "CpuCount": {
34
+ "title": "CPU",
35
+ "type": "string",
36
+ "enum": ["1", "2", "4", "6", "8"],
37
+ "default": "1"
38
+ },
39
+ "DiskSize": {
40
+ "title": "Disk Size",
41
+ "type": "string",
42
+ "default": "40"
43
+ },
44
+ "RamSize": {
45
+ "title": "RAM",
46
+ "type": "string",
47
+ "default": "4"
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,79 @@
1
+ {
2
+ "type": "object",
3
+ "title": "ManageIQ Databases",
4
+ "description": "ManageIQ Databases",
5
+ "required": ["CloudProvider", "ServiceCatalogId", "ServiceTemplateId", "DBInstanceClass", "Engine", "AllocatedStorage"],
6
+ "properties": {
7
+ "CloudProvider": {
8
+ "title": "Cloud Provider",
9
+ "type": "string",
10
+ "enum": [
11
+ "OpenStack",
12
+ "Google",
13
+ "VMware",
14
+ "Rackspace",
15
+ "Azure",
16
+ "AWS",
17
+ "Other"
18
+ ],
19
+ "default": "AWS"
20
+ },
21
+ "ChefRole": {
22
+ "title": "Chef Role",
23
+ "type": "string"
24
+ },
25
+ "ServiceCatalogId": {
26
+ "title": "ManageIQ Service Catalog ID",
27
+ "type": "string"
28
+ },
29
+ "ServiceTemplateId": {
30
+ "title": "ManageIQ Service Template ID",
31
+ "type": "string"
32
+ },
33
+ "DBInstanceClass": {
34
+ "title": "DB Instance Size",
35
+ "type": "string",
36
+ "enum": [
37
+ "db.m3.medium",
38
+ "db.m3.large",
39
+ "db.m3.xlarge"
40
+ ],
41
+ "default": "db.m3.medium"
42
+ },
43
+ "Engine": {
44
+ "title": "DB Engine",
45
+ "type": "string",
46
+ "enum": [
47
+ "aurora",
48
+ "mysql",
49
+ "postgresql",
50
+ "sqlserver"
51
+ ]
52
+ },
53
+ "AllocatedStorage": {
54
+ "title": "Disk Size",
55
+ "type": "string",
56
+ "default": "40"
57
+ },
58
+ "StorageType": {
59
+ "title": "Storage Type",
60
+ "type": "string",
61
+ "enum": [
62
+ "ssd",
63
+ "standard",
64
+ "gp2",
65
+ "io1"
66
+ ],
67
+ "default": "ssd"
68
+ },
69
+ "availability": {
70
+ "title": "Storage Redundancy",
71
+ "type": "string",
72
+ "enum": [
73
+ "normal",
74
+ "reduced"
75
+ ],
76
+ "default": "normal"
77
+ }
78
+ }
79
+ }
@@ -0,0 +1,49 @@
1
+ {
2
+ "type": "object",
3
+ "title": "ManageIQ Infrastructure",
4
+ "description": "ManageIQ Infrastructure",
5
+ "required": ["CloudProvider", "ServiceCatalogId", "ServiceTemplateId", "InstanceSize", "DiskSize"],
6
+ "properties": {
7
+ "CloudProvider": {
8
+ "title": "Cloud Provider",
9
+ "type": "string",
10
+ "enum": [
11
+ "OpenStack",
12
+ "Google",
13
+ "VMware",
14
+ "Rackspace",
15
+ "Azure",
16
+ "AWS",
17
+ "Other"
18
+ ],
19
+ "default": "AWS"
20
+ },
21
+ "ChefRole": {
22
+ "title": "Chef Role",
23
+ "type": "string"
24
+ },
25
+ "ServiceCatalogId": {
26
+ "title": "ManageIQ Service Catalog ID",
27
+ "type": "string"
28
+ },
29
+ "ServiceTemplateId": {
30
+ "title": "ManageIQ Service Template ID",
31
+ "type": "string"
32
+ },
33
+ "InstanceSize": {
34
+ "title": "Instance Size",
35
+ "type": "string",
36
+ "enum": [
37
+ "t2.micro",
38
+ "m3.medium",
39
+ "m3.large"
40
+ ],
41
+ "default": "m3.medium"
42
+ },
43
+ "DiskSize": {
44
+ "title": "Disk Size",
45
+ "type": "string",
46
+ "default": "40"
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,57 @@
1
+ {
2
+ "type": "object",
3
+ "title": "ManageIQ Storage",
4
+ "description": "ManageIQ Storage",
5
+ "required": ["CloudProvider", "ServiceCatalogId", "ServiceTemplateId", "availability", "region"],
6
+ "properties": {
7
+ "CloudProvider": {
8
+ "title": "Cloud Provider",
9
+ "type": "string",
10
+ "enum": [
11
+ "OpenStack",
12
+ "Google",
13
+ "VMware",
14
+ "Rackspace",
15
+ "Azure",
16
+ "AWS",
17
+ "Other"
18
+ ],
19
+ "default": "AWS"
20
+ },
21
+ "ChefRole": {
22
+ "title": "Chef Role",
23
+ "type": "string"
24
+ },
25
+ "ServiceCatalogId": {
26
+ "title": "ManageIQ Service Catalog ID",
27
+ "type": "string"
28
+ },
29
+ "ServiceTemplateId": {
30
+ "title": "ManageIQ Service Template ID",
31
+ "type": "string"
32
+ },
33
+ "availability": {
34
+ "title": "Storage Redundancy",
35
+ "type": "string",
36
+ "enum": [
37
+ "normal",
38
+ "reduced"
39
+ ],
40
+ "default": "normal"
41
+ },
42
+ "region": {
43
+ "title": "DB Engine",
44
+ "type": "string",
45
+ "enum": [
46
+ "",
47
+ "us-west-1",
48
+ "us-west-2",
49
+ "EU",
50
+ "ap-northeast-1",
51
+ "ap-southeast-1",
52
+ "ap-southeast-2"
53
+ ],
54
+ "default": ""
55
+ }
56
+ }
57
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "ManageIQ Databases": "Jellyfish::ManageIQ::Databases",
3
+ "ManageIQ Big Data": "Jellyfish::ManageIQ::BigData",
4
+ "ManageIQ Storage": "Jellyfish::ManageIQ::Storage",
5
+ "ManageIQ Infrastructure": "Jellyfish::ManageIQ::Infrastructure"
6
+ }
@@ -0,0 +1,38 @@
1
+ Rails.application.routes.draw do
2
+ scope '/api/v1' do
3
+ scope 'manageiq', module: 'manageiq' do
4
+ # Automate Routes
5
+ resources :automate, only: [] do
6
+ collection do
7
+ get :catalog_item_initialization
8
+ get :update_servicemix_and_chef
9
+ get :provision_rds
10
+
11
+ get :create_ec2
12
+ get :create_rds
13
+ get :create_s3
14
+ get :create_ses
15
+ get :create_vmware_vm
16
+ get :create_chef_node
17
+
18
+ get :retire_ec2
19
+ get :retire_rds
20
+ get :retire_s3
21
+ get :retire_ses
22
+ get :retire_vmware_vm
23
+ end
24
+ end
25
+
26
+ # Provision Request Response
27
+ # Gives us named routes like manageiq_start_service
28
+ # and route paths like /api/v1/manageiq/order_items/:id/start_service
29
+ namespace :order_items, defaults: { format: :json }, only: :update, as: 'manageiq' do
30
+ scope '/:id' do
31
+ put :start_service
32
+ put :stop_service
33
+ put :provision_update
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,16 @@
1
+ class CreateJellyfishManageiqDatabaseProducts < ActiveRecord::Migration
2
+ def change
3
+ create_table :jellyfish_manageiq_database_products do |t|
4
+ t.timestamps
5
+ t.string :cloud_provider
6
+ t.string :chef_role
7
+ t.integer :service_catalog_id
8
+ t.integer :service_template_id
9
+ t.string :db_instance_class
10
+ t.string :engine
11
+ t.float :allocated_storage
12
+ t.string :storage_type
13
+ t.string :availability
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ class CreateJellyfishManageiqBigDataProducts < ActiveRecord::Migration
2
+ def change
3
+ create_table :jellyfish_manageiq_big_data_products do |t|
4
+ t.timestamps
5
+ t.string :cloud_provider
6
+ t.string :chef_role
7
+ t.integer :service_catalog_id
8
+ t.integer :service_template_id
9
+ t.integer :cpu_count
10
+ t.float :disk_size
11
+ t.float :ram_size
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ class CreateJellyfishManageiqInfrastructureProducts < ActiveRecord::Migration
2
+ def change
3
+ create_table :jellyfish_manageiq_infrastructure_products do |t|
4
+ t.timestamps
5
+ t.string :cloud_provider
6
+ t.string :chef_role
7
+ t.integer :service_catalog_id
8
+ t.integer :service_template_id
9
+ t.string :instance_size
10
+ t.float :disk_size
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ class CreateJellyfishManageiqStorageProducts < ActiveRecord::Migration
2
+ def change
3
+ create_table :jellyfish_manageiq_storage_products do |t|
4
+ t.timestamps
5
+ t.string :cloud_provider
6
+ t.string :chef_role
7
+ t.integer :service_catalog_id
8
+ t.integer :service_template_id
9
+ t.string :availability
10
+ t.string :region
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,34 @@
1
+ require 'jellyfish/provisioner'
2
+ require 'jellyfish/manageiq/provisioner'
3
+ require 'jellyfish/manageiq/engine'
4
+ require 'jellyfish/manageiq/storage'
5
+ require 'jellyfish/manageiq/big_data'
6
+ require 'jellyfish/manageiq/databases'
7
+ require 'jellyfish/manageiq/infrastructure'
8
+
9
+ module Jellyfish
10
+ module ManageIQ
11
+ def self.miq_settings
12
+ # Note for miq_ssl below:
13
+ # On OS/X, for development only, it may be easiest just to disable certificate verification because the
14
+ # certificates are stored in the keychain, not the file system.
15
+ # https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
16
+ {
17
+ miq_url: ENV.fetch('MIQ_URL'),
18
+ miq_username: ENV.fetch('MIQ_USERNAME'),
19
+ miq_password: ENV.fetch('MIQ_PASSWORD'),
20
+ miq_user_email: ENV.fetch('MIQ_USER_EMAIL', 'miq@' + ::URI.parse(ENV.fetch('MIQ_URL')).host),
21
+ miq_user_token: ENV.fetch('MIQ_USER_TOKEN', 'jellyfish-token'),
22
+ miq_referer: ENV.fetch('MIQ_REFERER', ENV.fetch('DEFAULT_URL') + '/api/v1/manageiq/order_item/update_provision'),
23
+ miq_ssl: (::Rails.env.development? && ::OpenSSL::SSL::VERIFY_NONE) || ENV.fetch('MIQ_SSL', ::OpenSSL::SSL::VERIFY_PEER)
24
+ }
25
+ end
26
+
27
+ def self.aws_settings
28
+ {
29
+ aws_access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'),
30
+ aws_secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY')
31
+ }
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,6 @@
1
+ module Jellyfish
2
+ module ManageIQ
3
+ class BigData < Jellyfish::ManageIQ::Provisioner
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Jellyfish
2
+ module ManageIQ
3
+ class Databases < Jellyfish::ManageIQ::Provisioner
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,19 @@
1
+ module Jellyfish
2
+ module ManageIQ
3
+ class Engine < ::Rails::Engine
4
+ engine_name 'jellyfish_manageiq' # For identification in rake tasks
5
+
6
+ config.autoload_paths += %W(#{config.root}/lib)
7
+
8
+ # This lets our migrations run with a simple rake db:migrate from the app
9
+ # http://pivotallabs.com/leave-your-migrations-in-your-rails-engines/
10
+ initializer :append_migrations do |app|
11
+ unless app.root.to_s == root.to_s
12
+ config.paths['db/migrate'].expanded.each do |expanded_path|
13
+ app.config.paths['db/migrate'] << expanded_path
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end