cloudstack-cli 1.0.0.rc1 → 1.0.0.rc2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: abbccb8fdb7cb7d93fb79f33f58f53469e0763fd
4
- data.tar.gz: 6e4e7df9e6d4f4cbe5e6d79ffa0497426801d0c5
3
+ metadata.gz: fb18633b9ea89df8bc15123d54b7cad8c90a434a
4
+ data.tar.gz: ebebedd48f0edb2272944ffd8d8f903a441279be
5
5
  SHA512:
6
- metadata.gz: 48faa2904edaeb89a5dc81c7068b851ab1b99e241bdc2c836f30ac1dfaccdce608212cd6cc258fe3675dd8bb5fa58a3e3159b34d7649cfc2fd082423af724b22
7
- data.tar.gz: 3ee41e41a2ab280d2dce91ad2f57eeeb16b362428729b98e47522f514cf743eb72fdbe5e2bd82d2d1c7b5999cfca0b3e9f5fb6807e79d72575b737d936bd3f5e
6
+ metadata.gz: 3f744fdfe0acd813349be7a8da81c20b1d3a981c2ce6d4c63add9a3c27a4d11d927d05536d4ee06ce83af987005586dc63f398cf3730c34697c9e952fc7d3ac3
7
+ data.tar.gz: 87185f60b63cb39b2781bcbf8d69bdf784db0b26edf4114f0a2d936b5e986f166b2fb7bab2ee718fa3ffd8771137e9851626ced918b0eef59c100d89b63d52fa
data/.gitignore CHANGED
@@ -1,7 +1,4 @@
1
1
  .DS_Store
2
- results.html
3
- config/cloudstack.yml
4
2
  pkg
5
- html
6
3
  *.gem
7
4
  .bundle
data/Gemfile CHANGED
@@ -1,6 +1,10 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'cloudstack_client', git: 'git@github.com:niwo/cloudstack_client.git'
3
+ group :development do
4
+ gem 'cloudstack_client',
5
+ path: '../cloudstack_client/',
6
+ branch: 'master'
7
+ end
4
8
 
5
9
  # Specify your gem's dependencies in cloudstack-cli.gemspec
6
10
  gemspec
data/Gemfile.lock CHANGED
@@ -1,20 +1,21 @@
1
- GIT
2
- remote: git@github.com:niwo/cloudstack_client.git
3
- revision: b388af01e7403f65fc1ad5cd4c905a1f005afea3
4
- specs:
5
- cloudstack_client (1.0.0.rc1)
6
-
7
1
  PATH
8
2
  remote: .
9
3
  specs:
10
- cloudstack-cli (1.0.0.rc1)
11
- cloudstack_client (~> 1.0.0.rc1)
4
+ cloudstack-cli (1.0.0.rc2)
5
+ cloudstack_client (~> 1.0.2)
12
6
  thor (~> 0.19.1)
13
7
 
8
+ PATH
9
+ remote: ../cloudstack_client/
10
+ specs:
11
+ cloudstack_client (1.0.2)
12
+ msgpack (~> 0.5.11)
13
+
14
14
  GEM
15
15
  remote: https://rubygems.org/
16
16
  specs:
17
17
  json (1.8.2)
18
+ msgpack (0.5.11)
18
19
  rake (10.4.2)
19
20
  rdoc (4.2.0)
20
21
  json (~> 1.4)
@@ -25,5 +25,5 @@ Gem::Specification.new do |gem|
25
25
  gem.add_development_dependency('rake', '~> 10.4')
26
26
 
27
27
  gem.add_dependency('thor', '~> 0.19.1')
28
- gem.add_dependency('cloudstack_client', '~> 1.0.0.rc1')
28
+ gem.add_dependency('cloudstack_client', '~> 1.0.2')
29
29
  end
@@ -10,11 +10,25 @@ module CloudstackCli
10
10
 
11
11
  attr_reader :config
12
12
 
13
+ # rescue error globally
14
+ def self.start(given_args=ARGV, config={})
15
+ super
16
+ rescue => e
17
+ error_class = e.class.name.split('::')
18
+ if error_class.size == 2 && error_class.first == "CloudstackClient"
19
+ puts "\e[31mERROR\e[0m: #{error_class.last} - #{e.message}"
20
+ puts e.backtrace if ARGV.include? "--debug"
21
+ else
22
+ raise
23
+ end
24
+ end
25
+
13
26
  # catch control-c and exit
14
- trap("SIGINT") {
15
- puts " bye"
27
+ trap("SIGINT") do
28
+ puts
29
+ puts "bye.."
16
30
  exit!
17
- }
31
+ end
18
32
 
19
33
  # exit with return code 1 in case of a error
20
34
  def self.exit_on_failure?
@@ -23,7 +23,6 @@ module CloudstackCli
23
23
  say "cloudstack-cli version #{CloudstackCli::VERSION}"
24
24
  say " (cloudstack_client version #{CloudstackClient::VERSION})"
25
25
  end
26
- map %w(-v --version) => :version
27
26
 
28
27
  desc "setup", "Initial configuration of Cloudstack connection settings"
29
28
  def setup(env = options[:environment])
@@ -46,128 +45,52 @@ module CloudstackCli
46
45
  end
47
46
 
48
47
  desc "command COMMAND [arg1=val1 arg2=val2...]", "Run a custom api command"
49
- option :format, default: 'json',
48
+ option :format, default: 'yaml',
50
49
  enum: %w(json yaml), desc: "output format"
51
50
  option :pretty_print, default: true, type: :boolean,
52
51
  desc: "pretty print json output"
53
52
  def command(command, *args)
54
- params = {'command' => command}
53
+ params = { 'command' => command }
55
54
  args.each do |arg|
56
55
  arg = arg.split('=')
57
56
  params[arg[0]] = arg[1]
58
57
  end
58
+
59
+ unless client.api.commands.has_key? command
60
+ say "ERROR: ", :red
61
+ say "Unknown API command '#{command}'."
62
+ exit!
63
+ end
64
+
65
+ unless client.api.all_required_params?(command, params)
66
+ raise CloudstackClient::ParameterError, client.api.missing_params_msg(command)
67
+ end
68
+
59
69
  data = client.send_request(params)
60
- output = if options[:format] == 'json'
61
- options[:pretty_print] ? JSON.pretty_generate(data) : data.to_json
70
+ if options[:format] == 'json'
71
+ puts options[:pretty_print] ? JSON.pretty_generate(data) : data.to_json
62
72
  else
63
- data.to_yaml
73
+ puts data.to_yaml
64
74
  end
65
- puts output
66
- end
67
-
68
- # require subcommands
69
- Dir[File.dirname(__FILE__) + '/commands/*.rb'].each do |command|
70
- require command
71
75
  end
72
76
 
73
- desc "environment SUBCOMMAND ...ARGS", "Manage cloudstack-cli environments"
74
- subcommand :environment, Environment
75
- map 'env' => :environment
76
-
77
- desc "zone SUBCOMMAND ...ARGS", "Manage zones"
78
- subcommand :zone, Zone
77
+ # Require and describe subcommands
78
+ Dir[File.dirname(__FILE__) + '/commands/*.rb'].each do |command_path|
79
+ require command_path
79
80
 
80
- desc "pod SUBCOMMAND ...ARGS", "List pods"
81
- subcommand :pod, Pod
81
+ command = File.basename(command_path, ".rb")
82
+ class_names = command.split('_').collect(&:capitalize)
82
83
 
83
- desc "cluster SUBCOMMAND ...ARGS", "List clusters"
84
- subcommand :cluster, Cluster
85
-
86
- desc "host SUBCOMMAND ...ARGS", "List hosts"
87
- subcommand :host, Host
88
-
89
- desc "project SUBCOMMAND ...ARGS", "Manage servers"
90
- subcommand :project, Project
84
+ desc "#{command} SUBCOMMAND ...ARGS",
85
+ "#{class_names.join(' ')} commands"
86
+ subcommand command,
87
+ Object.const_get(class_names.join)
88
+ end
91
89
 
92
- desc "virtual_machine SUBCOMMAND ...ARGS", "Manage virtual machines"
93
- subcommand :virtual_machine, VirtualMachine
90
+ # Additional command maps (aliases)
91
+ map %w(-v --version) => :version
92
+ map 'env' => :environment
94
93
  map 'vm' => :virtual_machine
95
94
  map 'server' => :virtual_machine
96
-
97
- desc "compute_offer SUBCOMMAND ...ARGS", "Manage offerings"
98
- subcommand :compute_offer, ComputeOffer
99
-
100
- desc "disk_offer SUBCOMMAND ...ARGS", "Manage disk offerings"
101
- subcommand :disk_offering, DiskOffer
102
-
103
- desc "network SUBCOMMAND ...ARGS", "Manage networks"
104
- subcommand :network, Network
105
- map 'networks' => 'network'
106
-
107
- desc "physical_network SUBCOMMAND ...ARGS", "Manage physical networks"
108
- subcommand :physical_network, PhysicalNetwork
109
-
110
- desc "load_balancer SUBCOMMAND ...ARGS", "Manage load balancing rules"
111
- subcommand :load_balancer, LoadBalancer
112
-
113
- desc "template SUBCOMMAND ...ARGS", "Manage templates"
114
- subcommand :template, Template
115
-
116
- desc "iso SUBCOMMAND ...ARGS", "Manage iso's"
117
- subcommand :iso, Iso
118
-
119
- desc "router SUBCOMMAND ...ARGS", "Manage virtual routers"
120
- subcommand :router, Router
121
-
122
- desc "system_vm SUBCOMMAND ...ARGS", "Manage system vms"
123
- subcommand :system_vm, SystemVm
124
-
125
- desc "volume SUBCOMMAND ...ARGS", "Manage volumes"
126
- subcommand :volume, Volume
127
-
128
- desc "snapshot SUBCOMMAND ...ARGS", "Manage snapshots"
129
- subcommand :snapshot, Snapshot
130
-
131
- desc "stack SUBCOMMAND ...ARGS", "Manage stacks"
132
- subcommand :stack, Stack
133
-
134
- desc "account SUBCOMMAND ...ARGS", "Manage accounts"
135
- subcommand :account, Account
136
-
137
- desc "user SUBCOMMAND ...ARGS", "Manage users"
138
- subcommand :user, User
139
-
140
- desc "domain SUBCOMMAND ...ARGS", "Manage domains"
141
- subcommand :domain, Domain
142
-
143
- desc "ip_address SUBCOMMAND ...ARGS", "Manage ip addresses"
144
- subcommand :ip_address, IpAddress
145
-
146
- desc "capacity SUBCOMMAND ...ARGS", "Lists all the system wide capacities"
147
- subcommand :capacity, Capacity
148
-
149
- desc "port_rule SUBCOMMAND ...ARGS", "Manage portforwarding rules"
150
- subcommand :port_rule, PortRule
151
-
152
- desc "job SUBCOMMAND ...ARGS", "Display async jobs"
153
- subcommand :job, Job
154
-
155
- desc "ssh_key_pair SUBCOMMAND ...ARGS", "Manage ssh key pairs"
156
- subcommand :ssh_key_pair, SshKeyPair
157
-
158
- desc "storage_pool SUBCOMMAND ...ARGS", "Manage storage pools"
159
- subcommand :storage_pool, StoragePool
160
-
161
- desc "region SUBCOMMAND ...ARGS", "Manage regions"
162
- subcommand :region, Region
163
-
164
- desc "affinity_group SUBCOMMAND ...ARGS", "Manage affinity_groups"
165
- subcommand :affinity_group, AffinityGroup
166
-
167
- desc "configuration SUBCOMMAND ...ARGS", "List cloudstack configuration values"
168
- subcommand :configuration, Configuration
169
-
170
- desc "resource_limit SUBCOMMAND ...ARGS", "Show cloudstack resource limits"
171
- subcommand :resource_limit, ResourceLimit
172
95
  end
173
96
  end
@@ -22,25 +22,29 @@ class Environment < CloudstackCli::Base
22
22
  config = {}
23
23
  unless options[:url]
24
24
  say "Add a new environment...", :green
25
- say "Environment name: #{env}" if env
25
+ if env
26
+ say "Environment name: #{env}"
27
+ else
28
+ env = ask("Environment name:", :magenta)
29
+ end
26
30
  say "What's the URL of your Cloudstack API?", :yellow
27
31
  say "Example: https://my-cloudstack-service/client/api/", :green
28
32
  config[:url] = ask("URL:", :magenta)
29
33
  end
30
-
34
+
31
35
  unless options[:api_key]
32
36
  config[:api_key] = ask("API Key:", :magenta)
33
37
  end
34
-
38
+
35
39
  unless options[:secret_key]
36
40
  config[:secret_key] = ask("Secret Key:", :magenta)
37
41
  end
38
-
42
+
39
43
  if env
40
44
  config = {env => config}
41
45
  config[:default] = env if options[:default]
42
46
  end
43
-
47
+
44
48
  if File.exists? options[:config_file]
45
49
  old_config = parse_config_file
46
50
  if !env || old_config.has_key?(env)
@@ -72,10 +76,10 @@ class Environment < CloudstackCli::Base
72
76
  if config.keys.select { |key| !key.is_a? Symbol}.size == 0
73
77
  exit unless yes?("Do you really want to delete environment #{env}? [y/N]", :yellow)
74
78
  File.delete(options[:config_file])
75
- say "OK.", :green
79
+ say "OK.", :green
76
80
  exit
77
81
  end
78
- elsif config.delete(env)
82
+ elsif config.delete(env)
79
83
  else
80
84
  say "Environment #{env} does not exist.", :red
81
85
  exit 1
@@ -89,7 +93,7 @@ class Environment < CloudstackCli::Base
89
93
  desc "default [ENV]", "show or set the default environment"
90
94
  def default(env = nil)
91
95
  config = parse_config_file
92
-
96
+
93
97
  unless env
94
98
  default_env = config[:default] || '-'
95
99
  say "The current default environment is \"#{default_env}\""
@@ -137,4 +141,4 @@ class Environment < CloudstackCli::Base
137
141
 
138
142
  end
139
143
 
140
- end
144
+ end
@@ -0,0 +1,27 @@
1
+ class InfrastructureStack < CloudstackCli::Base
2
+
3
+ desc "create STACKFILE", "create a infrastructure stack"
4
+ def create(stackfile)
5
+ puts stack = parse_file(stackfile)
6
+ say "Create '#{stack["name"]}' infrastructure stack...", :green
7
+
8
+ create_domains(stack['domains'])
9
+
10
+ say "Finished.", :green
11
+ end
12
+
13
+ desc "destroy STACKFILE", "destroy a infrastructure stack"
14
+ def destroy(stackfile)
15
+
16
+ end
17
+
18
+ no_commands do
19
+ def create_domains(domains)
20
+ domains.each do |domain|
21
+ puts domain
22
+ end
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -99,7 +99,10 @@ module CloudstackCli
99
99
 
100
100
  def resolve_iso(options = options)
101
101
  if options[:iso]
102
- unless iso = client.list_isos(name: options[:iso]).first
102
+ unless iso = client.list_isos(
103
+ name: options[:iso],
104
+ project_id: options[:project_id]
105
+ ).first
103
106
  say "Error: Iso '#{args[:iso]}' is invalid.", :red
104
107
  exit 1
105
108
  end
@@ -115,7 +118,11 @@ module CloudstackCli
115
118
 
116
119
  def resolve_template(options = options)
117
120
  if options[:template]
118
- if template = client.list_templates(name: options[:template], template_filter: "all").first
121
+ if template = client.list_templates(
122
+ name: options[:template],
123
+ template_filter: "executable",
124
+ project_id: options[:project_id]
125
+ ).first
119
126
  options[:template_id] = template['id']
120
127
  else
121
128
  say "Error: Template #{options[:template]} not found.", :red
@@ -1,3 +1,3 @@
1
1
  module CloudstackCli
2
- VERSION = "1.0.0.rc1"
2
+ VERSION = "1.0.0.rc2"
3
3
  end
@@ -0,0 +1,36 @@
1
+ name: Test Infrastructure Stack
2
+ description: "Web Application Stack"
3
+ version: "1.0"
4
+ domains:
5
+ - name: Testdomain
6
+ network_domain: test.io
7
+ - name: Subdomain
8
+ network_domain: sub.test.io
9
+ parent_domain: Testdomain
10
+ accounts:
11
+ -
12
+ -
13
+ users:
14
+ -
15
+ -
16
+ projects:
17
+ -
18
+ -
19
+ compute_offerings:
20
+ -
21
+ -
22
+ network_offerings:
23
+ -
24
+ -
25
+ networks:
26
+ -
27
+ -
28
+ port_rules:
29
+ -
30
+ -
31
+ load_balancing_rules:
32
+ -
33
+ -
34
+ resource_limits:
35
+ -
36
+ -
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: 1.0.0.rc1
4
+ version: 1.0.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nik Wolfgramm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-24 00:00:00.000000000 Z
11
+ date: 2015-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.0.0.rc1
61
+ version: 1.0.2
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.0.0.rc1
68
+ version: 1.0.2
69
69
  description: cloudstack-cli is a CloudStack API command line client written in Ruby.
70
70
  email:
71
71
  - nik.wolfgramm@gmail.com
@@ -98,6 +98,7 @@ files:
98
98
  - lib/cloudstack-cli/commands/domain.rb
99
99
  - lib/cloudstack-cli/commands/environment.rb
100
100
  - lib/cloudstack-cli/commands/host.rb
101
+ - lib/cloudstack-cli/commands/infrastructure_stack.rb
101
102
  - lib/cloudstack-cli/commands/ip_address.rb
102
103
  - lib/cloudstack-cli/commands/iso.rb
103
104
  - lib/cloudstack-cli/commands/job.rb
@@ -111,7 +112,7 @@ files:
111
112
  - lib/cloudstack-cli/commands/resource_limit.rb
112
113
  - lib/cloudstack-cli/commands/router.rb
113
114
  - lib/cloudstack-cli/commands/snapshot.rb
114
- - lib/cloudstack-cli/commands/ssh_key_pairs.rb
115
+ - lib/cloudstack-cli/commands/ssh_key_pair.rb
115
116
  - lib/cloudstack-cli/commands/stack.rb
116
117
  - lib/cloudstack-cli/commands/storage_pool.rb
117
118
  - lib/cloudstack-cli/commands/system_vm.rb
@@ -123,6 +124,7 @@ files:
123
124
  - lib/cloudstack-cli/helper.rb
124
125
  - lib/cloudstack-cli/option_resolver.rb
125
126
  - lib/cloudstack-cli/version.rb
127
+ - test/infrastructure_stack.yaml
126
128
  - test/stack_example.json
127
129
  - test/stack_example.yml
128
130
  homepage: http://github.com/niwo/cloudstack-cli
@@ -152,5 +154,6 @@ signing_key:
152
154
  specification_version: 4
153
155
  summary: cloudstack-cli CloudStack API client
154
156
  test_files:
157
+ - test/infrastructure_stack.yaml
155
158
  - test/stack_example.json
156
159
  - test/stack_example.yml