virtualmonkey 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. data/.document +5 -0
  2. data/LICENSE +20 -0
  3. data/README.rdoc +77 -0
  4. data/Rakefile +51 -0
  5. data/VERSION +1 -0
  6. data/bin/grinder +102 -0
  7. data/bin/mcicp +46 -0
  8. data/bin/monkey +12 -0
  9. data/bin/vary_instance_types +59 -0
  10. data/config/cloud_variables/all_clouds.json +30 -0
  11. data/config/cloud_variables/east.json +9 -0
  12. data/config/cloud_variables/rackspace.json +7 -0
  13. data/config/cloud_variables/west.json +9 -0
  14. data/config/common_inputs/apache_haproxy.json +27 -0
  15. data/config/common_inputs/base.json +5 -0
  16. data/config/common_inputs/ebs_toolbox.json +10 -0
  17. data/config/common_inputs/haproxy.json +15 -0
  18. data/config/common_inputs/lamp.json +30 -0
  19. data/config/common_inputs/mysql.json +24 -0
  20. data/config/common_inputs/none.json +4 -0
  21. data/config/common_inputs/php.json +25 -0
  22. data/config/common_inputs/php_aio_trial_chef_alpha.json +3 -0
  23. data/config/common_inputs/php_app_fe_chef.json +12 -0
  24. data/config/common_inputs/php_elb.json +12 -0
  25. data/config/common_inputs/qstart.json +5 -0
  26. data/config/common_inputs/rails.json +31 -0
  27. data/config/common_inputs/rails_aio_demo_chef_alpha.json +3 -0
  28. data/config/common_inputs/rails_aio_developer_chef_alpha.json +10 -0
  29. data/config/common_inputs/rsgrid.json +10 -0
  30. data/config/common_inputs/tomcat.json +15 -0
  31. data/config/common_inputs/windows_blog_engine.json +3 -0
  32. data/config/common_inputs/windows_net_aio.json +14 -0
  33. data/config/troop/11H1/backup/base.json +10 -0
  34. data/config/troop/11H1/backup/lamp_mysql_50.json +10 -0
  35. data/config/troop/11H1/backup/lamp_mysql_51.json +10 -0
  36. data/config/troop/11H1/backup/loadbalancer-php.json +13 -0
  37. data/config/troop/11H1/backup/loadbalancer.json +14 -0
  38. data/config/troop/11H1/backup/loadbalancer_rails.json +13 -0
  39. data/config/troop/11H1/backup/loadbalancer_tomcat6.json +13 -0
  40. data/config/troop/11H1/backup/mysql50.json +11 -0
  41. data/config/troop/11H1/backup/mysql50_toolbox.json +12 -0
  42. data/config/troop/11H1/backup/mysql51.json +11 -0
  43. data/config/troop/11H1/backup/mysql51_toolbox.json +12 -0
  44. data/config/troop/11H1/backup/php_elb.json +11 -0
  45. data/config/troop/11H1/base.json +10 -0
  46. data/config/troop/11H1/ebs_toolbox.json +12 -0
  47. data/config/troop/11H1/lamp_mysql_50.json +10 -0
  48. data/config/troop/11H1/lamp_mysql_51.json +10 -0
  49. data/config/troop/11H1/loadbalancer-php.json +13 -0
  50. data/config/troop/11H1/loadbalancer.json +17 -0
  51. data/config/troop/11H1/loadbalancer_rails.json +13 -0
  52. data/config/troop/11H1/loadbalancer_tomcat6.json +13 -0
  53. data/config/troop/11H1/mysql50.json +11 -0
  54. data/config/troop/11H1/mysql50_toolbox.json +12 -0
  55. data/config/troop/11H1/mysql51.json +11 -0
  56. data/config/troop/11H1/mysql51_awsdns.json +11 -0
  57. data/config/troop/11H1/mysql51_debug.json +11 -0
  58. data/config/troop/11H1/mysql51_toolbox.json +12 -0
  59. data/config/troop/11H1/php.json +13 -0
  60. data/config/troop/11H1/php_elb.json +11 -0
  61. data/config/troop/11H1/rails.json +13 -0
  62. data/config/troop/11H1/tomcat6.json +13 -0
  63. data/config/troop/chef_quickstart.json +10 -0
  64. data/config/troop/just_elb +10 -0
  65. data/config/troop/lamp_v4.json +10 -0
  66. data/config/troop/patch_test.json +10 -0
  67. data/config/troop/rightlink.json +10 -0
  68. data/config/troop/simple_fail.json +11 -0
  69. data/config/troop/simple_pass.json +11 -0
  70. data/config/troop/windows_blog_engine.json +10 -0
  71. data/config/troop/windows_net_aio.json +10 -0
  72. data/config/troop/windows_quick_start.json +10 -0
  73. data/features/base.rb +31 -0
  74. data/features/db_toolbox.rb +59 -0
  75. data/features/ebs_toolbox.rb +62 -0
  76. data/features/lamp.rb +33 -0
  77. data/features/lb-apache-haproxy.rb +49 -0
  78. data/features/mysql_5.x_v2_v4_from_scratch.rb +71 -0
  79. data/features/mysql_5.x_v2_v4_from_scratch_awsdns.rb +71 -0
  80. data/features/mysql_5.x_v2_v4_from_scratch_dyndns.rb +71 -0
  81. data/features/mysql_v1_upgrade_v2.rb +54 -0
  82. data/features/old_cuke_features/Rakefile +121 -0
  83. data/features/old_cuke_features/Steps-TODO +31 -0
  84. data/features/old_cuke_features/app_state.feature +25 -0
  85. data/features/old_cuke_features/app_test.feature +24 -0
  86. data/features/old_cuke_features/base.feature +16 -0
  87. data/features/old_cuke_features/chef_quickstart.feature +11 -0
  88. data/features/old_cuke_features/db_toolbox.feature +38 -0
  89. data/features/old_cuke_features/ebs_toolbox.feature +39 -0
  90. data/features/old_cuke_features/elb_create_delete.feature +41 -0
  91. data/features/old_cuke_features/elb_generic.feature +27 -0
  92. data/features/old_cuke_features/fe_app_checks.feature +21 -0
  93. data/features/old_cuke_features/just-start.feature +13 -0
  94. data/features/old_cuke_features/lamp.feature +15 -0
  95. data/features/old_cuke_features/lb-apache-haproxy.feature +27 -0
  96. data/features/old_cuke_features/mysql_5.x_v2_v4_from_scratch.feature +33 -0
  97. data/features/old_cuke_features/mysql_5.x_v2_v4_from_scratch_awsdns.feature +33 -0
  98. data/features/old_cuke_features/mysql_5.x_v2_v4_from_scratch_dyndns.feature +33 -0
  99. data/features/old_cuke_features/mysql_chef_premium.feature +27 -0
  100. data/features/old_cuke_features/mysql_chef_premium_from_scratch.feature +37 -0
  101. data/features/old_cuke_features/mysql_v1_upgrade_v2.feature +42 -0
  102. data/features/old_cuke_features/php.feature +27 -0
  103. data/features/old_cuke_features/php_aio_trial_chef_alpha.feature +11 -0
  104. data/features/old_cuke_features/php_chef.feature +21 -0
  105. data/features/old_cuke_features/php_elb.feature +41 -0
  106. data/features/old_cuke_features/rails.feature +26 -0
  107. data/features/old_cuke_features/rails_aio_developer_chef.feature +17 -0
  108. data/features/old_cuke_features/reboot.feature +23 -0
  109. data/features/old_cuke_features/rightlink.feature +19 -0
  110. data/features/old_cuke_features/rsgrid.feature +19 -0
  111. data/features/old_cuke_features/simple.feature +8 -0
  112. data/features/old_cuke_features/simple_fail.feature +9 -0
  113. data/features/old_cuke_features/start-stop.feature +13 -0
  114. data/features/old_cuke_features/step_definitions/app.rb +21 -0
  115. data/features/old_cuke_features/step_definitions/deployment_steps.rb +112 -0
  116. data/features/old_cuke_features/step_definitions/ebs.rb +36 -0
  117. data/features/old_cuke_features/step_definitions/elb.rb +35 -0
  118. data/features/old_cuke_features/step_definitions/lb.rb +22 -0
  119. data/features/old_cuke_features/step_definitions/mysql_steps.rb +84 -0
  120. data/features/old_cuke_features/terminate.feature +7 -0
  121. data/features/old_cuke_features/tomcat6-tests-TODO +29 -0
  122. data/features/old_cuke_features/tomcat6.feature +27 -0
  123. data/features/patch_test.rb +33 -0
  124. data/features/php.rb +54 -0
  125. data/features/php_elb.rb +78 -0
  126. data/features/rails.rb +54 -0
  127. data/features/start_only.rb +26 -0
  128. data/features/tomcat6.rb +54 -0
  129. data/lib/virtualmonkey.rb +28 -0
  130. data/lib/virtualmonkey/application.rb +75 -0
  131. data/lib/virtualmonkey/application_frontend.rb +42 -0
  132. data/lib/virtualmonkey/command.rb +39 -0
  133. data/lib/virtualmonkey/command/clone.rb +50 -0
  134. data/lib/virtualmonkey/command/create.rb +21 -0
  135. data/lib/virtualmonkey/command/destroy.rb +51 -0
  136. data/lib/virtualmonkey/command/list.rb +10 -0
  137. data/lib/virtualmonkey/command/run.rb +76 -0
  138. data/lib/virtualmonkey/command/troop.rb +146 -0
  139. data/lib/virtualmonkey/cuke_monk.rb +184 -0
  140. data/lib/virtualmonkey/deployment_monk.rb +132 -0
  141. data/lib/virtualmonkey/deployment_runner.rb +333 -0
  142. data/lib/virtualmonkey/ebs.rb +161 -0
  143. data/lib/virtualmonkey/ebs_runner.rb +59 -0
  144. data/lib/virtualmonkey/elb_runner.rb +194 -0
  145. data/lib/virtualmonkey/fe_app_runner.rb +7 -0
  146. data/lib/virtualmonkey/file_locations.rb +7 -0
  147. data/lib/virtualmonkey/frontend.rb +124 -0
  148. data/lib/virtualmonkey/http_checks.rb +33 -0
  149. data/lib/virtualmonkey/index.html.erb +109 -0
  150. data/lib/virtualmonkey/lamp_runner.rb +29 -0
  151. data/lib/virtualmonkey/mysql.rb +172 -0
  152. data/lib/virtualmonkey/mysql_runner.rb +108 -0
  153. data/lib/virtualmonkey/mysql_toolbox_runner.rb +51 -0
  154. data/lib/virtualmonkey/patch_runner.rb +46 -0
  155. data/lib/virtualmonkey/php_aio_trial_chef_runner.rb +6 -0
  156. data/lib/virtualmonkey/php_chef_runner.rb +69 -0
  157. data/lib/virtualmonkey/rails_aio_developer_chef_runner.rb +8 -0
  158. data/lib/virtualmonkey/shared_dns.rb +67 -0
  159. data/lib/virtualmonkey/simple.rb +5 -0
  160. data/lib/virtualmonkey/simple_runner.rb +6 -0
  161. data/lib/virtualmonkey/test_case_interface.rb +151 -0
  162. data/lib/virtualmonkey/unified_application.rb +40 -0
  163. data/spec/bug3518.rb +16 -0
  164. data/spec/concurrent_writes_spec.rb +26 -0
  165. data/spec/cuke_job_spec.rb +26 -0
  166. data/spec/ek.rb +28 -0
  167. data/spec/little_ruby.rb +20 -0
  168. data/spec/mini.rb +25 -0
  169. data/spec/monitoring.rb +13 -0
  170. data/spec/release_aws_dns.rb +5 -0
  171. data/spec/release_dns.rb +5 -0
  172. data/spec/release_dyndns.rb +5 -0
  173. data/spec/shared_resources_spec.rb +25 -0
  174. data/spec/spec.opts +1 -0
  175. data/spec/spec_helper.rb +11 -0
  176. data/spec/virtualmonkey_spec.rb +7 -0
  177. data/virtualmonkey.gemspec +265 -0
  178. metadata +428 -0
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Jeremy Deininger
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,77 @@
1
+ = QuickStart
2
+ == Install
3
+ === from rubyforge (soon)
4
+ "gem install virtualmonkey"
5
+
6
+ === from source
7
+ "git clone http://github.com/jeremyd/virtualmonkey"
8
+ "gem install jeweler rspec"
9
+ "rake check_dependencies" <- Install any gems listed.
10
+ "rake install"
11
+
12
+ == Configuration
13
+ You need to setup ~/.fog and ~/.rest_connection with configuration options to match your RightScale account (for using the RightScale API) and your AWS credentials (for SimpleDB and S3).
14
+ Just run the monkey, and it will tell you how to setup your missing credentials.
15
+
16
+ == Usage
17
+ The command line client is "monkey". It lives in your gem binary path.
18
+ See the help pages for usage:
19
+ "monkey create --help"
20
+ "monkey run --help"
21
+ "monkey destroy --help"
22
+
23
+ = Virtual Monkey Architecture
24
+
25
+ == RightScale API access
26
+ Uses rest_connection library from http://github.com/jeremyd/rest_connection.git
27
+
28
+ == S3 and SimpleDB access
29
+ Uses Fog library from http://github.com/geemus/fog.git
30
+
31
+ == Virtual Monkey command line client "monkey"
32
+
33
+ == Cruise Control Hooks
34
+ (todo)
35
+
36
+ == Shared Resource Tracking (Amazon SimpleDB)
37
+ Shared Resources like DNS_IDs and EIPs will be shared among clients using conditional PUT operations to SimpleDB.
38
+ SharedDns
39
+
40
+ == Management Classes
41
+
42
+ === DeploymentMonk - handles create/load/delete of DeploymentSets
43
+ Using the RS API we create a set of all the 'basic variations' a deployment can have.
44
+ Basic variations currently are generated using permutations of Images, Clouds, and Instance Types.
45
+ === CukeMonk
46
+ handles running cucumber tests and collecting and posting results to S3
47
+ === VirtualMonkey::DeploymentRunner
48
+ * These are a set of specialty mixins per Deployment type for cluster management of a single deployment.
49
+
50
+ * This keeps our cucumber features from getting cluttered. Each step definition needs an equivalent DeploymentRunner method.
51
+
52
+ * 'One-off' variations are setup by the DeploymentRunner(s) and will be applied during a test run.
53
+ ex: OPT_PHP_VHOST_PORT, SLAVE_DNS_ID
54
+
55
+ * VirtualMonkey::MysqlRunner, VirtualMonkey::FeAppRunner, VirtualMonkey::EBSRunner, VirtualMonkey::Mysql, VirtualMonkey::EBS
56
+
57
+
58
+ === Cucumber feature tests
59
+ * Cucumber Features live in GEM_HOME/features
60
+ * These features can be run by hand -or- by CukeMonk via "monkey run" command.
61
+ * The features have one ENVIRONMENT variable that is used to pass in the Deployment nickname. To run by hand:
62
+ * "cucumber features/php.feature DEPLOYMENT=testing_deploy_x86_64"
63
+ === A Feature will:
64
+ 1) setup one-off variations using the VirtualMonkey::DeploymentRunner .
65
+ 2) exercise a cluster deployment using the VirtualMonkey::DeploymentRunner.
66
+
67
+ == Note on Patches/Pull Requests
68
+
69
+ * Fork the project.
70
+ * Make your feature addition or bug fix.
71
+ * Commit, do not mess with rakefile, version, or history.
72
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
73
+ * Send me a pull request. Bonus points for topic branches.
74
+
75
+ == Copyright
76
+
77
+ Copyright (c) 2010 Jeremy Deininger. See LICENSE for details.
@@ -0,0 +1,51 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "virtualmonkey"
8
+ gem.summary = %Q{testing cluster deployments}
9
+ gem.description = %Q{monkey see, monkey do, monkey repeat}
10
+ gem.email = "jeremy@rightscale.com"
11
+ gem.homepage = "http://github.com/jeremyd/virtualmonkey"
12
+ gem.authors = ["Jeremy Deininger"]
13
+ gem.add_development_dependency "rspec", ">= 1.2.9"
14
+ gem.add_development_dependency "jeweler"
15
+ gem.add_development_dependency "gemedit"
16
+ gem.add_dependency('json')
17
+ gem.add_dependency('trollop')
18
+ gem.add_dependency "rest_connection"
19
+ gem.add_dependency "fog"
20
+ gem.add_dependency "highline"
21
+ gem.add_dependency "rspec"
22
+ gem.add_dependency "eventmachine"
23
+ gem.add_dependency "right_popen"
24
+ gem.add_dependency "ruby-debug"
25
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
26
+ end
27
+ Jeweler::GemcutterTasks.new
28
+ rescue LoadError
29
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
30
+ end
31
+
32
+ #new rspec
33
+ #require 'rspec/core/rake_task'
34
+ #RSpec::Core::RakeTask.new do |t|
35
+ # t.rspec_opts = ["-c", "-f progress", "-r ./spec/spec_helper.rb"]
36
+ # t.pattern = 'spec/**/*_spec.rb'
37
+ #end
38
+
39
+ task :spec => :check_dependencies
40
+
41
+ task :default => :spec
42
+
43
+ require 'rake/rdoctask'
44
+ Rake::RDocTask.new do |rdoc|
45
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
46
+
47
+ rdoc.rdoc_dir = 'rdoc'
48
+ rdoc.title = "virtualmonkey #{version}"
49
+ rdoc.rdoc_files.include('README*')
50
+ rdoc.rdoc_files.include('lib/**/*.rb')
51
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,102 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Development ENV only
4
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ ###
7
+
8
+ require 'rubygems'
9
+ require 'virtualmonkey'
10
+ require 'ruby-debug'
11
+
12
+ usage = <<-EOS
13
+ After setting the 'DEPLOYMENT' and 'REST_CONNECTION_LOG' environment variables, run the grinder using:
14
+
15
+ grinder "testcase.rb" [breakline number]
16
+
17
+ DEVELOPERS: Grinder will drop you into ruby-debug at an exception. Setting the 'MONKEY_NO_DEBUG' environment variable will turn off this behavior.
18
+
19
+ Here are your environment variables:
20
+ export DEPLOYMENT=#{ENV['DEPLOYMENT']}
21
+ export REST_CONNECTION_LOG=#{ENV['REST_CONNECTION_LOG']}
22
+ export MONKEY_NO_DEBUG=#{ENV['MONKEY_NO_DEBUG']}
23
+ export MONKEY_NO_RESUME=#{ENV['MONKEY_NO_RESUME']}
24
+ EOS
25
+
26
+ raise usage unless ENV['DEPLOYMENT']
27
+ raise usage unless ARGV[0] and File.exist?(ARGV[0])
28
+ if ARGV[1]
29
+ @breakpoint = ARGV[1].to_i
30
+ else
31
+ @breakpoint = 1000000
32
+ end
33
+
34
+ @testcase = File.open(ARGV[0], "r")
35
+ testname = File.basename(ARGV[0])
36
+
37
+ linenum = 1
38
+ @resume = 0
39
+
40
+ # Should we resume?
41
+ test_states = "test_states"
42
+ state_dir = File.join(test_states, ENV['DEPLOYMENT'])
43
+ if File.directory?(state_dir)
44
+ unless ENV['MONKEY_NO_RESUME'] =~ /true/i
45
+ puts "Resuming previous testcase...\n"
46
+ @state_file = File.open(File.join(state_dir, testname), "r")
47
+ if @state_file.mtime < @testcase.mtime
48
+ puts "WARNING: testcase has been changed since state file."
49
+ puts "Scrapping previous testcase; Starting over...\n"
50
+ @state_file.close
51
+ File.delete(File.join(state_dir, testname))
52
+ else
53
+ begin
54
+ @resume += 1 if @state_file.readline
55
+ rescue EOFError => e
56
+ done = true
57
+ end while !done
58
+ @state_file.close
59
+ end
60
+ else
61
+ puts "Scrapping previous testcase; Starting over...\n"
62
+ File.delete(File.join(state_dir, testname))
63
+ end
64
+ else
65
+ Dir.mkdir(test_states) unless File.directory?(test_states)
66
+ Dir.mkdir(state_dir)
67
+ end
68
+ @state_file = File.open(File.join(state_dir, testname), "a")
69
+
70
+ # Grinding
71
+ done = false
72
+ timer = Time.now
73
+ begin
74
+ line = @testcase.readline
75
+ if line =~ /((=)|(set_var))/ or (@resume < linenum and linenum <= @breakpoint)
76
+ unless line =~ /^[ \t]*#/ or line =~ /^[ \t]*$/
77
+ puts("=" * line.length)
78
+ puts(line)
79
+ puts("=" * line.length)
80
+ line_timer = Time.now
81
+ eval(line)
82
+ line_elapsed = Time.now - line_timer
83
+ puts("Success. Time Elapsed: #{line_elapsed} seconds")
84
+ else
85
+ eval(line)
86
+ end
87
+ @state_file.syswrite(line) unless @resume > 0 and line =~ /((=)|(set_var))/
88
+ end
89
+ if linenum > @breakpoint
90
+ puts "Halting test at breakpoint (line #{@breakpoint})\n"
91
+ done = true
92
+ else
93
+ linenum += 1
94
+ end
95
+ rescue EOFError => e
96
+ @state_file.close
97
+ File.delete(File.join(state_dir, testname))
98
+ Dir.rmdir(state_dir)
99
+ done = true
100
+ end while !done
101
+ elapsed = Time.now - timer
102
+ puts "Total time elapsed: #{elapsed} seconds"
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'rest_connection'
5
+ require 'trollop'
6
+ require 'highline/import'
7
+
8
+ options = Trollop::options do
9
+ opt :from, "Copy MCIs from this Server Template (id)", :type => :integer, :required => :true
10
+ opt :to, "Copy MCIs to this Server Template (id)", :type => :integer, :required => :true
11
+ opt :nice, "Non-Destructive update of the destination Server Template"
12
+ end
13
+
14
+ class MciCp
15
+ def self.go(options)
16
+ temp1 = ServerTemplate.find(options[:from])
17
+ temp2 = ServerTemplate.find(options[:to])
18
+ from_st = ServerTemplateInternal.new(:href => temp1.href)
19
+ mci_payload = from_st.multi_cloud_images
20
+ to_st = ServerTemplateInternal.new(:href => temp2.href)
21
+ to_delete = to_st.multi_cloud_images
22
+ mci_payload.each do |mci|
23
+ begin
24
+ to_st.add_multi_cloud_image(mci['href'])
25
+ rescue => e
26
+ puts "image already added, skipping"
27
+ to_delete.delete(mci)
28
+ end
29
+ end
30
+ # TODO: need to set the 'right' default, but we can't lookup the default from the orig so we need some hax like a command line option regex for setting default (optional)
31
+ ubuntu_i386 = mci_payload.detect {|d| d['name'] =~ /Ubuntu.+i386/}
32
+ if ubuntu_i386
33
+ to_st.set_default_multi_cloud_image(ubuntu_i386['href'])
34
+ else
35
+ to_st.set_default_multi_cloud_image(mci_payload.first['href'])
36
+ end
37
+ unless options[:nice]
38
+ to_delete.each do |mci|
39
+ to_st.delete_multi_cloud_image(mci['href'])
40
+ end
41
+ end
42
+ puts 'done.'
43
+ end
44
+ end
45
+
46
+ MciCp.go(options)
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Development ENV only
4
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ ###
7
+
8
+ require 'rubygems'
9
+ require 'virtualmonkey'
10
+
11
+ VirtualMonkey::Command.go
12
+
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'rubygems'
4
+ require 'rest_connection'
5
+ require 'trollop'
6
+ require 'highline/import'
7
+
8
+ options = Trollop::options do
9
+ opt :tag, "Tag of the DeploymentSet that you want to vary the sizes on", :type => :string, :required => true
10
+ opt :spot, "Use spot instances", :default => false
11
+ opt :micro_mayhem, "Set everything to Micros", :default => false
12
+ end
13
+
14
+ class VariationEngine
15
+
16
+ def initialize(options)
17
+ @options = options
18
+ @instance_vars32 = { "m1.small" => "0.095", "c1.medium" => "0.19" }
19
+ @instance_vars64 = { "m1.large" => "0.38", "m1.xlarge" => "0.76", "m2.xlarge" => "0.57", "m2.2xlarge" => "1.34", "m2.4xlarge" => "2.68", "c1.xlarge" => "0.76" }
20
+ if options[:micro_mayhem]
21
+ @instance_vars32 = { "t1.micro" => "0.02" }
22
+ @instance_vars64 = { "t1.micro" => "0.02" }
23
+ end
24
+ @deployments = Deployment.find_by(:nickname) {|n| n =~ /^#{@options[:tag]}/ }
25
+ puts "loading #{@deployments.size} deployments matching your tag #{@options[:tag]}"
26
+ return @deployments
27
+ end
28
+
29
+ # select different instance types for every server
30
+ def vary_instance_types
31
+ small_counter = 0
32
+ large_counter = 0
33
+ @deployments.each do |deployment|
34
+ deployment.servers_no_reload.each do |server|
35
+ server.reload
36
+ server.settings
37
+ server.parameters
38
+ if server.ec2_instance_type =~ /small/
39
+ small_counter += 1
40
+ new_type = @instance_vars32.keys[small_counter % @instance_vars32.size]
41
+ server.instance_type = new_type
42
+ server.max_spot_price = @instance_vars32[new_type] if @options[:spot]
43
+ elsif server.ec2_instance_type =~ /large/
44
+ large_counter += 1
45
+ new_type = @instance_vars64.keys[large_counter % @instance_vars64.size]
46
+ server.instance_type = new_type
47
+ server.max_spot_price = @instance_vars64[new_type] if @options[:spot]
48
+ end
49
+ server.pricing = "spot" if @options[:spot]
50
+ server.save
51
+ end
52
+ end
53
+ end
54
+ end
55
+
56
+ e = VariationEngine.new(options)
57
+ e.vary_instance_types
58
+
59
+ puts "Done."
@@ -0,0 +1,30 @@
1
+ {
2
+ "1":{
3
+ "ec2_ssh_key_href":"https://my.rightscale.com/api/acct/2901/ec2_ssh_keys/7053",
4
+ "parameters":{
5
+ "PRIVATE_SSH_KEY":"key:publish-test:1"
6
+ },
7
+ "ec2_security_groups_href":"https://my.rightscale.com/api/acct/2901/ec2_security_groups/6411"
8
+ },
9
+ "2":{
10
+ "ec2_ssh_key_href":"https://my.rightscale.com/api/acct/2901/ec2_ssh_keys/198006",
11
+ "parameters":{
12
+ "PRIVATE_SSH_KEY":"key:publish-test-eu:2"
13
+ },
14
+ "ec2_security_groups_href":"https://my.rightscale.com/api/acct/2901/ec2_security_groups/48972"
15
+ },
16
+ "3":{
17
+ "ec2_ssh_key_href":"https://my.rightscale.com/api/acct/2901/ec2_ssh_keys/197758",
18
+ "parameters":{
19
+ "PRIVATE_SSH_KEY":"key:publish-test-west:3"
20
+ },
21
+ "ec2_security_groups_href":"https://my.rightscale.com/api/acct/2901/ec2_security_groups/97863"
22
+ },
23
+ "4":{
24
+ "ec2_ssh_key_href":"https://my.rightscale.com/api/acct/2901/ec2_ssh_keys/209603",
25
+ "parameters":{
26
+ "PRIVATE_SSH_KEY":"key:publish-test-ap:4"
27
+ },
28
+ "ec2_security_groups_href":"https://my.rightscale.com/api/acct/2901/ec2_security_groups/126284"
29
+ }
30
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "1":{
3
+ "ec2_ssh_key_href":"https://my.rightscale.com/api/acct/2901/ec2_ssh_keys/7053",
4
+ "parameters":{
5
+ "PRIVATE_SSH_KEY":"key:publish-test:1"
6
+ },
7
+ "ec2_security_groups_href":"https://my.rightscale.com/api/acct/2901/ec2_security_groups/6411"
8
+ }
9
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "232":{
3
+ "parameters":{
4
+ "PRIVATE_SSH_KEY":"key:publish-test:1"
5
+ }
6
+ }
7
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "3":{
3
+ "ec2_ssh_key_href":"https://my.rightscale.com/api/acct/2901/ec2_ssh_keys/197758",
4
+ "parameters":{
5
+ "PRIVATE_SSH_KEY":"key:publish-test-west:3"
6
+ },
7
+ "ec2_security_groups_href":"https://my.rightscale.com/api/acct/2901/ec2_security_groups/97863"
8
+ }
9
+ }