knife-oraclevm 0.0.1 → 0.0.3

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.
@@ -269,6 +269,32 @@ class Chef
269
269
  end
270
270
  return current
271
271
  end
272
+ #
273
+ # list_vm, display all vm's
274
+ #
275
+ def list_vm
276
+ current = {:errormsg => "", :status => "", :time => "", :vmstatus => ""}
277
+
278
+ conn_opts=get_cli_connection
279
+ Chef::Log.debug("#{conn_opts[:host]}...list vm")
280
+ Net::SSH.start( conn_opts[:host], conn_opts[:user], :password => conn_opts[:password], :port => conn_opts[:port] ) do|ssh|
281
+ output = ssh.exec!("list vm")
282
+ output.each_line do |line|
283
+ if line.match(/Status:/)
284
+ current[:status]=line.split[1].strip
285
+ elsif line.match(/Time:/)
286
+ line["Time: "]=""
287
+ current[:time]=line.strip
288
+ elsif line.match(/ id:/)
289
+ puts line.split(':')[2].strip
290
+ elsif line.match(/Error Msg:/)
291
+ line["Error Msg: "]=""
292
+ current[:errormsg]=line.strip
293
+ end
294
+ end
295
+ end
296
+ return current
297
+ end
272
298
 
273
299
  end
274
300
  end
@@ -0,0 +1,27 @@
1
+ #
2
+ # Author:: Geoff O'Callaghan (<geoffocallaghan@gmail.com>)
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+
6
+ require 'chef/knife'
7
+ require 'chef/knife/BaseOraclevmCommand'
8
+ require 'netaddr'
9
+ require 'net/ssh'
10
+
11
+ # Manage power state of a virtual machine
12
+ class Chef::Knife::OraclevmVmList < Chef::Knife::BaseOraclevmCommand
13
+
14
+ banner "knife oraclevm vm list (options)"
15
+
16
+ get_common_options
17
+
18
+ def run
19
+
20
+ $stdout.sync = true
21
+
22
+ vmname = @name_args[0]
23
+
24
+ list_vm
25
+
26
+ end
27
+ end
@@ -75,6 +75,21 @@ class Chef::Knife::OraclevmVmState < Chef::Knife::BaseOraclevmCommand
75
75
  else
76
76
  show_usage
77
77
  end
78
+ when 'Stopping'
79
+ case state
80
+ when 'on'
81
+ puts "Cannot power on virtual machine #{vmname} as it is Stopping"
82
+ when 'off'
83
+ puts "Cannot power off virtual machine #{vmname} as it is Stopping"
84
+ when 'suspend'
85
+ puts "Cannot Suspend virtual machine #{vmname} as it is Stopping"
86
+ when 'restart'
87
+ puts "Cannot Restrt virtual machine #{vmname} as it is Stopping"
88
+ when 'resume'
89
+ puts "Cannot Resume virtual machine #{vmname} as it is Stopping"
90
+ else
91
+ show_usage
92
+ end
78
93
  when 'Suspended'
79
94
  case state
80
95
  when 'on'
@@ -92,7 +107,7 @@ class Chef::Knife::OraclevmVmState < Chef::Knife::BaseOraclevmCommand
92
107
  show_usage
93
108
  end
94
109
  else
95
- puts "I don't know what a state of #{state} is on #{vmname}"
110
+ puts "I don't know what a state of #{current[:vmstatus]} is on #{vmname}"
96
111
  end
97
112
  end
98
113
  else
@@ -1,4 +1,4 @@
1
1
  module KnifeOracleVM
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.3"
3
3
  end
4
4
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-oraclevm
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Geoff O'Callaghan
@@ -62,6 +62,7 @@ files:
62
62
  - lib/knife-oraclevm/version.rb
63
63
  - lib/chef/knife/BaseOraclevmCommand.rb
64
64
  - lib/chef/knife/oraclevm_vm_state.rb
65
+ - lib/chef/knife/oraclevm_vm_list.rb
65
66
  has_rdoc: true
66
67
  homepage: http://github.com/gocallag/knife-oraclevm
67
68
  licenses: []