cloulu 0.0.0 → 0.1.1
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/bin/{cloulu → cl} +0 -0
- data/lib/cc_api_stub/applications.rb +53 -0
- data/lib/cc_api_stub/domains.rb +16 -0
- data/lib/cc_api_stub/frameworks.rb +22 -0
- data/lib/cc_api_stub/helper.rb +131 -0
- data/lib/cc_api_stub/login.rb +21 -0
- data/lib/cc_api_stub/organization_users.rb +21 -0
- data/lib/cc_api_stub/organizations.rb +70 -0
- data/lib/cc_api_stub/routes.rb +26 -0
- data/lib/cc_api_stub/runtimes.rb +22 -0
- data/lib/cc_api_stub/service_bindings.rb +22 -0
- data/lib/cc_api_stub/service_instances.rb +22 -0
- data/lib/cc_api_stub/services.rb +25 -0
- data/lib/cc_api_stub/spaces.rb +49 -0
- data/lib/cc_api_stub/users.rb +84 -0
- data/lib/cc_api_stub.rb +17 -0
- data/lib/cfoundry/auth_token.rb +63 -0
- data/lib/cfoundry/baseclient.rb +201 -0
- data/lib/cfoundry/chatty_hash.rb +46 -0
- data/lib/cfoundry/client.rb +46 -0
- data/lib/cfoundry/concerns/login_helpers.rb +13 -0
- data/lib/cfoundry/errors.rb +160 -0
- data/lib/cfoundry/rest_client.rb +299 -0
- data/lib/cfoundry/test_support.rb +3 -0
- data/lib/cfoundry/trace_helpers.rb +40 -0
- data/lib/cfoundry/uaaclient.rb +112 -0
- data/lib/cfoundry/upload_helpers.rb +187 -0
- data/lib/cfoundry/v1/app.rb +363 -0
- data/lib/cfoundry/v1/base.rb +72 -0
- data/lib/cfoundry/v1/client.rb +193 -0
- data/lib/cfoundry/v1/framework.rb +21 -0
- data/lib/cfoundry/v1/model.rb +178 -0
- data/lib/cfoundry/v1/model_magic.rb +129 -0
- data/lib/cfoundry/v1/runtime.rb +24 -0
- data/lib/cfoundry/v1/service.rb +39 -0
- data/lib/cfoundry/v1/service_instance.rb +32 -0
- data/lib/cfoundry/v1/service_plan.rb +19 -0
- data/lib/cfoundry/v1/user.rb +22 -0
- data/lib/cfoundry/v2/app.rb +392 -0
- data/lib/cfoundry/v2/base.rb +83 -0
- data/lib/cfoundry/v2/client.rb +138 -0
- data/lib/cfoundry/v2/domain.rb +11 -0
- data/lib/cfoundry/v2/framework.rb +14 -0
- data/lib/cfoundry/v2/model.rb +148 -0
- data/lib/cfoundry/v2/model_magic.rb +449 -0
- data/lib/cfoundry/v2/organization.rb +16 -0
- data/lib/cfoundry/v2/route.rb +15 -0
- data/lib/cfoundry/v2/runtime.rb +12 -0
- data/lib/cfoundry/v2/service.rb +19 -0
- data/lib/cfoundry/v2/service_auth_token.rb +9 -0
- data/lib/cfoundry/v2/service_binding.rb +10 -0
- data/lib/cfoundry/v2/service_instance.rb +14 -0
- data/lib/cfoundry/v2/service_plan.rb +12 -0
- data/lib/cfoundry/v2/space.rb +18 -0
- data/lib/cfoundry/v2/user.rb +64 -0
- data/lib/cfoundry/validator.rb +39 -0
- data/lib/cfoundry/version.rb +4 -0
- data/lib/cfoundry/zip.rb +56 -0
- data/lib/cfoundry.rb +2 -0
- data/lib/manifests-vmc-plugin/errors.rb +21 -0
- data/lib/manifests-vmc-plugin/loader/builder.rb +34 -0
- data/lib/manifests-vmc-plugin/loader/normalizer.rb +149 -0
- data/lib/manifests-vmc-plugin/loader/resolver.rb +79 -0
- data/lib/manifests-vmc-plugin/loader.rb +31 -0
- data/lib/manifests-vmc-plugin/plugin.rb +145 -0
- data/lib/manifests-vmc-plugin/version.rb +3 -0
- data/lib/manifests-vmc-plugin.rb +313 -0
- data/lib/mothership/base.rb +99 -0
- data/lib/mothership/callbacks.rb +85 -0
- data/lib/mothership/command.rb +146 -0
- data/lib/mothership/errors.rb +38 -0
- data/lib/mothership/help/commands.rb +53 -0
- data/lib/mothership/help/printer.rb +170 -0
- data/lib/mothership/help.rb +64 -0
- data/lib/mothership/inputs.rb +189 -0
- data/lib/mothership/parser.rb +182 -0
- data/lib/mothership/version.rb +3 -0
- data/lib/mothership.rb +64 -0
- data/lib/tunnel-vmc-plugin/plugin.rb +178 -0
- data/lib/tunnel-vmc-plugin/tunnel.rb +308 -0
- data/lib/tunnel-vmc-plugin/version.rb +3 -0
- data/lib/uaa/http.rb +168 -0
- data/lib/uaa/misc.rb +121 -0
- data/lib/uaa/scim.rb +292 -0
- data/lib/uaa/token_coder.rb +196 -0
- data/lib/uaa/token_issuer.rb +255 -0
- data/lib/uaa/util.rb +235 -0
- data/lib/uaa/version.rb +19 -0
- data/lib/uaa.rb +18 -0
- data/lib/vmc/cli/app/app.rb +45 -0
- data/lib/vmc/cli/app/apps.rb +99 -0
- data/lib/vmc/cli/app/base.rb +90 -0
- data/lib/vmc/cli/app/crashes.rb +42 -0
- data/lib/vmc/cli/app/delete.rb +95 -0
- data/lib/vmc/cli/app/deprecated.rb +11 -0
- data/lib/vmc/cli/app/env.rb +78 -0
- data/lib/vmc/cli/app/files.rb +137 -0
- data/lib/vmc/cli/app/health.rb +26 -0
- data/lib/vmc/cli/app/instances.rb +53 -0
- data/lib/vmc/cli/app/logs.rb +76 -0
- data/lib/vmc/cli/app/push/create.rb +165 -0
- data/lib/vmc/cli/app/push/interactions.rb +94 -0
- data/lib/vmc/cli/app/push/sync.rb +64 -0
- data/lib/vmc/cli/app/push.rb +109 -0
- data/lib/vmc/cli/app/rename.rb +35 -0
- data/lib/vmc/cli/app/restart.rb +20 -0
- data/lib/vmc/cli/app/scale.rb +71 -0
- data/lib/vmc/cli/app/start.rb +143 -0
- data/lib/vmc/cli/app/stats.rb +67 -0
- data/lib/vmc/cli/app/stop.rb +27 -0
- data/lib/vmc/cli/help.rb +11 -0
- data/lib/vmc/cli/interactive.rb +105 -0
- data/lib/vmc/cli/route/base.rb +12 -0
- data/lib/vmc/cli/route/map.rb +82 -0
- data/lib/vmc/cli/route/routes.rb +25 -0
- data/lib/vmc/cli/route/unmap.rb +94 -0
- data/lib/vmc/cli/service/base.rb +8 -0
- data/lib/vmc/cli/service/bind.rb +44 -0
- data/lib/vmc/cli/service/create.rb +126 -0
- data/lib/vmc/cli/service/delete.rb +86 -0
- data/lib/vmc/cli/service/rename.rb +35 -0
- data/lib/vmc/cli/service/service.rb +42 -0
- data/lib/vmc/cli/service/services.rb +114 -0
- data/lib/vmc/cli/service/unbind.rb +38 -0
- data/lib/vmc/cli/start/base.rb +94 -0
- data/lib/vmc/cli/start/colors.rb +13 -0
- data/lib/vmc/cli/start/info.rb +126 -0
- data/lib/vmc/cli/start/login.rb +97 -0
- data/lib/vmc/cli/start/logout.rb +17 -0
- data/lib/vmc/cli/start/target.rb +60 -0
- data/lib/vmc/cli/start/target_interactions.rb +37 -0
- data/lib/vmc/cli/start/targets.rb +16 -0
- data/lib/vmc/cli/user/base.rb +29 -0
- data/lib/vmc/cli/user/create.rb +39 -0
- data/lib/vmc/cli/user/delete.rb +27 -0
- data/lib/vmc/cli/user/passwd.rb +50 -0
- data/lib/vmc/cli/user/register.rb +42 -0
- data/lib/vmc/cli/user/users.rb +32 -0
- data/lib/vmc/cli/v2_check_cli.rb +16 -0
- data/lib/vmc/cli.rb +474 -0
- data/lib/vmc/constants.rb +13 -0
- data/lib/vmc/detect.rb +129 -0
- data/lib/vmc/errors.rb +19 -0
- data/lib/vmc/plugin.rb +56 -0
- data/lib/vmc/spacing.rb +89 -0
- data/lib/vmc/spec_helper.rb +1 -0
- data/lib/vmc/test_support.rb +6 -0
- data/lib/vmc/version.rb +3 -0
- data/lib/vmc.rb +8 -0
- data/vendor/errors/v1.yml +189 -0
- data/vendor/errors/v2.yml +360 -0
- metadata +303 -190
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
require "vmc/cli/start/base"
|
|
2
|
+
require "vmc/cli/start/target_interactions"
|
|
3
|
+
|
|
4
|
+
module VMC::Start
|
|
5
|
+
class Login < Base
|
|
6
|
+
def precondition
|
|
7
|
+
check_target
|
|
8
|
+
super
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
desc "Authenticate with the target"
|
|
12
|
+
group :start
|
|
13
|
+
input :username, :value => :email, :desc => "Account email",
|
|
14
|
+
:alias => "--email", :argument => :optional
|
|
15
|
+
input :password, :desc => "Account password"
|
|
16
|
+
input :organization, :desc => "Organization" , :aliases => %w{--org -o},
|
|
17
|
+
:from_given => by_name(:organization)
|
|
18
|
+
input :space, :desc => "Space", :alias => "-s",
|
|
19
|
+
:from_given => by_name(:space)
|
|
20
|
+
interactions TargetInteractions
|
|
21
|
+
def login
|
|
22
|
+
show_context
|
|
23
|
+
|
|
24
|
+
credentials =
|
|
25
|
+
{ :username => input[:username],
|
|
26
|
+
:password => input[:password]
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
prompts = client.login_prompts
|
|
30
|
+
|
|
31
|
+
# ask username first
|
|
32
|
+
if prompts.key? :username
|
|
33
|
+
type, label = prompts.delete :username
|
|
34
|
+
credentials[:username] ||= ask_prompt(type, label)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
info = target_info
|
|
38
|
+
|
|
39
|
+
auth_token = nil
|
|
40
|
+
authenticated = false
|
|
41
|
+
failed = false
|
|
42
|
+
remaining_attempts = 3
|
|
43
|
+
until authenticated || remaining_attempts <= 0
|
|
44
|
+
remaining_attempts -= 1
|
|
45
|
+
unless force?
|
|
46
|
+
ask_prompts(credentials, prompts)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
with_progress("Authenticating") do |s|
|
|
50
|
+
begin
|
|
51
|
+
auth_token = client.login(credentials[:username], credentials[:password])
|
|
52
|
+
authenticated = true
|
|
53
|
+
rescue CFoundry::Denied
|
|
54
|
+
return if force?
|
|
55
|
+
|
|
56
|
+
s.fail do
|
|
57
|
+
failed = true
|
|
58
|
+
credentials.delete(:password)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
info.merge!(auth_token.to_hash)
|
|
65
|
+
save_target_info(info)
|
|
66
|
+
invalidate_client
|
|
67
|
+
|
|
68
|
+
if v2?
|
|
69
|
+
line if input.interactive?(:organization) || input.interactive?(:space)
|
|
70
|
+
select_org_and_space(input, info)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
save_target_info(info)
|
|
74
|
+
ensure
|
|
75
|
+
exit_status 1 if not authenticated
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
private
|
|
79
|
+
|
|
80
|
+
def ask_prompts(credentials, prompts)
|
|
81
|
+
prompts.each do |name, meta|
|
|
82
|
+
type, label = meta
|
|
83
|
+
credentials[name] ||= ask_prompt(type, label)
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def ask_prompt(type, label)
|
|
88
|
+
if type == "password"
|
|
89
|
+
options = { :echo => "*", :forget => true }
|
|
90
|
+
else
|
|
91
|
+
options = {}
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
ask(label, options)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require "vmc/cli/start/base"
|
|
2
|
+
|
|
3
|
+
module VMC::Start
|
|
4
|
+
class Logout < Base
|
|
5
|
+
def precondition
|
|
6
|
+
check_target
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
desc "Log out from the target"
|
|
10
|
+
group :start
|
|
11
|
+
def logout
|
|
12
|
+
with_progress("Logging out") do
|
|
13
|
+
remove_target_info
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require "vmc/cli/start/base"
|
|
2
|
+
require "vmc/cli/start/target_interactions"
|
|
3
|
+
|
|
4
|
+
module VMC::Start
|
|
5
|
+
class Target < Base
|
|
6
|
+
def precondition; end
|
|
7
|
+
|
|
8
|
+
desc "Set or display the target cloud, organization, and space"
|
|
9
|
+
group :start
|
|
10
|
+
input :url, :desc => "Target URL to switch to", :argument => :optional
|
|
11
|
+
input :organization, :desc => "Organization" , :aliases => %w{--org -o},
|
|
12
|
+
:from_given => by_name(:organization)
|
|
13
|
+
input :space, :desc => "Space", :alias => "-s",
|
|
14
|
+
:from_given => by_name(:space)
|
|
15
|
+
interactions TargetInteractions
|
|
16
|
+
def target
|
|
17
|
+
unless input.has?(:url) || input.has?(:organization) || \
|
|
18
|
+
input.has?(:space)
|
|
19
|
+
display_target
|
|
20
|
+
display_org_and_space unless quiet?
|
|
21
|
+
return
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
if input.has?(:url)
|
|
25
|
+
target = sane_target_url(input[:url])
|
|
26
|
+
with_progress("Setting target to #{c(target, :name)}") do
|
|
27
|
+
begin
|
|
28
|
+
CFoundry::Client.new(target) # check that it's valid before setting
|
|
29
|
+
rescue CFoundry::TargetRefused
|
|
30
|
+
fail "Target refused connection."
|
|
31
|
+
rescue CFoundry::InvalidTarget
|
|
32
|
+
fail "Invalid target URI."
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
set_target(target)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
if v2?
|
|
40
|
+
puts "Warning: Targeting a v2 instance. Further commands will fail until a v1 instance is targeted. Please use the 'cf' command to target v2 instances."
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
def display_org_and_space
|
|
48
|
+
return unless v2?
|
|
49
|
+
|
|
50
|
+
if org = client.current_organization
|
|
51
|
+
line "organization: #{c(org.name, :name)}"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
if space = client.current_space
|
|
55
|
+
line "space: #{c(space.name, :name)}"
|
|
56
|
+
end
|
|
57
|
+
rescue CFoundry::APIError
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module VMC::Start
|
|
2
|
+
module TargetInteractions
|
|
3
|
+
def ask_organization
|
|
4
|
+
orgs = client.organizations(:depth => 0)
|
|
5
|
+
|
|
6
|
+
if orgs.empty?
|
|
7
|
+
unless quiet?
|
|
8
|
+
line
|
|
9
|
+
line c("There are no organizations.", :warning)
|
|
10
|
+
line "You may want to create one with #{c("create-org", :good)}."
|
|
11
|
+
end
|
|
12
|
+
elsif orgs.size == 1 && !input.interactive?(:organization)
|
|
13
|
+
orgs.first
|
|
14
|
+
else
|
|
15
|
+
ask("Organization",
|
|
16
|
+
:choices => orgs.sort_by(&:name),
|
|
17
|
+
:display => proc(&:name))
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def ask_space(org)
|
|
22
|
+
spaces = org.spaces(:depth => 0)
|
|
23
|
+
|
|
24
|
+
if spaces.empty?
|
|
25
|
+
unless quiet?
|
|
26
|
+
line
|
|
27
|
+
line c("There are no spaces in #{b(org.name)}.", :warning)
|
|
28
|
+
line "You may want to create one with #{c("create-space", :good)}."
|
|
29
|
+
end
|
|
30
|
+
elsif spaces.size == 1 && !input.interactive?(:spaces)
|
|
31
|
+
spaces.first
|
|
32
|
+
else
|
|
33
|
+
ask("Space", :choices => spaces, :display => proc(&:name))
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require "vmc/cli/start/base"
|
|
2
|
+
|
|
3
|
+
module VMC::Start
|
|
4
|
+
class Targets < Base
|
|
5
|
+
desc "List known targets."
|
|
6
|
+
group :start, :hidden => true
|
|
7
|
+
def targets
|
|
8
|
+
targets_info.each do |target, _|
|
|
9
|
+
line target
|
|
10
|
+
# TODO: print org/space
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require "vmc/cli/v2_check_cli"
|
|
2
|
+
|
|
3
|
+
module VMC
|
|
4
|
+
module User
|
|
5
|
+
class Base < V2CheckCLI
|
|
6
|
+
def precondition
|
|
7
|
+
check_logged_in
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
def validate_password!(password)
|
|
13
|
+
validate_password_verified!(password)
|
|
14
|
+
validate_password_strength!(password)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def validate_password_verified!(password)
|
|
18
|
+
fail "Passwords do not match." unless force? || password == input[:verify]
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def validate_password_strength!(password)
|
|
22
|
+
strength = client.base.password_score(password)
|
|
23
|
+
msg = "Your password strength is: #{strength}"
|
|
24
|
+
fail msg if strength == :weak
|
|
25
|
+
line msg
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require "vmc/cli/user/base"
|
|
2
|
+
|
|
3
|
+
module VMC::User
|
|
4
|
+
class Create < Base
|
|
5
|
+
desc "Create a user"
|
|
6
|
+
group :admin, :user, :hidden => true
|
|
7
|
+
input :email, :desc => "User email", :argument => :optional
|
|
8
|
+
input :password, :desc => "User password"
|
|
9
|
+
input :verify, :desc => "Repeat password"
|
|
10
|
+
def create_user
|
|
11
|
+
email = input[:email]
|
|
12
|
+
password = input[:password]
|
|
13
|
+
|
|
14
|
+
if !force? && password != input[:verify]
|
|
15
|
+
fail "Passwords don't match."
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
with_progress("Creating user") do
|
|
19
|
+
client.register(email, password)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
alias_command :add_user, :create_user
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def ask_email
|
|
28
|
+
ask("Email")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def ask_password
|
|
32
|
+
ask("Password", :echo => "*", :forget => true)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def ask_verify
|
|
36
|
+
ask("Verify Password", :echo => "*", :forget => true)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require "vmc/cli/user/base"
|
|
2
|
+
|
|
3
|
+
module VMC::User
|
|
4
|
+
class Delete < Base
|
|
5
|
+
desc "Delete a user"
|
|
6
|
+
group :admin, :user, :hidden => true
|
|
7
|
+
input :email, :desc => "User to delete", :argument => true
|
|
8
|
+
input :really, :type => :boolean, :forget => true, :hidden => true,
|
|
9
|
+
:default => proc { force? || interact }
|
|
10
|
+
def delete_user
|
|
11
|
+
no_v2
|
|
12
|
+
|
|
13
|
+
email = input[:email]
|
|
14
|
+
return unless input[:really, email]
|
|
15
|
+
|
|
16
|
+
with_progress("Deleting #{c(email, :name)}") do
|
|
17
|
+
client.user(email).delete!
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
def ask_really(email)
|
|
24
|
+
ask("Really delete user #{c(email, :name)}?", :default => false)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require "vmc/cli/user/base"
|
|
2
|
+
|
|
3
|
+
module VMC::User
|
|
4
|
+
class Passwd < Base
|
|
5
|
+
desc "Update a user's password"
|
|
6
|
+
group :admin, :user, :hidden => true
|
|
7
|
+
input :user, :desc => "User to update", :argument => :optional,
|
|
8
|
+
:default => proc { client.current_user },
|
|
9
|
+
:from_given => proc { |email|
|
|
10
|
+
if v2? && client.current_user.email != email
|
|
11
|
+
fail "You can only change your own password on V2."
|
|
12
|
+
else
|
|
13
|
+
client.user(email)
|
|
14
|
+
end
|
|
15
|
+
}
|
|
16
|
+
input :password, :desc => "Current password"
|
|
17
|
+
input :new_password, :desc => "New password"
|
|
18
|
+
input :verify, :desc => "Repeat new password"
|
|
19
|
+
def passwd
|
|
20
|
+
user = input[:user]
|
|
21
|
+
password = input[:password] if v2?
|
|
22
|
+
new_password = input[:new_password]
|
|
23
|
+
|
|
24
|
+
validate_password! new_password
|
|
25
|
+
|
|
26
|
+
with_progress("Changing password") do
|
|
27
|
+
if v2?
|
|
28
|
+
user.change_password!(new_password, password)
|
|
29
|
+
else
|
|
30
|
+
user.password = new_password
|
|
31
|
+
user.update!
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
def ask_password
|
|
39
|
+
ask("Current Password", :echo => "*", :forget => true)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def ask_new_password
|
|
43
|
+
ask("New Password", :echo => "*", :forget => true)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def ask_verify
|
|
47
|
+
ask("Verify Password", :echo => "*", :forget => true)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require "vmc/cli/user/base"
|
|
2
|
+
|
|
3
|
+
module VMC::User
|
|
4
|
+
class Register < Base
|
|
5
|
+
def precondition; end
|
|
6
|
+
|
|
7
|
+
desc "Create a user and log in"
|
|
8
|
+
group :admin, :user, :hidden => true
|
|
9
|
+
input :email, :desc => "Desired email", :argument => :optional
|
|
10
|
+
input :password, :desc => "Desired password"
|
|
11
|
+
input :verify, :desc => "Repeat password"
|
|
12
|
+
input :login, :desc => "Automatically log in?", :default => true
|
|
13
|
+
def register
|
|
14
|
+
email = input[:email]
|
|
15
|
+
password = input[:password]
|
|
16
|
+
|
|
17
|
+
validate_password!(password)
|
|
18
|
+
|
|
19
|
+
with_progress("Creating user") do
|
|
20
|
+
client.register(email, password)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
if input[:login]
|
|
24
|
+
invoke :login, :username => email, :password => password
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def ask_email
|
|
31
|
+
ask("Email")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def ask_password
|
|
35
|
+
ask("Password", :echo => "*", :forget => true)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def ask_verify
|
|
39
|
+
ask("Confirm Password", :echo => "*", :forget => true)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require "vmc/cli/user/base"
|
|
2
|
+
|
|
3
|
+
module VMC::User
|
|
4
|
+
class Users < Base
|
|
5
|
+
desc "List all users"
|
|
6
|
+
group :admin, :hidden => true
|
|
7
|
+
def users
|
|
8
|
+
users =
|
|
9
|
+
with_progress("Getting users") do
|
|
10
|
+
client.users(:depth => 0)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
spaced(users) do |u|
|
|
14
|
+
display_user(u)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def display_user(u)
|
|
21
|
+
if quiet?
|
|
22
|
+
puts u.email
|
|
23
|
+
else
|
|
24
|
+
line "#{c(u.email, :name)}:"
|
|
25
|
+
|
|
26
|
+
indented do
|
|
27
|
+
line "admin?: #{c(u.admin?, u.admin? ? :yes : :no)}"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require "vmc/cli/v2_check_cli"
|
|
2
|
+
|
|
3
|
+
module VMC
|
|
4
|
+
class V2CheckCLI < CLI
|
|
5
|
+
def precondition
|
|
6
|
+
fail_on_v2
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def fail_on_v2
|
|
10
|
+
if v2?
|
|
11
|
+
fail "You are targeting a version 2 instance of Cloud Foundry: you must use the 'cf' command line client (which you can get with 'gem install cf')."
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|