misty 0.8.0 → 0.9.0

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: 90247f6d9f8410d55769850fbb2e2e6332e35e7d
4
- data.tar.gz: 73c5cb98cf6826bfe7256e90e592498b25ab9500
3
+ metadata.gz: 24c73d4734cffeffc4b5260e68049b134bcde705
4
+ data.tar.gz: 6e17bf750a43f0adbab5750f3f8579d8d035c1b0
5
5
  SHA512:
6
- metadata.gz: d0cc5cfae68ecfe28122303f1f7b0a909faf9baf33441db4d85700e2e86c08f68e4dba0465476621a91b63eb1c7d1fe4530b9cf7f4753438c1bdb6b448d1bce5
7
- data.tar.gz: bb19851c6bd284bc0ef9d74eb740f84300f714fb33beb6ee16b6f94e3d86630bb59d622270ef3daed9d54753681b8b9cfbb5e3143638f5b0de23ba40b06be5c2
6
+ metadata.gz: be429bac2cfad875eb096de5f59d96dd0c84693127ded8c7ae9e08261076f1dcb5e61970b1f53d8c372f39a1610747532ed37e0b42065fe07b972af42a878ba9
7
+ data.tar.gz: ad4c281505bcdfb97c3d89121246642a91b21281b664351798848b6838a4520381d4803fbce31afe1904a407e71c3ddf9f3e4fe065a4a9192f7a629171946e1e
data/lib/misty/cloud.rb CHANGED
@@ -33,11 +33,10 @@ module Misty
33
33
 
34
34
  def build_service(service_name)
35
35
  service = Misty.services.find {|service| service.name == service_name}
36
- service.options = @params[service.name] if @params[service.name]
37
- service.version = service.options[:api_version]
38
- version = self.class.dot_to_underscore(service.version)
36
+ options = @params[service.name] ? @params[service.name] : {}
37
+ version = self.class.dot_to_underscore(service.version(options[:api_version]))
39
38
  klass = Object.const_get("Misty::Openstack::#{service.project.capitalize}::#{version.capitalize}")
40
- klass.new(@auth, @config, service.options)
39
+ klass.new(@auth, @config, options)
41
40
  end
42
41
 
43
42
  def application_catalog
@@ -68,24 +67,24 @@ module Misty
68
67
  @compute ||= build_service(:compute)
69
68
  end
70
69
 
71
- def container
72
- @container ||= build_service(:container)
70
+ def container_infrastructure_management
71
+ @container_infrastructure_management ||= build_service(:container_infrastructure_management)
73
72
  end
74
73
 
75
74
  def data_processing
76
75
  @data_processing ||= build_service(:data_processing)
77
76
  end
78
77
 
79
- def data_protection
80
- @data_protection ||= build_service(:data_protection)
78
+ def data_protection_orchestration
79
+ @data_protection_orchestration ||= build_service(:data_protection_orchestration)
81
80
  end
82
81
 
83
82
  def database
84
83
  @database ||= build_service(:database)
85
84
  end
86
85
 
87
- def dns
88
- @dns ||= build_service(:dns)
86
+ def domain_name_server
87
+ @domain_name_server ||= build_service(:domain_name_server)
89
88
  end
90
89
 
91
90
  def identity
@@ -132,6 +131,9 @@ module Misty
132
131
  @shared_file_systems ||= build_service(:shared_file_systems)
133
132
  end
134
133
 
134
+ alias container container_infrastructure_management
135
+ alias data_protection data_protection_orchestration
136
+ alias dns domain_name_server
135
137
  alias volume block_storage
136
138
 
137
139
  private
@@ -6,12 +6,12 @@ module Misty
6
6
  http_options = {}
7
7
  if uri.scheme == 'https'
8
8
  http_options[:use_ssl] = true
9
- if options[:ssl_verify_mode] && options[:ssl_verify_mode] == false
9
+ if options.fetch(:ssl_verify_mode, true) == false
10
10
  http_options[:verify_mode] = OpenSSL::SSL::VERIFY_NONE
11
11
  end
12
12
  end
13
13
 
14
- Net::HTTP.start(uri.host, uri.port, http_options) do |connection|
14
+ Net::HTTP.start(uri.host, uri.port, :ENV, http_options) do |connection|
15
15
  yield(connection)
16
16
  end
17
17
  end
data/lib/misty/misty.rb CHANGED
@@ -1,58 +1,63 @@
1
1
  require 'misty/services'
2
2
 
3
3
  module Misty
4
+ SERVICES = [
5
+ { name: :application_catalog, project: :murano, versions: ['v1']},
6
+ { name: :alarming, project: :aodh, versions: ['v2']},
7
+ { name: :backup, project: :freezer, versions: ['v1']},
8
+ { name: :baremetal, project: :ironic, versions: nil, microversion: 'v1'},
9
+ { name: :block_storage, project: :cinder, versions: ['v2', 'v1'], microversion: 'v3'},
10
+ { name: :clustering, project: :senlin, versions: ['v1']},
11
+ { name: :compute, project: :nova, versions: nil, microversion: 'v2.1'},
12
+ { name: :container_infrastructure_management, project: :magnum, versions: nil, microversion: 'v1'},
13
+ { name: :data_processing, project: :sahara, versions: ['v1.1']},
14
+ { name: :data_protection_orchestration, project: :karbor, versions: ['v1']},
15
+ { name: :database, project: :trove, versions: ['v1.0']},
16
+ { name: :domain_name_server, project: :designate, versions: ['v2']},
17
+ { name: :identity, project: :keystone, versions: ['v3', 'v2.0']},
18
+ { name: :image, project: :glance, versions: ['v2', 'v1']},
19
+ { name: :load_balancer, project: :octavia, versions: ['v2.0']},
20
+ { name: :messaging, project: :zaqar, versions: ['v2']},
21
+ { name: :metering, project: :ceilometer, versions: ['v2']},
22
+ { name: :networking, project: :neutron, versions: ['v2.0']},
23
+ { name: :nfv_orchestration, project: :tacker, versions: ['v1.0']},
24
+ { name: :object_storage, project: :swift, versions: ['v1']},
25
+ { name: :orchestration, project: :heat, versions: ['v1']},
26
+ { name: :search, project: :searchlight, versions: ['v1']},
27
+ { name: :shared_file_systems, project: :manila, versions: nil, microversion: 'v2'}
28
+ ]
29
+
4
30
  HEADER_JSON = {
5
31
  'Content-Type' => 'application/json',
6
32
  'Accept' => 'application/json'
7
33
  }
8
34
 
9
- # Default log file. Use :log_file option to override
10
- LOG_FILE = 'misty.log'
11
- # Default log level. Use :log_level option to override
12
- LOG_LEVEL = Logger::INFO
13
-
14
- # Default content type for REST responses
15
- # JSON format: :json
16
- # Ruby structures: :ruby
35
+ # Default REST content type. Use :json or :ruby
17
36
  CONTENT_TYPE = :ruby
18
37
 
19
- # Defaults Domain ID
38
+ # Default Domain ID
20
39
  DOMAIN_ID = 'default'
21
40
 
22
41
  # Default Interface
23
42
  INTERFACE = 'public'
24
43
 
44
+ # Default log file. Use :log_file option to override
45
+ LOG_FILE = 'misty.log'
46
+
47
+ # Default log level. Use :log_level option to override
48
+ LOG_LEVEL = Logger::INFO
49
+
25
50
  # Default Region ID
26
51
  REGION_ID = 'regionOne'
27
52
 
28
- # Default mode when SSL is used (uri.scheme == 'https')
53
+ # Default when uri.scheme is https
29
54
  SSL_VERIFY_MODE = true
30
55
 
31
56
  def self.services
32
57
  services = Misty::Services.new
33
- services.add(:application_catalog, :murano, ['v1'])
34
- services.add(:alarming, :aodh, ['v2'])
35
- services.add(:backup, :freezer, ['v1'])
36
- services.add(:baremetal, :ironic, ['v1'])
37
- services.add(:block_storage, :cinder, ['v3', 'v2', 'v1'])
38
- services.add(:clustering, :senlin, ['v1'])
39
- services.add(:compute, :nova, ['v2.1'])
40
- services.add(:container, :magnum, ['v1'])
41
- services.add(:data_processing, :sahara, ['v1.1'])
42
- services.add(:data_protection, :karbor, ['v1'])
43
- services.add(:database, :trove, ['v1.0'])
44
- services.add(:dns, :designate, ['v2'])
45
- services.add(:identity, :keystone, ['v3', 'v2.0'])
46
- services.add(:image, :glance, ['v2', 'v1'])
47
- services.add(:load_balancer, :octavia, ['v2.0'])
48
- services.add(:messaging, :zaqar, ['v2'])
49
- services.add(:metering, :ceilometer, ['v2'])
50
- services.add(:networking, :neutron, ['v2.0'])
51
- services.add(:nfv_orchestration, :tacker, ['v1.0'])
52
- services.add(:object_storage, :swift, ['v1'])
53
- services.add(:orchestration, :heat, ['v1'])
54
- services.add(:search, :searchlight, ['v1'])
55
- services.add(:shared_file_systems, :manila, ['v2'])
58
+ SERVICES.each do |service|
59
+ services.add(service)
60
+ end
56
61
  services
57
62
  end
58
63
 
@@ -0,0 +1,40 @@
1
+ module Misty
2
+ class Service
3
+ attr_reader :name, :microversion, :project, :versions
4
+
5
+ def initialize(params)
6
+ @name = params[:name]
7
+ @project = params[:project]
8
+ @versions = params[:versions]
9
+ @microversion = params[:microversion]
10
+ end
11
+
12
+ def to_s
13
+ res = "#{name}: #{project}"
14
+ res << ", versions: #{@versions}" if @versions
15
+ res << ", microversion: #{@microversion}" if @microversion
16
+ res
17
+ end
18
+
19
+ def version(api_version = nil)
20
+ if api_version
21
+ return api_version if (@versions && @versions.include?(api_version)) || @microversion == api_version
22
+ end
23
+ default_version
24
+ end
25
+
26
+ def default_version
27
+ return @microversion if @microversion
28
+ return self.versions.sort[-1]
29
+ end
30
+
31
+ def version=(val)
32
+ if @versions.include?(val)
33
+ @version = val
34
+ else
35
+ # Use highest version
36
+ @version = versions.sort[-1]
37
+ end
38
+ end
39
+ end
40
+ end
@@ -1,33 +1,7 @@
1
+ require 'misty/service'
2
+
1
3
  module Misty
2
4
  class Services
3
- class Service
4
- attr_reader :name, :options, :project, :versions, :version
5
-
6
- def initialize(name, project, versions)
7
- @name = name
8
- @project = project
9
- @versions = versions
10
- @options = {}
11
- end
12
-
13
- def options=(val)
14
- @options = val
15
- end
16
-
17
- def to_s
18
- "#{name}: #{project}: #{versions}"
19
- end
20
-
21
- def version=(val)
22
- if @versions.include?(val)
23
- @version = val
24
- else
25
- # Use highest version
26
- @version = versions.sort[-1]
27
- end
28
- end
29
- end
30
-
31
5
  include Enumerable
32
6
 
33
7
  attr_reader :services
@@ -37,7 +11,7 @@ module Misty
37
11
  end
38
12
 
39
13
  def add(*args)
40
- @services << Service.new(*args)
14
+ @services << Misty::Service.new(*args)
41
15
  end
42
16
 
43
17
  def each
data/lib/misty/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Misty
2
- VERSION = '0.8.0'
2
+ VERSION = '0.9.0'
3
3
  end
@@ -1,110 +1,137 @@
1
1
  require 'test_helper'
2
2
 
3
- def validate(service)
4
- service.must_be_kind_of Misty::Services::Service
3
+ def validate_service(service)
4
+ service.must_be_kind_of Misty::Service
5
5
  service.name.must_be_kind_of Symbol
6
6
  service.project.must_be_kind_of Symbol
7
+ end
8
+
9
+ def validate_versions(service)
7
10
  service.versions.must_be_kind_of Array
8
11
  service.versions.each do |version|
9
12
  version.must_be_kind_of String
10
13
  end
11
14
  end
12
15
 
16
+ def validate_microversion(service)
17
+ service.microversion.must_be_kind_of String
18
+ end
19
+
13
20
  describe Misty do
14
21
  describe '#set_services' do
15
22
  it 'has alarming service' do
16
23
  service = Misty::services.find { |s| s.name == :alarming}
17
- validate(service)
24
+ validate_service(service)
25
+ validate_versions(service)
18
26
  end
19
27
 
20
28
  it 'has baremetal service' do
21
29
  service = Misty::services.find { |s| s.name == :baremetal}
22
- validate(service)
30
+ validate_service(service)
31
+ validate_microversion(service)
23
32
  end
24
33
 
25
34
  it 'has block_storage service' do
26
35
  service = Misty::services.find { |s| s.name == :block_storage}
27
- validate(service)
36
+ validate_service(service)
37
+ validate_versions(service)
38
+ validate_microversion(service)
28
39
  end
29
40
 
30
41
  it 'has clustering service' do
31
42
  service = Misty::services.find { |s| s.name == :clustering}
32
- validate(service)
43
+ validate_service(service)
44
+ validate_versions(service)
33
45
  end
34
46
 
35
47
  it 'has compute service' do
36
48
  service = Misty::services.find { |s| s.name == :compute}
37
- validate(service)
49
+ validate_service(service)
50
+ validate_microversion(service)
38
51
  end
39
52
 
40
- it 'has container service' do
41
- service = Misty::services.find { |s| s.name == :container}
42
- validate(service)
53
+ it 'has container_infrastructure_management service' do
54
+ service = Misty::services.find { |s| s.name == :container_infrastructure_management}
55
+ validate_service(service)
56
+ validate_microversion(service)
43
57
  end
44
58
 
45
59
  it 'has data_processing service' do
46
60
  service = Misty::services.find { |s| s.name == :data_processing}
47
- validate(service)
61
+ validate_service(service)
62
+ validate_versions(service)
48
63
  end
49
64
 
50
65
  it 'has data_protection service' do
51
- service = Misty::services.find { |s| s.name == :data_protection}
52
- validate(service)
66
+ service = Misty::services.find { |s| s.name == :data_protection_orchestration}
67
+ validate_service(service)
68
+ validate_versions(service)
53
69
  end
54
70
 
55
71
  it 'has database service' do
56
72
  service = Misty::services.find { |s| s.name == :database}
57
- validate(service)
73
+ validate_service(service)
74
+ validate_versions(service)
58
75
  end
59
76
 
60
77
  it 'has dns service' do
61
- service = Misty::services.find { |s| s.name == :dns}
62
- validate(service)
78
+ service = Misty::services.find { |s| s.name == :domain_name_server}
79
+ validate_service(service)
80
+ validate_versions(service)
63
81
  end
64
82
 
65
83
  it 'has identity service' do
66
84
  service = Misty::services.find { |s| s.name == :identity}
67
- validate(service)
85
+ validate_service(service)
86
+ validate_versions(service)
68
87
  end
69
88
 
70
89
  it 'has image service' do
71
90
  service = Misty::services.find { |s| s.name == :image}
72
- validate(service)
91
+ validate_service(service)
92
+ validate_versions(service)
73
93
  end
74
94
 
75
95
  it 'has messaging service' do
76
96
  service = Misty::services.find { |s| s.name == :messaging}
77
- validate(service)
97
+ validate_service(service)
98
+ validate_versions(service)
78
99
  end
79
100
 
80
101
  it 'has metering service' do
81
102
  service = Misty::services.find { |s| s.name == :metering}
82
- validate(service)
103
+ validate_service(service)
104
+ validate_versions(service)
83
105
  end
84
106
 
85
107
  it 'has networking service' do
86
108
  service = Misty::services.find { |s| s.name == :networking}
87
- validate(service)
109
+ validate_service(service)
110
+ validate_versions(service)
88
111
  end
89
112
 
90
113
  it 'has object_storage service' do
91
114
  service = Misty::services.find { |s| s.name == :object_storage}
92
- validate(service)
115
+ validate_service(service)
116
+ validate_versions(service)
93
117
  end
94
118
 
95
119
  it 'has orchestration service' do
96
120
  service = Misty::services.find { |s| s.name == :orchestration}
97
- validate(service)
121
+ validate_service(service)
122
+ validate_versions(service)
98
123
  end
99
124
 
100
125
  it 'has search service' do
101
126
  service = Misty::services.find { |s| s.name == :search}
102
- validate(service)
127
+ validate_service(service)
128
+ validate_versions(service)
103
129
  end
104
130
 
105
131
  it 'has shared_file_systems service' do
106
132
  service = Misty::services.find { |s| s.name == :shared_file_systems}
107
- validate(service)
133
+ validate_service(service)
134
+ validate_microversion(service)
108
135
  end
109
136
 
110
137
  describe '#services' do
@@ -29,12 +29,12 @@ end
29
29
  # end
30
30
  describe 'Openstack API' do
31
31
  Misty.services.each do |service|
32
- service.versions.each do |version|
33
- it "#{service.project} #{version} loads a valid api structure" do
34
- require "misty/openstack/#{service.project}/#{Misty::Cloud.dot_to_underscore(version)}"
35
- api = Object.const_get("Misty::Openstack::#{service.project.capitalize}::#{Misty::Cloud.dot_to_underscore(version).capitalize}").api
36
- api_valid?(api)
37
- end
38
- end
32
+ #service.versions.each do |version|
33
+ # it "#{service.project} #{version} loads a valid api structure" do
34
+ # require "misty/openstack/#{service.project}/#{Misty::Cloud.dot_to_underscore(version)}"
35
+ # api = Object.const_get("Misty::Openstack::#{service.project.capitalize}::#{Misty::Cloud.dot_to_underscore(version).capitalize}").api
36
+ # api_valid?(api)
37
+ # end
38
+ #end
39
39
  end
40
40
  end
@@ -4,14 +4,17 @@ describe 'Services' do
4
4
  describe '#add' do
5
5
  it 'Adds a service' do
6
6
  services = Misty::Services.new
7
- services.add(:name, :project, ['v1', 'v2.0'])
8
- services.services.size.must_equal 1
7
+ services.add(name: :service_name, project: :project_name, versions: ['v1', 'v2.0'], microversion: 'v3')
9
8
  service = services.services[0]
10
- service.must_be_kind_of Misty::Services::Service
11
- service.name.must_equal :name
12
- service.project.must_equal :project
9
+
10
+ services.services.size.must_equal 1
11
+ service.must_be_kind_of Misty::Service
12
+ service.name.must_equal :service_name
13
+ service.project.must_equal :project_name
13
14
  service.versions.must_include 'v1'
14
- services.to_s.must_equal %Q{name: project: ["v1", "v2.0"]\n}
15
+ service.microversion.must_equal 'v3'
16
+ service.version.must_equal 'v3'
17
+ services.to_s.must_equal %Q{service_name: project_name, versions: ["v1", "v2.0"], microversion: v3\n}
15
18
  end
16
19
  end
17
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: misty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gilles Dubreuil
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-17 00:00:00.000000000 Z
11
+ date: 2017-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -196,6 +196,7 @@ files:
196
196
  - lib/misty/openstack/trove/v1_0.rb
197
197
  - lib/misty/openstack/zaqar/v2.rb
198
198
  - lib/misty/openstack/zaqar/zaqar_v2.rb
199
+ - lib/misty/service.rb
199
200
  - lib/misty/services.rb
200
201
  - lib/misty/version.rb
201
202
  - test/integration/compute_test.rb