bosh_cli 1.0.3 → 1.5.0.pre.1113

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.
Files changed (144) hide show
  1. data/bin/bosh +0 -9
  2. data/lib/cli.rb +69 -64
  3. data/lib/cli/backup_destination_path.rb +33 -0
  4. data/lib/cli/base_command.rb +57 -56
  5. data/lib/cli/blob_manager.rb +12 -12
  6. data/lib/cli/changeset_helper.rb +6 -7
  7. data/lib/cli/client/director.rb +724 -0
  8. data/lib/cli/command_handler.rb +6 -7
  9. data/lib/cli/commands/backup.rb +39 -0
  10. data/lib/cli/commands/biff.rb +42 -21
  11. data/lib/cli/commands/blob_management.rb +1 -1
  12. data/lib/cli/commands/cloudcheck.rb +11 -13
  13. data/lib/cli/commands/deployment.rb +53 -37
  14. data/lib/cli/commands/help.rb +3 -2
  15. data/lib/cli/commands/job_management.rb +67 -103
  16. data/lib/cli/commands/job_rename.rb +6 -8
  17. data/lib/cli/commands/log_management.rb +78 -55
  18. data/lib/cli/commands/maintenance.rb +36 -30
  19. data/lib/cli/commands/misc.rb +72 -51
  20. data/lib/cli/commands/package.rb +2 -2
  21. data/lib/cli/commands/property_management.rb +10 -12
  22. data/lib/cli/commands/release.rb +236 -133
  23. data/lib/cli/commands/snapshot.rb +93 -0
  24. data/lib/cli/commands/ssh.rb +216 -213
  25. data/lib/cli/commands/stemcell.rb +46 -34
  26. data/lib/cli/commands/task.rb +2 -2
  27. data/lib/cli/commands/user.rb +27 -3
  28. data/lib/cli/commands/vm.rb +28 -0
  29. data/lib/cli/commands/vms.rb +81 -23
  30. data/lib/cli/config.rb +6 -2
  31. data/lib/cli/core_ext.rb +31 -30
  32. data/lib/cli/deployment_helper.rb +134 -159
  33. data/lib/cli/deployment_manifest.rb +66 -0
  34. data/lib/cli/deployment_manifest_compiler.rb +0 -3
  35. data/lib/cli/event_log_renderer.rb +10 -10
  36. data/lib/cli/file_with_progress_bar.rb +52 -0
  37. data/lib/cli/job_builder.rb +1 -1
  38. data/lib/cli/job_command_args.rb +23 -0
  39. data/lib/cli/job_property_collection.rb +4 -7
  40. data/lib/cli/job_property_validator.rb +22 -12
  41. data/lib/cli/job_state.rb +54 -0
  42. data/lib/cli/line_wrap.rb +54 -0
  43. data/lib/cli/packaging_helper.rb +10 -10
  44. data/lib/cli/release.rb +18 -15
  45. data/lib/cli/release_builder.rb +9 -4
  46. data/lib/cli/release_compiler.rb +9 -9
  47. data/lib/cli/release_tarball.rb +3 -6
  48. data/lib/cli/resurrection.rb +31 -0
  49. data/lib/cli/runner.rb +56 -30
  50. data/lib/cli/stemcell.rb +25 -10
  51. data/lib/cli/task_log_renderer.rb +1 -1
  52. data/lib/cli/task_tracker.rb +10 -9
  53. data/lib/cli/validation.rb +3 -1
  54. data/lib/cli/version.rb +1 -1
  55. data/lib/cli/version_calc.rb +5 -18
  56. data/lib/cli/versions_index.rb +1 -1
  57. data/lib/cli/vm_state.rb +43 -0
  58. data/lib/cli/yaml_helper.rb +26 -35
  59. metadata +75 -208
  60. data/Rakefile +0 -56
  61. data/lib/cli/director.rb +0 -628
  62. data/spec/assets/biff/bad_gateway_config.yml +0 -28
  63. data/spec/assets/biff/good_simple_config.yml +0 -63
  64. data/spec/assets/biff/good_simple_golden_config.yml +0 -63
  65. data/spec/assets/biff/good_simple_template.erb +0 -69
  66. data/spec/assets/biff/ip_out_of_range.yml +0 -63
  67. data/spec/assets/biff/multiple_subnets_config.yml +0 -40
  68. data/spec/assets/biff/network_only_template.erb +0 -34
  69. data/spec/assets/biff/no_cc_config.yml +0 -27
  70. data/spec/assets/biff/no_range_config.yml +0 -27
  71. data/spec/assets/biff/no_subnet_config.yml +0 -16
  72. data/spec/assets/biff/ok_network_config.yml +0 -30
  73. data/spec/assets/biff/properties_template.erb +0 -6
  74. data/spec/assets/config/atmos/config/final.yml +0 -6
  75. data/spec/assets/config/atmos/config/private.yml +0 -4
  76. data/spec/assets/config/bad-providers/config/final.yml +0 -5
  77. data/spec/assets/config/bad-providers/config/private.yml +0 -4
  78. data/spec/assets/config/deprecation/config/final.yml +0 -5
  79. data/spec/assets/config/deprecation/config/private.yml +0 -2
  80. data/spec/assets/config/local/config/final.yml +0 -5
  81. data/spec/assets/config/local/config/private.yml +0 -1
  82. data/spec/assets/config/s3/config/final.yml +0 -5
  83. data/spec/assets/config/s3/config/private.yml +0 -5
  84. data/spec/assets/config/swift-hp/config/final.yml +0 -6
  85. data/spec/assets/config/swift-hp/config/private.yml +0 -7
  86. data/spec/assets/config/swift-rackspace/config/final.yml +0 -6
  87. data/spec/assets/config/swift-rackspace/config/private.yml +0 -6
  88. data/spec/assets/deployment.MF +0 -0
  89. data/spec/assets/plugins/bosh/cli/commands/echo.rb +0 -43
  90. data/spec/assets/plugins/bosh/cli/commands/ruby.rb +0 -24
  91. data/spec/assets/release/jobs/cacher.tgz +0 -0
  92. data/spec/assets/release/jobs/cacher/config/file1.conf +0 -0
  93. data/spec/assets/release/jobs/cacher/config/file2.conf +0 -0
  94. data/spec/assets/release/jobs/cacher/job.MF +0 -6
  95. data/spec/assets/release/jobs/cacher/monit +0 -1
  96. data/spec/assets/release/jobs/cleaner.tgz +0 -0
  97. data/spec/assets/release/jobs/cleaner/job.MF +0 -4
  98. data/spec/assets/release/jobs/cleaner/monit +0 -1
  99. data/spec/assets/release/jobs/sweeper.tgz +0 -0
  100. data/spec/assets/release/jobs/sweeper/config/test.conf +0 -1
  101. data/spec/assets/release/jobs/sweeper/job.MF +0 -5
  102. data/spec/assets/release/jobs/sweeper/monit +0 -1
  103. data/spec/assets/release/packages/mutator.tar.gz +0 -0
  104. data/spec/assets/release/packages/stuff.tgz +0 -0
  105. data/spec/assets/release/release.MF +0 -17
  106. data/spec/assets/release_invalid_checksum.tgz +0 -0
  107. data/spec/assets/release_invalid_jobs.tgz +0 -0
  108. data/spec/assets/release_no_name.tgz +0 -0
  109. data/spec/assets/release_no_version.tgz +0 -0
  110. data/spec/assets/stemcell/image +0 -1
  111. data/spec/assets/stemcell/stemcell.MF +0 -6
  112. data/spec/assets/stemcell_invalid_mf.tgz +0 -0
  113. data/spec/assets/stemcell_no_image.tgz +0 -0
  114. data/spec/assets/valid_release.tgz +0 -0
  115. data/spec/assets/valid_stemcell.tgz +0 -0
  116. data/spec/spec_helper.rb +0 -28
  117. data/spec/unit/base_command_spec.rb +0 -87
  118. data/spec/unit/biff_spec.rb +0 -172
  119. data/spec/unit/blob_manager_spec.rb +0 -288
  120. data/spec/unit/cache_spec.rb +0 -36
  121. data/spec/unit/cli_commands_spec.rb +0 -356
  122. data/spec/unit/config_spec.rb +0 -125
  123. data/spec/unit/core_ext_spec.rb +0 -81
  124. data/spec/unit/dependency_helper_spec.rb +0 -52
  125. data/spec/unit/deployment_manifest_compiler_spec.rb +0 -63
  126. data/spec/unit/deployment_manifest_spec.rb +0 -153
  127. data/spec/unit/director_spec.rb +0 -471
  128. data/spec/unit/director_task_spec.rb +0 -48
  129. data/spec/unit/event_log_renderer_spec.rb +0 -171
  130. data/spec/unit/hash_changeset_spec.rb +0 -73
  131. data/spec/unit/job_builder_spec.rb +0 -455
  132. data/spec/unit/job_property_collection_spec.rb +0 -111
  133. data/spec/unit/job_property_validator_spec.rb +0 -7
  134. data/spec/unit/job_rename_spec.rb +0 -200
  135. data/spec/unit/package_builder_spec.rb +0 -593
  136. data/spec/unit/release_builder_spec.rb +0 -120
  137. data/spec/unit/release_spec.rb +0 -173
  138. data/spec/unit/release_tarball_spec.rb +0 -29
  139. data/spec/unit/runner_spec.rb +0 -7
  140. data/spec/unit/ssh_spec.rb +0 -84
  141. data/spec/unit/stemcell_spec.rb +0 -17
  142. data/spec/unit/task_tracker_spec.rb +0 -131
  143. data/spec/unit/version_calc_spec.rb +0 -27
  144. data/spec/unit/versions_index_spec.rb +0 -144
@@ -1,6 +0,0 @@
1
- ---
2
-
3
- jobs:
4
- cc:
5
- srv_api_uri: <%= find("properties.cc.srv_api_uri") %>
6
- use_nginx: true
@@ -1,6 +0,0 @@
1
- ---
2
- blobstore:
3
- provider: atmos
4
- options:
5
- uid: bosh
6
- secret: foo
@@ -1,4 +0,0 @@
1
- ---
2
- blobstore:
3
- atmos:
4
- secret: bar
@@ -1,5 +0,0 @@
1
- ---
2
- blobstore:
3
- provider: s3
4
- options:
5
- bucket_name: test
@@ -1,4 +0,0 @@
1
- ---
2
- blobstore:
3
- atmos:
4
- secret: bar
@@ -1,5 +0,0 @@
1
- ---
2
- blobstore:
3
- provider: atmos
4
- options:
5
- uid: bosh
@@ -1,2 +0,0 @@
1
- ---
2
- blobstore_secret: bar
@@ -1,5 +0,0 @@
1
- ---
2
- blobstore:
3
- provider: local
4
- options:
5
- blobstore_path: /tmp/blobstore
@@ -1,5 +0,0 @@
1
- ---
2
- blobstore:
3
- provider: s3
4
- options:
5
- bucket_name: test
@@ -1,5 +0,0 @@
1
- ---
2
- blobstore:
3
- s3:
4
- secret_access_key: foo
5
- access_key_id: bar
@@ -1,6 +0,0 @@
1
- ---
2
- blobstore:
3
- provider: swift
4
- options:
5
- container_name: test
6
- swift_provider: hp
@@ -1,7 +0,0 @@
1
- ---
2
- blobstore:
3
- swift:
4
- hp:
5
- hp_account_id: foo
6
- hp_secret_key: bar
7
- hp_tenant_id: foo
@@ -1,6 +0,0 @@
1
- ---
2
- blobstore:
3
- provider: swift
4
- options:
5
- container_name: test
6
- swift_provider: rackspace
@@ -1,6 +0,0 @@
1
- ---
2
- blobstore:
3
- swift:
4
- rackspace:
5
- rackspace_username: foo
6
- rackspace_api_key: bar
File without changes
@@ -1,43 +0,0 @@
1
- module Bosh::Cli::Command
2
- class Echo < Base
3
-
4
- command :banner do
5
- usage "banner <string>"
6
- desc "Print a large banner"
7
- route :echo, :banner
8
- end
9
-
10
- command :say do
11
- usage "say <string> <color>"
12
- desc "Say something with color"
13
- option "--color <color>", "color"
14
- route :echo, :say_color
15
- end
16
-
17
- def parse_options(args)
18
- options = {}
19
- ["color"].each do |option|
20
- pos = args.index("--#{option}")
21
- if pos
22
- options[option] = args[pos + 1]
23
- args.delete_at(pos + 1)
24
- args.delete_at(pos)
25
- end
26
- end
27
- options
28
- end
29
-
30
- def banner(string)
31
- system "banner #{string}"
32
- end
33
-
34
- def say_color(*args)
35
- string = args.shift
36
- options = parse_options(args)
37
- if color = options["color"]
38
- string = string.send(:colorize, color.to_sym)
39
- end
40
- say(string)
41
- end
42
- end
43
- end
@@ -1,24 +0,0 @@
1
- module Bosh::Cli::Command
2
- class Ruby < Base
3
-
4
- command :ruby_version do
5
- usage "ruby version"
6
- desc "Say ruby version"
7
- route :ruby, :ruby_version
8
- end
9
-
10
- command :ruby_config do
11
- usage "ruby config <string>"
12
- desc "Query rbconfig"
13
- route :ruby, :ruby_config
14
- end
15
-
16
- def ruby_version
17
- say(RUBY_VERSION)
18
- end
19
-
20
- def ruby_config(string)
21
- say(::Config::CONFIG[string])
22
- end
23
- end
24
- end
@@ -1,6 +0,0 @@
1
- ---
2
- packages:
3
- - stuff
4
- templates:
5
- file1.conf: config/file1.conf
6
- file2.conf: config/file2.conf
@@ -1 +0,0 @@
1
- Monit conf goes here
@@ -1,4 +0,0 @@
1
- ---
2
- packages:
3
- - stuff
4
- - mutator
@@ -1 +0,0 @@
1
- Monit conf goes here
@@ -1,5 +0,0 @@
1
- ---
2
- packages:
3
- - mutator
4
- templates:
5
- test.conf: config/test
@@ -1 +0,0 @@
1
- Monit conf goes here
@@ -1,17 +0,0 @@
1
- ---
2
- name: appcloud
3
- version: 0.1
4
-
5
- packages:
6
- - name: stuff
7
- version: 0.1.17
8
- sha1: 6bbd4a12e3a59e10b96ecb9aac3d73ec4f819783
9
- - name: mutator
10
- version: 2.99.7
11
- sha1: 86bd8b15562cde007f030a303fa64779af5fa4e7
12
-
13
- jobs:
14
- - cacher
15
- - cleaner
16
- - sweeper
17
-
@@ -1 +0,0 @@
1
- STEMCELL
@@ -1,6 +0,0 @@
1
- ---
2
- name: ubuntu-stemcell
3
- version: 1
4
- cloud_properties:
5
- property1: test
6
- property2: test
@@ -1,28 +0,0 @@
1
- # Copyright (c) 2009-2012 VMware, Inc.
2
-
3
- require "rspec/core"
4
-
5
- $:.unshift(File.expand_path("../../lib", __FILE__))
6
- require "cli"
7
-
8
- def spec_asset(filename)
9
- File.expand_path(File.join(File.dirname(__FILE__), "assets", filename))
10
- end
11
-
12
- RSpec.configure do |c|
13
- c.before(:each) do
14
- Bosh::Cli::Config.interactive = false
15
- Bosh::Cli::Config.colorize = false
16
- Bosh::Cli::Config.output = StringIO.new
17
- end
18
-
19
- c.color_enabled = true
20
- end
21
-
22
- def get_tmp_file_path(content)
23
- tmp_file = File.open(File.join(Dir.mktmpdir, "tmp"), "w")
24
- tmp_file.write(content)
25
- tmp_file.close
26
-
27
- tmp_file.path
28
- end
@@ -1,87 +0,0 @@
1
- # Copyright (c) 2009-2012 VMware, Inc.
2
-
3
- require "spec_helper"
4
-
5
- describe Bosh::Cli::Command::Base do
6
-
7
- before :each do
8
- @runner = mock(Bosh::Cli::Runner)
9
- @config_file = File.join(Dir.mktmpdir, "bosh_config")
10
- @cache_dir = Dir.mktmpdir
11
- end
12
-
13
- def add_config(object)
14
- File.open(@config_file, "w") do |f|
15
- f.write(YAML.dump(object))
16
- end
17
- end
18
-
19
- def make
20
- cmd = Bosh::Cli::Command::Base.new(@runner)
21
- cmd.add_option(:config, @config_file)
22
- cmd
23
- end
24
-
25
- it "can access configuration and respects options" do
26
- add_config("target" => "localhost:8080", "deployment" => "test")
27
-
28
- cmd = make
29
- cmd.config.should be_a(Bosh::Cli::Config)
30
-
31
- cmd.target.should == "http://localhost:8080"
32
- cmd.deployment.should == "test"
33
- cmd.username.should be_nil
34
- cmd.password.should be_nil
35
- end
36
-
37
- it "looks up target, deployment and credentials in the right order" do
38
- cmd = make
39
-
40
- cmd.username.should be_nil
41
- cmd.password.should be_nil
42
- old_user = ENV["BOSH_USER"]
43
- old_password = ENV["BOSH_PASSWORD"]
44
-
45
- begin
46
- ENV["BOSH_USER"] = "foo"
47
- ENV["BOSH_PASSWORD"] = "bar"
48
- cmd.username.should == "foo"
49
- cmd.password.should == "bar"
50
- other_cmd = make
51
- other_cmd.add_option(:username, "new")
52
- other_cmd.add_option(:password, "baz")
53
-
54
- other_cmd.username.should == "new"
55
- other_cmd.password.should == "baz"
56
- ensure
57
- ENV["BOSH_USER"] = old_user
58
- ENV["BOSH_PASSWORD"] = old_password
59
- end
60
-
61
- add_config("target" => "localhost:8080", "deployment" => "test")
62
-
63
- cmd2 = make
64
- cmd2.add_option(:target, "foo")
65
- cmd2.add_option(:deployment, "bar")
66
- cmd2.target.should == "http://foo:25555"
67
- cmd2.deployment.should == "bar"
68
- end
69
-
70
- it "instantiates director when needed" do
71
- add_config("target" => "localhost:8080", "deployment" => "test")
72
-
73
- cmd = make
74
- cmd.director.should be_kind_of(Bosh::Cli::Director)
75
- cmd.director.director_uri.should == "http://localhost:8080"
76
- end
77
-
78
- it "has logged_in? helper" do
79
- cmd = make
80
- cmd.logged_in?.should be_false
81
- cmd.add_option(:username, "foo")
82
- cmd.logged_in?.should be_false
83
- cmd.add_option(:password, "bar")
84
- cmd.logged_in?.should be_true
85
- end
86
-
87
- end
@@ -1,172 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Bosh::Cli::Command::Biff do
4
-
5
- before :each do
6
- # Let us test all private methods.
7
- Bosh::Cli::Command::Biff.send(:public,
8
- *Bosh::Cli::Command::Biff.private_instance_methods)
9
- @biff = Bosh::Cli::Command::Biff.new
10
- end
11
-
12
- after :each do
13
- @biff.delete_temp_diff_files
14
- end
15
-
16
- it "throws an error when there is an IP out of range" do
17
- config_file = spec_asset("biff/ip_out_of_range.yml")
18
- template_file = spec_asset("biff/good_simple_template.erb")
19
- @biff.stub!(:deployment).and_return(config_file)
20
- lambda {
21
- @biff.biff(template_file)
22
- }.should raise_error(
23
- Bosh::Cli::CliError,
24
- "IP range '2..9' is not within " +
25
- "the bounds of network 'default', which only has 1 IPs.")
26
- end
27
-
28
- it "throws an error when there is more than one subnet for default" do
29
- config_file = spec_asset("biff/multiple_subnets_config.yml")
30
- template_file = spec_asset("biff/network_only_template.erb")
31
- @biff.stub!(:deployment).and_return(config_file)
32
- lambda {
33
- @biff.biff(template_file)
34
- }.should raise_error(Bosh::Cli::CliError, "Biff doesn't know how to deal " +
35
- "with anything other than one subnet in default")
36
- end
37
-
38
- it "throws an error when the gateway is anything other than the first ip" do
39
- config_file = spec_asset("biff/bad_gateway_config.yml")
40
- template_file = spec_asset("biff/network_only_template.erb")
41
- @biff.stub!(:deployment).and_return(config_file)
42
- lambda {
43
- @biff.biff(template_file)
44
- }.should raise_error(Bosh::Cli::CliError, "Biff only supports " +
45
- "configurations where the gateway is the first IP (e.g. 172.31.196.1).")
46
- end
47
-
48
- it "throws an error when the range is not specified in the config" do
49
- config_file = spec_asset("biff/no_range_config.yml")
50
- template_file = spec_asset("biff/network_only_template.erb")
51
- @biff.stub!(:deployment).and_return(config_file)
52
- lambda {
53
- @biff.biff(template_file)
54
- }.should raise_error(Bosh::Cli::CliError, "Biff requires each network to " +
55
- "have range and dns entries.")
56
- end
57
-
58
- it "throws an error if there are no subnets" do
59
- config_file = spec_asset("biff/no_subnet_config.yml")
60
- template_file = spec_asset("biff/network_only_template.erb")
61
- @biff.stub!(:deployment).and_return(config_file)
62
- lambda {
63
- @biff.biff(template_file)
64
- }.should raise_error(Bosh::Cli::CliError, "You must have subnets in default")
65
- end
66
-
67
- it "outputs the required yaml when the input does not contain it" do
68
- config_file = spec_asset("biff/no_cc_config.yml")
69
- template_file = spec_asset("biff/properties_template.erb")
70
- @biff.stub!(:deployment).and_return(config_file)
71
-
72
- @biff.should_receive(:say).with(
73
- "Could not find properties.cc.srv_api_uri.").once
74
-
75
- @biff.should_receive(:say).with("'#{template_file}' has it but " +
76
- "'#{config_file}' does not.").once
77
-
78
- # Cannot use this because 1.8.7 does not preserve Hash order, so this string
79
- # can come back in any order.
80
- @biff.should_receive(:say).with(/Add this to '':/).once
81
-
82
- lambda {
83
- @biff.biff(template_file)
84
- }.should raise_error Bosh::Cli::CliError, "There were 1 errors."
85
- end
86
-
87
- it "correctly generates a file and reports when there are no differences" do
88
- config_file = spec_asset("biff/good_simple_config.yml")
89
- template_file = spec_asset("biff/good_simple_template.erb")
90
- golden_file = spec_asset("biff/good_simple_golden_config.yml")
91
- @biff.stub!(:deployment).and_return(config_file)
92
- @biff.should_receive(:say).with("No differences.").once
93
-
94
- @biff.biff(template_file)
95
- @biff.template_output.should == File.read(golden_file)
96
- end
97
-
98
- it "asks whether you would like to keep the new file" do
99
- config_file = spec_asset("biff/ok_network_config.yml")
100
- template_file = spec_asset("biff/network_only_template.erb")
101
- @biff.stub!(:deployment).and_return(config_file)
102
- @biff.should_receive(:agree).with(
103
- "Would you like to keep the new version? [yn]").once.and_return(false)
104
-
105
- @biff.biff(template_file)
106
- end
107
-
108
- it "deletes temporary files" do
109
- config_file = spec_asset("biff/ok_network_config.yml")
110
- template_file = spec_asset("biff/network_only_template.erb")
111
- @biff.stub!(:deployment).and_return(config_file)
112
- @biff.should_receive(:agree).and_return(false)
113
- # Twice because of after :each
114
- @biff.should_receive(:delete_temp_diff_files).twice
115
- @biff.biff(template_file)
116
- end
117
-
118
- it "finds the object path" do
119
- obj = { "path1" => {"path2" => {"path3" => 3}} }
120
- @biff.find_in("path1.path2.path3", obj).should == 3
121
- end
122
-
123
- it "finds the object(boolean) path" do
124
- obj = { "path1" => {"path2" => {"path3" => false}} }
125
- @biff.find_in("path1.path2.path3", obj).should == false
126
- end
127
-
128
- it "finds the object path in an array by the name key" do
129
- obj = { "by_key" => 1, "arr" => [{"name" => "by_name"}]}
130
- @biff.find_in("arr.by_name", obj).should == {"name" => "by_name"}
131
- end
132
-
133
- it "allows ip_range to take negative ranges" do
134
- @biff.ip_helper = {
135
- "default" => { "range" => NetAddr::CIDR.create("192.168.1.0/22") }
136
- }
137
- @biff.ip_range(-11..-2, "default").should == "192.168.3.245 - 192.168.3.254"
138
- end
139
-
140
- it "deletes all except one entry from a Hash" do
141
- obj = { "by_key" => 1, "arr" => [{"name" => "by_name"}]}
142
- @biff.delete_all_except(obj, "by_key").should == { "by_key" => 1 }
143
- end
144
-
145
- it "deletes all except one entry from a Array" do
146
- obj = [ {"name" => "a"}, {"name" => "b"}, {"name" => "c"}]
147
- @biff.delete_all_except(obj, "b").should == [ {"name" => "b"} ]
148
- end
149
-
150
- it "gets a range from a static ip list correctly" do
151
- @biff.ip_helper = {
152
- "default" => {
153
- "static" => [
154
- NetAddr::CIDR.create("192.168.1.1"),
155
- NetAddr::CIDR.create("192.168.1.2"),
156
- NetAddr::CIDR.create("192.168.1.3") ]
157
- }}
158
- @biff.ip_range((1..2), "default.static").should ==
159
- "192.168.1.2 - 192.168.1.3"
160
- end
161
-
162
- it "gets an IP from a static ip list correctly" do
163
- @biff.ip_helper = {
164
- "default" => {
165
- "static" => [
166
- NetAddr::CIDR.create("192.168.1.1"),
167
- NetAddr::CIDR.create("192.168.1.2"),
168
- NetAddr::CIDR.create("192.168.1.3") ]
169
- }}
170
- @biff.ip(0, "default.static").should == "192.168.1.1"
171
- end
172
- end