cloudstack-cli 1.5.10 → 1.5.12

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: 9db726fce7f2ff20082296b4e424db14497a04ab
4
- data.tar.gz: 6d6177310113255ec6ff7b34fc56dece69ff0c66
3
+ metadata.gz: 83b0103b12d6560e9bffd194169b83c0f27c1222
4
+ data.tar.gz: a7f0cc886075681aa26fc07f95ea4cfbfc1469ad
5
5
  SHA512:
6
- metadata.gz: 2e6177a5cd286a74c2374ef3171d8c886e36e7abb94ded0e482bf1d4e86613ba56b103c00963fcfe30e6aad1bdfa49c2d659fd1bf5721a8cf81f94c0a8c89714
7
- data.tar.gz: a09c1c2ceed2856f46f5cececfd61248bb87fd87d7b5f62d0d8fe49bedbcde4ab94b98fd6cf7b87e308cdf5a6cbeb5222a5890a215bbf1956ad36d958cda0b21
6
+ metadata.gz: f235eb2acda88ef4e5ce20cef48fcff05a36bbd2741c5c8b08aad998422220b25444707f370e53403c536e4aea79861f9edcadc2290ba65d28051a255edd85d2
7
+ data.tar.gz: 33043d1de16cf62c30d19d666bc583da7344d94bd405cdf6052da70d38a635314c33b7e6d3ea795325d9f641bf6475ce6a52c1d83e591858858d417f047fe34d
data/Gemfile.lock CHANGED
@@ -6,15 +6,16 @@ PATH
6
6
  PATH
7
7
  remote: .
8
8
  specs:
9
- cloudstack-cli (1.5.10)
9
+ cloudstack-cli (1.5.12)
10
10
  cloudstack_client (~> 1.4.3)
11
- thor (~> 0.19)
11
+ thor (~> 0.19.4)
12
12
 
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
+ minitest (5.9.1)
16
17
  rake (11.3.0)
17
- thor (0.19.1)
18
+ thor (0.19.4)
18
19
 
19
20
  PLATFORMS
20
21
  ruby
@@ -22,6 +23,7 @@ PLATFORMS
22
23
  DEPENDENCIES
23
24
  cloudstack-cli!
24
25
  cloudstack_client!
26
+ minitest (~> 5.9)
25
27
  rake (~> 11.3)
26
28
 
27
29
  BUNDLED WITH
data/Rakefile CHANGED
@@ -1 +1,11 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs << "spec"
7
+ t.pattern = "spec/**/*_spec.rb"
8
+ t.warning = false
9
+ end
10
+
11
+ task default: :test
@@ -22,7 +22,8 @@ Gem::Specification.new do |gem|
22
22
  gem.rdoc_options = %w[--line-numbers --inline-source]
23
23
 
24
24
  gem.add_development_dependency('rake', '~> 11.3')
25
+ gem.add_development_dependency('minitest', '~> 5.9')
25
26
 
26
27
  gem.add_dependency('cloudstack_client', '~> 1.4.3')
27
- gem.add_dependency('thor', '~> 0.19')
28
+ gem.add_dependency('thor', '~> 0.19.4')
28
29
  end
File without changes
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: "web_stack_a"
3
+ description: "Web Application Stack"
4
+ version: "1.0"
5
+ zone: "Sandbox-simulator"
6
+ group: "my_web_stack"
7
+ servers:
8
+ - name: "web-01, web-02"
9
+ description: "Web nodes"
10
+ template: "CentOS 5.3(64-bit) no GUI (Simulator)"
11
+ offering: "Small Instance"
12
+ networks: "test-network"
13
+ port_rules: ":80, :443"
14
+ - name: "db-01"
15
+ description: "PostgreSQL Master"
16
+ template: "CentOS 5.3(64-bit) no GUI (Simulator)"
17
+ offering: "Medium Instance"
18
+ ip_network_list:
19
+ - name: "test-network"
20
+ ip: 10.1.1.11
File without changes
File without changes
File without changes
@@ -20,7 +20,7 @@ class Account < CloudstackCli::Base
20
20
  end
21
21
  end
22
22
 
23
- desc 'list', 'list accounts'
23
+ desc "list", "list accounts"
24
24
  option :format, default: "table",
25
25
  enum: %w(table json yaml)
26
26
  def list
@@ -4,7 +4,7 @@ class AffinityGroup < CloudstackCli::Base
4
4
  option :account
5
5
  option :name
6
6
  option :type
7
- option :listall
7
+ option :listall, type: :boolean, default: true
8
8
  option :keyword
9
9
  option :format, default: "table",
10
10
  enum: %w(table json yaml)
@@ -28,7 +28,7 @@ class IpAddress < CloudstackCli::Base
28
28
  desc "list", "list public IP address"
29
29
  option :project
30
30
  option :account
31
- option :listall
31
+ option :listall, type: :boolean, default: true
32
32
  option :format, default: "table",
33
33
  enum: %w(table json yaml)
34
34
  def list
@@ -0,0 +1,50 @@
1
+ class NetworkOffer < CloudstackCli::Base
2
+
3
+ desc 'list', 'list network offerings'
4
+ option :guest_ip_type, enum: %w(isolated shared),
5
+ desc: "list network offerings by guest type."
6
+ option :format, default: "table",
7
+ enum: %w(table json yaml)
8
+ def list
9
+ offerings = client.list_network_offerings(options)
10
+ if offerings.size < 1
11
+ puts "No offerings found."
12
+ else
13
+ case options[:format].to_sym
14
+ when :yaml
15
+ puts({network_offers: offerings}.to_yaml)
16
+ when :json
17
+ puts JSON.pretty_generate(network_offers: offerings)
18
+ else
19
+ table = [%w(Name Display_Text Default? Guest_IP_Type State)]
20
+ offerings.each do |offer|
21
+ table << [
22
+ offer['name'],
23
+ offer['displaytext'],
24
+ offer['isdefault'],
25
+ offer['guestiptype'],
26
+ offer['state'],
27
+ ]
28
+ end
29
+ print_table table
30
+ end
31
+ end
32
+ end
33
+
34
+ desc "show NAME", "show detailed infos about a network offering"
35
+ def show(name)
36
+ unless offer = client.list_network_offerings(name: name).first
37
+ say "Error: No network offering with name '#{name}' found.", :red
38
+ else
39
+ table = offer.map do |key, value|
40
+ if key == "service"
41
+ [ set_color("services", :yellow), value.map{|s| s["name"]}.join(", ") ]
42
+ else
43
+ [ set_color("#{key}", :yellow), "#{value}" ]
44
+ end
45
+ end
46
+ print_table table
47
+ end
48
+ end
49
+
50
+ end
@@ -7,7 +7,6 @@ class Router < CloudstackCli::Base
7
7
  option :state, desc: "the status of the router"
8
8
  option :redundant_state, desc: "the state of redundant virtual router",
9
9
  enum: %w(master backup fault unknown)
10
- option :listall, type: :boolean, desc: "list all routers", default: true
11
10
  option :reverse, type: :boolean, default: false, desc: "reverse listing of routers"
12
11
  option :command,
13
12
  desc: "command to execute for each router",
@@ -26,13 +25,14 @@ class Router < CloudstackCli::Base
26
25
 
27
26
  routers = client.list_routers(options)
28
27
  # show all routers unless project or account is set
29
- if options[:listall] && !options[:project] && !options[:account]
28
+ if !options[:project] && !options[:account]
30
29
  client.list_projects(listall: true).each do |project|
31
30
  routers = routers + client.list_routers(
32
31
  options.merge(projectid: project['id'])
33
32
  )
34
33
  end
35
34
  end
35
+ options[:listall] = true
36
36
  print_routers(routers, options)
37
37
  execute_router_commands(options[:command].downcase, routers) if options[:command]
38
38
  end
@@ -4,7 +4,7 @@ class Snapshot < CloudstackCli::Base
4
4
  option :account, desc: "the account associated with the snapshot"
5
5
  option :project, desc: "the project associated with the snapshot"
6
6
  option :domain, desc: "the domain name of the snapshot's account"
7
- option :listall, default: true, desc: "list all resources the caller has rights on"
7
+ option :listall, type: :boolean, default: true, desc: "list all resources the caller has rights on"
8
8
  option :state, desc: "filter snapshots by state"
9
9
  option :format, default: "table",
10
10
  enum: %w(table json yaml)
@@ -1,7 +1,7 @@
1
1
  class SshKeyPair < CloudstackCli::Base
2
2
 
3
3
  desc "list", 'list ssh key pairs'
4
- option :listall, default: true
4
+ option :listall, type: :boolean, default: true
5
5
  option :account, desc: "name of the account"
6
6
  option :project, desc: "name of the project"
7
7
  option :format, default: "table",
@@ -8,6 +8,8 @@ class Stack < CloudstackCli::Base
8
8
  desc: "Skip creation of port forwarding rules."
9
9
  option :concurrency, type: :numeric, default: 10, aliases: '-C',
10
10
  desc: "number of concurrent commands to execute"
11
+ option :assumeyes, type: :boolean, default: false, aliases: '-y',
12
+ desc: "answer yes for all questions"
11
13
  def create(stackfile)
12
14
  stack = parse_file(stackfile)
13
15
  project_id = find_project_by_name(stack["project"])
@@ -83,13 +85,16 @@ class Stack < CloudstackCli::Base
83
85
  end
84
86
  say "Finished.", :green
85
87
 
86
- if successful_jobs > 0 && yes?("Display password(s) for VM(s)? [y/N]:", :yellow)
87
- pw_table = jobs.select {|job| job[:status] == 1 && job[:result] }.map do |job|
88
- if result = job[:result]["virtualmachine"]
89
- ["#{result["name"]}:", result["password"] || "n/a"]
88
+ if successful_jobs > 0
89
+ if options[:assumeyes] || yes?("Display password(s) for VM(s)? [y/N]:", :yellow)
90
+ pw_table = [%w(VM Password)]
91
+ jobs.select {|job| job[:status] == 1 && job[:result] }.each do |job|
92
+ if result = job[:result]["virtualmachine"]
93
+ pw_table << ["#{result["name"]}:", result["password"] || "n/a"]
94
+ end
90
95
  end
96
+ print_table(pw_table) if pw_table.size > 0
91
97
  end
92
- print_table(pw_table) if pw_table.size > 0
93
98
  end
94
99
  end
95
100
 
@@ -1,7 +1,7 @@
1
1
  class User < CloudstackCli::Base
2
2
 
3
3
  desc 'list', 'list users'
4
- option :listall
4
+ option :listall, type: :boolean, default: true
5
5
  option :account
6
6
  option :format, default: "table",
7
7
  enum: %w(table json yaml)
@@ -10,7 +10,7 @@ class VirtualMachine < CloudstackCli::Base
10
10
  option :host, desc: "the name of the hypervisor host the VM belong to"
11
11
  option :filter, type: :hash,
12
12
  desc: "filter objects based on arrtibutes: (attr1:regex attr2:regex ...)"
13
- option :listall, desc: "list all virtual machines", default: true
13
+ option :listall, desc: "list all virtual machines", type: :boolean, default: true
14
14
  option :command,
15
15
  desc: "command to execute for the given virtual machines",
16
16
  enum: %w(START STOP REBOOT)
@@ -32,7 +32,7 @@ class VirtualMachine < CloudstackCli::Base
32
32
  virtual_machines = client.list_virtual_machines(options)
33
33
  virtual_machines = filter_objects(virtual_machines) if options[:filter]
34
34
  if virtual_machines.size < 1
35
- puts "No virtual_machines found."
35
+ puts "No virtual machines found."
36
36
  else
37
37
  print_virtual_machines(virtual_machines)
38
38
  execute_virtual_machines_commands(command, virtual_machines) if command
@@ -93,6 +93,8 @@ class VirtualMachine < CloudstackCli::Base
93
93
  desc: "optional binary data that can be sent to the virtual machine upon a successful deployment."
94
94
  option :concurrency, type: :numeric, default: 10, aliases: '-C',
95
95
  desc: "number of concurrent commands to execute"
96
+ option :assumeyes, type: :boolean, default: false, aliases: '-y',
97
+ desc: "answer yes for all questions"
96
98
  def create(*names)
97
99
  if names.size == 0
98
100
  say "Please provide at least one virtual machine name.", :yellow
@@ -140,13 +142,16 @@ class VirtualMachine < CloudstackCli::Base
140
142
  end
141
143
  say "Finished.", :green
142
144
 
143
- if successful_jobs > 0 && yes?("Display password(s) for VM(s)? [y/N]:", :yellow)
144
- pw_table = jobs.select {|job| job[:status] == 1 && job[:result] }.map do |job|
145
- if result = job[:result]["virtualmachine"]
146
- ["#{result["name"]}:", result["password"] || "n/a"]
145
+ if successful_jobs > 0
146
+ if options[:assumeyes] || yes?("Display password(s) for VM(s)? [y/N]:", :yellow)
147
+ pw_table = [%w(VM Password)]
148
+ jobs.select {|job| job[:status] == 1 && job[:result] }.each do |job|
149
+ if result = job[:result]["virtualmachine"]
150
+ pw_table << ["#{result["name"]}:", result["password"] || "n/a"]
151
+ end
147
152
  end
153
+ print_table(pw_table) if pw_table.size > 0
148
154
  end
149
- print_table(pw_table) if pw_table.size > 0
150
155
  end
151
156
  end
152
157
 
@@ -1,3 +1,3 @@
1
1
  module CloudstackCli
2
- VERSION = "1.5.10"
2
+ VERSION = "1.5.12"
3
3
  end
@@ -0,0 +1,101 @@
1
+ require "spec_helper"
2
+ require "cloudstack-cli"
3
+
4
+ describe VirtualMachine do
5
+
6
+ it "should support all CRUD actions" do
7
+ vmname = "testvm1"
8
+
9
+ # CREATE
10
+ out, err = capture_io{ CloudstackCli::Cli.start [
11
+ "vm",
12
+ "create",
13
+ vmname,
14
+ "--zone=#{ZONE}",
15
+ "--template=#{TEMPLATE}",
16
+ "--offering=#{OFFERING_S}",
17
+ "--networks=test-network",
18
+ "--port-rules=:80",
19
+ "--assumeyes",
20
+ CONFIG,
21
+ ]}
22
+ err.must_equal ""
23
+
24
+ # READ - LIST
25
+ out, err = capture_io{ CloudstackCli::Cli.start [
26
+ "vm",
27
+ "list",
28
+ CONFIG
29
+ ]}
30
+ err.must_equal ""
31
+ out.must_match(
32
+ /.*(#{vmname}).*/
33
+ )
34
+
35
+ # READ - SHOW
36
+ out, err = capture_io{ CloudstackCli::Cli.start [
37
+ "vm",
38
+ "show",
39
+ vmname,
40
+ CONFIG
41
+ ]}
42
+ err.must_equal ""
43
+ out.must_match(
44
+ /.*(#{vmname}).*/
45
+ )
46
+
47
+ # UPDATE - STOP
48
+ out, err = capture_io{ CloudstackCli::Cli.start [
49
+ "vm",
50
+ "stop",
51
+ vmname,
52
+ "--force",
53
+ CONFIG,
54
+ ]}
55
+ err.must_equal ""
56
+
57
+ # UPDATE - UPDATE ;-)
58
+ new_vmname = "testvm11"
59
+ out, err = capture_io{ CloudstackCli::Cli.start [
60
+ "vm",
61
+ "update",
62
+ vmname,
63
+ "--name=#{new_vmname}",
64
+ "--force",
65
+ CONFIG,
66
+ ]}
67
+ err.must_equal ""
68
+
69
+ # UPDATE - START
70
+ out, err = capture_io{ CloudstackCli::Cli.start [
71
+ "vm",
72
+ "start",
73
+ new_vmname,
74
+ CONFIG,
75
+ ]}
76
+ err.must_equal ""
77
+
78
+ # UPDATE - REBOOT
79
+ out, err = capture_io{ CloudstackCli::Cli.start [
80
+ "vm",
81
+ "reboot",
82
+ new_vmname,
83
+ "--force",
84
+ CONFIG,
85
+ ]}
86
+ err.must_equal ""
87
+
88
+ # DELETE
89
+ out, err = capture_io{ CloudstackCli::Cli.start [
90
+ "vm",
91
+ "destroy",
92
+ new_vmname,
93
+ "--expunge",
94
+ "--force",
95
+ CONFIG,
96
+ ]}
97
+ err.must_equal ""
98
+
99
+ end
100
+
101
+ end
@@ -0,0 +1,6 @@
1
+ ---
2
+ :default: development
3
+ development:
4
+ :url: http://127.0.0.1:8080/client/api
5
+ :api_key: 3B1lE0C33ceSOUg0jaIo8STNZ55I-mdvza0LXpZA8mrvtpBpgzJgE9YSsURBcQ6qKX090w5vv_AgGRZeYS9AiQ
6
+ :secret_key: mneyw6fg__Gt-ENg0E_9BfxcuiMJPSThe701Kuz7f5_EsJ0POoN4z9eoslECP5V9oDzB6XOlsCw1FuBqPjMmLg
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: "web_stack_a"
3
+ description: "Web Application Stack"
4
+ version: "1.0"
5
+ zone: "Sandbox-simulator"
6
+ group: "my_web_stack"
7
+ servers:
8
+ - name: "web-01, web-02"
9
+ description: "Web nodes"
10
+ template: "CentOS 5.3(64-bit) no GUI (Simulator)"
11
+ offering: "Small Instance"
12
+ networks: "test-network"
13
+ port_rules: ":80, :443"
14
+ - name: "db-01"
15
+ description: "PostgreSQL Master"
16
+ template: "CentOS 5.3(64-bit) no GUI (Simulator)"
17
+ offering: "Medium Instance"
18
+ ip_network_list:
19
+ - name: "test-network"
20
+ ip: 10.1.1.11
@@ -0,0 +1,12 @@
1
+ require "cloudstack-cli"
2
+
3
+ require "minitest/spec"
4
+ require "minitest/autorun"
5
+ require "minitest/pride"
6
+
7
+ # make the config file setup awailable to all specs
8
+ CONFIG = "--config-file=#{File.expand_path('cloudstack-cli.yml', File.dirname(__FILE__))}"
9
+ ZONE = "Sandbox-simulator"
10
+ TEMPLATE = "CentOS 5.3(64-bit) no GUI (Simulator)"
11
+ OFFERING_S = "Small Instance"
12
+ OFFERING_M = "Medium Instance"
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.5.10
4
+ version: 1.5.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nik Wolfgramm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-23 00:00:00.000000000 Z
11
+ date: 2016-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '11.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.9'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5.9'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: cloudstack_client
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +58,14 @@ dependencies:
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '0.19'
61
+ version: 0.19.4
48
62
  type: :runtime
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '0.19'
68
+ version: 0.19.4
55
69
  description: cloudstack-cli is a CloudStack API command line client written in Ruby.
56
70
  email:
57
71
  - nik.wolfgramm@gmail.com
@@ -69,6 +83,11 @@ files:
69
83
  - bin/cloudstack-cli
70
84
  - cloudstack-cli.gemspec
71
85
  - completions/cloudstack-cli.bash
86
+ - examples/ma-test.yml
87
+ - examples/stack-dev.yml
88
+ - examples/stack_example.json
89
+ - examples/stack_example.yml
90
+ - examples/stack_example_b.yml
72
91
  - lib/cloudstack-cli.rb
73
92
  - lib/cloudstack-cli/base.rb
74
93
  - lib/cloudstack-cli/cli.rb
@@ -87,6 +106,7 @@ files:
87
106
  - lib/cloudstack-cli/commands/job.rb
88
107
  - lib/cloudstack-cli/commands/load_balancer.rb
89
108
  - lib/cloudstack-cli/commands/network.rb
109
+ - lib/cloudstack-cli/commands/network_offer.rb
90
110
  - lib/cloudstack-cli/commands/physical_network.rb
91
111
  - lib/cloudstack-cli/commands/pod.rb
92
112
  - lib/cloudstack-cli/commands/port_rule.rb
@@ -108,10 +128,10 @@ files:
108
128
  - lib/cloudstack-cli/option_resolver.rb
109
129
  - lib/cloudstack-cli/thor_patch.rb
110
130
  - lib/cloudstack-cli/version.rb
111
- - test/ma-test.yml
112
- - test/stack_example.json
113
- - test/stack_example.yml
114
- - test/stack_example_b.yml
131
+ - spec/cloudstack-cli.yml
132
+ - spec/cloudstack-cli/commands/virtual_machine_spec.rb
133
+ - spec/fixtures/stack.yml
134
+ - spec/spec_helper.rb
115
135
  homepage: http://github.com/niwo/cloudstack-cli
116
136
  licenses:
117
137
  - MIT
@@ -139,7 +159,7 @@ signing_key:
139
159
  specification_version: 4
140
160
  summary: cloudstack-cli CloudStack API client
141
161
  test_files:
142
- - test/ma-test.yml
143
- - test/stack_example.json
144
- - test/stack_example.yml
145
- - test/stack_example_b.yml
162
+ - spec/cloudstack-cli.yml
163
+ - spec/cloudstack-cli/commands/virtual_machine_spec.rb
164
+ - spec/fixtures/stack.yml
165
+ - spec/spec_helper.rb