Class: CFCM::CLI::Command
- Inherits:
-
Thor
- Object
- Thor
- CFCM::CLI::Command
- Defined in:
- lib/cfcm/cli.rb
Instance Method Summary collapse
- #hard(probability = 10, frequency = 10) ⇒ Object
- #soft(username, password, app, target = "http://api.cloudfoundry.com", min = 1, max = 5, probability = 10, frequency = 10) ⇒ Object
- #version ⇒ Object
Instance Method Details
#hard(probability = 10, frequency = 10) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/cfcm/cli.rb', line 68 def hard(probability = 10, frequency = 10) if (![:iaas] || ![:input] || ![:config]) CFCM::Monkey::HardMonkey.new.show_help else if [:probability] if [:probability] < 1 || [:probability] > 100 puts "Probability must be between 1 and 100" return else probability = [:probability] end end if [:frequency] frequency = [:frequency] end dry_run = false if ([:dry_run]) dry_run = true end puts "Awakening the monkey on your #{[:iaas]} infrastructure with a #{probability}% chance of chaos every #{frequency} second#{frequency > 1? "s" : ""}" monkey = CFCM::Monkey::HardMonkey.new([:iaas], [:config], [:input], probability, frequency, dry_run) monkey.start end end |
#soft(username, password, app, target = "http://api.cloudfoundry.com", min = 1, max = 5, probability = 10, frequency = 10) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/cfcm/cli.rb', line 20 def soft(username, password, app, target = "http://api.cloudfoundry.com", min = 1, max = 5, probability = 10, frequency = 10) if [:target] target = [:target] end if [:min] min = [:min] end if [:max] max = [:max] end if [:probability] if [:probability] < 1 || [:probability] > 100 puts "Probability must be between 1 and 100" return else probability = [:probability] end end if [:frequency] frequency = [:frequency] end require 'cfcm/cf' session = CFCM::CF::Session.new(target, username, password) if session.is_logged_in if !session.app_exists(app) puts "Application not found" return end else puts "Could not log in" return end puts "Awakening the monkey on #{app} with a #{probability}% chance of chaos every #{frequency} second#{frequency > 1? "s" : ""}" monkey = CFCM::Monkey::SoftMonkey.new(session, app, probability, min, max, frequency) monkey.start end |