bosh-registry 1.3215.4.0 → 1.3232.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: 6529af5e63511367617db358ea4ee136ebee2b4d
4
- data.tar.gz: fabbb98aefbd324bb51933078adfa566310f4b9d
3
+ metadata.gz: 42185f98dd03fe90126899fecc12f75f0c5a7386
4
+ data.tar.gz: 106512bf2a7de26abd19878818d601f52f9a03f5
5
5
  SHA512:
6
- metadata.gz: d4893e23d4f6b191a9d0c3a888bb3410f93d713d4f6b989f1b11ac203fed3dc15c6aff440a3639d0d2d5c5775cf0c0fc0bf535ac4f0931f6079b25becef49c28
7
- data.tar.gz: 326ac8b500a8669f5ade426da6e1083188d363f7da43dfad5fc9a4f489d9a47ecbcbbb6462f99141207ecfbd64386a6e69e425d2d01a50d0007e79109934ca7b
6
+ metadata.gz: ab10189b2fb10c11ceab308a6738674e52f2dedd2ef66113bd2a3d093d68caa7774a990cdbb622b15ddf1acb0d0c9f5ca818d5fe93ffecd5eeb0403e6f8dddb4
7
+ data.tar.gz: ec419fdac7f02d7bdf8c14854d280cd747f4720a921eb541238e88ef977968f2c0829d7a503354559eb24f69dc75409f96b4ddd945b24ad0fbdd3ff0e39f377e
@@ -1,124 +1,8 @@
1
- # Copyright (c) 2009-2013 VMware, Inc.
2
- # Copyright (c) 2012 Piston Cloud Computing, Inc.
3
- require 'httpclient'
4
- require 'cloud/errors'
5
- require 'base64'
1
+ require 'bosh/cpi/registry_client'
6
2
 
3
+ # Shim for legacy usage (https://www.pivotaltracker.com/story/show/116920309)
4
+ # Also, note that the dependency on 'bosh_cpi' gem can be removed once this
5
+ # shim class is deleted.
7
6
  module Bosh::Registry
8
- ##
9
- # Represents Bosh Registry Client. It performs CRUD operations against
10
- # the OpenStack Registry.
11
- #
12
- # Settings example:
13
- # settings = {
14
- # "vm" => {
15
- # "name" => server_name
16
- # },
17
- # "agent_id" => agent_id,
18
- # "networks" => network_spec,
19
- # "disks" => {
20
- # "system" => "/dev/vda",
21
- # "ephemeral" => "/dev/vdb",
22
- # "persistent" => {"volume_id" => device_name}
23
- # }
24
- # }
25
- class Client
26
- attr_reader :endpoint
27
- attr_reader :user
28
- attr_reader :password
29
-
30
- def initialize(endpoint, user, password)
31
- @endpoint = endpoint
32
-
33
- unless @endpoint =~ /^http:\/\//
34
- @endpoint = "http://#{@endpoint}"
35
- end
36
-
37
- @user = user
38
- @password = password
39
-
40
- auth = Base64.encode64("#{@user}:#{@password}").gsub("\n", '')
41
-
42
- @headers = {
43
- "Accept" => 'application/json',
44
- "Authorization" => "Basic #{auth}"
45
- }
46
-
47
- @client = HTTPClient.new
48
- end
49
-
50
- ##
51
- # Update instance settings in the registry
52
- # @param [String] instance_id EC2 instance id
53
- # @param [Hash] settings New agent settings
54
- # @return [Boolean]
55
- def update_settings(instance_id, settings)
56
- unless settings.is_a?(Hash)
57
- raise ArgumentError, "Invalid settings format, Hash expected, #{settings.class} given"
58
- end
59
-
60
- payload = Yajl::Encoder.encode(settings)
61
- url = "#{@endpoint}/instances/#{instance_id}/settings"
62
-
63
- response = @client.put(url, {:body => payload, :header => @headers})
64
-
65
- unless HTTP::Status.successful?(response.status)
66
- cloud_error("Cannot update settings for '#{instance_id}', got HTTP #{response.status}")
67
- end
68
-
69
- true
70
- end
71
-
72
- ##
73
- # Read instance settings from the registry
74
- # @param [String] instance_id EC2 instance id
75
- # @return [Hash] Agent settings
76
- def read_settings(instance_id)
77
- url = "#{@endpoint}/instances/#{instance_id}/settings"
78
-
79
- response = @client.get(url, {:header => @headers})
80
-
81
- if response.status != 200
82
- cloud_error("Cannot read settings for '#{instance_id}', got HTTP #{response.status}")
83
- end
84
-
85
- body = Yajl::Parser.parse(response.body)
86
-
87
- unless body.is_a?(Hash)
88
- cloud_error("Invalid registry response, Hash expected, got #{body.class}: #{body}")
89
- end
90
-
91
- settings = Yajl::Parser.parse(body["settings"])
92
-
93
- unless settings.is_a?(Hash)
94
- cloud_error("Invalid settings format, Hash expected, got #{settings.class}: #{settings}")
95
- end
96
-
97
- settings
98
- rescue Yajl::ParseError => e
99
- cloud_error("Cannot parse settings for '#{instance_id}': #{e.message}")
100
- end
101
-
102
- ##
103
- # Delete instance settings from the registry
104
- # @param [String] instance_id EC2 instance id
105
- # @return [Boolean]
106
- def delete_settings(instance_id)
107
- url = "#{@endpoint}/instances/#{instance_id}/settings"
108
-
109
- response = @client.delete(url, {:header => @headers})
110
-
111
- unless [200, 404].include? response.status
112
- cloud_error("Cannot delete settings for '#{instance_id}', got HTTP #{response.status}")
113
- end
114
-
115
- true
116
- end
117
-
118
- private
119
-
120
- def cloud_error(message)
121
- raise Bosh::Clouds::CloudError, message
122
- end
123
- end
7
+ class Client < Bosh::Cpi::RegistryClient ; end
124
8
  end
@@ -54,7 +54,7 @@ module Bosh::Registry
54
54
  actual_ips = instance_ips(instance_id)
55
55
  unless actual_ips.include?(ip)
56
56
  raise InstanceError, "Instance IP mismatch, expected IP is " \
57
- "`%s', actual IP(s): `%s'" %
57
+ "'%s', actual IP(s): '%s'" %
58
58
  [ ip, actual_ips.join(", ") ]
59
59
  end
60
60
  end
@@ -63,7 +63,7 @@ module Bosh::Registry
63
63
  instance = Models::RegistryInstance[:instance_id => instance_id]
64
64
 
65
65
  if instance.nil?
66
- raise InstanceNotFound, "Can't find instance `#{instance_id}'"
66
+ raise InstanceNotFound, "Can't find instance '#{instance_id}'"
67
67
  end
68
68
 
69
69
  instance
@@ -71,4 +71,4 @@ module Bosh::Registry
71
71
 
72
72
  end
73
73
 
74
- end
74
+ end
@@ -75,7 +75,7 @@ module Bosh::Registry
75
75
  end
76
76
  raise ConnectionError, "Unable to connect to OpenStack API: #{e.message}"
77
77
  end
78
- raise InstanceNotFound, "Instance `#{instance_id}' not found" unless instance
78
+ raise InstanceNotFound, "Instance '#{instance_id}' not found" unless instance
79
79
  return (instance.private_ip_addresses + instance.floating_ip_addresses).compact
80
80
  end
81
81
 
@@ -1,5 +1,5 @@
1
1
  module Bosh
2
2
  module Registry
3
- VERSION = '1.3215.4.0'
3
+ VERSION = '1.3232.0'
4
4
  end
5
5
  end
@@ -5,20 +5,20 @@ module Bosh::Registry
5
5
 
6
6
  def load_yaml_file(path, expected_type = Hash)
7
7
  unless File.exists?(path)
8
- raise(ConfigError, "Cannot find file `#{path}'")
8
+ raise(ConfigError, "Cannot find file '#{path}'")
9
9
  end
10
10
 
11
11
  yaml = Psych.load_file(path)
12
12
 
13
13
  if expected_type && !yaml.is_a?(expected_type)
14
- raise ConfigError, "Incorrect file format in `#{path}', " \
14
+ raise ConfigError, "Incorrect file format in '#{path}', " \
15
15
  "#{expected_type} expected"
16
16
  end
17
17
 
18
18
  yaml
19
19
  rescue SystemCallError => e
20
- raise ConfigError, "Cannot load YAML file at `#{path}': #{e}"
20
+ raise ConfigError, "Cannot load YAML file at '#{path}': #{e}"
21
21
  end
22
22
 
23
23
  end
24
- end
24
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh-registry
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3215.4.0
4
+ version: 1.3232.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - VMware
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-14 00:00:00.000000000 Z
11
+ date: 2016-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 3.43.0
19
+ version: 4.32.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 3.43.0
26
+ version: 4.32.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sinatra
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.3215.4.0
103
+ version: 1.3232.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 1.3215.4.0
110
+ version: 1.3232.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rake
113
113
  requirement: !ruby/object:Gem::Requirement