knife-cloudstack 0.0.20 → 0.1.0

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: 9af3a37c77c5ed5deb9fe7ce951f784456908e25
4
- data.tar.gz: 2b68228f3093d6a493c277b8ba0c6a4eaabfc34a
3
+ metadata.gz: 1db722fa5971a7e39f6743be0651b7cdc3e087d4
4
+ data.tar.gz: 6bccfd84eb27700912af450f6029b1054ace7ed7
5
5
  SHA512:
6
- metadata.gz: 0fd3eac9a3aee944795b56840d2e0b8f691e39e5ca53d278ccc447745c783e5e9204a32c7041920f74350508d71f0060690e0e5786f338722381d7647e8958ca
7
- data.tar.gz: 546db947faf84987fa13c4394034de56f5c12c2f682f49b9672de62a8005071ab4c7b22f04038e7254298ddb29b010f65aaa94cc2fc79694ef267c32cdda50dc
6
+ metadata.gz: 4c1fd8f65b7acd6d60803a54d943ed5102262276cb3a595d09eb4e7ec75a4e9736820e9a70ed13e63e457e930b31213577149a349e86cea7b41b5b11f677aba8
7
+ data.tar.gz: 6d789a5a526c02b3f56e554ad179cb927fe9a7a0a3df10e7f82549d5255d215b1a14f0634e472a42d7b88ca1493e9148767a023a9781920fb221a55c991ed827
@@ -1,4 +1,13 @@
1
1
  = Changes
2
+ == 2016-03-18 (0.1.0)
3
+ * Added subcommand: <tt>cs volume attach</tt> (David Bruce 3 Jul 2015)
4
+ * Added subcommand: <tt>cs volume detach</tt> (David Bruce 3 Jul 2015)
5
+ * Removed gem depedency (Fred Neubauer 18 Mar 2016)
6
+
7
+ == 2015-04-24 (0.0.20)
8
+ * Added support for expunge option for <tt>cs server destroy</tt> (Anton Opgenoort 24 Mar 2015)
9
+ * Added support for Chef 12 Client (Sander Botman 24 Apr 2015)
10
+
2
11
  == 2015-03-19 (0.0.19)
3
12
  * Added support for --boostrap-proxy for <tt>cs server create</tt> (Rutger Te Nijenhuis 19 Feb 2015)
4
13
  * Bugfix: no implicit conversion of String into Integer error, if no Nic present (Frank Louwers 19 Mar 2015)
@@ -92,6 +92,15 @@ class Chef
92
92
  config[key] || Chef::Config[:knife][key] || nil
93
93
  end
94
94
 
95
+ def exit_with_error(error)
96
+ ui.error error
97
+ exit 1
98
+ end
99
+
100
+ def valid_cs_name?(name)
101
+ !!(name && /^[a-zA-Z0-9][a-zA-Z0-9_\-#]*$/.match(name))
102
+ end
103
+
95
104
  end
96
105
  end
97
106
  end
@@ -50,7 +50,6 @@ module KnifeCloudstack
50
50
  require 'knife-cloudstack/connection'
51
51
  require 'winrm'
52
52
  require 'httpclient'
53
- require 'em-winrm'
54
53
  Chef::Knife::Bootstrap.load_deps
55
54
  end
56
55
 
@@ -0,0 +1,70 @@
1
+ #
2
+ # Author:: David Bruce <dbruce@schubergphilis.com>
3
+ # Copyright:: Copyright (c) Schuberg Philis 2013
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'chef/knife/cs_base'
20
+
21
+ module KnifeCloudstack
22
+ class CsVolumeAttach < Chef::Knife
23
+ include Chef::Knife::KnifeCloudstackBase
24
+
25
+ deps do
26
+ require 'knife-cloudstack/connection'
27
+ Chef::Knife.load_deps
28
+ end
29
+
30
+ banner 'knife cs volume attach NAME VM (options)'
31
+
32
+ option :volume,
33
+ :long => '--volume VOLUME_NAME',
34
+ :description => 'Specify volume name to attach'
35
+
36
+ option :vm,
37
+ :long => '--vm VM_NAME',
38
+ :description => 'Name of the VM to attach disk to'
39
+
40
+ def run
41
+ validate_base_options
42
+
43
+ volumename = locate_config_value(:volume) || @name_args[0]
44
+ exit_with_error 'Invalid volume name.' unless valid_cs_name? volumename
45
+
46
+ vmname = locate_config_value(:vm) || @name_args[1]
47
+ exit_with_error 'Invalid virtual machine.' unless valid_cs_name? vmname
48
+
49
+ volume = connection.get_volume(volumename)
50
+ exit_with_error "Volume #{volumename} not found." unless volume && volume['id']
51
+ exit_with_error "Volume #{volumename} is currently attached." if volume['vmname']
52
+
53
+ vm = connection.get_server(vmname)
54
+ exit_with_error "Virtual machine #{vmname} not found." unless vm && vm['id']
55
+
56
+ puts ui.color("Attaching volume #{volumename} to #{vmname}", :magenta)
57
+
58
+ params = {
59
+ 'command' => 'attachVolume',
60
+ 'id' => volume['id'],
61
+ 'virtualmachineid' => vm['id']
62
+ }
63
+
64
+ json = connection.send_async_request(params)
65
+ exit_with_error 'Unable to attach volume' unless json
66
+
67
+ puts "Volume #{volumename} is now attached to #{json['volume']['vmname']}"
68
+ end
69
+ end # class
70
+ end
@@ -0,0 +1,61 @@
1
+ #
2
+ # Author:: David Bruce <dbruce@schubergphilis.com>
3
+ # Copyright:: Copyright (c) Schuberg Philis 2013
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'chef/knife/cs_base'
20
+
21
+ module KnifeCloudstack
22
+ class CsVolumeDetach < Chef::Knife
23
+
24
+ include Chef::Knife::KnifeCloudstackBase
25
+
26
+ deps do
27
+ require 'knife-cloudstack/connection'
28
+ Chef::Knife.load_deps
29
+ end
30
+
31
+ banner 'knife cs volume detach NAME (options)'
32
+
33
+ option :name,
34
+ :long => '--name',
35
+ :description => 'Specify volume name to detach'
36
+
37
+ def run
38
+ validate_base_options
39
+
40
+ volumename = locate_config_value(:volume) || @name_args[0]
41
+ exit_with_error 'Invalid volumename.' unless valid_cs_name? volumename
42
+
43
+ volume = connection.get_volume(volumename)
44
+ exit_with_error "Volume #{volumename} not found." unless volume && volume['id']
45
+ exit_with_error "Volume #{volumename} is not attached." unless volume['vmname']
46
+
47
+ puts ui.color("Detaching volume: #{volumename}", :magenta)
48
+
49
+ params = {
50
+ 'command' => 'detachVolume',
51
+ 'id' => volume['id']
52
+ }
53
+
54
+ json = connection.send_async_request(params)
55
+ exit_with_error 'Unable to detach volume' unless json
56
+
57
+ puts "Volume #{volumename} is now detached."
58
+
59
+ end
60
+ end # class
61
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-cloudstack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.20
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Holmes
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-04-24 00:00:00.000000000 Z
15
+ date: 2016-03-18 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: chef
@@ -100,12 +100,14 @@ files:
100
100
  - lib/chef/knife/cs_template_list.rb
101
101
  - lib/chef/knife/cs_template_register.rb
102
102
  - lib/chef/knife/cs_user_list.rb
103
+ - lib/chef/knife/cs_volume_attach.rb
103
104
  - lib/chef/knife/cs_volume_create.rb
104
105
  - lib/chef/knife/cs_volume_delete.rb
106
+ - lib/chef/knife/cs_volume_detach.rb
105
107
  - lib/chef/knife/cs_volume_list.rb
106
108
  - lib/chef/knife/cs_zone_list.rb
107
109
  - lib/knife-cloudstack/connection.rb
108
- homepage: http://cloudstack.org/
110
+ homepage: https://github.com/CloudStack-extras/knife-cloudstack
109
111
  licenses: []
110
112
  metadata: {}
111
113
  post_install_message: