Class: Qtc::Cli::Platform::Clouds
- Inherits:
-
Object
- Object
- Qtc::Cli::Platform::Clouds
show all
- Includes:
- Common
- Defined in:
- lib/qtc/cli/platform/clouds.rb
Instance Attribute Summary
Attributes included from Common
#datacenter_id
Instance Method Summary
collapse
Methods included from Common
#client, #current_cloud_dc, #current_cloud_id, #current_cloud_token, #extract_app_in_dir, #ini_filename, #inifile, #instance_info, #platform_base_url, #platform_client
Instance Method Details
#create(name, opts) ⇒ Object
27
28
29
30
31
|
# File 'lib/qtc/cli/platform/clouds.rb', line 27
def create(name, opts)
datacenter = opts.datacenter || 'eu-1'
data = {name: name, datacenter: datacenter, vpc: opts.vpc}
platform_client.post('/accounts', data)
end
|
#list ⇒ Object
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/qtc/cli/platform/clouds.rb', line 8
def list
accounts = platform_client.get('/user/accounts')
template = '%-40.40s %-40.40s'
puts template % ['ID', 'NAME']
accounts['results'].each do |account|
name = account['name']
name = "* #{name}" if account['id'] == inifile['platform']['current_cloud']
puts template % [account['id'], name]
end
end
|
#use(id) ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/qtc/cli/platform/clouds.rb', line 19
def use(id)
account = platform_client.get("/accounts/#{id}")
puts "Using cloud: #{account['name']} (#{id})"
inifile['platform']['current_cloud'] = id
inifile['platform']['current_dc'] = account['datacenter']['id']
inifile.save(filename: ini_filename)
end
|