admin-cf-plugin 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/admin-cf-plugin/curl.rb +4 -8
- data/lib/admin-cf-plugin/plugin.rb +1 -0
- data/lib/admin-cf-plugin/set_quota.rb +44 -0
- data/lib/admin-cf-plugin/version.rb +1 -1
- data/spec/set_quota_spec.rb +86 -0
- data/spec/spec_helper.rb +1 -0
- metadata +11 -8
data/lib/admin-cf-plugin/curl.rb
CHANGED
@@ -10,14 +10,10 @@ module CFAdmin
|
|
10
10
|
|
11
11
|
desc "Execute a raw request"
|
12
12
|
group :admin
|
13
|
-
input :mode, :argument => :required,
|
14
|
-
|
15
|
-
input :
|
16
|
-
|
17
|
-
input :headers, :argument => :splat,
|
18
|
-
:desc => "Headers (i.e. Foo: bar)"
|
19
|
-
input :body, :alias => "-b",
|
20
|
-
:desc => "Request body"
|
13
|
+
input :mode, :argument => :required, :desc => "Request mode (Get/Put/etc.)"
|
14
|
+
input :path, :argument => :required, :desc => "Request path"
|
15
|
+
input :headers, :argument => :splat, :desc => "Headers (i.e. Foo: bar)"
|
16
|
+
input :body, :alias => "-b", :desc => "Request body"
|
21
17
|
def curl
|
22
18
|
mode = input[:mode].upcase
|
23
19
|
path = input[:path]
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "cf/cli"
|
2
|
+
|
3
|
+
module CFAdmin
|
4
|
+
class SetQuota < CF::CLI
|
5
|
+
def precondition
|
6
|
+
check_target
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "Change the quota definition for the given (or current) organization."
|
10
|
+
group :admin
|
11
|
+
input :quota_definition, :argument => :optional,
|
12
|
+
:from_given => by_name(:quota_definition),
|
13
|
+
:desc => "Quota definition to set on the organization"
|
14
|
+
input :organization, :aliases => %w(org o), :argument => :optional,
|
15
|
+
:from_given => by_name(:organization),
|
16
|
+
:default => proc { client.current_organization || interact },
|
17
|
+
:desc => "Organization to update"
|
18
|
+
def set_quota
|
19
|
+
org = input[:organization]
|
20
|
+
quota = input[:quota_definition]
|
21
|
+
|
22
|
+
with_progress(<<MESSAGE.chomp) do
|
23
|
+
Setting quota of #{c(org.name, :name)} to #{c(quota.name, :name)}
|
24
|
+
MESSAGE
|
25
|
+
org.quota_definition = quota
|
26
|
+
org.update!
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def ask_quota_definition
|
33
|
+
ask("Quota",
|
34
|
+
:choices => client.quota_definitions,
|
35
|
+
:display => proc(&:name))
|
36
|
+
end
|
37
|
+
|
38
|
+
def ask_organization
|
39
|
+
ask("Organization",
|
40
|
+
:choices => client.organizations,
|
41
|
+
:display => proc(&:name))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe CFAdmin::SetQuota do
|
4
|
+
let(:fake_home_dir) { "#{SPEC_ROOT}/fixtures/fake_home_dir" }
|
5
|
+
|
6
|
+
stub_home_dir_with { fake_home_dir }
|
7
|
+
|
8
|
+
let(:paid_quota) { fake :quota_definition, :name => "paid" }
|
9
|
+
let(:free_quota) { fake :quota_definition, :name => "free" }
|
10
|
+
|
11
|
+
let(:organization) do
|
12
|
+
fake :organization, :name => "some-org-name",
|
13
|
+
:quota_definition => free_quota
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:client) do
|
17
|
+
fake_client :organizations => [organization],
|
18
|
+
:quota_definitions => [paid_quota, free_quota]
|
19
|
+
end
|
20
|
+
|
21
|
+
before do
|
22
|
+
stub_client
|
23
|
+
stub(organization).update!
|
24
|
+
end
|
25
|
+
|
26
|
+
context "when given an organization and a quota definition" do
|
27
|
+
it "promotes the organization to the given quota definition" do
|
28
|
+
expect {
|
29
|
+
cf %W[set-quota paid some-org-name]
|
30
|
+
}.to change {
|
31
|
+
organization.quota_definition
|
32
|
+
}.from(free_quota).to(paid_quota)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "shows progress to the user" do
|
36
|
+
cf %W[set-quota paid some-org-name]
|
37
|
+
expect(output).to say("Setting quota of some-org-name to paid... OK")
|
38
|
+
end
|
39
|
+
|
40
|
+
it "saves the changes made to the organization" do
|
41
|
+
mock(organization).update!
|
42
|
+
cf %W[set-quota paid some-org-name]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "when NOT given a quota definition" do
|
47
|
+
it "prompts for the quota definition" do
|
48
|
+
mock_ask("Quota", hash_including(:choices => client.quota_definitions)) do
|
49
|
+
paid_quota
|
50
|
+
end
|
51
|
+
|
52
|
+
cf %W[set-quota --organization some-org-name]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "when NOT given an organization" do
|
57
|
+
context "and the user has a current organization" do
|
58
|
+
before { client.current_organization = organization }
|
59
|
+
|
60
|
+
it "promotes the current to the given quota definition" do
|
61
|
+
expect {
|
62
|
+
cf %W[set-quota paid]
|
63
|
+
}.to change {
|
64
|
+
organization.quota_definition
|
65
|
+
}.from(free_quota).to(paid_quota)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "saves the changes made to the organization" do
|
69
|
+
mock(organization).update!
|
70
|
+
cf %W[set-quota paid]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context "and the user does NOT have a current organization" do
|
75
|
+
before { client.current_organization = nil }
|
76
|
+
|
77
|
+
it "prompts for the organization" do
|
78
|
+
mock_ask("Organization", hash_including(:choices => client.organizations)) do
|
79
|
+
organization
|
80
|
+
end
|
81
|
+
|
82
|
+
cf %W[set-quota paid]
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: admin-cf-plugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cfoundry
|
@@ -18,10 +18,10 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
21
|
+
version: 1.2.0
|
22
22
|
- - <
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: '1.
|
24
|
+
version: '1.3'
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,10 +29,10 @@ dependencies:
|
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 1.
|
32
|
+
version: 1.2.0
|
33
33
|
- - <
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: '1.
|
35
|
+
version: '1.3'
|
36
36
|
description:
|
37
37
|
email:
|
38
38
|
- asuraci@vmware.com
|
@@ -45,9 +45,11 @@ files:
|
|
45
45
|
- lib/admin-cf-plugin/guid.rb
|
46
46
|
- lib/admin-cf-plugin/plugin.rb
|
47
47
|
- lib/admin-cf-plugin/service_auth_token.rb
|
48
|
+
- lib/admin-cf-plugin/set_quota.rb
|
48
49
|
- lib/admin-cf-plugin/version.rb
|
49
50
|
- spec/curl_spec.rb
|
50
51
|
- spec/guid_spec.rb
|
52
|
+
- spec/set_quota_spec.rb
|
51
53
|
- spec/spec_helper.rb
|
52
54
|
homepage: http://cloudfoundry.com/
|
53
55
|
licenses: []
|
@@ -63,7 +65,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
63
65
|
version: '0'
|
64
66
|
segments:
|
65
67
|
- 0
|
66
|
-
hash: -
|
68
|
+
hash: -938949713629240288
|
67
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
70
|
none: false
|
69
71
|
requirements:
|
@@ -72,11 +74,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
74
|
version: '0'
|
73
75
|
requirements: []
|
74
76
|
rubyforge_project: admin-cf-plugin
|
75
|
-
rubygems_version: 1.8.
|
77
|
+
rubygems_version: 1.8.25
|
76
78
|
signing_key:
|
77
79
|
specification_version: 3
|
78
80
|
summary: Cloud Foundry administration commands.
|
79
81
|
test_files:
|
80
82
|
- spec/curl_spec.rb
|
81
83
|
- spec/guid_spec.rb
|
84
|
+
- spec/set_quota_spec.rb
|
82
85
|
- spec/spec_helper.rb
|