publish_to_web 2.3.0 → 2.4.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: 49d09ddb462630cc102a2dceec68d8d5cbea813c
4
- data.tar.gz: 2e3a235daec84af70c6f064743ed82ee3d397e43
3
+ metadata.gz: 1f4db33296b70fcd1d9d12c67673c57b2d65fcff
4
+ data.tar.gz: edb2dad4f8c146eb9a7fd6c788926e912de1ad52
5
5
  SHA512:
6
- metadata.gz: 7c1f98558959e1b40a1ee1bcc83272e0ae083c0eca35ca22f33ce1c0a0e3919dfd23f28b7980a620228b074db2e5e4138d259c386f9dfbb660a034f1612bf360
7
- data.tar.gz: 435cf3f3840011a70633c3fa699629ff5da3b55a95c499d8241b57662854d2de8288e161c77bc2db1ee832c061dcf997fb80222368c566a12ae2686b2a0fdc79
6
+ metadata.gz: c02c078adae039427353534023a9ffab730c37b84913961d26c4fde3b08fdec95bc919b907e53cd483108f5de36c28fb690a6b018f4a4fb93cbec7519a59e4e7
7
+ data.tar.gz: 42bb86b062e59ecf95f7079242fed975e297e86cfd0e9481319760a62da1684b80073e359b745d8cb374898acf98e5ab5b4d297b75483ff05bd33747967b7712
@@ -59,6 +59,7 @@ class PublishToWeb
59
59
  def check_local_endpoint
60
60
  logger.info "Checking if local backend is available at #{bind_host}:#{forward_port}"
61
61
  TCPSocket.new(bind_host, forward_port).close
62
+ logger.info " ✔ Local backend is available!"
62
63
 
63
64
  rescue Errno::ECONNREFUSED
64
65
  logger.warn "Local backend is not available (yet?) - waiting for it to become available"
@@ -78,6 +79,7 @@ class PublishToWeb
78
79
  directory.set_version
79
80
  directory.public_key
80
81
 
82
+ logger.info "Updating SMTP configuration"
81
83
  directory.smtp_config.tap do |smtp|
82
84
  config.smtp_host = smtp["host"]
83
85
  config.smtp_sender = smtp["sender"]
@@ -85,7 +87,15 @@ class PublishToWeb
85
87
  config.smtp_pass = smtp["password"]
86
88
  end
87
89
 
90
+ logger.info "Updating limits configuration"
91
+ if limits = directory.limits
92
+ config.account_limit = limits["accounts"]
93
+ end
94
+
95
+ directory.report_usage
96
+
88
97
  config.success = 'directory_configured'
98
+
89
99
  rescue PublishToWeb::Directory::HttpResponseError => err
90
100
  logger.warn "#{err.class}: #{err}"
91
101
  logger.warn "Failed to interact with directory, will try again in a bit"
@@ -129,7 +139,6 @@ class PublishToWeb
129
139
  retry
130
140
 
131
141
  rescue PublishToWeb::Directory::HttpResponseError
132
-
133
142
  # already handled by #prepare_directory, we just need to wait and retry...
134
143
 
135
144
  sleep 30
@@ -140,8 +149,6 @@ class PublishToWeb
140
149
  logger.error error.message
141
150
  logger.error error.backtrace.join("\n")
142
151
 
143
- abort error.message
144
-
145
152
  end
146
153
 
147
154
  private
@@ -22,7 +22,7 @@ class PublishToWeb
22
22
  end
23
23
 
24
24
  def enabled?
25
- !!store.get('ptw/enabled')
25
+ !!store.get('ptw/control/enabled')
26
26
  end
27
27
 
28
28
  config_attribute :hardware_id, "ptw/hardware_id"
@@ -37,5 +37,27 @@ class PublishToWeb
37
37
  config_attribute :smtp_sender, "smtp/sender"
38
38
  config_attribute :smtp_user, "smtp/username"
39
39
  config_attribute :smtp_pass, "smtp/password"
40
+
41
+ config_attribute :account_limit, "soul/account_limit"
42
+
43
+ def active_accounts
44
+ store.get 'soul/active_accounts'
45
+ end
46
+
47
+ def support_identifier
48
+ identifier = store.get('system/support_identifier')
49
+ if identifier.kind_of?(String) and identifier.strip.length > 0
50
+ identifier
51
+ end
52
+ end
53
+
54
+ def system_version
55
+ parts = [store.get('system/channel'), store.get('system/release_number')]
56
+ if parts.all? {|p| p.kind_of?(String) and p.strip.length > 0 }
57
+ parts.join("/")
58
+ else
59
+ "unknown"
60
+ end
61
+ end
40
62
  end
41
63
  end
@@ -54,7 +54,7 @@ class PublishToWeb
54
54
  end
55
55
 
56
56
  def version
57
- "platform-alpha"
57
+ config.system_version
58
58
  end
59
59
 
60
60
  def set_node_name(node_name)
@@ -71,7 +71,12 @@ class PublishToWeb
71
71
 
72
72
  def set_version
73
73
  logger.info "Setting version at directory to #{version}"
74
- response = HTTP.post url_for('set_version'), form: { license_key: license_key, version: Shellwords.shellescape(version) }
74
+ payload = {
75
+ license_key: license_key,
76
+ version: Shellwords.shellescape(version),
77
+ support_identifier: config.support_identifier
78
+ }
79
+ response = HTTP.post url_for('set_version'), form: payload
75
80
  if (200..299).include? response.status
76
81
  true
77
82
  else
@@ -79,6 +84,24 @@ class PublishToWeb
79
84
  end
80
85
  end
81
86
 
87
+ def report_usage
88
+ if active_accounts = config.active_accounts
89
+ logger.info "Reporting usage to directory"
90
+ payload = {
91
+ license_key: license_key,
92
+ active_accounts: active_accounts
93
+ }
94
+ response = HTTP.post url_for('usage'), form: payload
95
+ if (200..299).include? response.status
96
+ true
97
+ else
98
+ raise HttpResponseError.new("Failed to submit usage to directory", response)
99
+ end
100
+ else
101
+ logger.info "Not reporting usage as no data is available"
102
+ end
103
+ end
104
+
82
105
  def smtp_config
83
106
  logger.info "Retrieving SMTP configuration from directory"
84
107
  response = HTTP.get url_for('smtp_config'), params: { license_key: license_key }
@@ -89,6 +112,16 @@ class PublishToWeb
89
112
  end
90
113
  end
91
114
 
115
+ def limits
116
+ logger.info "Retrieving limits from directory"
117
+ response = HTTP.get url_for('limits'), params: { license_key: license_key }
118
+ if (200..299).include? response.status
119
+ JSON.parse(response.body)
120
+ else
121
+ raise HttpResponseError.new("Failed to retrieve limits from directory", response)
122
+ end
123
+ end
124
+
92
125
  private
93
126
 
94
127
  def public_key_ok?
@@ -123,7 +156,11 @@ class PublishToWeb
123
156
  logger.info "Retrieving connection info from directory #{host}"
124
157
  response = HTTP.get(url_for('info'), params: { license_key: license_key })
125
158
  if response.status == 200
126
- JSON.load(response.body)
159
+ data = JSON.load(response.body)
160
+ data.each do |key, value|
161
+ logger.info " #{key} = #{value}"
162
+ end
163
+ data
127
164
  else
128
165
  raise HttpResponseError.new("Failed to get connection info from directory", response)
129
166
  end
@@ -1,3 +1,3 @@
1
1
  class PublishToWeb
2
- VERSION = "2.3.0"
2
+ VERSION = "2.4.0"
3
3
  end
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_runtime_dependency "net-ssh", "~> 3.0"
24
24
  spec.add_runtime_dependency "http", "~> 1.0"
25
25
  spec.add_runtime_dependency "sshkey", "~> 1.8.0"
26
- spec.add_runtime_dependency "platform-skvs", "~> 0.2.0"
26
+ spec.add_runtime_dependency "platform-skvs", "~> 0.4.0"
27
27
  spec.add_runtime_dependency "rainbow", "~> 2.0"
28
28
 
29
29
  spec.add_development_dependency "bundler", "~> 1.11"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: publish_to_web
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christoph Olszowka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-11 00:00:00.000000000 Z
11
+ date: 2016-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.2.0
61
+ version: 0.4.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.2.0
68
+ version: 0.4.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rainbow
71
71
  requirement: !ruby/object:Gem::Requirement