iib 0.0.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.
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ ################################################################################
2
+ #
3
+ # Copyright 2014
4
+ # Author Imran Shakir
5
+ #
6
+ # All rights reserved. This program and the accompanying materials
7
+ # are made available under the terms of the Eclipse Public License v1.0
8
+ # which accompanies this distribution, and is available at
9
+ # http://www.eclipse.org/legal/epl-v10.html
10
+ #
11
+ # Contributors:
12
+ # Imran Shakir - initial implementation
13
+ #
14
+ ################################################################################
15
+ source 'https://rubygems.org'
16
+
17
+ # Specify your gem's dependencies in iib.gemspec
18
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,203 @@
1
+ Eclipse Public License - v 1.0
2
+
3
+ THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
4
+ LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
5
+ CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
6
+
7
+ 1. DEFINITIONS
8
+
9
+ "Contribution" means:
10
+
11
+ a) in the case of the initial Contributor, the initial code and documentation
12
+ distributed under this Agreement, and
13
+ b) in the case of each subsequent Contributor:
14
+ i) changes to the Program, and
15
+ ii) additions to the Program;
16
+
17
+ where such changes and/or additions to the Program originate from and are
18
+ distributed by that particular Contributor. A Contribution 'originates'
19
+ from a Contributor if it was added to the Program by such Contributor
20
+ itself or anyone acting on such Contributor's behalf. Contributions do not
21
+ include additions to the Program which: (i) are separate modules of
22
+ software distributed in conjunction with the Program under their own
23
+ license agreement, and (ii) are not derivative works of the Program.
24
+
25
+ "Contributor" means any person or entity that distributes the Program.
26
+
27
+ "Licensed Patents" mean patent claims licensable by a Contributor which are
28
+ necessarily infringed by the use or sale of its Contribution alone or when
29
+ combined with the Program.
30
+
31
+ "Program" means the Contributions distributed in accordance with this
32
+ Agreement.
33
+
34
+ "Recipient" means anyone who receives the Program under this Agreement,
35
+ including all Contributors.
36
+
37
+ 2. GRANT OF RIGHTS
38
+ a) Subject to the terms of this Agreement, each Contributor hereby grants
39
+ Recipient a non-exclusive, worldwide, royalty-free copyright license to
40
+ reproduce, prepare derivative works of, publicly display, publicly
41
+ perform, distribute and sublicense the Contribution of such Contributor,
42
+ if any, and such derivative works, in source code and object code form.
43
+ b) Subject to the terms of this Agreement, each Contributor hereby grants
44
+ Recipient a non-exclusive, worldwide, royalty-free patent license under
45
+ Licensed Patents to make, use, sell, offer to sell, import and otherwise
46
+ transfer the Contribution of such Contributor, if any, in source code and
47
+ object code form. This patent license shall apply to the combination of
48
+ the Contribution and the Program if, at the time the Contribution is
49
+ added by the Contributor, such addition of the Contribution causes such
50
+ combination to be covered by the Licensed Patents. The patent license
51
+ shall not apply to any other combinations which include the Contribution.
52
+ No hardware per se is licensed hereunder.
53
+ c) Recipient understands that although each Contributor grants the licenses
54
+ to its Contributions set forth herein, no assurances are provided by any
55
+ Contributor that the Program does not infringe the patent or other
56
+ intellectual property rights of any other entity. Each Contributor
57
+ disclaims any liability to Recipient for claims brought by any other
58
+ entity based on infringement of intellectual property rights or
59
+ otherwise. As a condition to exercising the rights and licenses granted
60
+ hereunder, each Recipient hereby assumes sole responsibility to secure
61
+ any other intellectual property rights needed, if any. For example, if a
62
+ third party patent license is required to allow Recipient to distribute
63
+ the Program, it is Recipient's responsibility to acquire that license
64
+ before distributing the Program.
65
+ d) Each Contributor represents that to its knowledge it has sufficient
66
+ copyright rights in its Contribution, if any, to grant the copyright
67
+ license set forth in this Agreement.
68
+
69
+ 3. REQUIREMENTS
70
+
71
+ A Contributor may choose to distribute the Program in object code form under
72
+ its own license agreement, provided that:
73
+
74
+ a) it complies with the terms and conditions of this Agreement; and
75
+ b) its license agreement:
76
+ i) effectively disclaims on behalf of all Contributors all warranties
77
+ and conditions, express and implied, including warranties or
78
+ conditions of title and non-infringement, and implied warranties or
79
+ conditions of merchantability and fitness for a particular purpose;
80
+ ii) effectively excludes on behalf of all Contributors all liability for
81
+ damages, including direct, indirect, special, incidental and
82
+ consequential damages, such as lost profits;
83
+ iii) states that any provisions which differ from this Agreement are
84
+ offered by that Contributor alone and not by any other party; and
85
+ iv) states that source code for the Program is available from such
86
+ Contributor, and informs licensees how to obtain it in a reasonable
87
+ manner on or through a medium customarily used for software exchange.
88
+
89
+ When the Program is made available in source code form:
90
+
91
+ a) it must be made available under this Agreement; and
92
+ b) a copy of this Agreement must be included with each copy of the Program.
93
+ Contributors may not remove or alter any copyright notices contained
94
+ within the Program.
95
+
96
+ Each Contributor must identify itself as the originator of its Contribution,
97
+ if
98
+ any, in a manner that reasonably allows subsequent Recipients to identify the
99
+ originator of the Contribution.
100
+
101
+ 4. COMMERCIAL DISTRIBUTION
102
+
103
+ Commercial distributors of software may accept certain responsibilities with
104
+ respect to end users, business partners and the like. While this license is
105
+ intended to facilitate the commercial use of the Program, the Contributor who
106
+ includes the Program in a commercial product offering should do so in a manner
107
+ which does not create potential liability for other Contributors. Therefore,
108
+ if a Contributor includes the Program in a commercial product offering, such
109
+ Contributor ("Commercial Contributor") hereby agrees to defend and indemnify
110
+ every other Contributor ("Indemnified Contributor") against any losses,
111
+ damages and costs (collectively "Losses") arising from claims, lawsuits and
112
+ other legal actions brought by a third party against the Indemnified
113
+ Contributor to the extent caused by the acts or omissions of such Commercial
114
+ Contributor in connection with its distribution of the Program in a commercial
115
+ product offering. The obligations in this section do not apply to any claims
116
+ or Losses relating to any actual or alleged intellectual property
117
+ infringement. In order to qualify, an Indemnified Contributor must:
118
+ a) promptly notify the Commercial Contributor in writing of such claim, and
119
+ b) allow the Commercial Contributor to control, and cooperate with the
120
+ Commercial Contributor in, the defense and any related settlement
121
+ negotiations. The Indemnified Contributor may participate in any such claim at
122
+ its own expense.
123
+
124
+ For example, a Contributor might include the Program in a commercial product
125
+ offering, Product X. That Contributor is then a Commercial Contributor. If
126
+ that Commercial Contributor then makes performance claims, or offers
127
+ warranties related to Product X, those performance claims and warranties are
128
+ such Commercial Contributor's responsibility alone. Under this section, the
129
+ Commercial Contributor would have to defend claims against the other
130
+ Contributors related to those performance claims and warranties, and if a
131
+ court requires any other Contributor to pay any damages as a result, the
132
+ Commercial Contributor must pay those damages.
133
+
134
+ 5. NO WARRANTY
135
+
136
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN
137
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
138
+ IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE,
139
+ NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each
140
+ Recipient is solely responsible for determining the appropriateness of using
141
+ and distributing the Program and assumes all risks associated with its
142
+ exercise of rights under this Agreement , including but not limited to the
143
+ risks and costs of program errors, compliance with applicable laws, damage to
144
+ or loss of data, programs or equipment, and unavailability or interruption of
145
+ operations.
146
+
147
+ 6. DISCLAIMER OF LIABILITY
148
+
149
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY
150
+ CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL,
151
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION
152
+ LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
153
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
154
+ ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
155
+ EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY
156
+ OF SUCH DAMAGES.
157
+
158
+ 7. GENERAL
159
+
160
+ If any provision of this Agreement is invalid or unenforceable under
161
+ applicable law, it shall not affect the validity or enforceability of the
162
+ remainder of the terms of this Agreement, and without further action by the
163
+ parties hereto, such provision shall be reformed to the minimum extent
164
+ necessary to make such provision valid and enforceable.
165
+
166
+ If Recipient institutes patent litigation against any entity (including a
167
+ cross-claim or counterclaim in a lawsuit) alleging that the Program itself
168
+ (excluding combinations of the Program with other software or hardware)
169
+ infringes such Recipient's patent(s), then such Recipient's rights granted
170
+ under Section 2(b) shall terminate as of the date such litigation is filed.
171
+
172
+ All Recipient's rights under this Agreement shall terminate if it fails to
173
+ comply with any of the material terms or conditions of this Agreement and does
174
+ not cure such failure in a reasonable period of time after becoming aware of
175
+ such noncompliance. If all Recipient's rights under this Agreement terminate,
176
+ Recipient agrees to cease use and distribution of the Program as soon as
177
+ reasonably practicable. However, Recipient's obligations under this Agreement
178
+ and any licenses granted by Recipient relating to the Program shall continue
179
+ and survive.
180
+
181
+ Everyone is permitted to copy and distribute copies of this Agreement, but in
182
+ order to avoid inconsistency the Agreement is copyrighted and may only be
183
+ modified in the following manner. The Agreement Steward reserves the right to
184
+ publish new versions (including revisions) of this Agreement from time to
185
+ time. No one other than the Agreement Steward has the right to modify this
186
+ Agreement. The Eclipse Foundation is the initial Agreement Steward. The
187
+ Eclipse Foundation may assign the responsibility to serve as the Agreement
188
+ Steward to a suitable separate entity. Each new version of the Agreement will
189
+ be given a distinguishing version number. The Program (including
190
+ Contributions) may always be distributed subject to the version of the
191
+ Agreement under which it was received. In addition, after a new version of the
192
+ Agreement is published, Contributor may elect to distribute the Program
193
+ (including its Contributions) under the new version. Except as expressly
194
+ stated in Sections 2(a) and 2(b) above, Recipient receives no rights or
195
+ licenses to the intellectual property of any Contributor under this Agreement,
196
+ whether expressly, by implication, estoppel or otherwise. All rights in the
197
+ Program not expressly granted under this Agreement are reserved.
198
+
199
+ This Agreement is governed by the laws of the State of New York and the
200
+ intellectual property laws of the United States of America. No party to this
201
+ Agreement will bring a legal action under this Agreement more than one year
202
+ after the cause of action arose. Each party waives its rights to a jury trial in
203
+ any resulting litigation.
@@ -0,0 +1,69 @@
1
+ # IIB
2
+
3
+ Note that this is currently being developed against the IIB v10 Open Beta package install. A significant quantity of the functionality will not work at lower levels of IBM Integration Bus or Websphere Message Broker.
4
+
5
+ A ruby gem allowing you to interact with IBM Integration Bus resources, currently using either the REST interface or the CLI.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'iib'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install iib
20
+
21
+ ## Usage
22
+
23
+ To get a list of Integration Nodes on the local system:
24
+
25
+ require 'iib/node'
26
+
27
+ nodes = IIB::Node.get_all_local_nodes
28
+ nodes.each do |node|
29
+ puts node.name
30
+ end
31
+
32
+ To create an Integration Node locally:
33
+
34
+ node = IIB::Node.create_local_node("MY_EXAMPLE_NODE")
35
+ puts node.name
36
+
37
+ To delete a local Integration Node:
38
+
39
+ IIB::Node.delete_local_node("MY_EXAMPLE_NODE")
40
+
41
+ To get a local Integration Node:
42
+
43
+ node = IIB::Node.new(name: "MY_TEST_NODE")
44
+
45
+ To get a remote Integration Node:
46
+
47
+ node = IIB::Node.new(hostname: 'localhost', port: 4414)
48
+
49
+ To start an Integration Node:
50
+
51
+ node.start
52
+
53
+ To stop an Integration Node:
54
+
55
+ node.stop
56
+
57
+ To check if an Integration Node is running:
58
+
59
+ node.is_running
60
+
61
+ ## Contributing
62
+
63
+ Contributions are very welcome, and will help greatly in ensuring platform coverage and covering different versions on IBM Integration Bus and Websphere Message Broker!
64
+
65
+ 1. Fork it ( https://github.com/[my-github-username]/iib/fork )
66
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
67
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
68
+ 4. Push to the branch (`git push origin my-new-feature`)
69
+ 5. Create a new Pull Request
@@ -0,0 +1,16 @@
1
+ ################################################################################
2
+ #
3
+ # Copyright 2014
4
+ # Author Imran Shakir
5
+ #
6
+ # All rights reserved. This program and the accompanying materials
7
+ # are made available under the terms of the Eclipse Public License v1.0
8
+ # which accompanies this distribution, and is available at
9
+ # http://www.eclipse.org/legal/epl-v10.html
10
+ #
11
+ # Contributors:
12
+ # Imran Shakir - initial implementation
13
+ #
14
+ ################################################################################
15
+ require "bundler/gem_tasks"
16
+
@@ -0,0 +1,40 @@
1
+ ################################################################################
2
+ #
3
+ # Copyright 2014
4
+ # Author Imran Shakir
5
+ #
6
+ # All rights reserved. This program and the accompanying materials
7
+ # are made available under the terms of the Eclipse Public License v1.0
8
+ # which accompanies this distribution, and is available at
9
+ # http://www.eclipse.org/legal/epl-v10.html
10
+ #
11
+ # Contributors:
12
+ # Imran Shakir - initial implementation
13
+ #
14
+ ################################################################################
15
+
16
+ # coding: utf-8
17
+ lib = File.expand_path('../lib', __FILE__)
18
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
19
+ require 'iib/version'
20
+
21
+ Gem::Specification.new do |spec|
22
+ spec.name = "iib"
23
+ spec.version = IIB::VERSION
24
+ spec.authors = ["ishakir"]
25
+ spec.email = ["shakimra@uk.ibm.com"]
26
+ spec.summary = %q{Interact with IBM Integration Bus resources}
27
+ spec.description = %q{Allows you to interact with IBM Integration Bus resources using either the REST API of an Integration Node or the CLI}
28
+ spec.homepage = ""
29
+ spec.license = "MIT"
30
+
31
+ spec.files = `git ls-files -z`.split("\x0")
32
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
33
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
34
+ spec.require_paths = ["lib"]
35
+
36
+ spec.add_development_dependency "bundler", "~> 1.6"
37
+ spec.add_development_dependency "rake"
38
+
39
+ spec.add_runtime_dependency 'mixlib-shellout'
40
+ end
@@ -0,0 +1,26 @@
1
+ ################################################################################
2
+ #
3
+ # Copyright 2014
4
+ # Author Imran Shakir
5
+ #
6
+ # All rights reserved. This program and the accompanying materials
7
+ # are made available under the terms of the Eclipse Public License v1.0
8
+ # which accompanies this distribution, and is available at
9
+ # http://www.eclipse.org/legal/epl-v10.html
10
+ #
11
+ # Contributors:
12
+ # Imran Shakir - initial implementation
13
+ #
14
+ ################################################################################
15
+ require 'iib/version'
16
+ require 'mkmf'
17
+
18
+ module IIB
19
+
20
+ def self.check_local_iib_environment
21
+ if find_executable('iib').nil?
22
+ fail RuntimeError, "Could not find the 'iib' command on path"
23
+ end
24
+ end
25
+
26
+ end
@@ -0,0 +1,61 @@
1
+ ################################################################################
2
+ #
3
+ # Copyright 2014
4
+ # Author Imran Shakir
5
+ #
6
+ # All rights reserved. This program and the accompanying materials
7
+ # are made available under the terms of the Eclipse Public License v1.0
8
+ # which accompanies this distribution, and is available at
9
+ # http://www.eclipse.org/legal/epl-v10.html
10
+ #
11
+ # Contributors:
12
+ # Imran Shakir - initial implementation
13
+ #
14
+ ################################################################################
15
+ require 'iib'
16
+ require 'iib/node/cli'
17
+ require 'iib/node/rest'
18
+
19
+ require 'mixlib/shellout'
20
+
21
+ module IIB
22
+ module Node
23
+
24
+ def self.new(options)
25
+ return IIB::Node::REST.new(options) if options.has_key?(:hostname)
26
+ return IIB::Node::CLI.new(options) if options.has_key?(:name)
27
+ end
28
+
29
+ def self.get_all_local_nodes
30
+ IIB.check_local_iib_environment
31
+
32
+ iib_list = Mixlib::ShellOut.new("iib list -d 0")
33
+ iib_list.run_command
34
+
35
+ output = iib_list.stdout
36
+ matches = output.scan(/BIP8099I:\ Broker:\ ([^\ ]*)\ \ -\ \ ([^\n]*)/m)
37
+
38
+ matches.map do |match|
39
+ IIB::Node.new(type: :CLI,name: match[0])
40
+ end
41
+ end
42
+
43
+ def self.create_local_node(name)
44
+ IIB.check_local_iib_environment
45
+
46
+ iib_create_broker = Mixlib::ShellOut.new("iib createbroker #{name}")
47
+ iib_create_broker.run_command
48
+
49
+ return IIB::Node.new(type: :CLI, name: name)
50
+ end
51
+
52
+ def self.delete_local_node(name)
53
+ IIB.check_local_iib_environment
54
+
55
+ iib_delete_broker = Mixlib::ShellOut.new("iib deletebroker #{name}")
56
+
57
+ iib_delete_broker.run_command
58
+ end
59
+
60
+ end
61
+ end
@@ -0,0 +1,65 @@
1
+ ################################################################################
2
+ #
3
+ # Copyright 2014
4
+ # Author Imran Shakir
5
+ #
6
+ # All rights reserved. This program and the accompanying materials
7
+ # are made available under the terms of the Eclipse Public License v1.0
8
+ # which accompanies this distribution, and is available at
9
+ # http://www.eclipse.org/legal/epl-v10.html
10
+ #
11
+ # Contributors:
12
+ # Imran Shakir - initial implementation
13
+ #
14
+ ################################################################################
15
+ require 'mixlib/shellout'
16
+
17
+ require 'iib'
18
+
19
+ module IIB
20
+ module Node
21
+ class CLI
22
+ include IIB::Node
23
+
24
+ attr_reader :name
25
+
26
+ def initialize(options)
27
+ @name = options[:name]
28
+ end
29
+
30
+ def is_running
31
+ IIB.check_local_iib_environment
32
+ iib_list = Mixlib::ShellOut.new("iib list")
33
+ iib_list.run_command
34
+
35
+ iib_list.stdout.lines.each do |line|
36
+ return true if line =~ /^BIP1325I.*'#{name}'.*$/
37
+ return false if line =~ /^BIP1326I.*'#{name}'.*$/
38
+ end
39
+ end
40
+
41
+ def start
42
+ IIB.check_local_iib_environment
43
+ iib_start = Mixlib::ShellOut.new("iib start #{name}")
44
+ iib_start.run_command
45
+ end
46
+
47
+ def stop
48
+ IIB.check_local_iib_environment
49
+ iib_stop = Mixlib::ShellOut.new("iib stop #{name}")
50
+ iib_stop.run_command
51
+ end
52
+
53
+ def ==(other_object)
54
+ return name == other_object.name
55
+ end
56
+
57
+ private
58
+
59
+ def strip_mqsi_command_response(stdout)
60
+ matches = stdout =~ /^.*\n(.*)\n.*$/
61
+ end
62
+
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,69 @@
1
+ ################################################################################
2
+ #
3
+ # Copyright 2014
4
+ # Author Imran Shakir
5
+ #
6
+ # All rights reserved. This program and the accompanying materials
7
+ # are made available under the terms of the Eclipse Public License v1.0
8
+ # which accompanies this distribution, and is available at
9
+ # http://www.eclipse.org/legal/epl-v10.html
10
+ #
11
+ # Contributors:
12
+ # Imran Shakir - initial implementation
13
+ #
14
+ ################################################################################
15
+ require 'net/http'
16
+ require 'uri'
17
+
18
+ module IIB
19
+ module Node
20
+ class REST
21
+ include IIB::Node
22
+
23
+ attr_reader :port
24
+
25
+ def initialize(options)
26
+ @hostname = options[:hostname]
27
+ @port = options[:port]
28
+ end
29
+
30
+ def name
31
+ rest_json = get_rest_json
32
+ rest_json["name"]
33
+ end
34
+
35
+ def start
36
+ action_not_remotable
37
+ end
38
+
39
+ def stop
40
+ action_not_remotable
41
+ end
42
+
43
+ private
44
+
45
+ def get_rest_json
46
+ return @rest_json if !@rest_json.nil?
47
+ @rest_json = top_level_rest_call
48
+ end
49
+
50
+ def top_level_rest_call
51
+ uri = URI.parse("http://#{@hostname}:#{@port}/?depth=2")
52
+
53
+ request = Net::HTTP::Get.new(uri.to_s)
54
+ request.add_field('Accept', 'application/json')
55
+
56
+ response = Net::HTTP.new(uri.host, uri.port).start do |http|
57
+ http.request(request)
58
+ end
59
+
60
+ JSON.parse(response.body)
61
+ end
62
+
63
+ def action_not_remotable
64
+ fail RuntimeError, "This action is not available on a remote Integration Node"
65
+ end
66
+
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,17 @@
1
+ ################################################################################
2
+ #
3
+ # Copyright 2014
4
+ # Author Imran Shakir
5
+ #
6
+ # All rights reserved. This program and the accompanying materials
7
+ # are made available under the terms of the Eclipse Public License v1.0
8
+ # which accompanies this distribution, and is available at
9
+ # http://www.eclipse.org/legal/epl-v10.html
10
+ #
11
+ # Contributors:
12
+ # Imran Shakir - initial implementation
13
+ #
14
+ ################################################################################
15
+ module IIB
16
+ VERSION = "0.0.1"
17
+ end
@@ -0,0 +1,128 @@
1
+ ################################################################################
2
+ #
3
+ # Copyright 2014
4
+ # Author Imran Shakir
5
+ #
6
+ # All rights reserved. This program and the accompanying materials
7
+ # are made available under the terms of the Eclipse Public License v1.0
8
+ # which accompanies this distribution, and is available at
9
+ # http://www.eclipse.org/legal/epl-v10.html
10
+ #
11
+ # Contributors:
12
+ # Imran Shakir - initial implementation
13
+ #
14
+ ################################################################################
15
+ require 'spec_helper'
16
+
17
+ require 'iib/node'
18
+
19
+ NODE_NAME = "IIB_RUBY_TEST_NODE"
20
+
21
+ describe 'getting all local integration nodes' do
22
+
23
+ it 'should return an empty array when there are no nodes' do
24
+ node = IIB::Node.new(name: NODE_NAME)
25
+ node.stop
26
+ IIB::Node.delete_local_node(NODE_NAME)
27
+
28
+ expect(IIB::Node.get_all_local_nodes).to be_empty
29
+
30
+ IIB::Node.create_local_node(NODE_NAME)
31
+ node.start
32
+ end
33
+
34
+ it 'should have one created integration node' do
35
+ created_node = IIB::Node.new(name: NODE_NAME)
36
+ expect(IIB::Node.get_all_local_nodes).to include(created_node)
37
+ end
38
+
39
+ end
40
+
41
+ describe 'local integration node' do
42
+
43
+ it 'has a name' do
44
+ node = IIB::Node.new(name: NODE_NAME)
45
+ expect(node.name).to eq(NODE_NAME)
46
+ end
47
+
48
+ # it 'has a port' do
49
+ # node = IIB::Node.new(name: NODE_NAME)
50
+ # end
51
+
52
+ it 'can be stopped and started' do
53
+ node = IIB::Node.new(name: NODE_NAME)
54
+ node.stop
55
+ node.start
56
+ end
57
+
58
+ it 'can be running' do
59
+ node = IIB::Node.new(name: NODE_NAME)
60
+ expect(node.is_running).to be true
61
+ end
62
+
63
+ it 'can be not running' do
64
+ node = IIB::Node.new(name: NODE_NAME)
65
+ node.stop
66
+ expect(node.is_running).to be false
67
+ node.start
68
+ end
69
+
70
+ end
71
+
72
+ describe 'remote integration node' do
73
+
74
+ # it 'has a name' do
75
+ # node = IIB::Node.new(hostname: 'localhost', port: 4414)
76
+ # expect(node.name).to eq(NODE_NAME)
77
+ # end
78
+
79
+ it 'has a port' do
80
+ node = IIB::Node.new(hostname: 'localhost', port: 4414)
81
+ expect(node.port).to eq(4414)
82
+ end
83
+
84
+ it 'cannot be started' do
85
+ node = IIB::Node.new(hostname: 'localhost', port: 4414)
86
+ expect{node.start}.to raise_error(RuntimeError)
87
+ end
88
+
89
+ it 'cannot be stopped' do
90
+ node = IIB::Node.new(hostname: 'localhost', port: 4414)
91
+ expect{node.stop}.to raise_error(RuntimeError)
92
+ end
93
+
94
+ end
95
+
96
+ describe 'creating local integration nodes' do
97
+
98
+ it 'should return an IIB::Node object with the correct name' do
99
+ node_name = "IIB_RUBY_CREATE_TEST_NODE"
100
+ created_node = IIB::Node.create_local_node(node_name)
101
+
102
+ expect(created_node.name).to equal(node_name)
103
+ IIB::Node.delete_local_node(node_name)
104
+ end
105
+
106
+ end
107
+
108
+ describe 'deleting local integration nodes' do
109
+
110
+ it 'should correctly delete a created node' do
111
+ node_name = "IIB_RUBY_DELETE_TEST_NODE"
112
+ IIB::Node.create_local_node(node_name)
113
+ IIB::Node.delete_local_node(node_name)
114
+ expect(IIB::Node.get_all_local_nodes.size).to eq(1)
115
+ end
116
+
117
+ end
118
+
119
+ describe 'equals on integration nodes' do
120
+
121
+ it 'should equal if two local nodes have the same name' do
122
+ node_name = "RUBY_TEST_EQUALS_NODE"
123
+ node_one = IIB::Node.new(name: node_name)
124
+ node_two = IIB::Node.new(name: node_name)
125
+ expect(node_one).to eq(node_two)
126
+ end
127
+
128
+ end
@@ -0,0 +1,47 @@
1
+ ################################################################################
2
+ #
3
+ # Copyright 2014
4
+ # Author Imran Shakir
5
+ #
6
+ # All rights reserved. This program and the accompanying materials
7
+ # are made available under the terms of the Eclipse Public License v1.0
8
+ # which accompanies this distribution, and is available at
9
+ # http://www.eclipse.org/legal/epl-v10.html
10
+ #
11
+ # Contributors:
12
+ # Imran Shakir - initial implementation
13
+ #
14
+ ################################################################################
15
+ require 'iib/node'
16
+
17
+ RSpec.configure do |config|
18
+
19
+ config.fail_fast = true
20
+
21
+ config.before(:all) do
22
+
23
+ puts "Doing test setup"
24
+
25
+ # Create a local integration node for use (this is an expensive operation)
26
+ node = IIB::Node.create_local_node("IIB_RUBY_TEST_NODE")
27
+ node.start
28
+
29
+ end
30
+
31
+ config.after(:all) do
32
+
33
+ node = IIB::Node.new(name: "IIB_RUBY_TEST_NODE")
34
+ node.stop
35
+
36
+ # Delete the local integration node created in setup
37
+ IIB::Node.delete_local_node("IIB_RUBY_TEST_NODE")
38
+
39
+ end
40
+ end
41
+
42
+ IIB.check_local_iib_environment
43
+
44
+ # Check there are zero nodes on the machine
45
+ unless IIB::Node.get_all_local_nodes.empty?
46
+ fail RuntimeError, "Please only run the tests when there are no Integration Nodes defined in the local environment"
47
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: iib
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - ishakir
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-07-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.6'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.6'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
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: mixlib-shellout
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'
62
+ description: Allows you to interact with IBM Integration Bus resources using either
63
+ the REST API of an Integration Node or the CLI
64
+ email:
65
+ - shakimra@uk.ibm.com
66
+ executables: []
67
+ extensions: []
68
+ extra_rdoc_files: []
69
+ files:
70
+ - .gitignore
71
+ - Gemfile
72
+ - LICENSE
73
+ - README.md
74
+ - Rakefile
75
+ - iib.gemspec
76
+ - lib/iib.rb
77
+ - lib/iib/node.rb
78
+ - lib/iib/node/CLI.rb
79
+ - lib/iib/node/REST.rb
80
+ - lib/iib/version.rb
81
+ - spec/node_spec.rb
82
+ - spec/spec_helper.rb
83
+ homepage: ''
84
+ licenses:
85
+ - MIT
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubyforge_project:
104
+ rubygems_version: 1.8.24
105
+ signing_key:
106
+ specification_version: 3
107
+ summary: Interact with IBM Integration Bus resources
108
+ test_files:
109
+ - spec/node_spec.rb
110
+ - spec/spec_helper.rb