cloudstack-cli 0.7.4 → 0.8.0
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 +4 -4
- data/CHANGELOG.md +2 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +10 -3
- data/README.md +80 -43
- data/completions/cs.bash +38 -0
- data/lib/cloudstack-cli/base.rb +6 -0
- data/lib/cloudstack-cli/cli.rb +14 -0
- data/lib/cloudstack-cli/commands/environment.rb +19 -7
- data/lib/cloudstack-cli/version.rb +1 -1
- metadata +20 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f42a25136394a7e73e0d22f3a9a0bd83d60a73eb
|
4
|
+
data.tar.gz: 709963bf4063b0554ac1822c5825df8661e18c0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 057b1a7111b838b0a94b08230496a50d0485b5ae36b4ab7b9e024e6e980ac06f7d7e7624623160218043412c3980dba22a260d37460995b86beaea56f259f8f1
|
7
|
+
data.tar.gz: 26a448beb6dcaee8f7512a30f3bd47f71c0681d305db5ec3e09be6f53b43963d9a2ff90f181de88f1e0c233183426975f718a136b7b14e94402ee9db6c94c61a
|
data/CHANGELOG.md
ADDED
data/Gemfile
CHANGED
@@ -3,4 +3,5 @@ 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'
|
6
|
+
gem 'cloudstack_client', git: 'git@github.com:niwo/cloudstack_client.git', branch: 'master'
|
7
|
+
gem 'thor', git: 'git@github.com:erikhuda/thor.git', branch: 'master'
|
data/Gemfile.lock
CHANGED
@@ -1,6 +1,13 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git@github.com:erikhuda/thor.git
|
3
|
+
revision: 2c6e4fe957efa63cdd7edc61e3fd166d5e8409f2
|
4
|
+
branch: master
|
5
|
+
specs:
|
6
|
+
thor (0.18.1)
|
7
|
+
|
1
8
|
GIT
|
2
9
|
remote: git@github.com:niwo/cloudstack_client.git
|
3
|
-
revision:
|
10
|
+
revision: 5547d67014571b3818e0a695604207a10c7d6cf4
|
4
11
|
branch: master
|
5
12
|
specs:
|
6
13
|
cloudstack_client (0.4.4)
|
@@ -8,7 +15,7 @@ GIT
|
|
8
15
|
PATH
|
9
16
|
remote: .
|
10
17
|
specs:
|
11
|
-
cloudstack-cli (0.7.
|
18
|
+
cloudstack-cli (0.7.4)
|
12
19
|
cloudstack_client (~> 0.4, >= 0.4.4)
|
13
20
|
thor (~> 0.18)
|
14
21
|
|
@@ -19,7 +26,6 @@ GEM
|
|
19
26
|
rake (10.1.1)
|
20
27
|
rdoc (4.1.1)
|
21
28
|
json (~> 1.4)
|
22
|
-
thor (0.18.1)
|
23
29
|
|
24
30
|
PLATFORMS
|
25
31
|
ruby
|
@@ -29,3 +35,4 @@ DEPENDENCIES
|
|
29
35
|
cloudstack_client!
|
30
36
|
rake (~> 10.1)
|
31
37
|
rdoc (~> 4.1)
|
38
|
+
thor!
|
data/README.md
CHANGED
@@ -9,28 +9,49 @@ cloudstack-cli uses the [cloudstack_client](https://github.com/niwo/cloudstack_c
|
|
9
9
|
|
10
10
|
Install the cloudstack-cli gem:
|
11
11
|
|
12
|
-
|
12
|
+
```sh
|
13
|
+
$ gem install cloudstack-cli
|
14
|
+
```
|
13
15
|
|
14
16
|
## Setup
|
15
17
|
|
16
|
-
Create
|
18
|
+
### Create a cloudstack-cli environmet
|
17
19
|
|
18
|
-
|
20
|
+
Create your first environment, which defines your connection options:
|
21
|
+
|
22
|
+
```sh
|
23
|
+
$ cs environment add [environment-name]
|
24
|
+
```
|
19
25
|
|
20
26
|
cloudstack-cli expects to find a configuartion file with the API URL and your CloudStack credentials in your home directory named .cloudstack-cli.yml. If the file is located elsewhere you can specify the loaction using the --config option.
|
21
27
|
|
22
28
|
cloudstack-cli supports multiple environments using the --environment option.
|
23
29
|
|
30
|
+
see `cs help environment` for more options.
|
31
|
+
|
24
32
|
Example content of the configuration file:
|
25
33
|
|
26
|
-
|
27
|
-
|
28
|
-
|
34
|
+
```yaml
|
35
|
+
:url: "https://my-cloudstack-server/client/api/"
|
36
|
+
:api_key: "cloudstack-api-key"
|
37
|
+
:secret_key: "cloudstack-api-secret"
|
38
|
+
|
39
|
+
test:
|
40
|
+
:url: "http://my-cloudstack-testserver/client/api/"
|
41
|
+
:api_key: "cloudstack-api-key"
|
42
|
+
:secret_key: "cloudstack-api-secret"
|
43
|
+
```
|
44
|
+
|
45
|
+
### Shell tab auto-completion
|
46
|
+
|
47
|
+
To enable tab auto-completion for cloudstack-cli, add the following lines to your ~/.bash_profile file.
|
48
|
+
|
49
|
+
```sh
|
50
|
+
# Bash, ~/.bash_profile
|
51
|
+
eval "$(cs completion --shell=bash)"
|
52
|
+
```
|
29
53
|
|
30
|
-
|
31
|
-
:url: "http://my-cloudstack-testserver/client/api/"
|
32
|
-
:api_key: "cloudstack-api-key"
|
33
|
-
:secret_key: "cloudstack-api-secret"
|
54
|
+
__Note__: use `~/.bashrc` on Ubuntu
|
34
55
|
|
35
56
|
## Usage
|
36
57
|
|
@@ -38,75 +59,91 @@ For additional documentation find the RubyDoc [here](http://rubydoc.info/gems/cl
|
|
38
59
|
|
39
60
|
See the help screen:
|
40
61
|
|
41
|
-
|
62
|
+
```sh
|
63
|
+
$ cs
|
64
|
+
```
|
42
65
|
|
43
66
|
### Example: Bootsrapping a server
|
44
67
|
|
45
68
|
Bootsraps a server using a template and creating port-forwarding rules for port 22 and 80.
|
46
69
|
|
47
|
-
|
70
|
+
```sh
|
71
|
+
$ cs server create server-01 --template CentOS-6.4-x64-v1.4 --zone DC1 --offering 1cpu_1gb --port-rules :22 :80
|
72
|
+
```
|
48
73
|
|
49
74
|
### Example: Run a any custom API command
|
50
75
|
|
51
76
|
Run the "listAlerts" command against the Cloudstack API with an argument of type=8:
|
52
77
|
|
53
|
-
|
78
|
+
```sh
|
79
|
+
$ cs command listAlerts type=8
|
80
|
+
```
|
54
81
|
|
55
82
|
### Example: Creating a complete stack of servers
|
56
83
|
|
57
84
|
An example stackfile looks like this (my_stackfile.json)
|
58
85
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
86
|
+
```json
|
87
|
+
{
|
88
|
+
"name": "web_stack-a",
|
89
|
+
"description": "Web Application Stack",
|
90
|
+
"version": "1.0",
|
91
|
+
"zone": "DC-BIE-1",
|
92
|
+
"group": "my_web_stack",
|
93
|
+
"keypair": "mykeypair",
|
94
|
+
"servers": [
|
67
95
|
{
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
96
|
+
"name": "web-d1, web-d2",
|
97
|
+
"description": "Web nodes",
|
98
|
+
"template": "CentOS-6.4-x64-v1.2",
|
99
|
+
"offering": "1cpu_1gb",
|
100
|
+
"networks": "server_network",
|
101
|
+
"port_rules": ":80, :443"
|
74
102
|
},
|
75
103
|
{
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
104
|
+
"name": "db-01",
|
105
|
+
"description": "PostgreSQL Master",
|
106
|
+
"iso": "CentOS-6.4-x86_64-swisstxt-v15",
|
107
|
+
"disk_offering": "Perf Storage",
|
108
|
+
"disk_size": "5",
|
109
|
+
"offering": "2cpu_4gb",
|
110
|
+
"networks": [
|
111
|
+
"server_network",
|
112
|
+
"storage_network"
|
113
|
+
]
|
86
114
|
}
|
87
|
-
|
88
|
-
|
115
|
+
]
|
116
|
+
}
|
117
|
+
```
|
89
118
|
|
90
119
|
Create the stack of servers from above:
|
91
120
|
|
92
|
-
|
121
|
+
```sh
|
122
|
+
$ cs stack create my_stackfile.json
|
123
|
+
```
|
93
124
|
|
94
125
|
### Example: Sort computing offerings
|
95
126
|
|
96
127
|
Sort all computing offerings by CPU and Memory grouped my Domain:
|
97
128
|
|
98
|
-
|
129
|
+
```sh
|
130
|
+
$ cs offering sort
|
131
|
+
```
|
99
132
|
|
100
133
|
### Example: Stop all backup routers of a given project
|
101
134
|
|
102
135
|
Stop all virtual routers of project Demo (you could filter by zone too):
|
103
136
|
(This command is helpful if you have to deploy new versions of Cloudstack when using redundant routers)
|
104
137
|
|
105
|
-
|
138
|
+
```sh
|
139
|
+
$ cs router list --project Demo --status running --redundant-state BACKUP --command stop
|
140
|
+
````
|
106
141
|
|
107
142
|
Hint: You can watch the status of the command with watch.
|
108
143
|
|
109
|
-
|
144
|
+
```sh
|
145
|
+
$ watch -n cs router list --project Demo
|
146
|
+
```
|
110
147
|
|
111
148
|
|
112
149
|
## References
|
data/completions/cs.bash
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# cloudstack-cli
|
4
|
+
# https://github.com/niwo/cloudstack-cli
|
5
|
+
#
|
6
|
+
# Copyright (c) 2014 Nik Wolfgramm
|
7
|
+
# Licensed under the MIT license.
|
8
|
+
# https://raw.github.com/niwo/cloudstack-cli/master/LICENSE.txt
|
9
|
+
|
10
|
+
# Usage:
|
11
|
+
#
|
12
|
+
# To enable bash <tab> completion for cloudstack-cli, add the following line (minus the
|
13
|
+
# leading #, which is the bash comment character) to your ~/.bash_profile file (use ~/.bashrc on Ubuntu):
|
14
|
+
#
|
15
|
+
# eval "$(cs completion --shell=bash)"
|
16
|
+
|
17
|
+
_cs() {
|
18
|
+
COMPREPLY=()
|
19
|
+
local word="${COMP_WORDS[COMP_CWORD]}"
|
20
|
+
if [ "$COMP_CWORD" -eq 1 ]; then
|
21
|
+
COMPREPLY=( $(compgen -W "$(cs help | grep cs | cut -d ' ' -f4)" -- "$word") )
|
22
|
+
else
|
23
|
+
local words=("${COMP_WORDS[@]}")
|
24
|
+
if [ $(echo ${words[@]} | wc -w) -eq 2 ]; then
|
25
|
+
COMPREPLY=( $(compgen -W "$(${words[@]} help | grep cs | cut -d ' ' -f5)" -- "$word") )
|
26
|
+
fi
|
27
|
+
if [ $(echo ${words[@]} | wc -w) -ge 3 ]; then
|
28
|
+
local cp1=$(echo ${words[@]} | cut -d ' ' -f1-2)
|
29
|
+
local cp2=$(echo ${words[@]} | cut -d ' ' -f3)
|
30
|
+
if [ "$cp2" != "help" ]; then
|
31
|
+
local cp3=$($cp1 help $cp2)
|
32
|
+
COMPREPLY=( $(compgen -W "$(echo $cp3 | awk 'NR>1{print $1}' RS=[ FS='\=')" -- "$word") )
|
33
|
+
fi
|
34
|
+
fi
|
35
|
+
fi
|
36
|
+
}
|
37
|
+
|
38
|
+
complete -F _cs cs
|
data/lib/cloudstack-cli/base.rb
CHANGED
@@ -51,6 +51,12 @@ module CloudstackCli
|
|
51
51
|
exit 1
|
52
52
|
end
|
53
53
|
end
|
54
|
+
|
55
|
+
unless config.key?(:url) && config.key?(:api_key) && config.key?(:secret_key)
|
56
|
+
say "The environment #{env || '\'-\''} contains no valid data.", :red
|
57
|
+
say "Please check with 'cs environment list' and set a valid default environment."
|
58
|
+
exit 1
|
59
|
+
end
|
54
60
|
config
|
55
61
|
end
|
56
62
|
|
data/lib/cloudstack-cli/cli.rb
CHANGED
@@ -29,6 +29,20 @@ module CloudstackCli
|
|
29
29
|
:config_file => options[:config_file]
|
30
30
|
end
|
31
31
|
|
32
|
+
desc "completion", "loads the shell scripts for tab auto-completion"
|
33
|
+
option :shell, default: 'bash'
|
34
|
+
def completion
|
35
|
+
shell_script = File.join(
|
36
|
+
File.dirname(__FILE__), '..', '..',
|
37
|
+
'completions', "cs.#{options[:shell]}"
|
38
|
+
)
|
39
|
+
unless File.file? shell_script
|
40
|
+
say "Specified cloudstack-cli shell auto-completion rules for #{options[:shell]} not found.", :red
|
41
|
+
exit 1
|
42
|
+
end
|
43
|
+
puts File.read shell_script
|
44
|
+
end
|
45
|
+
|
32
46
|
desc "command COMMAND [arg1=val1 arg2=val2...]", "run a custom api command"
|
33
47
|
def command(command, *args)
|
34
48
|
params = {'command' => command}
|
@@ -4,7 +4,7 @@ class Environment < CloudstackCli::Base
|
|
4
4
|
def list
|
5
5
|
config = parse_config_file
|
6
6
|
table = [%w(Name URL Default)]
|
7
|
-
table << ['-', config[:url], !config[:default]]
|
7
|
+
table << ['-', config[:url], !config[:default]] if config.key?(:url)
|
8
8
|
config.each_key do |key|
|
9
9
|
unless key.class == Symbol
|
10
10
|
table << [key, config[key][:url], key == config[:default]]
|
@@ -64,14 +64,26 @@ class Environment < CloudstackCli::Base
|
|
64
64
|
desc "delete", "delete a Cloudstack connection"
|
65
65
|
def delete(env)
|
66
66
|
config = parse_config_file
|
67
|
-
if
|
68
|
-
|
69
|
-
config.delete
|
70
|
-
|
71
|
-
|
67
|
+
if env == '-'
|
68
|
+
config.delete(:url)
|
69
|
+
config.delete(:api_key)
|
70
|
+
config.delete(:secret_key)
|
71
|
+
# check if the config file is empty, delete it if true
|
72
|
+
if config.keys.select { |key| !key.is_a? Symbol}.size == 0
|
73
|
+
exit unless yes?("Do you really want to delete environment #{env}? [y/N]", :yellow)
|
74
|
+
File.delete(options[:config_file])
|
75
|
+
say "OK.", :green
|
76
|
+
exit
|
77
|
+
end
|
78
|
+
elsif config.delete(env)
|
72
79
|
else
|
73
80
|
say "Environment #{env} does not exist.", :red
|
81
|
+
exit 1
|
74
82
|
end
|
83
|
+
exit unless yes?("Do you really want to delete environment #{env}? [y/N]", :yellow)
|
84
|
+
config.delete :default if config[:default] == env
|
85
|
+
write_config_file(config)
|
86
|
+
say "OK.", :green
|
75
87
|
end
|
76
88
|
|
77
89
|
desc "default [ENV]", "show or set the default environment"
|
@@ -84,7 +96,7 @@ class Environment < CloudstackCli::Base
|
|
84
96
|
exit 0
|
85
97
|
end
|
86
98
|
|
87
|
-
if env == '-'
|
99
|
+
if env == '-' && config.key?(:url)
|
88
100
|
config.delete :default
|
89
101
|
else
|
90
102
|
unless config.has_key?(env)
|
metadata
CHANGED
@@ -1,75 +1,75 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudstack-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
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-02-
|
11
|
+
date: 2014-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdoc
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4.1'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.1'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: thor
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0.18'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.18'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: cloudstack_client
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0.4'
|
62
|
-
- -
|
62
|
+
- - ">="
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: 0.4.4
|
65
65
|
type: :runtime
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
|
-
- - ~>
|
69
|
+
- - "~>"
|
70
70
|
- !ruby/object:Gem::Version
|
71
71
|
version: '0.4'
|
72
|
-
- -
|
72
|
+
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: 0.4.4
|
75
75
|
description: cloudstack-cli is a CloudStack API command line client written in Ruby.
|
@@ -80,13 +80,15 @@ executables:
|
|
80
80
|
extensions: []
|
81
81
|
extra_rdoc_files: []
|
82
82
|
files:
|
83
|
-
- .gitignore
|
83
|
+
- ".gitignore"
|
84
|
+
- CHANGELOG.md
|
84
85
|
- Gemfile
|
85
86
|
- Gemfile.lock
|
86
87
|
- LICENSE.txt
|
87
88
|
- README.md
|
88
89
|
- bin/cs
|
89
90
|
- cloudstack-cli.gemspec
|
91
|
+
- completions/cs.bash
|
90
92
|
- lib/cloudstack-cli.rb
|
91
93
|
- lib/cloudstack-cli/base.rb
|
92
94
|
- lib/cloudstack-cli/cli.rb
|
@@ -128,23 +130,23 @@ licenses:
|
|
128
130
|
metadata: {}
|
129
131
|
post_install_message:
|
130
132
|
rdoc_options:
|
131
|
-
- --line-numbers
|
132
|
-
- --inline-source
|
133
|
+
- "--line-numbers"
|
134
|
+
- "--inline-source"
|
133
135
|
require_paths:
|
134
136
|
- lib
|
135
137
|
required_ruby_version: !ruby/object:Gem::Requirement
|
136
138
|
requirements:
|
137
|
-
- -
|
139
|
+
- - ">="
|
138
140
|
- !ruby/object:Gem::Version
|
139
141
|
version: 1.9.3
|
140
142
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
143
|
requirements:
|
142
|
-
- -
|
144
|
+
- - ">="
|
143
145
|
- !ruby/object:Gem::Version
|
144
146
|
version: '0'
|
145
147
|
requirements: []
|
146
148
|
rubyforge_project:
|
147
|
-
rubygems_version: 2.0
|
149
|
+
rubygems_version: 2.2.0
|
148
150
|
signing_key:
|
149
151
|
specification_version: 4
|
150
152
|
summary: cloudstack-cli CloudStack API client
|