Class: VMC::Cli::Command::Admin
- Inherits:
-
Base
show all
- Defined in:
- lib/cli/commands/admin.rb
Constant Summary
Constants inherited
from Base
Base::MANIFEST
Instance Attribute Summary
Attributes inherited from Base
#no_prompt, #prompt_ok
Instance Method Summary
collapse
Methods inherited from Base
#auth_token, #client, #client_info, #find_in_hash, #find_symbol, #frameworks_info, #initialize, #load_manifest, #load_manifest_structure, #manifest, #manifest_file, #merge_manifest, #merge_parent, #quota_client_info, #resolve_in, #resolve_lexically, #resolve_manifest, #resolve_symbol, #runtimes_info, #target_base, #target_url
Instance Method Details
#add_user(email = nil) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/cli/commands/admin.rb', line 24
def add_user(email=nil)
email ||= @options[:email]
email ||= ask("Email") unless no_prompt
password = @options[:password]
unless no_prompt || password
password = ask("Password", :echo => "*")
password2 = ask("Verify Password", :echo => "*")
err "Passwords did not match, try again" if password != password2
end
err "Need a valid email" unless email
err "Need a password" unless password
display 'Creating New User: ', false
client.add_user(email, password)
display 'OK'.green
return unless VMC::Cli::Config.auth_token.nil?
@options[:password] = password
cmd = User.new(@options)
cmd.login(email)
end
|
#change_quota(apps = nil, uris = nil) ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/cli/commands/admin.rb', line 48
def change_quota(apps=nil,uris=nil)
info = quota_client_info
email = info[:user]
err "Need to be logged in to change quota." unless email
say "Changing quota begin\n"
unless no_prompt
email = ask "Email"
user_info = client.get_user_info(email)
err "no this email." unless user_info
say "Changing quota for '#{email}'\n"
end
unless no_prompt
mem = ask "memory"
apps = ask "apps"
uris = ask "uris"
services = ask "services"
end
err "apps required" unless mem
err "apps required" unless apps
err "uris required" unless uris
err "services required" unless uris
client.change_quota(mem, apps, uris, services, user_info, email)
say "\nSuccessfully changed quota".green
end
|
#delete_user(user_email) ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/cli/commands/admin.rb', line 74
def delete_user(user_email)
client.proxy_for(user_email)
@options[:proxy] = user_email
apps = client.apps
if (apps && !apps.empty?)
unless no_prompt
proceed = ask(
"\nDeployed applications and associated services will be DELETED, continue?",
:default => false
)
err "Aborted" unless proceed
end
cmd = Apps.new(@options.merge({ :force => true }))
apps.each { |app| cmd.delete(app[:name]) }
end
services = client.services
if (services && !services.empty?)
cmd = Services.new(@options)
services.each { |s| cmd.delete_service(s[:name])}
end
display 'Deleting User: ', false
client.proxy = nil
client.delete_user(user_email)
display 'OK'.green
end
|
#list_users ⇒ Object
Also known as:
users
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/cli/commands/admin.rb', line 5
def list_users
users = client.users
users.sort! {|a, b| a[:email] <=> b[:email] }
return display JSON.pretty_generate(users || []) if @options[:json]
display "\n"
return display "No Users" if users.nil? || users.empty?
users_table = table do |t|
t.headings = 'Email', 'Admin', 'Apps'
users.each do |user|
t << [user[:email], user[:admin], user[:apps].map {|x| x[:name]}.join(', ')]
end
end
display users_table
end
|