nova-dsl 0.1.1
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.
- data/Gemfile +13 -0
- data/README +0 -0
- data/Rakefile +23 -0
- data/bin/nova-dsl +6 -0
- data/example.sh +10 -0
- data/examples/nova_list.rb +6 -0
- data/examples/open4_ex.rb +18 -0
- data/examples/simple_provision.rb +10 -0
- data/lib/common/attribute_checker.rb +10 -0
- data/lib/common/attribute_resolver.rb +22 -0
- data/lib/common/helpers.rb +63 -0
- data/lib/common/log.rb +100 -0
- data/lib/nova/commands/nova_list.rb +28 -0
- data/lib/nova/commands/nova_provision.rb +54 -0
- data/lib/nova/utils/nova_error.rb +9 -0
- data/lib/nova/utils/nova_vm.rb +91 -0
- data/lib/nova/wrapper/nova_console_wrapper.rb +66 -0
- data/lib/nova/wrapper/nova_stdout_parser.rb +59 -0
- data/lib/nova-dsl.rb +7 -0
- data/lib/version.rb +3 -0
- data/nova-dsl.gemspec +24 -0
- data/spec/nova_wrapper_spec.rb +46 -0
- metadata +70 -0
data/Gemfile
ADDED
data/README
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
$:.push '.', '..', './lib', File.expand_path(File.dirname(__FILE__))
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
|
5
|
+
|
6
|
+
task :default => :test
|
7
|
+
|
8
|
+
task :test => [:rspec_report, :rspec]
|
9
|
+
|
10
|
+
require 'rspec'
|
11
|
+
require 'rspec/core/rake_task'
|
12
|
+
desc "Run rspec unit tests "
|
13
|
+
RSpec::Core::RakeTask.new(:rspec) do |t|
|
14
|
+
t.rspec_opts = ["-c", "-f progress"]
|
15
|
+
t.pattern ='**/spec/**/*_spec.rb'
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Reporting rspec results to reports/rspec_report.html"
|
19
|
+
RSpec::Core::RakeTask.new(:rspec_report) do |t|
|
20
|
+
t.rspec_opts = ["-c", "-f html", "--out reports/rspec_report.html"]
|
21
|
+
t.pattern ='**/spec/**/*_spec.rb'
|
22
|
+
end
|
23
|
+
|
data/bin/nova-dsl
ADDED
data/example.sh
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
$:.push '.'
|
2
|
+
require "common/log"
|
3
|
+
|
4
|
+
require "open4"
|
5
|
+
|
6
|
+
result_stdout = nil
|
7
|
+
result_stderr = nil
|
8
|
+
|
9
|
+
status = Open4::popen4("env /usr/local/bin/nova list1 ") do |pid, stdin, stdout, stderr|
|
10
|
+
result_stdout = stdout.read.strip
|
11
|
+
result_stderr = stderr.read.strip
|
12
|
+
end
|
13
|
+
|
14
|
+
puts "status: #{status.inspect}"
|
15
|
+
puts "exitstatus : #{status.exitstatus}"
|
16
|
+
|
17
|
+
puts "stdout: #{result_stdout}" if status.success?
|
18
|
+
puts "stdout err: #{result_stderr}" unless status.success?
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'common/log'
|
2
|
+
|
3
|
+
|
4
|
+
#Habdles unknown method calls with arguments as variable sets
|
5
|
+
|
6
|
+
module Common
|
7
|
+
module DefaultAttributeResolver
|
8
|
+
|
9
|
+
def method_missing (name, *args, &script)
|
10
|
+
if args[0].nil?
|
11
|
+
LOGGER.warn("Attribute '#{name}' is missing, no parameters specified when calling '#{name}'
|
12
|
+
at #{self.class} instance, I'm gonna return 'nil'")
|
13
|
+
nil
|
14
|
+
else
|
15
|
+
LOGGER.debug("Method '#{name}' missing, set new @#{name}: @#{name}=#{args[0]}")
|
16
|
+
instance_variable_set("@#{name}".to_sym, args[0])
|
17
|
+
self.class.send(:define_method, name, proc { instance_variable_get("@#{name}") })
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
$:.push '.', '..', '../..'
|
2
|
+
require 'common/log'
|
3
|
+
require 'open4'
|
4
|
+
|
5
|
+
|
6
|
+
module Common
|
7
|
+
|
8
|
+
# Wraps out the system calls, accepted only 0 results, otherwise NovaCallError raised
|
9
|
+
# @param block [Proc] system call 'system' or whateveg
|
10
|
+
# @return [Object] console output of the call within block
|
11
|
+
def self.system_call(args ={}, &block)
|
12
|
+
|
13
|
+
type_checker args[:source], String
|
14
|
+
src = "source #{args[:source]} && " unless args[:source].nil?
|
15
|
+
src ||= ''
|
16
|
+
|
17
|
+
result = []
|
18
|
+
ok_count = 0
|
19
|
+
fail_count = 0
|
20
|
+
|
21
|
+
if block.nil?
|
22
|
+
LOGGER.error("'system_call_checker' has received empty block, raising Runtime EX ")
|
23
|
+
raise "Empty block has been given to 'system_call_checker'"
|
24
|
+
end
|
25
|
+
|
26
|
+
block_commands = yield
|
27
|
+
block_commands = block_commands.split("\n").map { |x| x.strip }
|
28
|
+
|
29
|
+
result_stdout = nil
|
30
|
+
result_stderr = nil
|
31
|
+
proc_pid = nil
|
32
|
+
block_commands.each do |cmd|
|
33
|
+
composite = src + cmd
|
34
|
+
status = Open4::popen4(composite) do |pid, stdin, stdout, stderr|
|
35
|
+
LOGGER.debug("Command '#{composite}' is running as pid: #{pid} ")
|
36
|
+
proc_pid = pid
|
37
|
+
result_stdout = stdout.read.strip
|
38
|
+
result_stderr = stderr.read.strip
|
39
|
+
end
|
40
|
+
|
41
|
+
LOGGER.debug("Process #{proc_pid} finished, code: #{status.exitstatus}")
|
42
|
+
if status.success?; ok_count+=1 else fail_count+=1 end
|
43
|
+
LOGGER.error("#{result_stderr}") unless status.success?
|
44
|
+
|
45
|
+
|
46
|
+
cmd_result = {}
|
47
|
+
cmd_result[:status] = status.exitstatus
|
48
|
+
cmd_result[:out] = status.success? ? result_stdout : result_stderr
|
49
|
+
|
50
|
+
result << cmd_result
|
51
|
+
end
|
52
|
+
LOGGER.debug("#{result.size} commands executed, ok: #{ok_count}, failed: #{fail_count}")
|
53
|
+
|
54
|
+
result
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.type_checker(value, clazz)
|
58
|
+
return value if value.nil?
|
59
|
+
raise TypeError.new("Waiting #{clazz} class but received #{value.class} ") unless value.is_a?(clazz)
|
60
|
+
value
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
data/lib/common/log.rb
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
require "logger"
|
2
|
+
require "singleton"
|
3
|
+
|
4
|
+
module Common
|
5
|
+
|
6
|
+
#Logger singleton wrapper for the project
|
7
|
+
class Log
|
8
|
+
|
9
|
+
include Singleton
|
10
|
+
|
11
|
+
@@default_cfg = {
|
12
|
+
:level => Logger::DEBUG,
|
13
|
+
:device => STDOUT,
|
14
|
+
:formatter => "%Y-%m-%dT%H:%M:%S "
|
15
|
+
}
|
16
|
+
|
17
|
+
@@cfg = {}
|
18
|
+
|
19
|
+
@@configured = false
|
20
|
+
|
21
|
+
class << self
|
22
|
+
|
23
|
+
def configure(log_cfg = {})
|
24
|
+
@@cfg = @@default_cfg.merge(log_cfg)
|
25
|
+
@@configured = true
|
26
|
+
end
|
27
|
+
|
28
|
+
def new
|
29
|
+
super
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
def initialize
|
35
|
+
reinitialize @@default_cfg.merge(@@cfg)
|
36
|
+
end
|
37
|
+
|
38
|
+
def logger
|
39
|
+
@logger
|
40
|
+
end
|
41
|
+
|
42
|
+
def debug(message=nil, *opts, &block)
|
43
|
+
add(Logger::DEBUG, message, nil, opts, &block)
|
44
|
+
end
|
45
|
+
|
46
|
+
def info(message=nil, *opts, &block)
|
47
|
+
add(Logger::INFO, message, nil, opts, &block)
|
48
|
+
end
|
49
|
+
|
50
|
+
def warn(message=nil, *opts, &block)
|
51
|
+
add(Logger::WARN, message, nil, opts, &block)
|
52
|
+
end
|
53
|
+
|
54
|
+
def error(message=nil, *opts, &block)
|
55
|
+
add(Logger::ERROR, message, nil, opts, &block)
|
56
|
+
end
|
57
|
+
|
58
|
+
def fatal(message=nil, *opts, &block)
|
59
|
+
add(Logger::FATAL, message, nil, opts, &block)
|
60
|
+
end
|
61
|
+
|
62
|
+
def unknown(message=nil, *opts, &block)
|
63
|
+
add(Logger::UNKNOWN, message, nil, opts, &block)
|
64
|
+
end
|
65
|
+
|
66
|
+
def add(severity, message, progname, opts = {}, &block)
|
67
|
+
message ||= ''
|
68
|
+
raise "You can only pass String or Exception classes as a logger message, you have pass #{message.class}" unless (message.is_a?(String)) || (message.is_a?(Exception))
|
69
|
+
progname||=""
|
70
|
+
progname[0,0] = ("[%s] " % caller[1]) if opts.include? :line
|
71
|
+
use_trace = opts.include? :trace
|
72
|
+
if (message.is_a?(Exception))
|
73
|
+
message = "Exception: #{message.class}: #{message.message}"
|
74
|
+
message += ", trace: #{message.backtrace}" if use_trace
|
75
|
+
end
|
76
|
+
if !message.nil? and block_given?
|
77
|
+
message<<" "<< (yield).to_s
|
78
|
+
end
|
79
|
+
@logger.add(severity, message, progname)
|
80
|
+
end
|
81
|
+
|
82
|
+
def debug?; @logger.debug? end
|
83
|
+
def info?; @logger.info? end
|
84
|
+
def level=(val);@logger.level= val end
|
85
|
+
|
86
|
+
def reinitialize(cfg)
|
87
|
+
@logger = Logger.new(cfg[:device])
|
88
|
+
@logger.level= cfg[:level]
|
89
|
+
@logger.datetime_format= cfg[:formatter]
|
90
|
+
end
|
91
|
+
|
92
|
+
def configure(log_cfg = {})
|
93
|
+
@@cfg = @@default_cfg.merge(log_cfg)
|
94
|
+
@@configured = true
|
95
|
+
reinitialize @@cfg
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
LOGGER = Common::Log.instance
|
@@ -0,0 +1,28 @@
|
|
1
|
+
$:.push '.'
|
2
|
+
require 'common/log'
|
3
|
+
require 'nova/utils/nova_error'
|
4
|
+
require 'common/attribute_resolver'
|
5
|
+
require 'nova/wrapper/nova_console_wrapper'
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def nova_list(&script)
|
9
|
+
NovaDsl::NovaList.new(&script).run
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module NovaDsl
|
14
|
+
class NovaList
|
15
|
+
|
16
|
+
include NovaDsl::NovaConsoleWrapper
|
17
|
+
|
18
|
+
def initialize(&script)
|
19
|
+
LOGGER.debug ("Initiating new nova list")
|
20
|
+
end
|
21
|
+
|
22
|
+
def run
|
23
|
+
container = nova_list
|
24
|
+
LOGGER.debug("Returning container size: #{container.size}")
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
$:.push '.'
|
2
|
+
require 'common/log'
|
3
|
+
require 'nova/utils/nova_error'
|
4
|
+
require 'common/attribute_resolver'
|
5
|
+
require 'nova/wrapper/nova_console_wrapper'
|
6
|
+
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def provision(name, &script)
|
10
|
+
NovaDsl::Provision.new(name, &script).run
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module NovaDsl
|
15
|
+
|
16
|
+
class Provision
|
17
|
+
|
18
|
+
include Common::DefaultAttributeResolver, NovaDsl::NovaConsoleWrapper
|
19
|
+
|
20
|
+
attr_accessor :name
|
21
|
+
|
22
|
+
def initialize(name, &script)
|
23
|
+
LOGGER.info("New vm provision, name '#{name}'")
|
24
|
+
raise DslMissParameter.new("Missing vm name argument while processing provisioning ") if name.nil?
|
25
|
+
raise DslMissBody.new("Missing body do...end while processing provisioning") unless block_given?
|
26
|
+
@name = name
|
27
|
+
instance_eval &script
|
28
|
+
self
|
29
|
+
end
|
30
|
+
|
31
|
+
def run
|
32
|
+
nova_provision(provision_manifest)
|
33
|
+
end
|
34
|
+
|
35
|
+
def provision_manifest
|
36
|
+
LOGGER.debug("Checking provision manifest")
|
37
|
+
vars = self.instance_variables
|
38
|
+
raise DslMissParameter.new("Missing missing parameter 'name'") unless vars.include?(:@name)
|
39
|
+
raise DslMissParameter.new("Missing missing parameter 'image'") unless vars.include?(:@image)
|
40
|
+
raise DslMissParameter.new("Missing missing parameter 'flavor'") unless vars.include?(:@flavor)
|
41
|
+
raise DslMissParameter.new("Missing missing parameter 'key_name'") unless vars.include?(:@key)
|
42
|
+
|
43
|
+
res = {:name => @name, :image => @image, :flavor => @flavor, :key => @key}
|
44
|
+
res.merge!(:source => @profile) unless @profile.nil?
|
45
|
+
LOGGER.debug("Configuring provision configuration: #{res}")
|
46
|
+
res
|
47
|
+
end
|
48
|
+
|
49
|
+
def to_s
|
50
|
+
"Provision new vm: #{name}, flavor: #{@flavor}, image #{@image} "
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
$:.push '.'
|
2
|
+
require 'common/log'
|
3
|
+
require 'common/helpers'
|
4
|
+
|
5
|
+
module NovaDsl
|
6
|
+
|
7
|
+
#Class NovaVm represents Nova Virtual Machine information
|
8
|
+
class NovaVm
|
9
|
+
ACTIVE = 'ACTIVE'
|
10
|
+
QUEUED = 'QUEUED'
|
11
|
+
|
12
|
+
attr_accessor :id, :name, :status, :ip
|
13
|
+
|
14
|
+
def initialize(id, name, ip = nil, status = nil)
|
15
|
+
LOGGER.debug("New NovaVm cerated: id: #{id}, name: #{name}, ip:#{ip}, status: #{status}")
|
16
|
+
@id = id
|
17
|
+
@name = name
|
18
|
+
@ip = ip
|
19
|
+
@status = status
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.fabric(configs = { })
|
23
|
+
LOGGER.debug("Fabric new NovaVm class with properties #{configs.inspect}")
|
24
|
+
Common::type_checker configs, Hash
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
class NovaVmsContainer
|
31
|
+
|
32
|
+
attr_accessor :vms
|
33
|
+
|
34
|
+
def initialize(vms_array = [])
|
35
|
+
Common::type_checker vms_array, Array
|
36
|
+
vms_array.each { |v| Common::type_checker v, NovaDsl::NovaVm }
|
37
|
+
@vms = vms_array
|
38
|
+
end
|
39
|
+
|
40
|
+
def [](index)
|
41
|
+
raise IndexError("Index #{index} is too large ") unless index < @vms.size
|
42
|
+
@vms[index]
|
43
|
+
end
|
44
|
+
|
45
|
+
def <<(vm)
|
46
|
+
if vm.is_a? NovaDsl::NovaVm;
|
47
|
+
@vms << vm
|
48
|
+
end
|
49
|
+
if vm.is_a? Array;
|
50
|
+
@vms += vm
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def merge!(container)
|
55
|
+
Common::type_checker container, NovaVmsContainer
|
56
|
+
@vms |= container.vms
|
57
|
+
self
|
58
|
+
end
|
59
|
+
|
60
|
+
def merge(container)
|
61
|
+
Common::type_checker container, NovaVmsContainer
|
62
|
+
NovaVmsContainer.new( @vms|container.vms )
|
63
|
+
end
|
64
|
+
|
65
|
+
def size
|
66
|
+
@vms.size
|
67
|
+
end
|
68
|
+
|
69
|
+
def find_by_id(id)
|
70
|
+
Common::type_checker id, Fixnum
|
71
|
+
@vms.select { |v| v.id.eql?(id) }
|
72
|
+
end
|
73
|
+
|
74
|
+
def find_by_ip(ip)
|
75
|
+
Common::type_checker ip, Fixnum
|
76
|
+
@vms.select { |v| v.ip.eql?(ip) }
|
77
|
+
end
|
78
|
+
|
79
|
+
def find_by_name(name)
|
80
|
+
Common::type_checker name, String
|
81
|
+
@vms.select { |v| v.name.eql?(name) }
|
82
|
+
end
|
83
|
+
|
84
|
+
def find_by_status(status)
|
85
|
+
Common::type_checker status, String
|
86
|
+
@vms.select { |v| v.status.eql?(status) }
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
$:.push '.'
|
2
|
+
require 'common/log'
|
3
|
+
require 'common/helpers'
|
4
|
+
require 'nova/utils/nova_error'
|
5
|
+
require 'nova/wrapper/nova_stdout_parser'
|
6
|
+
require 'nova/utils/nova_vm'
|
7
|
+
|
8
|
+
module NovaDsl
|
9
|
+
|
10
|
+
module NovaConsoleWrapper
|
11
|
+
|
12
|
+
include NovaDsl::NovaStdoutParser
|
13
|
+
|
14
|
+
def nova_provision(configs = {})
|
15
|
+
LOGGER.debug("Call 'nova boot' with parameters :#{configs.inspect}")
|
16
|
+
raise NovaDsl::DslMissParameter.new("Missing 'name' attribute when calling provision at wrapper") if configs[:name].nil?
|
17
|
+
Common::
|
18
|
+
raise NovaDsl::DslMissParameter.new("Missing 'image' attribute when calling provision at wrapper") if configs[:image].nil?
|
19
|
+
raise NovaDsl::DslMissParameter.new("Missing 'flavor' attribute when
|
20
|
+
calling provision at wrapper") if configs[:flavor].nil?
|
21
|
+
raise NovaDsl::DslMissParameter.new("Missing 'key' attribute when calling provision at wrapper") if configs[:key].nil?
|
22
|
+
|
23
|
+
configs[:security_groups] ||= %w(default)
|
24
|
+
|
25
|
+
configs[:source] ||= ''
|
26
|
+
|
27
|
+
Common::system_call(:source => configs[:source]){
|
28
|
+
"/usr/local/bin/nova boot --image #{configs[:image]} --flavor #{configs[:flavor]} --key_name #{configs[:key]} --security_groups #{configs[:security_groups]*','} #{configs[:name]}"
|
29
|
+
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
def nova_list
|
34
|
+
LOGGER.debug("Call 'nova list' ")
|
35
|
+
results = Common::system_call(:source => '~/scripts/x25novaDEV.sh') {
|
36
|
+
"/usr/local/bin/nova list"
|
37
|
+
}
|
38
|
+
|
39
|
+
vms = NovaDsl::NovaVmsContainer.new
|
40
|
+
|
41
|
+
results.each do |result|
|
42
|
+
if result[:status].eql?(0)
|
43
|
+
vms.merge!(parse_nova_list_stdout result[:out])
|
44
|
+
else
|
45
|
+
LOGGER.debug("Skipping command stdout parsing because exitstatus is #{result[:status]}")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
vms
|
49
|
+
end
|
50
|
+
|
51
|
+
def nova_delete
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
def nova_image_list
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
def nova_flavor_list
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
$:.push '.'
|
2
|
+
require 'common/log'
|
3
|
+
require 'common/helpers'
|
4
|
+
require 'nova/utils/nova_error'
|
5
|
+
require 'nova/utils/nova_vm'
|
6
|
+
|
7
|
+
module NovaDsl
|
8
|
+
|
9
|
+
module NovaStdoutParser
|
10
|
+
|
11
|
+
#Searches ip in the word, that ENDS by ip.
|
12
|
+
#Ex: s="fo_my_vm_bar_435.as.341 = 10.3.4.5"
|
13
|
+
#The result: s[IP_SEARCHER=~s, s.length] results in `10.3.4.5`
|
14
|
+
#TODO: It should supports multiple ips such as: 'private=10.35.9.40, 50.56.54.87'
|
15
|
+
IP_SEARCHER=/[a-zA-Z0-9]*(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/
|
16
|
+
|
17
|
+
def parse_nova_list_stdout(stdout)
|
18
|
+
LOGGER.debug("Parsing stdout, size: #{stdout.size}")
|
19
|
+
Common::type_checker stdout, String
|
20
|
+
|
21
|
+
initial_strings = stdout.split("\n")
|
22
|
+
LOGGER.debug("Parsing #{initial_strings.size} lines, assuming first three should be a headers and other stuff")
|
23
|
+
|
24
|
+
vms = NovaDsl::NovaVmsContainer.new
|
25
|
+
|
26
|
+
initial_strings.each_with_index do |line, index|
|
27
|
+
columns = line.split("|").map { |s| s.strip }
|
28
|
+
if index >=3 && columns.size.eql?(5)
|
29
|
+
id = columns[1].to_i
|
30
|
+
name = columns[2].to_s
|
31
|
+
status = columns[3].capitalize
|
32
|
+
ip = columns[4][IP_SEARCHER=~columns[4], columns[4].size]
|
33
|
+
|
34
|
+
vms << NovaDsl::NovaVm.new(id, name, ip, status)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
vms
|
38
|
+
end
|
39
|
+
|
40
|
+
def parse_nova_show_stdout(stdout)
|
41
|
+
LOGGER.debug("Parsing nova stdout")
|
42
|
+
Common::type_checker stdout, String
|
43
|
+
|
44
|
+
initial_strings = stdout.split("\n")
|
45
|
+
LOGGER.debug("Creating key-value info instance")
|
46
|
+
|
47
|
+
initial_strings.each_with_index do |line, index|
|
48
|
+
columns = line.split('|').map { |s| s.strip }
|
49
|
+
if index >= 3 && columns.size.eql?(5)
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
|
data/lib/nova-dsl.rb
ADDED
data/lib/version.rb
ADDED
data/nova-dsl.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
$:.push "."
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "lib/version"
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "nova-dsl"
|
6
|
+
s.version = NovaDsl::VERSION
|
7
|
+
s.authors = ["gapcoder"]
|
8
|
+
s.email = ["vlaskinvlad@gmail.com"]
|
9
|
+
s.homepage = ""
|
10
|
+
s.summary = %q{Dsl wrapper for python nova-client}
|
11
|
+
s.description = %q{Call this from a line nova-client}
|
12
|
+
|
13
|
+
s.rubyforge_project = "nova-dsl"
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
s.bindir = 'bin'
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
# s.add_runtime_dependency "rest-client"
|
24
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
$:.push '.'
|
2
|
+
|
3
|
+
require 'rspec'
|
4
|
+
|
5
|
+
require 'nova/wrapper/nova_console_wrapper'
|
6
|
+
|
7
|
+
|
8
|
+
describe NovaDsl::NovaConsoleWrapper do
|
9
|
+
|
10
|
+
include NovaDsl::NovaConsoleWrapper
|
11
|
+
|
12
|
+
before :each do
|
13
|
+
@name = 'foo_vm'
|
14
|
+
@flavor = 3
|
15
|
+
@image = 543
|
16
|
+
@key = 'gd_test.key'
|
17
|
+
@security_groups = ['default', 'allowall', 'apache']
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should be able to provision vm" do
|
22
|
+
pending
|
23
|
+
nova_provision({ }).should raise_error
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should raise error when accepting nil args"
|
27
|
+
|
28
|
+
it "should get list of provisioned vms"
|
29
|
+
|
30
|
+
it "should get flavor list"
|
31
|
+
|
32
|
+
it "should get image list"
|
33
|
+
|
34
|
+
it "should get instance info"
|
35
|
+
|
36
|
+
it "should delete vm by it's id"
|
37
|
+
|
38
|
+
it "should register additional names in dns"
|
39
|
+
|
40
|
+
it "should be able to check vm ping is ok"
|
41
|
+
|
42
|
+
it "should check vm port 22 is accessible"
|
43
|
+
|
44
|
+
it "should check vm is accessible by ssh"
|
45
|
+
|
46
|
+
end
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nova-dsl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- gapcoder
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-10 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Call this from a line nova-client
|
15
|
+
email:
|
16
|
+
- vlaskinvlad@gmail.com
|
17
|
+
executables:
|
18
|
+
- nova-dsl
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- Gemfile
|
23
|
+
- README
|
24
|
+
- Rakefile
|
25
|
+
- bin/nova-dsl
|
26
|
+
- example.sh
|
27
|
+
- examples/nova_list.rb
|
28
|
+
- examples/open4_ex.rb
|
29
|
+
- examples/simple_provision.rb
|
30
|
+
- lib/common/attribute_checker.rb
|
31
|
+
- lib/common/attribute_resolver.rb
|
32
|
+
- lib/common/helpers.rb
|
33
|
+
- lib/common/log.rb
|
34
|
+
- lib/nova-dsl.rb
|
35
|
+
- lib/nova/commands/nova_list.rb
|
36
|
+
- lib/nova/commands/nova_provision.rb
|
37
|
+
- lib/nova/utils/nova_error.rb
|
38
|
+
- lib/nova/utils/nova_vm.rb
|
39
|
+
- lib/nova/wrapper/nova_console_wrapper.rb
|
40
|
+
- lib/nova/wrapper/nova_stdout_parser.rb
|
41
|
+
- lib/version.rb
|
42
|
+
- nova-dsl.gemspec
|
43
|
+
- spec/nova_wrapper_spec.rb
|
44
|
+
homepage: ''
|
45
|
+
licenses: []
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirements: []
|
63
|
+
rubyforge_project: nova-dsl
|
64
|
+
rubygems_version: 1.8.15
|
65
|
+
signing_key:
|
66
|
+
specification_version: 3
|
67
|
+
summary: Dsl wrapper for python nova-client
|
68
|
+
test_files:
|
69
|
+
- spec/nova_wrapper_spec.rb
|
70
|
+
has_rdoc:
|