knife-xapi 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -479,6 +479,11 @@ class Chef::Knife
479
479
  ui.msg ""
480
480
  end
481
481
 
482
+ def print_record(record)
483
+ puts ""
484
+ PP.pp record
485
+ end
486
+
482
487
  # return true (yes) false (no)
483
488
  # to the asked question
484
489
  def yes_no?(msg)
@@ -0,0 +1,44 @@
1
+ #
2
+ # Author:: Jesse Nelson (<spheromak@gmail.com>)
3
+ #
4
+ # Copyright:: Copyright (c) 2012 Jesse Nelson
5
+ #
6
+ # License:: Apache License, Version 2.0
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+
21
+
22
+ require 'chef/knife/xapi_base'
23
+ require 'pry'
24
+ class Chef
25
+ class Knife
26
+ class XapiNetList < Knife
27
+ include Chef::Knife::XapiBase
28
+
29
+ banner "knife xapi net list"
30
+
31
+ def run
32
+ xapi.network.get_all_records.each do |k, net|
33
+ color_kv "Name: ", net['name_label']
34
+ color_kv " Info: ", net['name_description'], [:magenta, :cyan] unless net['name_description'].empty?
35
+ color_kv " MTU: ", net['MTU'], [:magenta, :cyan]
36
+ color_kv " UUID: ", net['uuid'], [:magenta, :cyan]
37
+ ui.msg ""
38
+ end
39
+ end
40
+
41
+ end
42
+ end
43
+ end
44
+
@@ -0,0 +1,67 @@
1
+ #
2
+ # Author:: Jesse Nelson (<spheromak@gmail.com>)
3
+ #
4
+ # Copyright:: Copyright (c) 2012 Jesse Nelson
5
+ #
6
+ # License:: Apache License, Version 2.0
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+
21
+
22
+ require 'chef/knife/xapi_base'
23
+
24
+ class Chef
25
+ class Knife
26
+ class XapiVifList < Knife
27
+ include Chef::Knife::XapiBase
28
+
29
+ banner "knife xapi vif list"
30
+
31
+ option :vif_name,
32
+ :short => "-N",
33
+ :long => "--vif-name",
34
+ :default => false,
35
+ :description => "Indicates this is a vif name not a guest name"
36
+
37
+ def run
38
+ # Get all vifs known to the system
39
+ name = @name_args[0]
40
+
41
+ # if we were passed a guest name find its vdi's
42
+ # otherwise do it for everything
43
+ vifs = Array.new
44
+ if name.nil? or name.empty?
45
+ vifs = xapi.VIF.getAllRecords
46
+
47
+ elsif config[:vif_name]
48
+ vdis = xapi.VIF.get_by_name_label( name )
49
+
50
+ else
51
+ ref = xapi.VM.get_by_name_label( name )
52
+ vm = xapi.VM.get_record( ref.first )
53
+
54
+ vm["VIFs"].each do |vif|
55
+ vdis << xapi.VIF.get_record( vif )["VIF"]
56
+ end
57
+ end
58
+
59
+ vifs.each do |vif|
60
+ print_vif_info vif
61
+ end
62
+
63
+ end
64
+ end
65
+ end
66
+ end
67
+
@@ -0,0 +1,40 @@
1
+ #
2
+ # Author:: Jesse Nelson (<spheromak@gmail.com>)
3
+ #
4
+ # Copyright:: Copyright (c) 2012 Jesse Nelson
5
+ #
6
+ # License:: Apache License, Version 2.0
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+
21
+
22
+ require 'chef/knife/xapi_base'
23
+ require 'pry'
24
+ class Chef
25
+ class Knife
26
+ class XapiVlanList < Knife
27
+ include Chef::Knife::XapiBase
28
+
29
+ banner "knife xapi vlan list"
30
+
31
+ def run
32
+ xapi.VLAN.get_all_records.map { |k,v| v["tag"].to_i }.uniq.sort.each do |vlan|
33
+ color_kv "Tag: ", vlan.to_s
34
+ end
35
+ end
36
+
37
+ end
38
+ end
39
+ end
40
+
@@ -1,3 +1,3 @@
1
1
  module KnifeXenserver
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-xapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,56 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-01 00:00:00.000000000 Z
12
+ date: 2013-05-23 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: chef
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: highline
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: units
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
14
62
  - !ruby/object:Gem::Dependency
15
63
  name: chef
16
64
  requirement: !ruby/object:Gem::Requirement
@@ -73,11 +121,14 @@ files:
73
121
  - lib/chef/knife/xapi_guest_list.rb
74
122
  - lib/chef/knife/xapi_guest_start.rb
75
123
  - lib/chef/knife/xapi_guest_stop.rb
124
+ - lib/chef/knife/xapi_network_list.rb
76
125
  - lib/chef/knife/xapi_vdi_attach.rb
77
126
  - lib/chef/knife/xapi_vdi_create.rb
78
127
  - lib/chef/knife/xapi_vdi_delete.rb
79
128
  - lib/chef/knife/xapi_vdi_detach.rb
80
129
  - lib/chef/knife/xapi_vdi_list.rb
130
+ - lib/chef/knife/xapi_vif_list.rb
131
+ - lib/chef/knife/xapi_vlan_list.rb
81
132
  - lib/chef/knife/xapi_vmselect.rb
82
133
  - lib/knife-xapi/version.rb
83
134
  - lib/xenapi/README