sfcc 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,9 @@
1
+ == 0.1.2
2
+
3
+ * build with ruby 1.9
4
+ * allow creation of object path with only namespace argument
5
+ * Hoe no longer required for building
6
+ * Gemfile/bundler (1.x) support
1
7
 
2
8
  == 0.1.1
3
9
 
data/README.rdoc CHANGED
@@ -54,6 +54,16 @@ ruby-like API to do CIM based management.
54
54
 
55
55
  * ObjectPath qualifier methods crash
56
56
 
57
+ == Links
58
+
59
+ === Documentation
60
+
61
+ * http://rdoc.info/projects/dmacvicar/ruby-sfcc
62
+
63
+ === Code Metrics
64
+
65
+ * http://getcaliper.com/caliper/project?repo=git%3A%2F%2Fgithub.com%2Fdmacvicar%2Fruby-sfcc.git
66
+
57
67
  == Authors
58
68
 
59
69
  * Duncan Mac-Vicar P. <dmacvicar@suse.de>
@@ -65,6 +65,8 @@ static VALUE get_class(int argc, VALUE *argv, VALUE self)
65
65
  *
66
66
  * return the available class names for the given
67
67
  * +object_path+ and +flags+
68
+ *
69
+ * The following flag is supported: Flags::DeepInheritance.
68
70
  */
69
71
  static VALUE class_names(int argc, VALUE *argv, VALUE self)
70
72
  {
@@ -39,7 +39,7 @@ static VALUE namespace(VALUE self)
39
39
  Data_Get_Struct(self, CMPIObjectPath, ptr);
40
40
  cimstr = ptr->ft->getNameSpace(ptr, &status);
41
41
  if (!status.rc)
42
- return cimstr ? rb_str_new2(cimstr->ft->getCharPtr(cimstr, NULL)) : Qnil;
42
+ return CIMSTR_2_RUBYSTR(cimstr);
43
43
  sfcc_rb_raise_if_error(status, "Can't get namespace");
44
44
  return Qnil;
45
45
  }
@@ -76,7 +76,7 @@ static VALUE hostname(VALUE self)
76
76
  Data_Get_Struct(self, CMPIObjectPath, ptr);
77
77
  cimstr = ptr->ft->getHostname(ptr, &status);
78
78
  if (!status.rc)
79
- return cimstr ? rb_str_new2(cimstr->ft->getCharPtr(cimstr, NULL)) : Qnil;
79
+ return CIMSTR_2_RUBYSTR(cimstr);
80
80
  sfcc_rb_raise_if_error(status, "Can't get hostname");
81
81
  return Qnil;
82
82
  }
@@ -106,7 +106,7 @@ static VALUE class_name(VALUE self)
106
106
  CMPIString *cimstr = NULL;
107
107
  Data_Get_Struct(self, CMPIObjectPath, ptr);
108
108
  cimstr = ptr->ft->getClassName(ptr, NULL);
109
- return cimstr ? rb_str_new2(cimstr->ft->getCharPtr(cimstr, NULL)) : Qnil;
109
+ return CIMSTR_2_RUBYSTR(cimstr);
110
110
  }
111
111
 
112
112
  /**
@@ -170,7 +170,7 @@ static VALUE each_key(VALUE self)
170
170
  for (; k < num_props; ++k) {
171
171
  data = ptr->ft->getKeyAt(ptr, k, &key_name, &status);
172
172
  if (!status.rc) {
173
- rb_yield_values(2, (key_name ? rb_str_intern(rb_str_new2(key_name->ft->getCharPtr(key_name, NULL))) : Qnil), sfcc_cimdata_to_value(data));
173
+ rb_yield_values(2, rb_str_intern(CIMSTR_2_RUBYSTR(key_name)), sfcc_cimdata_to_value(data));
174
174
  }
175
175
  else {
176
176
  sfcc_rb_raise_if_error(status, "Can't retrieve key #%d", k);
@@ -350,7 +350,7 @@ static VALUE to_s(VALUE self)
350
350
  CMPIString *cimstr = NULL;
351
351
  Data_Get_Struct(self, CMPIObjectPath, ptr);
352
352
  cimstr = ptr->ft->toString(ptr, NULL);
353
- return cimstr ? rb_str_new2(cimstr->ft->getCharPtr(cimstr, NULL)) : Qnil;
353
+ return CIMSTR_2_RUBYSTR(cimstr);
354
354
  }
355
355
 
356
356
  /**
@@ -360,12 +360,18 @@ static VALUE to_s(VALUE self)
360
360
  * Creates an object path from +namespace+ and +class_name+
361
361
  *
362
362
  */
363
- static VALUE new(VALUE klass, VALUE namespace, VALUE class_name)
363
+ static VALUE new(int argc, VALUE *argv, VALUE self)
364
364
  {
365
+ VALUE namespace;
366
+ VALUE class_name;
367
+
365
368
  CMPIStatus status;
366
369
  CMPIObjectPath *ptr = NULL;
367
370
  CMPIObjectPath *newop = NULL;
368
371
  memset(&status, 0, sizeof(CMPIStatus));
372
+
373
+ rb_scan_args(argc, argv, "11", &namespace, &class_name);
374
+
369
375
  ptr = newCMPIObjectPath(NIL_P(namespace) ? NULL : StringValuePtr(namespace),
370
376
  NIL_P(class_name) ? NULL : StringValuePtr(class_name),
371
377
  &status);
@@ -398,7 +404,7 @@ void init_cim_object_path()
398
404
  VALUE klass = rb_define_class_under(cimc, "ObjectPath", rb_cObject);
399
405
  cSfccCimObjectPath = klass;
400
406
 
401
- rb_define_singleton_method(klass, "new", new, 2);
407
+ rb_define_singleton_method(klass, "new", new, -1);
402
408
  rb_define_method(klass, "namespace=", set_namespace, 1);
403
409
  rb_define_method(klass, "namespace", namespace, 0);
404
410
  rb_define_method(klass, "hostname=", set_hostname, 1);
data/ext/sfcc/sfcc.h CHANGED
@@ -16,7 +16,14 @@
16
16
  #include <CimClientLib/cmcimacs.h>
17
17
 
18
18
  #include "ruby.h"
19
- #include "st.h"
19
+
20
+ #include <ruby.h>
21
+ #ifdef HAVE_RUBY_ST_H
22
+ # include <ruby/st.h>
23
+ #else
24
+ # include <st.h>
25
+ #endif
26
+
20
27
  #include <unistd.h>
21
28
  #include <stdlib.h>
22
29
 
@@ -49,6 +56,8 @@ extern VALUE mSfccCim;
49
56
 
50
57
  #define SFCC_INC_REFCOUNT(x) (void)(0);
51
58
 
59
+ #define CIMSTR_2_RUBYSTR(x) (x ? (x->ft->getCharPtr(x, NULL) ? rb_str_new2(x->ft->getCharPtr(x, NULL)) : Qnil) : Qnil)
60
+
52
61
  /**
53
62
  * raises a ruby exception if the status is an error
54
63
  * whenever possible, adds the custom message if not null
data/lib/sfcc.rb CHANGED
@@ -1,12 +1,10 @@
1
-
1
+ require 'sfcc/version'
2
2
  require "sfcc.so" # native
3
3
  require 'enumerator'
4
4
  require 'uri'
5
5
 
6
6
  module Sfcc
7
7
 
8
- VERSION = "0.1.1"
9
-
10
8
  module Flags
11
9
  LocalOnly = 1
12
10
  DeepInheritance = 2
@@ -0,0 +1,3 @@
1
+ module Sfcc
2
+ VERSION = "0.1.2"
3
+ end
metadata CHANGED
@@ -1,173 +1,140 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sfcc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 2
9
+ version: 0.1.2
5
10
  platform: ruby
6
11
  authors:
7
- - Duncan Mac-Vicar P.
12
+ - Duncan Mac-Vicar
8
13
  autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-01-18 00:00:00 +01:00
17
+ date: 2010-08-19 00:00:00 +02:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !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
21
+ name: rake-compiler
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
30
25
  requirements:
31
26
  - - ">="
32
27
  - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
33
30
  version: "0"
34
- version:
35
- - !ruby/object:Gem::Dependency
36
- name: rubyforge
37
31
  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:
32
+ version_requirements: *id001
45
33
  - !ruby/object:Gem::Dependency
46
- name: gemcutter
47
- type: :development
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
34
+ name: mocha
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
50
38
  requirements:
51
39
  - - ">="
52
40
  - !ruby/object:Gem::Version
53
- version: 0.3.0
54
- version:
41
+ segments:
42
+ - 0
43
+ - 9
44
+ version: "0.9"
45
+ type: :development
46
+ version_requirements: *id002
55
47
  - !ruby/object:Gem::Dependency
56
48
  name: yard
57
- type: :development
58
- version_requirement:
59
- version_requirements: !ruby/object:Gem::Requirement
49
+ prerelease: false
50
+ requirement: &id003 !ruby/object:Gem::Requirement
51
+ none: false
60
52
  requirements:
61
53
  - - ">="
62
54
  - !ruby/object:Gem::Version
63
- version: 0.5.3
64
- version:
65
- - !ruby/object:Gem::Dependency
66
- name: hoe-yard
55
+ segments:
56
+ - 0
57
+ - 5
58
+ version: "0.5"
67
59
  type: :development
68
- version_requirement:
69
- version_requirements: !ruby/object:Gem::Requirement
70
- requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- version: 0.1.1
74
- version:
60
+ version_requirements: *id003
75
61
  - !ruby/object:Gem::Dependency
76
- name: rake-compiler
77
- type: :development
78
- version_requirement:
79
- version_requirements: !ruby/object:Gem::Requirement
62
+ name: shoulda
63
+ prerelease: false
64
+ requirement: &id004 !ruby/object:Gem::Requirement
65
+ none: false
80
66
  requirements:
81
67
  - - ">="
82
68
  - !ruby/object:Gem::Version
69
+ segments:
70
+ - 0
83
71
  version: "0"
84
- version:
85
- - !ruby/object:Gem::Dependency
86
- name: hoe
87
72
  type: :development
88
- version_requirement:
89
- version_requirements: !ruby/object:Gem::Requirement
90
- requirements:
91
- - - ">="
92
- - !ruby/object:Gem::Version
93
- version: 2.5.0
94
- version:
73
+ version_requirements: *id004
95
74
  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.
96
75
  email:
97
76
  - dmacvicar@suse.de
98
77
  executables: []
99
78
 
100
- extensions:
101
- - ext/sfcc/extconf.rb
102
- extra_rdoc_files:
103
- - Manifest.txt
104
- - README.rdoc
105
- - CHANGELOG.rdoc
106
- - TODO.rdoc
79
+ extensions: []
80
+
81
+ extra_rdoc_files: []
82
+
107
83
  files:
108
- - CHANGELOG.rdoc
109
- - MIT-LICENSE
110
- - Manifest.txt
111
- - README.rdoc
112
- - Rakefile
113
- - TODO.rdoc
114
- - ext/sfcc/cim_class.c
115
- - ext/sfcc/cim_class.h
116
- - ext/sfcc/cim_client.c
84
+ - lib/sfcc.rb
85
+ - lib/sfcc/version.rb
86
+ - ext/sfcc/extconf.rb
117
87
  - ext/sfcc/cim_client.h
118
- - ext/sfcc/cim_enumeration.c
119
- - ext/sfcc/cim_enumeration.h
120
- - ext/sfcc/cim_instance.c
88
+ - ext/sfcc/cim_object_path.h
121
89
  - ext/sfcc/cim_instance.h
90
+ - ext/sfcc/cim_enumeration.h
91
+ - ext/sfcc/sfcc.h
92
+ - ext/sfcc/cim_class.h
93
+ - ext/sfcc/cim_string.h
94
+ - ext/sfcc/cim_enumeration.c
95
+ - ext/sfcc/cim_client.c
122
96
  - ext/sfcc/cim_object_path.c
123
- - ext/sfcc/cim_object_path.h
124
97
  - ext/sfcc/cim_string.c
125
- - ext/sfcc/cim_string.h
126
- - ext/sfcc/extconf.rb
98
+ - ext/sfcc/cim_instance.c
127
99
  - ext/sfcc/sfcc.c
128
- - ext/sfcc/sfcc.h
129
- - lib/sfcc.rb
130
- - test/helper.rb
131
- - test/test_sfcc.rb
132
- - test/test_sfcc_cim_class.rb
133
- - test/test_sfcc_cim_client.rb
134
- - test/test_sfcc_cim_instance.rb
135
- - test/test_sfcc_cim_object_path.rb
100
+ - ext/sfcc/cim_class.c
101
+ - CHANGELOG.rdoc
102
+ - README.rdoc
136
103
  has_rdoc: true
137
- homepage: http://github.com/dmacvicar/ruby-sfcc
104
+ homepage: http://www.github.com/dmacvicar/ruby-sfcc
138
105
  licenses: []
139
106
 
140
- post_install_message:
141
- rdoc_options:
142
- - --title
143
- - Sfcc Documentation
144
- - --quiet
107
+ post_install_message: " ____\n\
108
+ /@ ~-.\n\
109
+ / __ .- | remember to have fun! \n // // @ \n\n"
110
+ rdoc_options: []
111
+
145
112
  require_paths:
146
113
  - lib
147
- - ext
148
114
  required_ruby_version: !ruby/object:Gem::Requirement
115
+ none: false
149
116
  requirements:
150
117
  - - ">="
151
118
  - !ruby/object:Gem::Version
119
+ segments:
120
+ - 0
152
121
  version: "0"
153
- version:
154
122
  required_rubygems_version: !ruby/object:Gem::Requirement
123
+ none: false
155
124
  requirements:
156
125
  - - ">="
157
126
  - !ruby/object:Gem::Version
158
- version: "0"
159
- version:
127
+ segments:
128
+ - 1
129
+ - 3
130
+ - 6
131
+ version: 1.3.6
160
132
  requirements: []
161
133
 
162
- rubyforge_project: sfcc
163
- rubygems_version: 1.3.5
134
+ rubyforge_project:
135
+ rubygems_version: 1.3.7
164
136
  signing_key:
165
137
  specification_version: 3
166
138
  summary: WBEM client for ruby based on the sblim-sfcc library
167
- test_files:
168
- - test/test_sfcc_cim_object_path.rb
169
- - test/test_sfcc_cim_enumeration.rb
170
- - test/test_sfcc_cim_client.rb
171
- - test/test_sfcc_cim_instance.rb
172
- - test/test_sfcc.rb
173
- - test/test_sfcc_cim_class.rb
139
+ test_files: []
140
+
data/MIT-LICENSE DELETED
@@ -1,22 +0,0 @@
1
-
2
- Copyright (c) 2009 Novell Inc.
3
-
4
- Permission is hereby granted, free of charge, to any person obtaining
5
- a copy of this software and associated documentation files (the
6
- "Software"), to deal in the Software without restriction, including
7
- without limitation the rights to use, copy, modify, merge, publish,
8
- distribute, sublicense, and/or sell copies of the Software, and to
9
- permit persons to whom the Software is furnished to do so, subject to
10
- the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be
13
- included in all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
-
data/Manifest.txt DELETED
@@ -1,28 +0,0 @@
1
- CHANGELOG.rdoc
2
- MIT-LICENSE
3
- Manifest.txt
4
- README.rdoc
5
- Rakefile
6
- TODO.rdoc
7
- ext/sfcc/cim_class.c
8
- ext/sfcc/cim_class.h
9
- ext/sfcc/cim_client.c
10
- ext/sfcc/cim_client.h
11
- ext/sfcc/cim_enumeration.c
12
- ext/sfcc/cim_enumeration.h
13
- ext/sfcc/cim_instance.c
14
- ext/sfcc/cim_instance.h
15
- ext/sfcc/cim_object_path.c
16
- ext/sfcc/cim_object_path.h
17
- ext/sfcc/cim_string.c
18
- ext/sfcc/cim_string.h
19
- ext/sfcc/extconf.rb
20
- ext/sfcc/sfcc.c
21
- ext/sfcc/sfcc.h
22
- lib/sfcc.rb
23
- test/helper.rb
24
- test/test_sfcc.rb
25
- test/test_sfcc_cim_class.rb
26
- test/test_sfcc_cim_client.rb
27
- test/test_sfcc_cim_instance.rb
28
- test/test_sfcc_cim_object_path.rb
data/Rakefile DELETED
@@ -1,32 +0,0 @@
1
- $: << File.join(File.dirname(__FILE__), "test")
2
- require 'rubygems'
3
- gem 'hoe', '>= 2.1.0'
4
- require 'hoe'
5
-
6
- task :default => [:compile, :docs, :test]
7
-
8
- Hoe.plugin :yard
9
-
10
- HOE = Hoe.spec 'sfcc' do
11
- developer('Duncan Mac-Vicar P.', 'dmacvicar@suse.de')
12
- self.summary = "WBEM client for ruby based on the sblim-sfcc library"
13
- self.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."
14
- self.readme_file = ['README', ENV['HLANG'], 'rdoc'].compact.join('.')
15
- self.history_file = ['CHANGELOG', ENV['HLANG'], 'rdoc'].compact.join('.')
16
- self.extra_rdoc_files = FileList['*.rdoc']
17
- self.clean_globs = [
18
- 'lib/sfcc/*.{o,so,bundle,a,log,dll}',
19
- ]
20
-
21
- %w{ rake-compiler }.each do |dep|
22
- self.extra_dev_deps << [dep, '>= 0']
23
- end
24
- self.extra_deps << ['shoulda', '>= 0']
25
- self.extra_deps << ['yard', '>= 0']
26
- self.spec_extras = { :extensions => ["ext/sfcc/extconf.rb"] }
27
- end
28
-
29
-
30
- gem 'rake-compiler', '>= 0.4.1'
31
- require 'rake/extensiontask'
32
- Rake::ExtensionTask.new('sfcc')
data/TODO.rdoc DELETED
@@ -1,28 +0,0 @@
1
-
2
- == General:
3
-
4
- * add convencience [] operator to Class and Instance to set and
5
- retrieve properties
6
-
7
- == Missing relevant APIs
8
-
9
- Other APIs may be missing, but they may not be relevant in a ruby
10
- style API.
11
-
12
- === CIMCClass
13
-
14
- Only available in the v2 API (we use v1):
15
-
16
- * getSuperClassName
17
- * getKeyList
18
- * toString
19
- * relocate
20
- * getCharClassName
21
- * getCharSuperClassName
22
- * isAssociation
23
- * isAbstract
24
- * isIndication
25
- * getPropQualAt
26
-
27
-
28
-
data/test/helper.rb DELETED
@@ -1,32 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
4
- require 'tempfile'
5
-
6
- %w(../lib ../ext).each do |path|
7
- $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), path)))
8
- end
9
-
10
- require 'rubygems'
11
- require 'sfcc'
12
-
13
- class SfccTestCase < Test::Unit::TestCase
14
- ASSETS = File.expand_path(File.join(File.dirname(__FILE__), 'assets'))
15
-
16
- unless RUBY_VERSION >= '1.9'
17
- undef :default_test
18
- end
19
-
20
- def cimom_running?
21
- `ps -e`.each_line do |line|
22
- return true if line =~ /sfcbd/
23
- end
24
- return false
25
- end
26
-
27
- def setup_cim_client
28
- @client = Sfcc::Cim::Client.connect('http://root@localhost:5988')
29
- # @client = Sfcc::Cim::Client.connect(:host => 'localhost', :scheme => 'http', :user => 'root', :port => '5988')
30
- end
31
-
32
- end
data/test/test_sfcc.rb DELETED
@@ -1,69 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'helper')
2
- require 'pp'
3
-
4
- class BasicTest < SfccTestCase
5
-
6
- context "a running CIMOM with no auth" do
7
- setup do
8
- setup_cim_client
9
- end
10
-
11
- should "be running" do
12
- assert cimom_running?
13
- end
14
-
15
- should "be of class Client" do
16
- assert_kind_of(Sfcc::Cim::Client, @client)
17
- end
18
-
19
- context "a new object path for root/cimv2" do
20
- setup do
21
- @op = Sfcc::Cim::ObjectPath.new("root/cimv2", "")
22
- end
23
-
24
- should "be of class ObjectPath" do
25
- assert_kind_of(Sfcc::Cim::ObjectPath, @op)
26
- end
27
-
28
- should "allow for query" do
29
- result = @client.query(@op, "select * from CIM_ComputerSystem", "wql")
30
- result.each do |instance|
31
- puts instance
32
- end
33
- end
34
-
35
- context "class names" do
36
- setup do
37
- @class_names = @client.class_names(@op, Sfcc::Flags::DeepInheritance)
38
- end
39
-
40
- should "be a Cimc::Enumeration" do
41
- assert_kind_of(Sfcc::Cim::Enumeration, @class_names)
42
- end
43
-
44
- should "include CIM_ManagedElement" do
45
- assert !@class_names.select { |x| x.to_s == "CIM_ManagedElement" }.empty?
46
- end
47
-
48
- should "have every element of type Sfcc::Cim::ObjectPath" do
49
- @class_names.each { |n| assert_kind_of(Sfcc::Cim::ObjectPath, n) }
50
- end
51
- end
52
-
53
- context "classes" do
54
- setup do
55
- @classes = @client.classes(@op, Sfcc::Flags::DeepInheritance)
56
- end
57
-
58
- should "be a Cimc::Enumeration" do
59
- assert_kind_of(Sfcc::Cim::Enumeration, @classes)
60
- end
61
-
62
- should "have every alement of type Cimc::Class" do
63
- @classes.each { |c| assert_kind_of(Sfcc::Cim::Class, c) }
64
- end
65
- end
66
-
67
- end
68
- end
69
- end
@@ -1,53 +0,0 @@
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
-
@@ -1,164 +0,0 @@
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 a class from the object path" do
37
- @op = Sfcc::Cim::ObjectPath.new("root/cimv2", "Linux_OperatingSystem")
38
- cimclass = @client.get_class(@op)
39
- assert_kind_of Sfcc::Cim::Class, cimclass
40
- end
41
-
42
- should "report error when getting invalid class" do
43
- @op = Sfcc::Cim::ObjectPath.new("root/cimv2", "NotExistingClass")
44
- assert_raise Sfcc::Cim::ErrorNotFound do
45
- cimclass = @client.get_class(@op)
46
- end
47
- end
48
-
49
- should "be able to get an instance from the object path" do
50
- @op = Sfcc::Cim::ObjectPath.new("root/cimv2", "Linux_OperatingSystem")
51
- instance = @client.query(@op, "select * from Linux_OperatingSystem", "wql").to_a.first
52
- instance2 = @client.get_instance(instance.object_path)
53
- assert_kind_of Sfcc::Cim::Instance, instance2
54
- end
55
-
56
- should "be able to create an instance" do
57
- op = Sfcc::Cim::ObjectPath.new("root/cimv2", "Linux_OperatingSystem")
58
- instance = Sfcc::Cim::Instance.new(op)
59
- assert_raise Sfcc::Cim::ErrorNotSupported do
60
- new_op = @client.create_instance(op, instance)
61
- end
62
- end
63
-
64
- should "be able to set an instance" do
65
- @op = Sfcc::Cim::ObjectPath.new("root/cimv2", "Linux_OperatingSystem")
66
- instance = @client.query(@op, "select * from Linux_OperatingSystem", "wql").to_a.first
67
- assert_raise Sfcc::Cim::ErrorNotSupported do
68
- instance = @client.set_instance(instance.object_path, instance)
69
- end
70
- end
71
-
72
- should "be able to delete an instance" do
73
- instance = @client.query(@op, "select * from Linux_OperatingSystem", "wql").to_a.first
74
- assert_raise Sfcc::Cim::ErrorNotSupported do
75
- @client.delete_instance(instance.object_path)
76
- end
77
- end
78
-
79
- should "be able to get associator for an instance" do
80
- op = Sfcc::Cim::ObjectPath.new("root/cimv2", "")
81
- op = @client.query(op, "select * from CIM_ComputerSystem", "wql").to_a.first.object_path
82
- associators = @client.associators(op, 'CIM_RunningOS').to_a
83
- assert !associators.empty?
84
- associators.each { |assoc| assert_kind_of Sfcc::Cim::Instance, assoc }
85
- pp associators
86
- end
87
-
88
- should "be able to get associator names for an instance" do
89
- op = Sfcc::Cim::ObjectPath.new("root/cimv2", "")
90
- op = @client.query(op, "select * from CIM_ComputerSystem", "wql").to_a.first.object_path
91
- associators = @client.associator_names(op, 'CIM_RunningOS').to_a
92
- assert !associators.empty?
93
- associators.each { |assoc| assert_kind_of Sfcc::Cim::ObjectPath, assoc }
94
- pp associators
95
- end
96
-
97
- should "be able to get references for an instance" do
98
- op = Sfcc::Cim::ObjectPath.new("root/cimv2", "")
99
- op = @client.query(op, "select * from CIM_OperatingSystem", "wql").to_a.first.object_path
100
- associators = @client.references(op, 'CIM_RunningOS').to_a
101
- assert !associators.empty?
102
- associators.each { |assoc| assert_kind_of Sfcc::Cim::Instance, assoc }
103
- pp associators
104
- end
105
-
106
- should "be able to get reference names for an instance" do
107
- op = Sfcc::Cim::ObjectPath.new("root/cimv2", "")
108
- op = @client.query(op, "select * from CIM_OperatingSystem", "wql").to_a.first.object_path
109
- associators = @client.reference_names(op, 'CIM_RunningOS').to_a
110
- assert !associators.empty?
111
- associators.each { |assoc| assert_kind_of Sfcc::Cim::ObjectPath, assoc }
112
- pp associators
113
- end
114
-
115
- should "be able to invoke methods using an object path" do
116
- @op = Sfcc::Cim::ObjectPath.new("root/cimv2", "Linux_OperatingSystem")
117
- @client.query(@op, "select * from Linux_OperatingSystem", "wql").each do |instance|
118
- # @client.instances(@op, Sfcc::Flags::IncludeClassOrigin | Sfcc::Flags::IncludeQualifiers, nil).each do |instance|
119
- path = instance.object_path
120
- assert_kind_of Sfcc::Cim::ObjectPath, path
121
- out = {}
122
- ret = @client.invoke_method(path, :execCmd, {:cmd => "cat /etc/SuSE-release"}, out)
123
- assert out.has_key?(:out), "output parameter is present"
124
- assert out[:out].match(/VERSION/)
125
- assert_equal 0, ret, "execCmd returns 0"
126
- end
127
- end
128
-
129
- context "class names" do
130
- setup do
131
- @class_names = @client.class_names(@op, Sfcc::Flags::DeepInheritance)
132
- end
133
-
134
- should "be a Cimc::Enumeration" do
135
- assert_kind_of(Sfcc::Cim::Enumeration, @class_names)
136
- end
137
-
138
- should "include CIM_ManagedElement" do
139
- assert !@class_names.select { |x| x.to_s == "CIM_ManagedElement" }.empty?
140
- end
141
-
142
- should "have every element of type Sfcc::Cim::ObjectPath" do
143
- @class_names.each { |n| assert_kind_of(Sfcc::Cim::ObjectPath, n) }
144
- end
145
- end
146
-
147
- context "classes" do
148
- setup do
149
- @classes = @client.classes(@op, Sfcc::Flags::DeepInheritance)
150
- end
151
-
152
- should "be a Cimc::Enumeration" do
153
- assert_kind_of(Sfcc::Cim::Enumeration, @classes)
154
- end
155
-
156
- should "have every alement of type Cimc::Class" do
157
- @classes.each { |c| assert_kind_of(Sfcc::Cim::Class, c) }
158
- end
159
- end
160
-
161
- end
162
-
163
- end
164
-
@@ -1,24 +0,0 @@
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
-
@@ -1,89 +0,0 @@
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
-
@@ -1,85 +0,0 @@
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