vmc 0.4.0.beta.16 → 0.4.0.beta.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/vmc-ng/lib/vmc/cli.rb +4 -0
- data/vmc-ng/lib/vmc/cli/app.rb +80 -57
- data/vmc-ng/lib/vmc/cli/interactive.rb +2 -2
- data/vmc-ng/lib/vmc/cli/service.rb +73 -42
- data/vmc-ng/lib/vmc/cli/user.rb +1 -1
- data/vmc-ng/lib/vmc/version.rb +1 -1
- metadata +13 -13
    
        data/vmc-ng/lib/vmc/cli.rb
    CHANGED
    
    
    
        data/vmc-ng/lib/vmc/cli/app.rb
    CHANGED
    
    | @@ -33,6 +33,14 @@ module VMC | |
| 33 33 | 
             
                }
         | 
| 34 34 |  | 
| 35 35 |  | 
| 36 | 
            +
                def self.find_by_name(what)
         | 
| 37 | 
            +
                  proc { |name, choices|
         | 
| 38 | 
            +
                    choices.find { |c| c.name == name } ||
         | 
| 39 | 
            +
                      fail("Unknown #{what} '#{name}'")
         | 
| 40 | 
            +
                  }
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
             | 
| 36 44 | 
             
                desc "List your applications"
         | 
| 37 45 | 
             
                group :apps
         | 
| 38 46 | 
             
                input :name, :desc => "Filter by name regexp"
         | 
| @@ -86,14 +94,29 @@ module VMC | |
| 86 94 | 
             
                      :desc => "Number of instances to run") {
         | 
| 87 95 | 
             
                  ask("Instances", :default => 1)
         | 
| 88 96 | 
             
                }
         | 
| 89 | 
            -
                input(:framework, :desc => "Framework to use" | 
| 90 | 
            -
             | 
| 97 | 
            +
                input(:framework, :desc => "Framework to use",
         | 
| 98 | 
            +
                      :from_given => find_by_name("framework")) { |choices, default, other|
         | 
| 99 | 
            +
                  choices = choices.sort_by(&:name)
         | 
| 100 | 
            +
                  choices << other if other
         | 
| 101 | 
            +
             | 
| 102 | 
            +
                  opts = {
         | 
| 103 | 
            +
                    :choices => choices,
         | 
| 104 | 
            +
                    :display => proc { |f|
         | 
| 105 | 
            +
                      if f == other
         | 
| 106 | 
            +
                        "other"
         | 
| 107 | 
            +
                      else
         | 
| 108 | 
            +
                        f.name
         | 
| 109 | 
            +
                      end
         | 
| 110 | 
            +
                    }
         | 
| 111 | 
            +
                  }
         | 
| 112 | 
            +
             | 
| 91 113 | 
             
                  opts[:default] = default if default
         | 
| 92 114 |  | 
| 93 115 | 
             
                  ask("Framework", opts)
         | 
| 94 116 | 
             
                }
         | 
| 95 | 
            -
                input(:runtime, :desc => "Runtime to run it with" | 
| 96 | 
            -
             | 
| 117 | 
            +
                input(:runtime, :desc => "Runtime to run it with",
         | 
| 118 | 
            +
                      :from_given => find_by_name("runtime")) { |choices|
         | 
| 119 | 
            +
                  ask("Runtime", :choices => choices, :display => proc(&:name))
         | 
| 97 120 | 
             
                }
         | 
| 98 121 | 
             
                input(:command, :desc => "Startup command for standalone app") {
         | 
| 99 122 | 
             
                  ask("Startup command")
         | 
| @@ -115,14 +138,7 @@ module VMC | |
| 115 138 |  | 
| 116 139 | 
             
                  name = input[:name] if input[:name]
         | 
| 117 140 |  | 
| 118 | 
            -
                  exists =
         | 
| 119 | 
            -
                    if v2?
         | 
| 120 | 
            -
                      client.current_space.apps.find { |a| a.name == name }
         | 
| 121 | 
            -
                    elsif client.app(name).exists?
         | 
| 122 | 
            -
                      client.app(name)
         | 
| 123 | 
            -
                    end
         | 
| 124 | 
            -
             | 
| 125 | 
            -
                  if exists
         | 
| 141 | 
            +
                  if exists = client.app_by_name(name)
         | 
| 126 142 | 
             
                    upload_app(exists, path)
         | 
| 127 143 | 
             
                    invoke :restart, :name => exists.name if input[:restart]
         | 
| 128 144 | 
             
                    return
         | 
| @@ -137,28 +153,22 @@ module VMC | |
| 137 153 | 
             
                  app.space = client.current_space if v2?
         | 
| 138 154 | 
             
                  app.total_instances = input[:instances]
         | 
| 139 155 |  | 
| 140 | 
            -
                  framework_names = frameworks.collect(&:name).sort
         | 
| 141 156 | 
             
                  if detected.empty?
         | 
| 142 | 
            -
                     | 
| 157 | 
            +
                    framework = input[:framework, frameworks, nil, false]
         | 
| 143 158 | 
             
                  else
         | 
| 144 159 | 
             
                    detected_names = detected.collect(&:name).sort
         | 
| 145 | 
            -
                     | 
| 146 | 
            -
                      input[:framework, detected_names + ["other"], default && default.name]
         | 
| 160 | 
            +
                    framework = input[:framework, detected, default, true]
         | 
| 147 161 |  | 
| 148 | 
            -
                    if  | 
| 162 | 
            +
                    if framework == :other
         | 
| 149 163 | 
             
                      input.forget(:framework)
         | 
| 150 | 
            -
                       | 
| 164 | 
            +
                      framework = input[:framework, frameworks, nil, false]
         | 
| 151 165 | 
             
                    end
         | 
| 152 166 | 
             
                  end
         | 
| 153 167 |  | 
| 154 | 
            -
                  framework = frameworks.find { |f| f.name == framework_name }
         | 
| 155 | 
            -
             | 
| 156 168 | 
             
                  runtimes = v2? ? client.runtimes : framework.runtimes
         | 
| 157 | 
            -
                   | 
| 158 | 
            -
                  runtime = runtimes.find { |r| r.name == runtime_name }
         | 
| 169 | 
            +
                  runtime = input[:runtime, runtimes]
         | 
| 159 170 |  | 
| 160 171 | 
             
                  fail "Invalid framework '#{input[:framework]}'" unless framework
         | 
| 161 | 
            -
             | 
| 162 172 | 
             
                  fail "Invalid runtime '#{input[:runtime]}'" unless runtime
         | 
| 163 173 |  | 
| 164 174 | 
             
                  app.framework = framework
         | 
| @@ -237,10 +247,12 @@ module VMC | |
| 237 247 | 
             
                  names = input[:names]
         | 
| 238 248 | 
             
                  fail "No applications given." if names.empty?
         | 
| 239 249 |  | 
| 250 | 
            +
                  apps = client.apps
         | 
| 251 | 
            +
             | 
| 240 252 | 
             
                  names.each do |name|
         | 
| 241 | 
            -
                    app =  | 
| 253 | 
            +
                    app = apps.find { |a| a.name == name }
         | 
| 242 254 |  | 
| 243 | 
            -
                    fail "Unknown application '#{name}'" unless app | 
| 255 | 
            +
                    fail "Unknown application '#{name}'" unless app
         | 
| 244 256 |  | 
| 245 257 | 
             
                    app = filter(:start_app, app)
         | 
| 246 258 |  | 
| @@ -256,6 +268,9 @@ module VMC | |
| 256 268 | 
             
                      app.start!
         | 
| 257 269 | 
             
                    end
         | 
| 258 270 |  | 
| 271 | 
            +
                    # TODO: reenable for v2
         | 
| 272 | 
            +
                    next if v2?
         | 
| 273 | 
            +
             | 
| 259 274 | 
             
                    check_application(app)
         | 
| 260 275 |  | 
| 261 276 | 
             
                    if app.debug_mode && !quiet?
         | 
| @@ -274,16 +289,14 @@ module VMC | |
| 274 289 | 
             
                  names = input[:names]
         | 
| 275 290 | 
             
                  fail "No applications given." if names.empty?
         | 
| 276 291 |  | 
| 292 | 
            +
                  apps = client.apps
         | 
| 293 | 
            +
             | 
| 277 294 | 
             
                  names.each do |name|
         | 
| 278 | 
            -
                     | 
| 279 | 
            -
                      app = client.app(name)
         | 
| 295 | 
            +
                    app = apps.find { |a| a.name == name }
         | 
| 280 296 |  | 
| 281 | 
            -
             | 
| 282 | 
            -
                        s.fail do
         | 
| 283 | 
            -
                          err "Unknown application '#{name}'"
         | 
| 284 | 
            -
                        end
         | 
| 285 | 
            -
                      end
         | 
| 297 | 
            +
                    fail "Unknown application '#{name}'" unless app
         | 
| 286 298 |  | 
| 299 | 
            +
                    with_progress("Stopping #{c(name, :name)}") do |s|
         | 
| 287 300 | 
             
                      if app.stopped?
         | 
| 288 301 | 
             
                        s.skip do
         | 
| 289 302 | 
             
                          err "Application is not running."
         | 
| @@ -311,12 +324,14 @@ module VMC | |
| 311 324 |  | 
| 312 325 | 
             
                desc "Delete an application"
         | 
| 313 326 | 
             
                group :apps, :manage
         | 
| 314 | 
            -
                input(:really, :type => :boolean) { |name, color|
         | 
| 327 | 
            +
                input(:really, :type => :boolean, :forget => true) { |name, color|
         | 
| 315 328 | 
             
                  force? || ask("Really delete #{c(name, color)}?", :default => false)
         | 
| 316 329 | 
             
                }
         | 
| 317 | 
            -
                input(: | 
| 318 | 
            -
                      :desc => "Applications to delete" | 
| 319 | 
            -
             | 
| 330 | 
            +
                input(:apps, :argument => :splat, :singular => :app,
         | 
| 331 | 
            +
                      :desc => "Applications to delete",
         | 
| 332 | 
            +
                      :from_given => find_by_name("application")) { |apps|
         | 
| 333 | 
            +
                  [ask("Delete which application?", :choices => apps.sort_by(&:name),
         | 
| 334 | 
            +
                       :display => proc(&:name))]
         | 
| 320 335 | 
             
                }
         | 
| 321 336 | 
             
                input :orphaned, :aliases => "-o", :type => :boolean,
         | 
| 322 337 | 
             
                  :desc => "Delete orphaned instances"
         | 
| @@ -344,15 +359,7 @@ module VMC | |
| 344 359 | 
             
                  apps = client.apps
         | 
| 345 360 | 
             
                  fail "No applications." if apps.empty?
         | 
| 346 361 |  | 
| 347 | 
            -
                   | 
| 348 | 
            -
             | 
| 349 | 
            -
                  to_delete = names.collect do |n|
         | 
| 350 | 
            -
                    if app = apps.find { |a| a.name == n }
         | 
| 351 | 
            -
                      app
         | 
| 352 | 
            -
                    else
         | 
| 353 | 
            -
                      fail "Unknown application '#{n}'"
         | 
| 354 | 
            -
                    end
         | 
| 355 | 
            -
                  end
         | 
| 362 | 
            +
                  to_delete = input[:apps, apps]
         | 
| 356 363 |  | 
| 357 364 | 
             
                  deleted = []
         | 
| 358 365 | 
             
                  to_delete.each do |app|
         | 
| @@ -379,13 +386,15 @@ module VMC | |
| 379 386 | 
             
                input :names, :argument => :splat, :singular => :name,
         | 
| 380 387 | 
             
                  :desc => "Applications to list instances of"
         | 
| 381 388 | 
             
                def instances(input)
         | 
| 389 | 
            +
                  no_v2
         | 
| 390 | 
            +
             | 
| 382 391 | 
             
                  names = input[:names]
         | 
| 383 392 | 
             
                  fail "No applications given." if names.empty?
         | 
| 384 393 |  | 
| 385 394 | 
             
                  names.each do |name|
         | 
| 386 395 | 
             
                    instances =
         | 
| 387 396 | 
             
                      with_progress("Getting instances for #{c(name, :name)}") do
         | 
| 388 | 
            -
                        client. | 
| 397 | 
            +
                        client.app_by_name(name).instances
         | 
| 389 398 | 
             
                      end
         | 
| 390 399 |  | 
| 391 400 | 
             
                    instances.each do |i|
         | 
| @@ -415,7 +424,7 @@ module VMC | |
| 415 424 | 
             
                  :desc => "Restart app after updating?"
         | 
| 416 425 | 
             
                def scale(input)
         | 
| 417 426 | 
             
                  name = input[:name]
         | 
| 418 | 
            -
                  app = client. | 
| 427 | 
            +
                  app = client.app_by_name(name)
         | 
| 419 428 |  | 
| 420 429 | 
             
                  instances = input.given(:instances)
         | 
| 421 430 | 
             
                  memory = input.given(:memory)
         | 
| @@ -453,9 +462,11 @@ module VMC | |
| 453 462 | 
             
                input :all, :default => false,
         | 
| 454 463 | 
             
                  :desc => "Get logs for every instance"
         | 
| 455 464 | 
             
                def logs(input)
         | 
| 465 | 
            +
                  no_v2
         | 
| 466 | 
            +
             | 
| 456 467 | 
             
                  name = input[:name]
         | 
| 457 468 |  | 
| 458 | 
            -
                  app = client. | 
| 469 | 
            +
                  app = client.app_by_name(name)
         | 
| 459 470 | 
             
                  fail "Unknown application '#{name}'" unless app.exists?
         | 
| 460 471 |  | 
| 461 472 | 
             
                  instances =
         | 
| @@ -504,6 +515,8 @@ module VMC | |
| 504 515 | 
             
                input :path, :argument => true, :default => "/",
         | 
| 505 516 | 
             
                  :desc => "Path of file to read"
         | 
| 506 517 | 
             
                def file(input)
         | 
| 518 | 
            +
                  no_v2
         | 
| 519 | 
            +
             | 
| 507 520 | 
             
                  file =
         | 
| 508 521 | 
             
                    with_progress("Getting file contents") do
         | 
| 509 522 | 
             
                      client.app(input[:name]).file(*input[:path].split("/"))
         | 
| @@ -521,6 +534,8 @@ module VMC | |
| 521 534 | 
             
                input :path, :argument => true, :default => "/",
         | 
| 522 535 | 
             
                  :desc => "Path of directory to list"
         | 
| 523 536 | 
             
                def files(input)
         | 
| 537 | 
            +
                  no_v2
         | 
| 538 | 
            +
             | 
| 524 539 | 
             
                  files =
         | 
| 525 540 | 
             
                    with_progress("Getting file listing") do
         | 
| 526 541 | 
             
                      client.app(input[:name]).files(*input[:path].split("/"))
         | 
| @@ -538,10 +553,12 @@ module VMC | |
| 538 553 | 
             
                input :names, :argument => :splat, :singular => :name,
         | 
| 539 554 | 
             
                  :desc => "Application to check the status of"
         | 
| 540 555 | 
             
                def health(input)
         | 
| 556 | 
            +
                  # TODO: get all apps and filter
         | 
| 557 | 
            +
             | 
| 541 558 | 
             
                  apps =
         | 
| 542 559 | 
             
                    with_progress("Getting application health") do
         | 
| 543 560 | 
             
                      input[:names].collect do |n|
         | 
| 544 | 
            -
                        [n, app_status(client. | 
| 561 | 
            +
                        [n, app_status(client.app_by_name(n))]
         | 
| 545 562 | 
             
                      end
         | 
| 546 563 | 
             
                    end
         | 
| 547 564 |  | 
| @@ -561,9 +578,11 @@ module VMC | |
| 561 578 | 
             
                input :name, :argument => true,
         | 
| 562 579 | 
             
                  :desc => "Application to get the stats for"
         | 
| 563 580 | 
             
                def stats(input)
         | 
| 581 | 
            +
                  no_v2
         | 
| 582 | 
            +
             | 
| 564 583 | 
             
                  stats =
         | 
| 565 584 | 
             
                    with_progress("Getting stats for #{c(input[:name], :name)}") do
         | 
| 566 | 
            -
                      client. | 
| 585 | 
            +
                      client.app_by_name(input[:name]).stats
         | 
| 567 586 | 
             
                    end
         | 
| 568 587 |  | 
| 569 588 | 
             
                  stats.sort_by { |k, _| k }.each do |idx, info|
         | 
| @@ -592,11 +611,13 @@ module VMC | |
| 592 611 | 
             
                input :url, :argument => true,
         | 
| 593 612 | 
             
                  :desc => "URL to route"
         | 
| 594 613 | 
             
                def map(input)
         | 
| 614 | 
            +
                  no_v2
         | 
| 615 | 
            +
             | 
| 595 616 | 
             
                  name = input[:name]
         | 
| 596 617 | 
             
                  simple = input[:url].sub(/^https?:\/\/(.*)\/?/i, '\1')
         | 
| 597 618 |  | 
| 598 619 | 
             
                  with_progress("Updating #{c(name, :name)}") do
         | 
| 599 | 
            -
                    app = client. | 
| 620 | 
            +
                    app = client.app_by_name(name)
         | 
| 600 621 | 
             
                    app.urls << simple
         | 
| 601 622 | 
             
                    app.update!
         | 
| 602 623 | 
             
                  end
         | 
| @@ -611,8 +632,10 @@ module VMC | |
| 611 632 | 
             
                  ask("Which URL?", :choices => choices)
         | 
| 612 633 | 
             
                }
         | 
| 613 634 | 
             
                def unmap(input)
         | 
| 635 | 
            +
                  no_v2
         | 
| 636 | 
            +
             | 
| 614 637 | 
             
                  name = input[:name]
         | 
| 615 | 
            -
                  app = client. | 
| 638 | 
            +
                  app = client.app_by_name(name)
         | 
| 616 639 |  | 
| 617 640 | 
             
                  url = input[:url, app.urls]
         | 
| 618 641 |  | 
| @@ -642,7 +665,7 @@ module VMC | |
| 642 665 |  | 
| 643 666 | 
             
                  vars =
         | 
| 644 667 | 
             
                    with_progress("Getting env for #{c(input[:name], :name)}") do |s|
         | 
| 645 | 
            -
                      app = client. | 
| 668 | 
            +
                      app = client.app_by_name(appname)
         | 
| 646 669 |  | 
| 647 670 | 
             
                      unless app.exists?
         | 
| 648 671 | 
             
                        s.fail do
         | 
| @@ -689,7 +712,7 @@ module VMC | |
| 689 712 | 
             
                    fail "Invalid variable name; must match #{VALID_ENV_VAR.inspect}"
         | 
| 690 713 | 
             
                  end
         | 
| 691 714 |  | 
| 692 | 
            -
                  app = client. | 
| 715 | 
            +
                  app = client.app_by_name(appname)
         | 
| 693 716 | 
             
                  fail "Unknown application '#{appname}'" unless app.exists?
         | 
| 694 717 |  | 
| 695 718 | 
             
                  with_progress("Updating #{c(app.name, :name)}") do
         | 
| @@ -721,7 +744,7 @@ module VMC | |
| 721 744 | 
             
                  appname = input[:name]
         | 
| 722 745 | 
             
                  name = input[:var]
         | 
| 723 746 |  | 
| 724 | 
            -
                  app = client. | 
| 747 | 
            +
                  app = client.app_by_name(appname)
         | 
| 725 748 | 
             
                  fail "Unknown application '#{appname}'" unless app.exists?
         | 
| 726 749 |  | 
| 727 750 | 
             
                  with_progress("Updating #{c(app.name, :name)}") do
         | 
| @@ -752,11 +775,11 @@ module VMC | |
| 752 775 | 
             
                  end
         | 
| 753 776 |  | 
| 754 777 | 
             
                  if runtime = options[:runtime]
         | 
| 755 | 
            -
                    return false if a.runtime !~ /#{runtime}/
         | 
| 778 | 
            +
                    return false if a.runtime.name !~ /#{runtime}/
         | 
| 756 779 | 
             
                  end
         | 
| 757 780 |  | 
| 758 781 | 
             
                  if framework = options[:framework]
         | 
| 759 | 
            -
                    return false if a.framework !~ /#{framework}/
         | 
| 782 | 
            +
                    return false if a.framework.name !~ /#{framework}/
         | 
| 760 783 | 
             
                  end
         | 
| 761 784 |  | 
| 762 785 | 
             
                  if url = options[:url]
         | 
| @@ -12,9 +12,9 @@ module VMC | |
| 12 12 | 
             
                  end
         | 
| 13 13 | 
             
                end
         | 
| 14 14 |  | 
| 15 | 
            -
                def list_choices(choices, options)
         | 
| 15 | 
            +
                def list_choices(choices, options = {})
         | 
| 16 16 | 
             
                  choices.each_with_index do |o, i|
         | 
| 17 | 
            -
                    puts "#{c(i + 1, :number)}: #{o}"
         | 
| 17 | 
            +
                    puts "#{c(i + 1, :number)}: #{show_choice(o, options)}"
         | 
| 18 18 | 
             
                  end
         | 
| 19 19 | 
             
                end
         | 
| 20 20 |  | 
| @@ -6,69 +6,87 @@ module VMC | |
| 6 6 | 
             
                group :services
         | 
| 7 7 | 
             
                input :name, :desc => "Filter by name regexp"
         | 
| 8 8 | 
             
                input :app, :desc => "Filter by bound application regexp"
         | 
| 9 | 
            +
                input :service, :desc => "Filter by service regexp"
         | 
| 10 | 
            +
                # TODO: not in v2
         | 
| 9 11 | 
             
                input :type, :desc => "Filter by service type regexp"
         | 
| 10 | 
            -
                input :vendor, :desc => "Filter by service vendor regexp"
         | 
| 11 12 | 
             
                input :tier, :desc => "Filter by service tier regexp"
         | 
| 12 13 | 
             
                def services(input)
         | 
| 13 | 
            -
                   | 
| 14 | 
            +
                  instances =
         | 
| 14 15 | 
             
                    with_progress("Getting service instances") do
         | 
| 15 | 
            -
                      client.service_instances
         | 
| 16 | 
            +
                      client.service_instances(2)
         | 
| 16 17 | 
             
                    end
         | 
| 17 18 |  | 
| 18 | 
            -
                   | 
| 19 | 
            -
             | 
| 20 | 
            -
                  if services.empty? and !quiet?
         | 
| 19 | 
            +
                  if instances.empty? and !quiet?
         | 
| 20 | 
            +
                    puts ""
         | 
| 21 21 | 
             
                    puts "No services."
         | 
| 22 22 | 
             
                  end
         | 
| 23 23 |  | 
| 24 | 
            -
                   | 
| 25 | 
            -
                     | 
| 26 | 
            -
                    services.reject! do |s|
         | 
| 27 | 
            -
                      apps.none? { |a| a.services.include? s.name }
         | 
| 28 | 
            -
                    end
         | 
| 29 | 
            -
                  end
         | 
| 30 | 
            -
             | 
| 31 | 
            -
                  services.each do |s|
         | 
| 32 | 
            -
                    display_service(s) if service_matches(s, input)
         | 
| 24 | 
            +
                  instances.each.with_index do |i, n|
         | 
| 25 | 
            +
                    display_instance(i) if instance_matches(i, input)
         | 
| 33 26 | 
             
                  end
         | 
| 34 27 | 
             
                end
         | 
| 35 28 |  | 
| 29 | 
            +
                services_from_label = proc { |label, services|
         | 
| 30 | 
            +
                  services.select { |s| s.label == label }
         | 
| 31 | 
            +
                }
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                plan_from_name = proc { |name, plans|
         | 
| 34 | 
            +
                  plans.find { |p| p.name == name }
         | 
| 35 | 
            +
                }
         | 
| 36 36 |  | 
| 37 37 | 
             
                desc "Create a service"
         | 
| 38 38 | 
             
                group :services, :manage
         | 
| 39 39 | 
             
                input(:service, :argument => true,
         | 
| 40 | 
            -
                      :desc => "What kind of service (e.g. redis, mysql)" | 
| 41 | 
            -
             | 
| 40 | 
            +
                      :desc => "What kind of service (e.g. redis, mysql)",
         | 
| 41 | 
            +
                      :from_given => services_from_label) { |services|
         | 
| 42 | 
            +
                  [ask("What kind?", :choices => services.sort_by(&:label),
         | 
| 43 | 
            +
                       :display => proc { |s| "#{c(s.label, :name)} v#{s.version}" },
         | 
| 44 | 
            +
                       :complete => proc { |s| "#{s.label} v#{s.version}" })]
         | 
| 42 45 | 
             
                }
         | 
| 43 46 | 
             
                input(:name, :argument => true,
         | 
| 44 | 
            -
                      :desc => " | 
| 47 | 
            +
                      :desc => "Name for your instance") { |service|
         | 
| 45 48 | 
             
                  random = sprintf("%x", rand(1000000))
         | 
| 46 49 | 
             
                  ask "Name?", :default => "#{service.label}-#{random}"
         | 
| 47 50 | 
             
                }
         | 
| 48 | 
            -
                input(:version, :desc => "Version of the service") { | | 
| 49 | 
            -
                  ask "Which version?", :choices =>  | 
| 51 | 
            +
                input(:version, :desc => "Version of the service") { |services|
         | 
| 52 | 
            +
                  ask "Which version?", :choices => services,
         | 
| 53 | 
            +
                    :display => proc(&:version)
         | 
| 54 | 
            +
                }
         | 
| 55 | 
            +
                input(:plan, :desc => "Service plan",
         | 
| 56 | 
            +
                      :from_given => plan_from_name) { |plans|
         | 
| 57 | 
            +
                  ask "Which plan?", :choices => plans.sort_by(&:name),
         | 
| 58 | 
            +
                    :display => proc { |p| "#{p.name}: #{p.description}" },
         | 
| 59 | 
            +
                    :complete => proc(&:name)
         | 
| 50 60 | 
             
                }
         | 
| 51 61 | 
             
                input :bind, :alias => "--app",
         | 
| 52 62 | 
             
                  :desc => "Application to immediately bind to"
         | 
| 53 63 | 
             
                def create_service(input)
         | 
| 54 64 | 
             
                  services = client.services
         | 
| 55 65 |  | 
| 56 | 
            -
                   | 
| 57 | 
            -
                  services = services.select { |s| s.label == service_label }
         | 
| 66 | 
            +
                  services = input[:service, services]
         | 
| 58 67 |  | 
| 59 68 | 
             
                  if services.size == 1
         | 
| 60 69 | 
             
                    service = services.first
         | 
| 61 70 | 
             
                  else
         | 
| 62 | 
            -
                     | 
| 63 | 
            -
                    service = services.find { |s| s.version == version }
         | 
| 71 | 
            +
                    service = input[:version, services]
         | 
| 64 72 | 
             
                  end
         | 
| 65 73 |  | 
| 74 | 
            +
                  plans = service.service_plans
         | 
| 75 | 
            +
                  plan = plans.find { |p| p.name == "D100" } || input[:plan, plans]
         | 
| 76 | 
            +
             | 
| 66 77 | 
             
                  instance = client.service_instance
         | 
| 67 78 | 
             
                  instance.name = input[:name, service]
         | 
| 68 | 
            -
             | 
| 69 | 
            -
                   | 
| 70 | 
            -
             | 
| 71 | 
            -
             | 
| 79 | 
            +
             | 
| 80 | 
            +
                  if v2?
         | 
| 81 | 
            +
                    instance.service_plan = plan
         | 
| 82 | 
            +
                    instance.space = client.current_space
         | 
| 83 | 
            +
                    instance.credentials = {} # TODO: ?
         | 
| 84 | 
            +
                  else
         | 
| 85 | 
            +
                    instance.type = service.type
         | 
| 86 | 
            +
                    instance.vendor = service.label
         | 
| 87 | 
            +
                    instance.version = service.version
         | 
| 88 | 
            +
                    instance.tier = "free"
         | 
| 89 | 
            +
                  end
         | 
| 72 90 |  | 
| 73 91 | 
             
                  with_progress("Creating service #{c(instance.name, :name)}") do
         | 
| 74 92 | 
             
                    instance.create!
         | 
| @@ -97,7 +115,7 @@ module VMC | |
| 97 115 | 
             
                  appname = input[:app, client.apps.collect(&:name)]
         | 
| 98 116 |  | 
| 99 117 | 
             
                  with_progress("Binding #{c(name, :name)} to #{c(appname, :name)}") do
         | 
| 100 | 
            -
                    client. | 
| 118 | 
            +
                    client.app_by_name(appname).bind(name)
         | 
| 101 119 | 
             
                  end
         | 
| 102 120 | 
             
                end
         | 
| 103 121 |  | 
| @@ -115,7 +133,7 @@ module VMC | |
| 115 133 | 
             
                def unbind_service(input)
         | 
| 116 134 | 
             
                  appname = input[:app, client.apps.collect(&:name)]
         | 
| 117 135 |  | 
| 118 | 
            -
                  app = client. | 
| 136 | 
            +
                  app = client.app_by_name(appname)
         | 
| 119 137 | 
             
                  name = input[:name, app.services]
         | 
| 120 138 |  | 
| 121 139 | 
             
                  with_progress("Unbinding #{c(name, :name)} from #{c(appname, :name)}") do
         | 
| @@ -130,7 +148,7 @@ module VMC | |
| 130 148 | 
             
                      :desc => "Service to delete") { |choices|
         | 
| 131 149 | 
             
                  ask "Delete which service?", :choices => choices
         | 
| 132 150 | 
             
                }
         | 
| 133 | 
            -
                input(:really, :type => :boolean) { |name, color|
         | 
| 151 | 
            +
                input(:really, :type => :boolean, :forget => true) { |name, color|
         | 
| 134 152 | 
             
                  force? || ask("Really delete #{c(name, color)}?", :default => false)
         | 
| 135 153 | 
             
                }
         | 
| 136 154 | 
             
                input :all, :default => false, :desc => "Delete all services"
         | 
| @@ -160,31 +178,44 @@ module VMC | |
| 160 178 |  | 
| 161 179 | 
             
                private
         | 
| 162 180 |  | 
| 163 | 
            -
                def  | 
| 181 | 
            +
                def instance_matches(i, options)
         | 
| 182 | 
            +
                  if app = options[:app]
         | 
| 183 | 
            +
                    return false if i.service_bindings.none? { |b|
         | 
| 184 | 
            +
                      b.app.name == app
         | 
| 185 | 
            +
                    }
         | 
| 186 | 
            +
                  end
         | 
| 187 | 
            +
             | 
| 164 188 | 
             
                  if name = options[:name]
         | 
| 165 | 
            -
                    return false if  | 
| 189 | 
            +
                    return false if i.name !~ /#{name}/
         | 
| 166 190 | 
             
                  end
         | 
| 167 191 |  | 
| 168 | 
            -
                  if  | 
| 169 | 
            -
                    return false if  | 
| 192 | 
            +
                  if service = options[:service]
         | 
| 193 | 
            +
                    return false if i.service_plan.service.label !~ /#{service}/
         | 
| 170 194 | 
             
                  end
         | 
| 171 195 |  | 
| 172 | 
            -
                  if  | 
| 173 | 
            -
                    return false if  | 
| 196 | 
            +
                  if !v2? && type = options[:type]
         | 
| 197 | 
            +
                    return false if i.type !~ /#{type}/
         | 
| 174 198 | 
             
                  end
         | 
| 175 199 |  | 
| 176 | 
            -
                  if tier = options[:tier]
         | 
| 177 | 
            -
                    return false if  | 
| 200 | 
            +
                  if !v2? && tier = options[:tier]
         | 
| 201 | 
            +
                    return false if i.tier !~ /#{tier}/
         | 
| 178 202 | 
             
                  end
         | 
| 179 203 |  | 
| 180 204 | 
             
                  true
         | 
| 181 205 | 
             
                end
         | 
| 182 206 |  | 
| 183 | 
            -
                def  | 
| 207 | 
            +
                def display_instance(i)
         | 
| 184 208 | 
             
                  if quiet?
         | 
| 185 | 
            -
                    puts  | 
| 209 | 
            +
                    puts i.name
         | 
| 186 210 | 
             
                  else
         | 
| 187 | 
            -
                     | 
| 211 | 
            +
                    plan = i.service_plan
         | 
| 212 | 
            +
                    service = plan.service
         | 
| 213 | 
            +
             | 
| 214 | 
            +
                    puts ""
         | 
| 215 | 
            +
                    puts "#{c(i.name, :name)}: #{service.label} v#{service.version}"
         | 
| 216 | 
            +
                    puts "  description: #{service.description}"
         | 
| 217 | 
            +
                    puts "  plan: #{c(plan.name, :name)}"
         | 
| 218 | 
            +
                    puts "    description: #{plan.description}"
         | 
| 188 219 | 
             
                  end
         | 
| 189 220 | 
             
                end
         | 
| 190 221 | 
             
              end
         | 
    
        data/vmc-ng/lib/vmc/cli/user.rb
    CHANGED
    
    | @@ -46,7 +46,7 @@ module VMC | |
| 46 46 | 
             
                desc "Delete a user"
         | 
| 47 47 | 
             
                group :admin, :user, :hidden => true
         | 
| 48 48 | 
             
                input :email, :argument => true, :desc => "User to delete"
         | 
| 49 | 
            -
                input(:really, :type => :boolean) { |email|
         | 
| 49 | 
            +
                input(:really, :type => :boolean, :forget => true) { |email|
         | 
| 50 50 | 
             
                  force? || ask("Really delete user #{c(email, :name)}?", :default => false)
         | 
| 51 51 | 
             
                }
         | 
| 52 52 | 
             
                def delete_user(input)
         | 
    
        data/vmc-ng/lib/vmc/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,15 +1,15 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: vmc
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              hash:  | 
| 4 | 
            +
              hash: 62196417
         | 
| 5 5 | 
             
              prerelease: 6
         | 
| 6 6 | 
             
              segments: 
         | 
| 7 7 | 
             
              - 0
         | 
| 8 8 | 
             
              - 4
         | 
| 9 9 | 
             
              - 0
         | 
| 10 10 | 
             
              - beta
         | 
| 11 | 
            -
              -  | 
| 12 | 
            -
              version: 0.4.0.beta. | 
| 11 | 
            +
              - 17
         | 
| 12 | 
            +
              version: 0.4.0.beta.17
         | 
| 13 13 | 
             
            platform: ruby
         | 
| 14 14 | 
             
            authors: 
         | 
| 15 15 | 
             
            - VMware
         | 
| @@ -17,7 +17,7 @@ autorequire: | |
| 17 17 | 
             
            bindir: bin
         | 
| 18 18 | 
             
            cert_chain: []
         | 
| 19 19 |  | 
| 20 | 
            -
            date: 2012-07- | 
| 20 | 
            +
            date: 2012-07-14 00:00:00 Z
         | 
| 21 21 | 
             
            dependencies: 
         | 
| 22 22 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 23 23 | 
             
              name: json_pure
         | 
| @@ -233,12 +233,12 @@ dependencies: | |
| 233 233 | 
             
                requirements: 
         | 
| 234 234 | 
             
                - - ~>
         | 
| 235 235 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 236 | 
            -
                    hash:  | 
| 236 | 
            +
                    hash: 7
         | 
| 237 237 | 
             
                    segments: 
         | 
| 238 238 | 
             
                    - 0
         | 
| 239 239 | 
             
                    - 4
         | 
| 240 | 
            -
                    -  | 
| 241 | 
            -
                    version: 0.4. | 
| 240 | 
            +
                    - 4
         | 
| 241 | 
            +
                    version: 0.4.4
         | 
| 242 242 | 
             
              type: :runtime
         | 
| 243 243 | 
             
              version_requirements: *id013
         | 
| 244 244 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| @@ -249,12 +249,12 @@ dependencies: | |
| 249 249 | 
             
                requirements: 
         | 
| 250 250 | 
             
                - - ~>
         | 
| 251 251 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 252 | 
            -
                    hash:  | 
| 252 | 
            +
                    hash: 21
         | 
| 253 253 | 
             
                    segments: 
         | 
| 254 254 | 
             
                    - 0
         | 
| 255 255 | 
             
                    - 3
         | 
| 256 | 
            -
                    -  | 
| 257 | 
            -
                    version: 0.3. | 
| 256 | 
            +
                    - 3
         | 
| 257 | 
            +
                    version: 0.3.3
         | 
| 258 258 | 
             
              type: :runtime
         | 
| 259 259 | 
             
              version_requirements: *id014
         | 
| 260 260 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| @@ -265,12 +265,12 @@ dependencies: | |
| 265 265 | 
             
                requirements: 
         | 
| 266 266 | 
             
                - - ~>
         | 
| 267 267 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 268 | 
            -
                    hash:  | 
| 268 | 
            +
                    hash: 21
         | 
| 269 269 | 
             
                    segments: 
         | 
| 270 270 | 
             
                    - 0
         | 
| 271 271 | 
             
                    - 0
         | 
| 272 | 
            -
                    -  | 
| 273 | 
            -
                    version: 0.0. | 
| 272 | 
            +
                    - 5
         | 
| 273 | 
            +
                    version: 0.0.5
         | 
| 274 274 | 
             
              type: :runtime
         | 
| 275 275 | 
             
              version_requirements: *id015
         | 
| 276 276 | 
             
            - !ruby/object:Gem::Dependency 
         |