megam_api 0.17 → 0.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/lib/megam/api.rb +20 -35
  4. data/lib/megam/api/{nodes.rb → assemblies.rb} +9 -9
  5. data/lib/megam/api/domains.rb +30 -0
  6. data/lib/megam/api/organizations.rb +30 -0
  7. data/lib/megam/api/version.rb +1 -1
  8. data/lib/megam/core/assemblies.rb +180 -0
  9. data/lib/megam/core/{node_collection.rb → assemblies_collection.rb} +44 -65
  10. data/lib/megam/core/csar.rb +0 -1
  11. data/lib/megam/core/domains.rb +129 -0
  12. data/lib/megam/core/json_compat.rb +17 -4
  13. data/lib/megam/core/organizations.rb +129 -0
  14. data/test/test_accounts.rb +1 -1
  15. data/test/test_assemblies.rb +10 -0
  16. data/test/test_domains.rb +27 -0
  17. data/test/test_helper.rb +25 -16
  18. data/test/test_organizations.rb +26 -0
  19. metadata +12 -38
  20. data/lib/megam/api/app_request.rb +0 -27
  21. data/lib/megam/api/appdefns.rb +0 -47
  22. data/lib/megam/api/bolt_request.rb +0 -27
  23. data/lib/megam/api/boltdefns.rb +0 -39
  24. data/lib/megam/api/cloud_tools.rb +0 -35
  25. data/lib/megam/api/logs.rb +0 -18
  26. data/lib/megam/api/predefs.rb +0 -35
  27. data/lib/megam/builder/delete_node.rb +0 -107
  28. data/lib/megam/builder/make_node.rb +0 -133
  29. data/lib/megam/core/app_request.rb +0 -227
  30. data/lib/megam/core/app_request_collection.rb +0 -148
  31. data/lib/megam/core/appdefns.rb +0 -182
  32. data/lib/megam/core/appdefns_collection.rb +0 -148
  33. data/lib/megam/core/bolt_request.rb +0 -225
  34. data/lib/megam/core/bolt_request_collection.rb +0 -148
  35. data/lib/megam/core/boltdefns.rb +0 -207
  36. data/lib/megam/core/boltdefns_collection.rb +0 -148
  37. data/lib/megam/core/cloudinstruction.rb +0 -110
  38. data/lib/megam/core/cloudinstruction_collection.rb +0 -145
  39. data/lib/megam/core/cloudinstruction_group.rb +0 -99
  40. data/lib/megam/core/cloudtemplate.rb +0 -127
  41. data/lib/megam/core/cloudtemplate_collection.rb +0 -145
  42. data/lib/megam/core/cloudtool.rb +0 -152
  43. data/lib/megam/core/cloudtool_collection.rb +0 -145
  44. data/lib/megam/core/node.rb +0 -366
  45. data/lib/megam/core/predef.rb +0 -201
  46. data/lib/megam/core/predef_collection.rb +0 -164
  47. data/test/test_appdefns.rb +0 -35
  48. data/test/test_appreqs.rb +0 -25
  49. data/test/test_boltdefns.rb +0 -32
  50. data/test/test_boltreqs.rb +0 -26
  51. data/test/test_cloudtools.rb +0 -22
  52. data/test/test_nodes.rb +0 -140
  53. data/test/test_predefs.rb +0 -72
@@ -1,148 +0,0 @@
1
- # Copyright:: Copyright (c) 2012, 2014 Megam Systems
2
- # License:: Apache License, Version 2.0
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by boltlicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
- module Megam
17
- class BoltdefnsCollection
18
- include Enumerable
19
-
20
-
21
- attr_reader :iterator
22
- def initialize
23
- @boltdefns = Array.new
24
- @boltdefns_by_name = Hash.new
25
- @insert_after_idx = nil
26
- end
27
-
28
- def all_boltdefns
29
- @boltdefns
30
- end
31
-
32
- def [](index)
33
- @boltdefns[index]
34
- end
35
-
36
- def []=(index, arg)
37
- is_megam_boltdefn(arg)
38
- @boltdefns[index] = arg
39
- @boltdefns_by_name[arg.id] = index
40
- end
41
-
42
- def <<(*args)
43
- args.flatten.each do |a|
44
- is_megam_boltdefn(a)
45
- @boltdefns << a
46
- @boltdefns_by_name[a.id] = @boltdefns.length - 1
47
- end
48
- self
49
- end
50
-
51
- # 'push' is an alias method to <<
52
- alias_method :push, :<<
53
-
54
- def insert(boltdefn)
55
- is_megam_boltdefn(boltdefn)
56
- if @insert_after_idx
57
- # in the middle of executing a run, so any boltdefnss inserted now should
58
- # be placed after the most recent addition done by the currently executing
59
- # boltdefns
60
- @boltdefns.insert(@insert_after_idx + 1, boltdefn)
61
- # update name -> location mappings and register new boltdefns
62
- @boltdefns_by_name.each_key do |key|
63
- @boltdefns_by_name[key] += 1 if @boltdefns_by_name[key] > @insert_after_idx
64
- end
65
- @boltdefns_by_name[boltdefn.id] = @insert_after_idx + 1
66
- @insert_after_idx += 1
67
- else
68
- @boltdefns << boltdefn
69
- @boltdefns_by_name[boltdefn.id] = @boltdefns.length - 1
70
- end
71
- end
72
-
73
- def each
74
- @boltdefns.each do |boltdefn|
75
- yield boltdefn
76
- end
77
- end
78
-
79
- def each_index
80
- @boltdefns.each_index do |i|
81
- yield i
82
- end
83
- end
84
-
85
- def empty?
86
- @boltdefns.empty?
87
- end
88
-
89
- def lookup(boltdefn)
90
- lookup_by = nil
91
- if boltdefn.kind_of?(Megam::Boltdefns)
92
- lookup_by = boltdefn.id
93
- elsif boltdefn.kind_of?(String)
94
- lookup_by = boltdefn
95
- else
96
- raise ArgumentError, "Must pass a Megam::Boltdefns or String to lookup"
97
- end
98
- res = @boltdefns_by_name[lookup_by]
99
- unless res
100
- raise ArgumentError, "Cannot find a boltdefn matching #{lookup_by} (did you define it first?)"
101
- end
102
- @boltdefns[res]
103
- end
104
-
105
- # Transform the ruby obj -> to a Hash
106
- def to_hash
107
- index_hash = Hash.new
108
- self.each do |boltdefn|
109
- index_hash[boltdefn.id] = boltdefn.to_s
110
- end
111
- index_hash
112
- end
113
-
114
- # Serialize this object as a hash: called from JsonCompat.
115
- # Verify if this called from JsonCompat during testing.
116
- def to_json(*a)
117
- for_json.to_json(*a)
118
- end
119
-
120
-
121
- def self.json_create(o)
122
- collection = self.new()
123
- o["results"].each do |boltdefns_list|
124
- boltdefns_array = boltdefns_list.kind_of?(Array) ? boltdefns_list : [ boltdefns_list ]
125
- boltdefns_array.each do |boltdefn|
126
- collection.insert(boltdefn)
127
- end
128
- end
129
- collection
130
- end
131
-
132
- private
133
-
134
-
135
-
136
- def is_megam_boltdefn(arg)
137
- unless arg.kind_of?(Megam::Boltdefns)
138
- raise ArgumentError, "Members must be Megam::Boltdefn's"
139
- end
140
- true
141
- end
142
-
143
- def to_s
144
- Megam::Stuff.styled_hash(to_hash)
145
- end
146
-
147
- end
148
- end
@@ -1,110 +0,0 @@
1
- # Copyright:: Copyright (c) 2012, 2014 Megam Systems
2
- # License:: Apache License, Version 2.0
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
- module Megam
17
- class CloudInstruction
18
- def initialize
19
- @action = nil
20
- @command = nil
21
- @name = nil
22
- end
23
-
24
- def cloud_instruction
25
- self
26
- end
27
-
28
-
29
- def action(arg=nil)
30
- if arg != nil
31
- @action = arg
32
- else
33
- @action
34
- end
35
- end
36
-
37
- def command(arg=nil)
38
- if arg != nil
39
- @command = arg
40
- else
41
- @command
42
- end
43
- end
44
-
45
- def name(arg=nil)
46
- if arg != nil
47
- @name = arg
48
- else
49
- @name
50
- end
51
- end
52
-
53
- def error?
54
- crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
55
- end
56
-
57
- # Transform the ruby obj -> to a Hash
58
- def to_hash
59
- index_hash = Hash.new
60
- index_hash["json_claz"] = self.class.name
61
- index_hash["action"] = action
62
- index_hash["command"] = command
63
- index_hash["name"] = name
64
- index_hash
65
- end
66
-
67
- # Serialize this object as a hash: called from JsonCompat.
68
- # Verify if this called from JsonCompat during testing.
69
- def to_json(*a)
70
- for_json.to_json(*a)
71
- end
72
-
73
- def for_json
74
- result = {
75
- "action" => action,
76
- "command" => command,
77
- "name" => name
78
- }
79
- result
80
- end
81
-
82
- #
83
- def self.json_create(o)
84
- cloudinstruction = new
85
- cloudinstruction.action(o["action"]) if o.has_key?("action")
86
- cloudinstruction.command(o["command"]) if o.has_key?("command")
87
- cloudinstruction.name(o["name"]) if o.has_key?("name")
88
- cloudinstruction
89
- end
90
-
91
- def self.from_hash(o)
92
- cloudinstruction = self.new()
93
- cloudinstruction.from_hash(o)
94
- cloudinstruction
95
- end
96
-
97
- def from_hash(o)
98
- @action = o[:action] if o.has_key?(:action)
99
- @command = o[:command] if o.has_key?(:command)
100
- @name = o[:name] if o.has_key?(:name)
101
- self
102
- end
103
-
104
-
105
- def to_s
106
- Megam::Stuff.styled_hash(to_hash)
107
- end
108
-
109
- end
110
- end
@@ -1,145 +0,0 @@
1
- # Copyright:: Copyright (c) 2012, 2014 Megam Systems
2
- # License:: Apache License, Version 2.0
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
- module Megam
17
- class CloudInstructionCollection
18
- include Enumerable
19
-
20
- attr_reader :iterator
21
- def initialize
22
- @cloudinstructions = Array.new
23
- @cloudinstructions_by_name = Hash.new
24
- @insert_after_idx = nil
25
- end
26
-
27
- def all_cloudinstructions
28
- @cloudinstructions
29
- end
30
-
31
- def [](index)
32
- @cloudinstructions[index]
33
- end
34
-
35
- def []=(index, arg)
36
- is_megam_cloudinstruction(arg)
37
- @cloudinstructions[index] = arg
38
- @cloudinstructions_by_name[arg.action] = index
39
- end
40
-
41
- def <<(*args)
42
- args.flatten.each do |a|
43
- is_megam_cloudinstruction(a)
44
- @cloudinstructions << a
45
- @cloudinstructions_by_name[a.action] =@cloudinstructions.length - 1
46
- end
47
- self
48
- end
49
-
50
- # 'push' is an alias method to <<
51
- alias_method :push, :<<
52
-
53
- def insert(cloudinstruction)
54
- is_megam_cloudinstruction(cloudinstruction)
55
- if @insert_after_idx
56
- # in the middle of executing a run, so any predefs inserted now should
57
- # be placed after the most recent addition done by the currently executing
58
- # cloudinstructions
59
- @cloudinstructions.insert(@insert_after_idx + 1, cloudinstruction)
60
- # update name -> location mappings and register new cloudinstructions
61
- @cloudinstructions_by_name.each_key do |key|
62
- @cloudinstructions_by_name[key] += 1 if@cloudinstructions_by_name[key] > @insert_after_idx
63
- end
64
- @cloudinstructions_by_name[cloudinstruction.action] = @insert_after_idx + 1
65
- @insert_after_idx += 1
66
- else
67
- @cloudinstructions << cloudinstruction
68
- @cloudinstructions_by_name[cloudinstruction.action] =@cloudinstructions.length - 1
69
- end
70
- end
71
-
72
- def each
73
- @cloudinstructions.each do |cloudinstruction|
74
- yield cloudinstruction
75
- end
76
- end
77
-
78
- def each_index
79
- @cloudinstructions.each_index do |i|
80
- yield i
81
- end
82
- end
83
-
84
- def empty?
85
- @cloudinstructions.empty?
86
- end
87
-
88
- def lookup(cloudinstruction)
89
- lookup_by = nil
90
- if cloudinstruction.kind_of?(Megam::CloudInstruction)
91
- lookup_by = cloudinstruction.action
92
- elsif cloudinstruction.kind_of?(String)
93
- lookup_by = cloudinstruction
94
- else
95
- raise ArgumentError, "Must pass a Megam::CloudInstruction or String to lookup"
96
- end
97
- res =@cloudinstructions_by_name[lookup_by]
98
- unless res
99
- raise ArgumentError, "Cannot find a cloudinstruction matching #{lookup_by} (did you define it first?)"
100
- end
101
- @cloudinstructions[res]
102
- end
103
-
104
- # Transform the ruby obj -> to a Hash
105
- def to_hash
106
- index_hash = Hash.new
107
- self.each do |cloudinstruction|
108
- index_hash[cloudinstruction.action] = cloudinstruction
109
- end
110
- index_hash
111
- end
112
-
113
- # Serialize this object as a hash: called from JsonCompat.
114
- # Verify if this called from JsonCompat during testing.
115
- def to_json(*a)
116
- for_json.to_json(*a)
117
- end
118
-
119
-
120
- def self.json_create(o)
121
- collection = self.new()
122
- o["results"].each do |cloudinstructions_list|
123
- cloudinstructions_array = cloudinstructions_list.kind_of?(Array) ? cloudinstructions_list : [ cloudinstructions_list ]
124
- cloudinstructions_array.each do |cloudinstruction|
125
- collection.insert(cloudinstruction)
126
- end
127
- end
128
- collection
129
- end
130
-
131
- private
132
-
133
- def is_megam_cloudinstruction(arg)
134
- unless arg.kind_of?(Megam::CloudInstruction)
135
- raise ArgumentError, "Members must be Megam::CloudInstruction's"
136
- end
137
- true
138
- end
139
-
140
- def to_s
141
- Megam::Stuff.styled_hash(to_hash)
142
- end
143
-
144
- end
145
- end
@@ -1,99 +0,0 @@
1
- # Copyright:: Copyright (c) 2012, 2014 Megam Systems
2
- # License:: Apache License, Version 2.0
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
- module Megam
17
- class CloudInstructionGroup
18
- def initialize
19
- @group = nil
20
- @cloud_instructions_array = nil
21
- end
22
-
23
- def cloudinstruction_group
24
- self
25
- end
26
-
27
- def group(arg=nil)
28
- if arg != nil
29
- @group = arg
30
- else
31
- @group
32
- end
33
- end
34
-
35
- def cloud_instructions_array(arg=nil)
36
- if arg != nil
37
- @cloud_instructions_array = arg
38
- else
39
- @cloud_instructions_array
40
- end
41
- end
42
-
43
-
44
- def error?
45
- crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
46
- end
47
-
48
-
49
-
50
- # Transform the ruby obj -> to a Hash
51
- def to_hash
52
- index_hash = Hash.new
53
- index_hash["json_claz"] = self.class.name
54
- index_hash["group"] = group
55
- cloud_instructions_array.each do |single_cig|
56
- index_hash[""] = single_cig
57
- end
58
- index_hash
59
- end
60
-
61
- # Serialize this object as a hash: called from JsonCompat.
62
- # Verify if this called from JsonCompat during testing.
63
- def to_json(*a)
64
- for_json.to_json(*a)
65
- end
66
-
67
- def for_json
68
- result = {
69
- "group" => group
70
- }
71
- result
72
- end
73
-
74
- #
75
- def self.json_create(o)
76
- cloudinstruction_group = new
77
- cloudinstruction_group.group(o["group"]) if o.has_key?("group")
78
- cloudinstruction_group.cloud_instructions_array(o["results"]) if o.has_key?("results")
79
- cloudinstruction_group
80
- end
81
-
82
- def self.from_hash(o)
83
- cloudinstruction_group = self.new()
84
- cloudinstruction_group.from_hash(o)
85
- cloudinstruction_group
86
- end
87
-
88
- def from_hash(o)
89
- @group = o[:group] if o.has_key?(:group)
90
- @cloudinstructions = o[:cloud_instructions_array] if o.has_key?(:cloud_instructions_array)
91
- self
92
- end
93
-
94
- def to_s
95
- Megam::Stuff.styled_hash(to_hash)
96
- end
97
-
98
- end
99
- end