megam_api 0.81 → 0.82

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c7466e46e439d0da4cf472e1b19dd2841efcd2eb
4
- data.tar.gz: e9916130b60222949e521bf5d49ad678480b0acf
3
+ metadata.gz: 0aabc47d2b9470f5e1124a0ca4462c079559c02e
4
+ data.tar.gz: 206edc529af7e41803d383ee00155cbd70ea6bc3
5
5
  SHA512:
6
- metadata.gz: 2dec71bf5241d1a3311698cf48e15cfbe20c343188993dbb1bcdd003d6a198f3850c4a59f8ec31e30869c70ee389e131277bc711ba1bab3bca630049e3781dac
7
- data.tar.gz: 07bf76ee7a910c200503f130d86ac87c5aeaa786281a10964f6d4cccc9104308a735485d90d97d66703859274f3b465a3ee07f5189ff9aef3c9087c1d219fc4d
6
+ metadata.gz: 843a3be8d21e1fd528f1a9af2498f2d412c9b6fe3f5af8358c2251ef3b0558566f8480f1102377dd02d5aa8f9100ea42d8f0a18d22255d83b09be1ae6a846024
7
+ data.tar.gz: d28f35f170b43a93f4cb354019020a644c645e721200b141f14167006551d24c2b20daa9b7b185ee9e8166f2c2fa78efb00afac9924f6edf3bb43986fe69f574
data/.gitignore CHANGED
@@ -1,6 +1,7 @@
1
1
  *.gem
2
2
  *.rbc
3
3
  .bundle
4
+ .project
4
5
  .config
5
6
  coverage
6
7
  Gemfile.lock
data/.project CHANGED
@@ -12,6 +12,7 @@
12
12
  </buildCommand>
13
13
  </buildSpec>
14
14
  <natures>
15
+ <nature>com.aptana.projects.webnature</nature>
15
16
  <nature>com.aptana.ruby.core.rubynature</nature>
16
17
  </natures>
17
18
  </projectDescription>
@@ -1,5 +1,5 @@
1
1
  module Megam
2
2
  class API
3
- VERSION = "0.81"
3
+ VERSION = "0.82"
4
4
  end
5
5
  end
@@ -4,12 +4,11 @@ module Megam
4
4
  class Mixins
5
5
  class Assemblies
6
6
  attr_reader :assembly
7
-
8
7
  def initialize(params)
9
8
  @assembly = Assembly.new(params)
10
9
  end
11
10
 
12
- def to_hash
11
+ def to_hash
13
12
  assembly.to_hash
14
13
  end
15
14
  end
@@ -5,10 +5,10 @@ require File.expand_path("#{File.dirname(__FILE__)}/outputs")
5
5
  module Megam
6
6
  class Mixins
7
7
  class Assembly
8
- attr_reader :components, :policies, :outputs, :mixins
9
-
8
+ attr_reader :name, :components, :policies, :outputs, :mixins
10
9
  def initialize(params)
11
- params = Hash[params.map{ |k, v| [k.to_sym, v] }]
10
+ params = Hash[params.map{ |k, v| [k.to_sym, v] }]
11
+ @name = params[:assemblyname]
12
12
  @mixins = CommonDeployable.new(params)
13
13
  @outputs = Outputs.new(params)
14
14
  @components = add_components(params)
@@ -17,6 +17,7 @@ module Megam
17
17
 
18
18
  def to_hash
19
19
  result = @mixins.to_hash
20
+ result[:name] = @name if @name
20
21
  result[:components] = @components if @components
21
22
  result[:outputs] = @outputs.to_array if @outputs
22
23
  result[:policies] = @policies if @policies
@@ -24,16 +25,17 @@ module Megam
24
25
  end
25
26
 
26
27
  private
28
+
27
29
  # If @components_enabled for type
28
- def components_enabled?
29
- true # enable if its not a TORPEDO
30
+ def components_enabled?(params)
31
+ true if params[:cattype] != 'TORPEDO'.freeze
30
32
  end
31
33
 
32
34
  def add_components(params)
33
- unless components_enabled?
34
- @components = Components.new(params)
35
- else
36
- @components = []
35
+ if components_enabled?(params)
36
+ @components = Components.new(params).to_a
37
+ else
38
+ @components = []
37
39
  end
38
40
  end
39
41
 
@@ -4,47 +4,43 @@ module Megam
4
4
  class Mixins
5
5
  class CommonDeployable
6
6
  include Nilavu::MegamAttributes
7
- attr_reader :assemblyname, :componentname, :status, :inputs, :tosca_type
7
+ attr_reader :status, :inputs, :tosca_type
8
8
 
9
- DEFAULT_TOSCA_PREFIX = 'tosca'.freeze
10
- # this is a mutable string, if nothing exists then we use ubuntu
11
- DEFAULT_TOSCA_SUFFIX = 'ubuntu'.freeze
9
+ DEFAULT_TOSCA_PREFIX = 'tosca'.freeze
10
+ # this is a mutable string, if nothing exists then we use ubuntu
11
+ DEFAULT_TOSCA_SUFFIX = 'ubuntu'.freeze
12
12
 
13
13
  ATTRIBUTES = [
14
- :assemblyname,
15
- :componentname,
16
14
  :tosca_type,
17
15
  :status,
18
16
  :inputs]
19
17
 
20
- def attributes
21
- ATTRIBUTES
22
- end
18
+ def attributes
19
+ ATTRIBUTES
20
+ end
21
+
23
22
  def initialize(params)
24
- @assemblyname = ""
25
23
  @tosca_type = ""
26
24
  @status = "launching"
27
- bld_toscatype(params)
25
+ bld_toscatype(params)
28
26
  @inputs = InputGroupData.new(params)
29
27
  set_attributes(params)
30
28
  end
31
29
 
32
-
33
30
  def to_hash
34
31
  h = {
35
- :name => assemblyname,
36
32
  :status => status,
37
33
  :tosca_type => tosca_type,
38
- :inputs => inputs.to_hash
34
+ :inputs => inputs.to_hash
39
35
  }
40
36
  end
41
37
 
42
- def bld_toscatype(mkp)
43
- tosca_suffix = DEFAULT_TOSCA_SUFFIX
44
- tosca_suffix = "#{mkp[:mkp_name]}" unless mkp[:cattype] != 'TORPEDO'.freeze
45
- @tosca_type = DEFAULT_TOSCA_PREFIX + ".#{mkp[:cattype].downcase}.#{mkp[:mkp_name].downcase}"
46
- end
47
- end
38
+ def bld_toscatype(params)
39
+ tosca_suffix = DEFAULT_TOSCA_SUFFIX
40
+ tosca_suffix = "#{params[:mkp_name]}" unless params[:cattype] != 'TORPEDO'.freeze
41
+ @tosca_type = DEFAULT_TOSCA_PREFIX + ".#{params[:cattype].downcase}.#{params[:mkp_name].downcase}"
42
+ end
43
+ end
48
44
 
49
45
  class InputGroupData
50
46
  include Nilavu::MegamAttributes
@@ -58,11 +54,11 @@ module Megam
58
54
  :hdd,
59
55
  :version,
60
56
  :display_name,
61
- :password]
57
+ :password]
62
58
 
63
- def attributes
64
- ATTRIBUTES
65
- end
59
+ def attributes
60
+ ATTRIBUTES
61
+ end
66
62
 
67
63
  def initialize(params)
68
64
  set_attributes(params)
@@ -1,73 +1,129 @@
1
1
  require File.expand_path("#{File.dirname(__FILE__)}/megam_attributes")
2
+ require File.expand_path("#{File.dirname(__FILE__)}/common_deployable")
3
+ require File.expand_path("#{File.dirname(__FILE__)}/outputs")
4
+
2
5
  module Megam
3
6
  class Mixins
4
7
  class Components
5
- attr_reader :mixins, :repo, :related_components, :operations, :artifacts
6
-
8
+ attr_reader :mixins, :name, :repo, :related_components, :operations, :artifacts, :outputs
7
9
  def initialize(params)
8
10
  @mixins = CommonDeployable.new(params)
9
- @artifacts = Outputs.new(params)
10
- add_repo(params)
11
- add_operations(params)
12
- add_related_components(params)
13
- add_artifacts(params)
11
+ @name = params[:componentname]
12
+ @outputs = Outputs.new(params)
13
+ @operations = add_operations(params)
14
+ @related_components = add_related_components(params)
15
+ @artifacts = add_artifacts(params)
16
+ @repo = add_repo(params)
17
+ end
18
+
19
+ def to_hash
20
+ result = @mixins.to_hash
21
+ result[:name] = @name if @name
22
+ result[:artifacts] = @artifacts if @artifacts
23
+ result[:repo] = @repo if @repo
24
+ result[:operations] = @operations if @operations
25
+ result[:outputs] = @outputs.to_array if @outputs
26
+ result[:related_components] = @related_components if @related_components
27
+ result
14
28
  end
15
29
 
30
+ def to_a
31
+ [to_hash]
32
+ end
33
+
16
34
  private
35
+
17
36
  def add_repo(params)
37
+ Repo.new(params).tohash
18
38
  end
19
39
 
20
40
  def add_related_components(params)
21
- related_components = [ "#{params[:assemblyname]}.#{params[:domain]}/#{params[:componentname]}"]
41
+ related_components = []
42
+ related_components << "#{params[:assemblyname]}.#{params[:domain]}/#{params[:componentname]}" if params.key?(:bind_type)
22
43
  end
23
44
 
24
45
  def add_operations(params)
25
- create_operation(Operations.CI, Operations.CI_DESCRIPTON, [:type, :token, :username])
26
- create_operation(Operations.BIND, Operations.BIND_DESCRIPTON, [:type, :token, :username])
46
+ operations = []
47
+ operations.push(create_operation(Operations::CI, Operations::CI_DESCRIPTON, params)) unless params[:scm_name].strip.empty?
48
+ operations.push(create_operation(Operations::BIND, Operations::BIND_DESCRIPTON, params)) if params.key?(:bind_type)
27
49
  end
28
50
 
29
- def create_operation(type, desc,properties)
30
- Operations.new.add_operation(type, desc, properties)
51
+ def create_operation(type, desc, params)
52
+ Operations.new(params, type, desc).tohash
31
53
  end
32
54
 
33
55
  def add_artifacts(params)
56
+ Artifacts.new(params).tohash
34
57
  end
35
58
  end
36
59
 
37
60
  class Repo
38
- include Nilavu::MegamAttributes
61
+ include Nilavu::MegamAttributes
62
+ attr_reader :type, :source, :url, :oneclick
39
63
  ATTRIBUTES = [
40
64
  :type,
41
65
  :source,
42
66
  :oneclick,
43
- :url]
67
+ :url]
68
+
69
+ def attributes
70
+ ATTRIBUTES
71
+ end
44
72
 
45
73
  def initialize(params)
46
74
  set_attributes(params)
75
+ @type = params[:type]
76
+ @source = params[:scm_name]
77
+ @url = params[:source]
78
+ @oneclick = params[:oneclick]
47
79
  end
80
+
81
+ def tohash
82
+ { :rtype => @type,
83
+ :source => @source,
84
+ :oneclick => @oneclick,
85
+ :url => @url
86
+ }
87
+ end
88
+
48
89
  end
49
90
 
50
91
  class Operations
51
92
  include Nilavu::MegamAttributes
93
+ attr_reader :type, :desc, :prop
94
+
52
95
  ATTRIBUTES = []
53
96
 
54
- CI = "ci".freeze
97
+ CI = "CI".freeze
55
98
  CI_DESCRIPTON = "always up to date code. sweet."
56
99
 
57
- def initialize(params)
58
- set_attributes(params)
100
+ BIND = "bind".freeze
101
+ BIND_DESCRIPTON = "bind. sweet."
102
+ def initialize(params,type, desc)
103
+ @type = type
104
+ @desc = desc
105
+ #set_attributes(params)
106
+ @prop = prop(params)
59
107
  end
60
108
 
61
- def add_operation(type, desc, properties)
62
- ATTRIBUTES.merge(properties)
63
- set_attributes(properties)
109
+ def attributes
110
+ ATTRIBUTES
64
111
  end
65
112
 
66
- def to_hash
67
- #{ 'type' => 'ci',
68
- # 'description' => 'Continous Integration',
69
- # 'properties' => self.to_hash
113
+ def tohash
114
+ { :operation_type => @type,
115
+ :description => @desc,
116
+ :properties => @prop
117
+ }
70
118
  end
119
+ #Key_name mismatch. Key_name is to be changed.
120
+ def prop(params)
121
+ op = []
122
+ op << { 'key' => 'type', 'value' => params[:scm_name] }
123
+ op << { 'key' => 'token', 'value' => params[:scmtoken] || '' }
124
+ op << { 'key' => 'username', 'value' => params[:scmowner] || '' }
125
+ op
126
+ end
71
127
  end
72
128
 
73
129
  class Artifacts
@@ -75,11 +131,22 @@ module Megam
75
131
  ATTRIBUTES = [
76
132
  :type,
77
133
  :content,
78
- :requirements]
134
+ :requirements]
135
+
136
+ def attributes
137
+ ATTRIBUTES
138
+ end
79
139
 
80
140
  def initialize(params)
81
141
  set_attributes(params)
82
142
  end
143
+
144
+ def tohash
145
+ { :artifact_type => "",
146
+ :content => "",
147
+ :requirements => []
148
+ }
149
+ end
83
150
  end
84
151
  end
85
152
  end
@@ -1,20 +1,18 @@
1
1
  module Nilavu
2
2
  module MegamAttributes
3
3
  ATTRIBUTES = []
4
- KEY = "key".freeze
5
- VALUE = "value".freeze
4
+ KEY = "key".freeze
5
+ VALUE = "value".freeze
6
6
  attr_accessor *ATTRIBUTES
7
+ def attributes
8
+ NotImplementedError
9
+ end
7
10
 
8
- def attributes
9
- NotImplementedError
10
- end
11
11
  def initialize(control_data={})
12
12
  set_attributes(control_data)
13
13
  end
14
14
 
15
15
  def set_attributes(control_data)
16
- #control_data.symbolize_keys!
17
- #control_data = Hash[control_data.map{ |k, v| [k.to_sym, v] }]
18
16
  attributes.each { |a| instance_variable_set("@#{a}", control_data[a]) unless control_data[a].nil? }
19
17
  end
20
18
 
@@ -1,24 +1,24 @@
1
1
  require File.expand_path("#{File.dirname(__FILE__)}/megam_attributes")
2
- module Megam
3
- class Outputs
4
- include Nilavu::MegamAttributes
5
-
6
- attr_reader :nodeip, :publicip, :privateip, :lastsuccessfulupdate, :laststatus
7
2
 
8
- ATTRIBUTES = [
9
- ]
3
+ module Megam
4
+ class Outputs
5
+ include Nilavu::MegamAttributes
10
6
 
11
- def attributes
12
- ATTRIBUTES
13
- end
7
+ attr_reader :nodeip, :publicip, :privateip, :lastsuccessfulupdate, :laststatus
14
8
 
15
- def initialize(params)
16
- set_attributes(params)
17
- end
9
+ ATTRIBUTES = [
10
+ ]
11
+ def attributes
12
+ ATTRIBUTES
13
+ end
18
14
 
19
- def to_array
20
- array = []
21
- end
15
+ def initialize(params)
16
+ set_attributes(params)
17
+ end
22
18
 
19
+ def to_array
20
+ array = []
23
21
  end
22
+
23
+ end
24
24
  end
@@ -6,35 +6,39 @@ require 'minitest/autorun'
6
6
  require File.expand_path("#{File.dirname(__FILE__)}/../../lib/megam/mixins/assemblies")
7
7
  class TestMixinsAssemblies < MiniTest::Unit::TestCase
8
8
 
9
+ #=begin
9
10
  def test_torpedo
10
11
  ## input the torpedo hash
11
12
  tmp_hash = {"utf8"=>"✓", "mkp_name" => "ubuntu", "cattype":"TORPEDO", "version":"14.04", "assemblyname"=>"biblical", "domain"=>"megambox.com", "ram"=>"896", "cpu"=>"0.5", "SSH_USEOLD_name"=>"tom", "SSH_NEW_name"=>"", "sshoption"=>"SSH_USEOLD", "provider"=>"one", "componentname"=>"ovid", "commit"=>" Create ", "controller"=>"marketplaces", "action"=>"create", "email"=>"8@8.com", "api_key"=>"-NQi-aSKHcmKntCsXb03jw==", "host"=>"192.168.1.105", "org_id"=>"ORG1270367691894554624", "ssh_keypair_name"=>"tom", "name"=>"tom", "path"=>"8@8.com_tom"}
12
- assembly_array = Megam::Mixins::Assemblies.new(tmp_hash).to_array
13
+
14
+ #{"utf8"=>"✓", "version"=>"14.04", "mkp_name"=>"ubuntu", "cattype"=>"TORPEDO", "assemblyname"=>"implanting", "domain"=>"megambox.com", "ram"=>"896", "cpu"=>"0.5", "SSH_USEOLD_name"=>"tom", "SSH_NEW_name"=>"", "sshoption"=>"SSH_USEOLD", "provider"=>"one", "componentname"=>"sad", "commit"=>" Create "}
15
+
16
+
17
+ #assemblies: [{"status"=>"launching", "tosca_type"=>"tosca.torpedo.ubuntu", "inputs"=>[{"key"=>"domain", "value"=>"megambox.com"}, {"key"=>"provider", "value"=>"one"}, {"key"=>"cpu", "value"=>"0.5"}, {"key"=>"ram", "value"=>"896"}, {"key"=>"version", "value"=>"14.04"}], "name"=>"implanting", "components"=>[], "outputs"=>[], "policies"=>[]}]
18
+
19
+
20
+
21
+ assembly_array = Megam::Mixins::Assemblies.new(tmp_hash).to_hash
13
22
  puts "=========================================> END <==============================================="
14
23
  puts assembly_array.inspect
15
24
 
16
25
  #response = megams.post_billings(tmp_hash)
17
26
  #assert_equal(201, response.status)
18
27
  end
28
+ #=end
19
29
  =begin
20
30
  def test_app_starterpack
21
31
  ## input the torpedo hash
22
- tmp_hash = { :accounts_id => "ACT93476985797",
23
- :line1 => "paypal",
24
- :line2 => "#kjbh76",
25
- :country_code => "",
26
- :postal_code => "",
27
- :state => "",
28
- :phone => "",
29
- :bill_type => ""
30
- }
32
+ tmp_hash = {"utf8"=>"✓", "version"=>"8.x", "mkp_name"=>"Java", "cattype"=>"APP", "componentname"=>"marine", "sshoption"=>"SSH_NEW", "scm_name"=>"", "type"=>"source", "provider"=>"one", "assemblyname"=>"umiak", "domain"=>"megambox.com", "ram"=>"896", "cpu"=>"0.5", "radio_app_scm"=>"starter_pack", "source"=>"https://github.com/megamsys/java-spring-petclinic.git", "check_ci"=>"true", "starterpack_git"=>"https://github.com/megamsys/java-spring-petclinic.git", "SSH_NEW_name"=>"tom", "commit"=>" Create "}
31
33
 
32
- # comp_dable
33
- # compare the results
34
- response = megams.post_billings(tmp_hash)
35
- assert_equal(201, response.status)
36
- end
37
34
 
35
+
36
+ assembly_array = Megam::Mixins::Assemblies.new(tmp_hash).to_hash
37
+ puts "=========================================> END <==============================================="
38
+ puts assembly_array.inspect
39
+
40
+ end
41
+ =begin
38
42
  def test_app_git
39
43
  ## input the torpedo hash
40
44
  tmp_hash = { :accounts_id => "ACT93476985797",
@@ -1,56 +1,19 @@
1
- class TestMixinsComponent < MiniTest::Unit::TestCase
1
+ gem 'minitest' # ensure we are using the gem version
2
+ require 'minitest/autorun'
2
3
 
3
- def test_app
4
- ## input the torpedo hash
5
- tmp_hash = { :accounts_id => "ACT93476985797",
6
- :line1 => "paypal",
7
- :line2 => "#kjbh76",
8
- :country_code => "",
9
- :postal_code => "",
10
- :state => "",
11
- :phone => "",
12
- :bill_type => ""
13
- }
4
+ require File.expand_path("#{File.dirname(__FILE__)}/../../lib/megam/mixins/components")
14
5
 
15
- # comp_dable
16
- # compare the results
17
- response = megams.post_billings(tmp_hash)
18
- assert_equal(201, response.status)
19
- end
6
+ class TestMixinsComponent < MiniTest::Unit::TestCase
20
7
 
21
- def test_service
8
+ def test_app_starterpack
22
9
  ## input the torpedo hash
23
- tmp_hash = { :accounts_id => "ACT93476985797",
24
- :line1 => "paypal",
25
- :line2 => "#kjbh76",
26
- :country_code => "",
27
- :postal_code => "",
28
- :state => "",
29
- :phone => "",
30
- :bill_type => ""
31
- }
10
+ tmp_hash = {"utf8"=>"✓", "version"=>"8.x", "mkp_name"=>"Java", "cattype"=>"APP", "componentname"=>"marine", "sshoption"=>"SSH_NEW", "scm_name"=>"", "type"=>"source", "provider"=>"one", "assemblyname"=>"umiak", "domain"=>"megambox.com", "ram"=>"896", "cpu"=>"0.5", "radio_app_scm"=>"starter_pack", "source"=>"https://github.com/megamsys/java-spring-petclinic.git", "check_ci"=>"true", "starterpack_git"=>"https://github.com/megamsys/java-spring-petclinic.git", "SSH_NEW_name"=>"tom", "commit"=>" Create "}
32
11
 
33
- # comp_dable
34
- # compare the results
35
- response = megams.post_billings(tmp_hash)
36
- assert_equal(201, response.status)
37
- end
38
-
39
- def test_microservice
40
- ## input the torpedo hash
41
- tmp_hash = { :accounts_id => "ACT93476985797",
42
- :line1 => "paypal",
43
- :line2 => "#kjbh76",
44
- :country_code => "",
45
- :postal_code => "",
46
- :state => "",
47
- :phone => "",
48
- :bill_type => ""
49
- }
12
+ tmp_hash = Hash[tmp_hash.map{ |k, v| [k.to_sym, v] }]
13
+ assembly_array = Megam::Mixins::Components.new(tmp_hash).to_hash
14
+ puts "=========================================> END <==============================================="
15
+ puts assembly_array.inspect
50
16
 
51
- # comp_dable
52
- # compare the results
53
- response = megams.post_billings(tmp_hash)
54
- assert_equal(201, response.status)
55
17
  end
18
+
56
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: megam_api
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.81'
4
+ version: '0.82'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rajthilak, Kishorekumar Neelamegam, Thomas Alrin, Yeshwanth Kumar, Subash Sethurajan,