sfcc 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,53 @@
1
+ require File.join(File.dirname(__FILE__), 'helper')
2
+ require 'pp'
3
+
4
+ class SfccCimcClass < SfccTestCase
5
+
6
+ context "a CIM environment and client" do
7
+ setup do
8
+ setup_cim_client
9
+ op = Sfcc::Cim::ObjectPath.new("root/cimv2", "CIM_ComputerSystem")
10
+ @cimclass = @client.get_class(op)
11
+ end
12
+
13
+ should "be running" do
14
+ assert cimom_running?
15
+ end
16
+
17
+ should "be able to enumerate properties" do
18
+ @cimclass.each_property do |k, v|
19
+ assert_not_nil(k)
20
+ end
21
+
22
+ properties = @cimclass.properties
23
+ assert !properties.empty?
24
+ assert_equal properties.size, @cimclass.property_count
25
+ pp properties
26
+ end
27
+
28
+ should "be able to enumerate qualifiers" do
29
+ @cimclass.each_qualifier do |k, v|
30
+ assert_not_nil(k)
31
+ end
32
+
33
+ qualifiers = @cimclass.qualifiers
34
+ assert qualifiers.empty?
35
+ assert_equal qualifiers.size, @cimclass.qualifier_count
36
+ pp qualifiers
37
+ end
38
+
39
+ should "be able to enumerate qualifiers for a property" do
40
+ @cimclass.each_property_qualifier("Status") do |k, v|
41
+ assert_not_nil(k)
42
+ end
43
+
44
+ qualifiers = @cimclass.property_qualifiers("Status")
45
+ assert qualifiers.empty?
46
+ assert_equal qualifiers.size, @cimclass.qualifier_count
47
+ pp qualifiers
48
+ end
49
+
50
+ end
51
+
52
+ end
53
+
@@ -0,0 +1,151 @@
1
+ require File.join(File.dirname(__FILE__), 'helper')
2
+ require 'pp'
3
+
4
+ class SfccCimcClient < SfccTestCase
5
+
6
+ context "a running CIMOM with no auth" do
7
+
8
+ setup do
9
+ setup_cim_client
10
+ @op = Sfcc::Cim::ObjectPath.new("root/cimv2", "")
11
+ end
12
+
13
+ should "be running" do
14
+ assert cimom_running?
15
+ end
16
+
17
+ should "be of class Client" do
18
+ assert_kind_of(Sfcc::Cim::Client, @client)
19
+ end
20
+
21
+ should "allow for query" do
22
+ result = @client.query(@op, "select * from CIM_OperatingSystem", "wql")
23
+ result.each do |instance|
24
+ puts "query result: #{instance}"
25
+ end
26
+ end
27
+
28
+ should "be able to get set properties using an object path" do
29
+ @op = Sfcc::Cim::ObjectPath.new("root/cimv2", "Linux_OperatingSystem")
30
+ # @client.instance_names(@op).each do |path|
31
+ @client.query(@op, "select * from Linux_OperatingSystem", "wql").each do |instance|
32
+ # assert ! @client.property(instance.object_path, "PrimaryOwnerContact").empty?
33
+ end
34
+ end
35
+
36
+ should "be able to get an instance from the object path" do
37
+ @op = Sfcc::Cim::ObjectPath.new("root/cimv2", "Linux_OperatingSystem")
38
+ instance = @client.query(@op, "select * from Linux_OperatingSystem", "wql").to_a.first
39
+ instance2 = @client.get_instance(instance.object_path)
40
+ assert_kind_of Sfcc::Cim::Instance, instance2
41
+ end
42
+
43
+ should "be able to create an instance" do
44
+ op = Sfcc::Cim::ObjectPath.new("root/cimv2", "Linux_OperatingSystem")
45
+ instance = Sfcc::Cim::Instance.new(op)
46
+ assert_raise Sfcc::Cim::ErrorNotSupported do
47
+ new_op = @client.create_instance(op, instance)
48
+ end
49
+ end
50
+
51
+ should "be able to set an instance" do
52
+ @op = Sfcc::Cim::ObjectPath.new("root/cimv2", "Linux_OperatingSystem")
53
+ instance = @client.query(@op, "select * from Linux_OperatingSystem", "wql").to_a.first
54
+ assert_raise Sfcc::Cim::ErrorNotSupported do
55
+ instance = @client.set_instance(instance.object_path, instance)
56
+ end
57
+ end
58
+
59
+ should "be able to delete an instance" do
60
+ instance = @client.query(@op, "select * from Linux_OperatingSystem", "wql").to_a.first
61
+ assert_raise Sfcc::Cim::ErrorNotSupported do
62
+ @client.delete_instance(instance.object_path)
63
+ end
64
+ end
65
+
66
+ should "be able to get associator for an instance" do
67
+ op = Sfcc::Cim::ObjectPath.new("root/cimv2", "")
68
+ op = @client.query(op, "select * from CIM_ComputerSystem", "wql").to_a.first.object_path
69
+ associators = @client.associators(op, 'CIM_RunningOS').to_a
70
+ assert !associators.empty?
71
+ associators.each { |assoc| assert_kind_of Sfcc::Cim::Instance, assoc }
72
+ pp associators
73
+ end
74
+
75
+ should "be able to get associator names for an instance" do
76
+ op = Sfcc::Cim::ObjectPath.new("root/cimv2", "")
77
+ op = @client.query(op, "select * from CIM_ComputerSystem", "wql").to_a.first.object_path
78
+ associators = @client.associator_names(op, 'CIM_RunningOS').to_a
79
+ assert !associators.empty?
80
+ associators.each { |assoc| assert_kind_of Sfcc::Cim::ObjectPath, assoc }
81
+ pp associators
82
+ end
83
+
84
+ should "be able to get references for an instance" do
85
+ op = Sfcc::Cim::ObjectPath.new("root/cimv2", "")
86
+ op = @client.query(op, "select * from CIM_OperatingSystem", "wql").to_a.first.object_path
87
+ associators = @client.references(op, 'CIM_RunningOS').to_a
88
+ assert !associators.empty?
89
+ associators.each { |assoc| assert_kind_of Sfcc::Cim::Instance, assoc }
90
+ pp associators
91
+ end
92
+
93
+ should "be able to get reference names for an instance" do
94
+ op = Sfcc::Cim::ObjectPath.new("root/cimv2", "")
95
+ op = @client.query(op, "select * from CIM_OperatingSystem", "wql").to_a.first.object_path
96
+ associators = @client.reference_names(op, 'CIM_RunningOS').to_a
97
+ assert !associators.empty?
98
+ associators.each { |assoc| assert_kind_of Sfcc::Cim::ObjectPath, assoc }
99
+ pp associators
100
+ end
101
+
102
+ should "be able to invoke methods using an object path" do
103
+ @op = Sfcc::Cim::ObjectPath.new("root/cimv2", "Linux_OperatingSystem")
104
+ @client.query(@op, "select * from Linux_OperatingSystem", "wql").each do |instance|
105
+ # @client.instances(@op, Sfcc::Flags::IncludeClassOrigin | Sfcc::Flags::IncludeQualifiers, nil).each do |instance|
106
+ path = instance.object_path
107
+ assert_kind_of Sfcc::Cim::ObjectPath, path
108
+ out = {}
109
+ ret = @client.invoke_method(path, :execCmd, {:cmd => "cat /etc/SuSE-release"}, out)
110
+ assert out.has_key?(:out), "output parameter is present"
111
+ assert out[:out].match(/VERSION/)
112
+ assert_equal 0, ret, "execCmd returns 0"
113
+ end
114
+ end
115
+
116
+ context "class names" do
117
+ setup do
118
+ @class_names = @client.class_names(@op, Sfcc::Flags::DeepInheritance)
119
+ end
120
+
121
+ should "be a Cimc::Enumeration" do
122
+ assert_kind_of(Sfcc::Cim::Enumeration, @class_names)
123
+ end
124
+
125
+ should "include CIM_ManagedElement" do
126
+ assert !@class_names.select { |x| x.to_s == "CIM_ManagedElement" }.empty?
127
+ end
128
+
129
+ should "have every element of type Sfcc::Cim::ObjectPath" do
130
+ @class_names.each { |n| assert_kind_of(Sfcc::Cim::ObjectPath, n) }
131
+ end
132
+ end
133
+
134
+ context "classes" do
135
+ setup do
136
+ @classes = @client.classes(@op, Sfcc::Flags::DeepInheritance)
137
+ end
138
+
139
+ should "be a Cimc::Enumeration" do
140
+ assert_kind_of(Sfcc::Cim::Enumeration, @classes)
141
+ end
142
+
143
+ should "have every alement of type Cimc::Class" do
144
+ @classes.each { |c| assert_kind_of(Sfcc::Cim::Class, c) }
145
+ end
146
+ end
147
+
148
+ end
149
+
150
+ end
151
+
@@ -0,0 +1,24 @@
1
+
2
+ require File.join(File.dirname(__FILE__), 'helper')
3
+ require 'pp'
4
+
5
+ class SfccCimEnumerationTest < SfccTestCase
6
+
7
+ context "enumeration of instances" do
8
+ setup do
9
+ setup_cim_client
10
+ op = Sfcc::Cim::ObjectPath.new("root/cimv2", "")
11
+ @enm = @client.query(op, "select * from CIM_ComputerSystem", "wql")
12
+ end
13
+
14
+ should "be running" do
15
+ assert cimom_running?
16
+ end
17
+
18
+ should "be able to iterate twice" do
19
+ assert !@enm.to_a.empty?
20
+ assert !@enm.to_a.empty?
21
+ end
22
+ end
23
+ end
24
+
@@ -0,0 +1,89 @@
1
+
2
+ require File.join(File.dirname(__FILE__), 'helper')
3
+ require 'pp'
4
+
5
+ class SfccCimInstanceTest < SfccTestCase
6
+
7
+ context "object path for CIM_ComputerSystem and running CIMOM with no auth" do
8
+ setup do
9
+ setup_cim_client
10
+ @op_computer_system = Sfcc::Cim::ObjectPath.new("root/cimv2", "CIM_ComputerSystem")
11
+ end
12
+
13
+ should "be running" do
14
+ assert cimom_running?
15
+ end
16
+
17
+ should "be able to create an instance" do
18
+ instance = Sfcc::Cim::Instance.new(@op_computer_system)
19
+ end
20
+ end
21
+
22
+ context "an instance of CIM_ComputerSystem" do
23
+ setup do
24
+ setup_cim_client
25
+ op = Sfcc::Cim::ObjectPath.new("root/cimv2", "")
26
+ @instance = @client.query(op, "select * from CIM_ComputerSystem", "wql").to_a.first
27
+ end
28
+
29
+ should "be running" do
30
+ assert cimom_running?
31
+ end
32
+
33
+ should "respond to property Name" do
34
+ assert_kind_of(String, @instance.property('Name'))
35
+ end
36
+
37
+ should "be able to iterate over properties" do
38
+ @instance.each_property do |name, value|
39
+ puts "#{name} -> #{value}"
40
+ puts "---"
41
+ end
42
+ end
43
+
44
+ should "be able to set and retrieve stringproperties" do
45
+ assert_raises Sfcc::Cim::ErrorNoSuchProperty do
46
+ @instance.property("foobar");
47
+ end
48
+ assert_nothing_raised do
49
+ @instance.set_property("Name", "newname");
50
+ end
51
+ assert_equal "newname", @instance.property("Name")
52
+ end
53
+
54
+ should "be able to set and retrieve stringproperties" do
55
+ assert_raises Sfcc::Cim::ErrorNoSuchProperty do
56
+ @instance.property("foobar");
57
+ end
58
+ assert_nothing_raised do
59
+ @instance.set_property("Name", "newname");
60
+ end
61
+ assert_equal "newname", @instance.property("Name")
62
+ end
63
+
64
+ should "be able to enumerate qualifiers" do
65
+ @instance.each_qualifier do |k, v|
66
+ assert_not_nil(k)
67
+ end
68
+
69
+ qualifiers = @instance.qualifiers
70
+ assert qualifiers.empty?
71
+ assert_equal qualifiers.size, @instance.qualifier_count
72
+ pp qualifiers
73
+ end
74
+
75
+ should "be able to enumerate qualifiers for a property" do
76
+ @instance.each_property_qualifier("Status") do |k, v|
77
+ assert_not_nil(k)
78
+ end
79
+
80
+ qualifiers = @instance.property_qualifiers("Status")
81
+ assert qualifiers.empty?
82
+ assert_equal qualifiers.size, @instance.qualifier_count
83
+ pp qualifiers
84
+ end
85
+
86
+
87
+ end
88
+ end
89
+
@@ -0,0 +1,85 @@
1
+
2
+ require File.join(File.dirname(__FILE__), 'helper')
3
+ require 'pp'
4
+
5
+ class SfccCimcObjectPathTest < SfccTestCase
6
+
7
+ context "a new object path for an instance of root/cimv2:Linux_OperatingSystem" do
8
+ setup do
9
+ setup_cim_client
10
+ @op = Sfcc::Cim::ObjectPath.new("root/cimv2", "")
11
+ @op = @client.query(@op, "select * from Linux_OperatingSystem", "wql").first.object_path
12
+ end
13
+
14
+ should "be running" do
15
+ assert cimom_running?
16
+ end
17
+
18
+ should "have root/cimv2 as namespace" do
19
+ assert_equal "root/cimv2", @op.namespace
20
+ end
21
+
22
+ should "change its namespace after setting it" do
23
+ @op.namespace = "root/cimv3"
24
+ assert_equal "root/cimv3", @op.namespace
25
+ end
26
+
27
+ should "not have namespace at the beginning" do
28
+ assert_raise Sfcc::Cim::ErrorNotSupported do
29
+ @op.hostname
30
+ end
31
+ end
32
+
33
+ should "change its hostname after setting it" do
34
+ assert_raise Sfcc::Cim::ErrorNotSupported do
35
+ @op.hostname = "foo.bar.com"
36
+ end
37
+ assert_raise Sfcc::Cim::ErrorNotSupported do
38
+ assert_equal "foo.bar.com", @op.hostname
39
+ end
40
+ end
41
+
42
+ should "respond to class_name" do
43
+ assert_equal "Linux_OperatingSystem", @op.class_name
44
+ end
45
+
46
+ should "change its class name after setting it" do
47
+ @op.class_name = "BarClass"
48
+ assert_equal "BarClass", @op.class_name
49
+ end
50
+
51
+ should "respond to keys and set them" do
52
+ assert_raise Sfcc::Cim::ErrorNoSuchProperty do
53
+ @op.key("foo")
54
+ end
55
+ assert_equal 4, @op.key_count
56
+
57
+ assert_nothing_raised do
58
+ @op.add_key("prop0", "hello")
59
+ @op.add_key("prop1", true)
60
+ @op.add_key("prop2", false)
61
+ end
62
+ assert_equal 7, @op.key_count
63
+
64
+ assert_equal "hello", @op.key("prop0")
65
+ assert_equal true, @op.key("prop1")
66
+ assert_equal false, @op.key("prop2")
67
+ end
68
+
69
+ should "be able to set namespace and classname from other object path" do
70
+ op = Sfcc::Cim::ObjectPath.new("root/cimv2", "Linux_OperatingSystem")
71
+ op2 = Sfcc::Cim::ObjectPath.new("root/cimv3", "FooBar")
72
+ assert_equal "Linux_OperatingSystem", op.class_name
73
+ op.set_namespace_from(op2)
74
+ assert_equal "FooBar", op2.class_name
75
+ assert_equal "root/cimv3", op2.namespace
76
+ end
77
+
78
+ should "be able to retrieve qualifiers" do
79
+ # CRASH? CIMOM?
80
+ #op = Sfcc::Cim::ObjectPath.new("root/cimv2", "Linux_OperatingSystem")
81
+ # assert_equal "2.17.1", @op.class_qualifier("Version")
82
+ #assert_equal "Number", op.property_qualifier("NumberOfUsers", "Description")
83
+ end
84
+ end
85
+ end
metadata ADDED
@@ -0,0 +1,152 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sfcc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Duncan Mac-Vicar P.
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-01-15 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: shoulda
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: yard
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: rubyforge
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 2.0.3
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: gemcutter
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 0.3.0
54
+ version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake-compiler
57
+ type: :development
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
65
+ - !ruby/object:Gem::Dependency
66
+ name: hoe
67
+ type: :development
68
+ version_requirement:
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: 2.5.0
74
+ version:
75
+ description: ruby-sfcc allows to access a CIMOM either with the WBEM protocol or by using the SfcbLocal interface provided by the sblim-sfcb CIMOM implementation from the sblim project.
76
+ email:
77
+ - dmacvicar@suse.de
78
+ executables: []
79
+
80
+ extensions:
81
+ - ext/sfcc/extconf.rb
82
+ extra_rdoc_files:
83
+ - Manifest.txt
84
+ - README.rdoc
85
+ - CHANGELOG.rdoc
86
+ - TODO.rdoc
87
+ files:
88
+ - CHANGELOG.rdoc
89
+ - MIT-LICENSE
90
+ - Manifest.txt
91
+ - README.rdoc
92
+ - Rakefile
93
+ - TODO.rdoc
94
+ - ext/sfcc/cim_class.c
95
+ - ext/sfcc/cim_class.h
96
+ - ext/sfcc/cim_client.c
97
+ - ext/sfcc/cim_client.h
98
+ - ext/sfcc/cim_enumeration.c
99
+ - ext/sfcc/cim_enumeration.h
100
+ - ext/sfcc/cim_instance.c
101
+ - ext/sfcc/cim_instance.h
102
+ - ext/sfcc/cim_object_path.c
103
+ - ext/sfcc/cim_object_path.h
104
+ - ext/sfcc/cim_string.c
105
+ - ext/sfcc/cim_string.h
106
+ - ext/sfcc/extconf.rb
107
+ - ext/sfcc/sfcc.c
108
+ - ext/sfcc/sfcc.h
109
+ - lib/sfcc.rb
110
+ - test/helper.rb
111
+ - test/test_sfcc.rb
112
+ - test/test_sfcc_cim_class.rb
113
+ - test/test_sfcc_cim_client.rb
114
+ - test/test_sfcc_cim_instance.rb
115
+ - test/test_sfcc_cim_object_path.rb
116
+ has_rdoc: true
117
+ homepage: http://github.com/dmacvicar/ruby-sfcc
118
+ licenses: []
119
+
120
+ post_install_message:
121
+ rdoc_options:
122
+ - --main
123
+ - README.rdoc
124
+ require_paths:
125
+ - lib
126
+ - ext
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: "0"
132
+ version:
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: "0"
138
+ version:
139
+ requirements: []
140
+
141
+ rubyforge_project: sfcc
142
+ rubygems_version: 1.3.5
143
+ signing_key:
144
+ specification_version: 3
145
+ summary: WBEM client for ruby based on the sblim-sfcc library
146
+ test_files:
147
+ - test/test_sfcc_cim_object_path.rb
148
+ - test/test_sfcc_cim_enumeration.rb
149
+ - test/test_sfcc_cim_client.rb
150
+ - test/test_sfcc_cim_instance.rb
151
+ - test/test_sfcc.rb
152
+ - test/test_sfcc_cim_class.rb