cloudstack-cli 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4fd382092e6b838e263390534e9ce894d76e74b
4
- data.tar.gz: d97473fb465c269be305e4f6a24722503616dff9
3
+ metadata.gz: 5dfcca0f542e684213495618ed1c34536fd1490e
4
+ data.tar.gz: 9af0ffdc6f40c4894f27fccb44d71e097949664a
5
5
  SHA512:
6
- metadata.gz: 9d192a430759b011154bc20d8f2a9290b810f30783b3d50e65569c68164ea66edaa1bf678d437a1b5e4d14418081bfa408ddad3016cdb96a5172ee89e8596eab
7
- data.tar.gz: f27eaad931a0f977a63159b1cccf9f3074edcb526f6a3c6712914ec6ebd56de1d1740fedfa8829ec343fad065d556f650b8155902e5dc08bd64b2e1d5faad185
6
+ metadata.gz: 3aba197e1259357da8ca08a17129e401ceedb00afa8b6aefea6b801c795fffc659aee9ce6dc39ddecb2f4edc5a93f7af58ef44309b865a6ef0dbe57e7a64a294
7
+ data.tar.gz: 299ac9cc95acba6dc197ca1bb0215f2930f3aff8671fef1d60b48e8ab6b0fb79a5613ae0dac7a77a8dde9ab9bfe02f14aefcbd495b0e6d6276f0af3f6b73af97
data/Gemfile CHANGED
@@ -3,3 +3,4 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in cloudstack-cli.gemspec
4
4
  gemspec
5
5
 
6
+ gem 'cloudstack_client', git: 'git@github.com:niwo/cloudstack_client.git', branch: 'master'
data/Gemfile.lock CHANGED
@@ -1,14 +1,20 @@
1
+ GIT
2
+ remote: git@github.com:niwo/cloudstack_client.git
3
+ revision: 7b28996ead63220d04b36766651d734e28383f90
4
+ branch: master
5
+ specs:
6
+ cloudstack_client (0.3.6)
7
+
1
8
  PATH
2
9
  remote: .
3
10
  specs:
4
11
  cloudstack-cli (0.5.4)
5
- cloudstack_client (~> 0.3)
12
+ cloudstack_client (>= 0.3.5)
6
13
  thor (~> 0.18)
7
14
 
8
15
  GEM
9
16
  remote: https://rubygems.org/
10
17
  specs:
11
- cloudstack_client (0.3.4)
12
18
  json (1.8.1)
13
19
  rake (10.1.1)
14
20
  rdoc (4.1.1)
@@ -20,5 +26,6 @@ PLATFORMS
20
26
 
21
27
  DEPENDENCIES
22
28
  cloudstack-cli!
29
+ cloudstack_client!
23
30
  rake (~> 10.1)
24
31
  rdoc (~> 4.1)
@@ -4,25 +4,26 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'cloudstack-cli/version'
5
5
 
6
6
  Gem::Specification.new do |gem|
7
- gem.name = "cloudstack-cli"
7
+ gem.name = 'cloudstack-cli'
8
8
  gem.version = CloudstackCli::VERSION
9
- gem.authors = ["Nik Wolfgramm"]
10
- gem.email = ["nik.wolfgramm@gmail.com"]
9
+ gem.authors = ['Nik Wolfgramm']
10
+ gem.email = %w(nik.wolfgramm@gmail.com)
11
11
  gem.description = %q{cloudstack-cli is a CloudStack API client written in Ruby.}
12
12
  gem.summary = %q{cloudstack-cli CloudStack API client}
13
- gem.homepage = "https://github.com/niwo/cloudstack-cli"
13
+ gem.date = Time.now.utc.strftime("%Y-%m-%d")
14
+ gem.homepage = 'https://github.com/niwo/cloudstack-cli'
14
15
  gem.license = 'MIT'
15
16
 
16
17
  gem.required_ruby_version = '>= 1.9.3'
17
18
  gem.files = `git ls-files`.split($/)
18
- gem.executables = ['cs']
19
+ gem.executables = %w(cs)
19
20
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
20
- gem.require_paths = ["lib"]
21
+ gem.require_paths = %w(lib)
21
22
  gem.rdoc_options = %w[--line-numbers --inline-source]
22
23
 
23
24
  gem.add_development_dependency('rdoc', '~> 4.1')
24
25
  gem.add_development_dependency('rake', '~> 10.1')
25
26
 
26
27
  gem.add_dependency('thor', '~> 0.18')
27
- gem.add_dependency('cloudstack_client', '~> 0.3')
28
+ gem.add_dependency('cloudstack_client', '~> 0.3', '>= 0.3.6')
28
29
  end
@@ -30,7 +30,7 @@ module CloudstackCli
30
30
  )
31
31
  end
32
32
 
33
- def load_configuration(config_file = options[:config], env = options[:environment])
33
+ def load_configuration(config_file = options[:config_file], env = options[:environment])
34
34
  unless File.exists?(config_file)
35
35
  say "Configuration file #{config_file} not found.", :red
36
36
  say "Please run \'cs setup\' to create one."
@@ -3,59 +3,29 @@ module CloudstackCli
3
3
  include Thor::Actions
4
4
 
5
5
  package_name "cloudstack-cli"
6
- map %w(-v --version) => :version
7
6
 
8
- class_option :config,
7
+ class_option :config_file,
9
8
  default: File.join(Dir.home, '.cloudstack-cli.yml'),
10
9
  aliases: '-c',
11
10
  desc: 'location of your cloudstack-cli configuration file'
12
11
 
13
- class_option :environment,
12
+ class_option :env,
14
13
  aliases: '-e',
15
- desc: 'environment to load from the configuration file'
14
+ desc: 'environment to use'
16
15
 
17
16
  class_option :debug,
18
17
  desc: 'enable debug output',
19
18
  type: :boolean
20
19
 
21
- desc "version", "outputs the cloudstack-cli version"
20
+ desc "version", "print cloudstack-cli version number"
22
21
  def version
23
- say "cloudstack-cli v#{CloudstackCli::VERSION}"
22
+ say "cloudstack-cli version #{CloudstackCli::VERSION}"
24
23
  end
24
+ map %w(-v --version) => :version
25
25
 
26
- desc "setup", "initial setup of the Cloudstack connection"
27
- option :url
28
- option :api_key
29
- option :secret_key
30
- def setup(file = options[:config])
31
- config = {}
32
- unless options[:url]
33
- say "Configuring #{options[:environment] || 'default'} environment."
34
- say "What's the URL of your Cloudstack API?", :yellow
35
- say "Example: https://my-cloudstack-service/client/api/"
36
- config[:url] = ask("URL:", :magenta)
37
- end
38
- unless options[:api_key]
39
- config[:api_key] = ask("API Key:", :magenta)
40
- end
41
- unless options[:secret_key]
42
- config[:secret_key] = ask("Secret Key:", :magenta)
43
- end
44
- if options[:environment]
45
- config = {options[:environment] => config}
46
- end
47
- if File.exists? file
48
- begin
49
- old_config = YAML::load(IO.read(file))
50
- rescue
51
- error "Can't load configuration from file #{config_file}."
52
- exit 1
53
- end
54
- say "Warning: #{file} already exists.", :red
55
- exit unless yes?("Do you want to merge your settings? [y/N]", :red)
56
- config = old_config.merge(config)
57
- end
58
- File.open(file, 'w+') {|f| f.write(config.to_yaml) }
26
+ desc "setup", "initial configuration of Cloudstack connection settings"
27
+ def setup
28
+ invoke "environment:add", :environment => options[:environment]
59
29
  end
60
30
 
61
31
  desc "command COMMAND [arg1=val1 arg2=val2...]", "run a custom api command"
@@ -72,8 +42,10 @@ module CloudstackCli
72
42
  Dir[File.dirname(__FILE__) + '/commands/*.rb'].each do |command|
73
43
  require command
74
44
  end
75
-
76
- map :env => :environment
45
+
46
+ desc "environment SUBCOMMAND ...ARGS", "Manage cloudstack-cli environments"
47
+ subcommand :environment, Environment
48
+ map 'env' => :environment
77
49
 
78
50
  desc "zone SUBCOMMAND ...ARGS", "Manage zones"
79
51
  subcommand :zone, Zone
@@ -1,22 +1,72 @@
1
1
  class Environment < CloudstackCli::Base
2
2
 
3
3
  desc "list", "list cloudstack-cli environments"
4
- def environments(file = options[:config])
5
- config = {}
4
+ def list
5
+ config = parse_configfile(options[:config_file])
6
+ table = [%w(Name URL)]
7
+ table << ["default", config[:url]]
8
+ config.each_key do |key|
9
+ table << [key, config[key][:url]] unless key.class == Symbol
10
+ end
11
+ print_table table
12
+ end
13
+
14
+ desc "add", "add a new Cloudstack environment"
15
+ option :url
16
+ option :api_key
17
+ option :secret_key
18
+ def add(env = options[:environment])
19
+ config = {}
20
+ unless options[:url]
21
+ say "Add a new environment (#{env || 'default'})."
22
+ say "What's the URL of your Cloudstack API?", :yellow
23
+ say "Example: https://my-cloudstack-service/client/api/", :green
24
+ config[:url] = ask("URL:", :magenta)
25
+ end
26
+ unless options[:api_key]
27
+ config[:api_key] = ask("API Key:", :magenta)
28
+ end
29
+ unless options[:secret_key]
30
+ config[:secret_key] = ask("Secret Key:", :magenta)
31
+ end
32
+ if env
33
+ config = {env => config}
34
+ end
35
+ if File.exists? options[:config_file]
36
+ old_config = parse_configfile(options[:config_file])
37
+ say "Warning: #{options[:config_file]} already exists.", :red
38
+ exit unless yes?("Do you want to merge your settings? [y/N]", :red)
39
+ config = old_config.merge(config)
40
+ end
41
+ File.open(options[:config_file], 'w+') {|f| f.write(config.to_yaml) }
42
+ say "OK, config-file written to #{options[:config_file]}.", :green
43
+ end
44
+
45
+ desc "delete", "delete a Cloudstack connection"
46
+ def delete(name)
47
+ config = parse_configfile(options[:config_file])
48
+ exit unless yes?("Do you really want delete environment #{name}? [y/N]", :red)
49
+ config.delete(name)
50
+ File.open(options[:config_file], 'w+') {|f| f.write(config.to_yaml) }
51
+ say "OK.", :green
52
+ end
53
+
54
+ no_commands do
55
+
56
+ def parse_configfile(file)
6
57
  if File.exists? file
7
58
  begin
8
- config = YAML::load(IO.read(file))
59
+ return YAML::load(IO.read(file))
9
60
  rescue
10
- error "Can't load configuration from file #{config_file}."
61
+ say "Error loading configuration from file #{file}.", :red
11
62
  exit 1
12
63
  end
13
- table = [%w(Name URL)]
14
- table << ["default", config[:url]]
15
- config.each_key do |key|
16
- table << [key, config[key][:url]] unless key.class == Symbol
17
- end
18
- print_table table
64
+ else
65
+ say "Can't load configuration from file #{file}.", :red
66
+ exit 1
19
67
  end
20
68
  end
21
69
 
70
+ end
71
+
22
72
  end
@@ -1,12 +1,11 @@
1
1
  class Network < CloudstackCli::Base
2
2
 
3
3
  desc "list", "list networks"
4
- option :project
5
- option :account
6
- option :zone
4
+ option :project, desc: 'the project name of the network'
5
+ option :account, desc: 'the owner of the network'
6
+ option :zone, desc: 'typehe name of the zone the network belongs to'
7
7
  option :type, desc: 'the type of the network'
8
- option :showid, type: :boolean
9
- option :isdefault, type: :boolean
8
+ option :showid, type: :boolean, desc: 'show the network id'
10
9
  def list
11
10
  project = find_project if options[:project]
12
11
  if options[:zone]
@@ -23,8 +22,8 @@ class Network < CloudstackCli::Base
23
22
  elsif options[:account]
24
23
  networks = client.list_networks(account: options[:account], zone_id: zone_id)
25
24
  else
26
- networks = client.list_networks(isdefault: options[:isdefault], zone_id: zone_id)
27
- networks += client.list_networks(project_id: -1, isdefault: options[:isdefault], zone_id: zone_id)
25
+ networks = client.list_networks(zone_id: zone_id)
26
+ networks += client.list_networks(project_id: -1, zone_id: zone_id)
28
27
  end
29
28
 
30
29
  if options[:type]
@@ -1,19 +1,29 @@
1
1
  class Volume < CloudstackCli::Base
2
2
 
3
3
  desc "list", "list volumes"
4
- option :project
4
+ option :project, desc: 'list resources by project'
5
+ option :account, desc: 'list resources by account'
6
+ option :keyword, desc: 'list by keyword'
7
+ option :name, desc: 'name of the disk volume'
8
+ option :type, desc: 'type of disk volume (ROOT or DATADISK)'
5
9
  def list
6
- projectid = find_project['id'] if options[:project]
7
- volumes = client.list_volumes(projectid)
10
+ if options[:project]
11
+ projectid = find_project['id']
12
+ options[:project_id] = projectid if projectid
13
+ end
14
+ volumes = client.list_volumes(options)
8
15
  if volumes.size < 1
9
- puts "No volumes found."
16
+ say "No volumes found."
10
17
  else
11
- table = [["Name", "Type", "Size", "VM", "Storage", "Offeringname"]]
18
+ table = [%w(Name Type Size VM Storage Offeringname)]
12
19
  volumes.each do |volume|
13
- table << [volume['name'], volume['type'],
20
+ table << [
21
+ volume['name'], volume['type'],
14
22
  (volume['size'] / 1024**3).to_s + 'GB',
15
23
  volume['vmname'],
16
- volume['storage'], volume['diskofferingname']]
24
+ volume['storage'],
25
+ volume['diskofferingname']
26
+ ]
17
27
  end
18
28
  print_table(table)
19
29
  end
@@ -1,3 +1,3 @@
1
1
  module CloudstackCli
2
- VERSION = "0.5.4"
2
+ VERSION = "0.5.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudstack-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nik Wolfgramm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-13 00:00:00.000000000 Z
11
+ date: 2014-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc
@@ -59,6 +59,9 @@ dependencies:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0.3'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 0.3.6
62
65
  type: :runtime
63
66
  prerelease: false
64
67
  version_requirements: !ruby/object:Gem::Requirement
@@ -66,6 +69,9 @@ dependencies:
66
69
  - - "~>"
67
70
  - !ruby/object:Gem::Version
68
71
  version: '0.3'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 0.3.6
69
75
  description: cloudstack-cli is a CloudStack API client written in Ruby.
70
76
  email:
71
77
  - nik.wolfgramm@gmail.com