rhoconnect 3.1.2 → 3.2.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (248) hide show
  1. data/CHANGELOG.md +14 -2
  2. data/CREDITS +151 -10
  3. data/Gemfile +16 -5
  4. data/Gemfile.lock +58 -23
  5. data/Rakefile +70 -50
  6. data/bench/bench_runner.rb +2 -2
  7. data/bench/benchapp/Gemfile +6 -0
  8. data/bench/benchapp/Gemfile.lock +5 -0
  9. data/bench/benchapp/config.ru +2 -0
  10. data/bench/lib/bench/cli.rb +2 -0
  11. data/bench/lib/bench/distr_runner.rb +3 -2
  12. data/bench/lib/bench/runner.rb +1 -1
  13. data/bench/lib/bench.rb +10 -1
  14. data/bench/run_bench.sh +1 -1
  15. data/bench/scripts/test_query_script.rb +2 -1
  16. data/bench/spec/bench_spec_helper.rb +1 -0
  17. data/bin/rhoconnect +9 -27
  18. data/bin/rhoconnect-benchmark +10 -1
  19. data/commands/commands/dtach_commands/dtach_about.rb +6 -0
  20. data/commands/commands/dtach_commands/dtach_install.rb +30 -0
  21. data/commands/commands/redis_commands/redis_about.rb +6 -0
  22. data/commands/commands/redis_commands/redis_attach.rb +6 -0
  23. data/commands/commands/redis_commands/redis_download.rb +33 -0
  24. data/commands/commands/redis_commands/redis_install.rb +26 -0
  25. data/commands/commands/redis_commands/redis_make.rb +9 -0
  26. data/commands/commands/redis_commands/redis_restart.rb +7 -0
  27. data/commands/commands/redis_commands/redis_runner.rb +67 -0
  28. data/commands/commands/redis_commands/redis_start.rb +6 -0
  29. data/commands/commands/redis_commands/redis_startbg.rb +6 -0
  30. data/commands/commands/redis_commands/redis_stop.rb +6 -0
  31. data/commands/commands/rhoconnect/attach.rb +7 -0
  32. data/commands/commands/rhoconnect/clean_start.rb +9 -0
  33. data/commands/commands/rhoconnect/config.rb +15 -0
  34. data/commands/commands/rhoconnect/console.rb +15 -0
  35. data/commands/commands/rhoconnect/console_helper.rb +3 -0
  36. data/commands/commands/rhoconnect/create_user.rb +18 -0
  37. data/commands/commands/rhoconnect/delete_device.rb +9 -0
  38. data/commands/commands/rhoconnect/delete_user.rb +8 -0
  39. data/commands/commands/rhoconnect/flushdb.rb +14 -0
  40. data/commands/commands/rhoconnect/get_token.rb +25 -0
  41. data/commands/commands/rhoconnect/reset.rb +16 -0
  42. data/commands/commands/rhoconnect/reset_refresh.rb +11 -0
  43. data/commands/commands/rhoconnect/restart.rb +7 -0
  44. data/commands/commands/rhoconnect/secret.rb +11 -0
  45. data/commands/commands/rhoconnect/set_admin_password.rb +26 -0
  46. data/commands/commands/rhoconnect/spec.rb +15 -0
  47. data/commands/commands/rhoconnect/start.rb +18 -0
  48. data/commands/commands/rhoconnect/startbg.rb +34 -0
  49. data/commands/commands/rhoconnect/startdebug.rb +35 -0
  50. data/commands/commands/rhoconnect/stop.rb +11 -0
  51. data/commands/commands/rhoconnect/war.rb +32 -0
  52. data/commands/commands/rhoconnect/web.rb +7 -0
  53. data/commands/execute.rb +35 -0
  54. data/commands/generators/app.rb +6 -0
  55. data/commands/generators/source.rb +6 -0
  56. data/commands/utilities/dtach_installed.rb +10 -0
  57. data/doc/benchmarks-running.txt +5 -0
  58. data/doc/command-line.txt +216 -27
  59. data/doc/heroku-addon.txt +1 -1
  60. data/doc/preparing-production.txt +20 -1
  61. data/doc/public/cli.txt +191 -0
  62. data/doc/push-backend-setup.txt +148 -0
  63. data/doc/push-client-setup.txt +61 -0
  64. data/doc/push-server-setup.txt +91 -0
  65. data/doc/push.txt +8 -137
  66. data/doc/rest-api.txt +96 -0
  67. data/doc/settings.txt +1 -1
  68. data/doc/supported-platforms.txt +2 -1
  69. data/doc/tutorial.txt +6 -4
  70. data/examples/simple/Gemfile +39 -0
  71. data/examples/simple/Rakefile +7 -12
  72. data/examples/simple/config.ru +16 -31
  73. data/examples/simple/settings/settings.yml +5 -4
  74. data/examples/simple/sources/product.rb +51 -0
  75. data/generators/templates/application/Gemfile +7 -0
  76. data/generators/templates/application/Rakefile +5 -18
  77. data/generators/templates/application/config.ru +11 -19
  78. data/install.sh +24 -49
  79. data/installer/unix-like/create_texts.rb +71 -123
  80. data/installer/unix-like/post_install.sh +3 -0
  81. data/installer/unix-like/post_uninstall.sh +2 -0
  82. data/installer/unix-like/pre_install.sh +5 -3
  83. data/installer/unix-like/pre_uninstall.sh +14 -6
  84. data/installer/unix-like/rho_connect_install_checkers.rb +1 -1
  85. data/installer/unix-like/rho_connect_install_constants.rb +6 -10
  86. data/installer/unix-like/rho_connect_install_debian.rb +2 -2
  87. data/installer/unix-like/rho_connect_install_dnd.rb +2 -5
  88. data/installer/unix-like/rho_connect_install_installers.rb +15 -23
  89. data/installer/unix-like/rho_connect_install_yum.rb +2 -2
  90. data/installer/utils/constants.rb +4 -4
  91. data/installer/utils/create_sha1.rb +1 -1
  92. data/installer/utils/nix_install_test.rb +32 -31
  93. data/installer/utils/nix_installation.rake +1 -1
  94. data/installer/utils/package_upload/repos.rake +34 -30
  95. data/installer/utils/package_upload/s3_upload.rb +3 -3
  96. data/lib/rhoconnect/api/source/fast_delete.rb +10 -0
  97. data/lib/rhoconnect/api/source/fast_insert.rb +10 -0
  98. data/lib/rhoconnect/api/source/fast_update.rb +10 -0
  99. data/lib/rhoconnect/api/source/get_source_params.rb +1 -1
  100. data/lib/rhoconnect/api/source/list_sources.rb +2 -2
  101. data/lib/rhoconnect/api/source/save_adapter.rb +1 -1
  102. data/lib/rhoconnect/api/source/update_source_params.rb +6 -0
  103. data/lib/rhoconnect/async.rb +82 -0
  104. data/lib/rhoconnect/bulk_data/bulk_data.rb +5 -1
  105. data/lib/rhoconnect/client_sync.rb +18 -3
  106. data/lib/rhoconnect/console/rhoconnect_api.rb +2 -2
  107. data/lib/rhoconnect/console/server.rb +5 -32
  108. data/lib/rhoconnect/console.rb +2 -2
  109. data/lib/rhoconnect/graph_helper.rb +225 -0
  110. data/lib/rhoconnect/jobs/bulk_data_job.rb +24 -2
  111. data/lib/rhoconnect/server.rb +31 -11
  112. data/lib/rhoconnect/source.rb +10 -5
  113. data/lib/rhoconnect/source_sync.rb +32 -2
  114. data/lib/rhoconnect/tasks.rb +19 -108
  115. data/lib/rhoconnect/test_methods.rb +20 -0
  116. data/lib/rhoconnect/utilities.rb +118 -0
  117. data/lib/rhoconnect/version.rb +1 -1
  118. data/lib/rhoconnect/web-console/controllers/admins.js +245 -0
  119. data/lib/rhoconnect/web-console/models/adapter.js +53 -0
  120. data/lib/rhoconnect/web-console/models/client.js +105 -0
  121. data/lib/rhoconnect/web-console/models/doc.js +113 -0
  122. data/lib/rhoconnect/web-console/models/session.js +40 -0
  123. data/lib/rhoconnect/web-console/models/source.js +115 -0
  124. data/lib/rhoconnect/web-console/models/stats.js +84 -0
  125. data/lib/rhoconnect/web-console/models/user.js +111 -0
  126. data/lib/rhoconnect/web-console/public/backbone.js +1432 -0
  127. data/lib/rhoconnect/web-console/public/bootstrap.css +3990 -0
  128. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/excanvas.min.js +0 -0
  129. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.barRenderer.min.js +0 -0
  130. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.canvasAxisLabelRenderer.js +0 -0
  131. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.canvasAxisTickRenderer.js +0 -0
  132. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.canvasTextRenderer.js +0 -0
  133. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.categoryAxisRenderer.min.js +0 -0
  134. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.cursor.js +0 -0
  135. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.dateAxisRenderer.js +0 -0
  136. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.dateAxisRenderer.min.js +0 -0
  137. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jqplot.pointLabels.min.js +0 -0
  138. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jquery-1.4.2.min.js +0 -0
  139. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jquery.jqplot.min.css +0 -0
  140. data/lib/rhoconnect/{console/app → web-console}/public/jqplot/jquery.jqplot.min.js +0 -0
  141. data/lib/rhoconnect/web-console/public/jquery-1.7.1.min.js +154 -0
  142. data/lib/rhoconnect/web-console/public/rhoconnect-web.js +15 -0
  143. data/lib/rhoconnect/web-console/public/underscore.js +999 -0
  144. data/lib/rhoconnect/web-console/server.rb +55 -0
  145. data/lib/rhoconnect/web-console/templates/index.erb +90 -0
  146. data/lib/rhoconnect/web-console/templates/jqplot.erb +60 -0
  147. data/lib/rhoconnect/web-console/views/api_token.js +16 -0
  148. data/lib/rhoconnect/web-console/views/doc.js +63 -0
  149. data/lib/rhoconnect/web-console/views/edit_user.js +43 -0
  150. data/lib/rhoconnect/web-console/views/home.js +56 -0
  151. data/lib/rhoconnect/web-console/views/index.js +63 -0
  152. data/lib/rhoconnect/web-console/views/new_ping.js +58 -0
  153. data/lib/rhoconnect/web-console/views/new_user.js +29 -0
  154. data/lib/rhoconnect/web-console/views/server_doc.js +103 -0
  155. data/lib/rhoconnect/web-console/views/set_adapter.js +38 -0
  156. data/lib/rhoconnect/web-console/views/settings.js +53 -0
  157. data/lib/rhoconnect/web-console/views/show_device.js +56 -0
  158. data/lib/rhoconnect/web-console/views/show_user.js +38 -0
  159. data/lib/rhoconnect/web-console/views/source_docs.js +30 -0
  160. data/lib/rhoconnect/web-console/views/stats.js +69 -0
  161. data/lib/rhoconnect/web-console/views/users.js +20 -0
  162. data/lib/rhoconnect.rb +2 -1
  163. data/rhoconnect.gemspec +3 -1
  164. data/spec/api/application/rhoconnect_api_spec.rb +3 -5
  165. data/spec/api/source/fast_delete_spec.rb +27 -0
  166. data/spec/api/source/fast_insert_spec.rb +28 -0
  167. data/spec/api/source/fast_update_spec.rb +51 -0
  168. data/spec/api/source/get_source_params_spec.rb +1 -0
  169. data/spec/api/source/update_source_params_spec.rb +24 -0
  170. data/spec/async_spec.rb +19 -0
  171. data/spec/client_sync_spec.rb +19 -2
  172. data/spec/javascripts/PlayerSpec.js +58 -0
  173. data/spec/javascripts/admins_routes_spec.js +117 -0
  174. data/spec/javascripts/admins_spec.js +27 -0
  175. data/spec/javascripts/doc_view_spec.js +37 -0
  176. data/spec/javascripts/edit_user_view_spec.js +44 -0
  177. data/spec/javascripts/helpers/SpecHelper.js +9 -0
  178. data/spec/javascripts/helpers/jasmine-jquery.js +305 -0
  179. data/spec/javascripts/helpers/jasmine-sinon.js +43 -0
  180. data/spec/javascripts/helpers/sinon-1.3.2.js +3551 -0
  181. data/spec/javascripts/home_view_spec.js +39 -0
  182. data/spec/javascripts/index_view_spec.js +42 -0
  183. data/spec/javascripts/new_ping_view_spec.js +48 -0
  184. data/spec/javascripts/new_user_view_spec.js +42 -0
  185. data/spec/javascripts/server_doc_view_spec.js +39 -0
  186. data/spec/javascripts/set_adapter_view_spec.js +32 -0
  187. data/spec/javascripts/show_device_view_spec.js +41 -0
  188. data/spec/javascripts/show_user_view_spec.js +46 -0
  189. data/spec/javascripts/source_docs_view_spec.js +36 -0
  190. data/spec/javascripts/support/jasmine.yml +79 -0
  191. data/spec/javascripts/support/jasmine_config.rb +23 -0
  192. data/spec/javascripts/support/jasmine_runner.rb +32 -0
  193. data/spec/javascripts/users_view_spec.js +35 -0
  194. data/spec/jobs/bulk_data_job_spec.rb +10 -2
  195. data/spec/perf/bulk_data_perf_spec.rb +1 -0
  196. data/spec/server/server_spec.rb +3 -1
  197. data/spec/source_sync_spec.rb +14 -1
  198. data/spec/spec_helper.rb +51 -0
  199. data/spec/store_spec.rb +6 -0
  200. data/spec/test_methods_spec.rb +11 -0
  201. data/tasks/redis.rake +3 -1
  202. metadata +172 -64
  203. data/doc/contributing.txt +0 -60
  204. data/lib/rhoconnect/console/app/helpers/auth_helper.rb +0 -22
  205. data/lib/rhoconnect/console/app/helpers/extensions.rb +0 -19
  206. data/lib/rhoconnect/console/app/helpers/helpers.rb +0 -57
  207. data/lib/rhoconnect/console/app/public/ThickBox.css +0 -649
  208. data/lib/rhoconnect/console/app/public/home.css +0 -431
  209. data/lib/rhoconnect/console/app/public/images/foot_logo_rhoconnect.png +0 -0
  210. data/lib/rhoconnect/console/app/public/images/header_halo.jpg +0 -0
  211. data/lib/rhoconnect/console/app/public/images/land_separator.gif +0 -0
  212. data/lib/rhoconnect/console/app/public/images/landing_header.jpg +0 -0
  213. data/lib/rhoconnect/console/app/public/images/logo_rhoconnect.png +0 -0
  214. data/lib/rhoconnect/console/app/public/images/tabs_separator.png +0 -0
  215. data/lib/rhoconnect/console/app/public/main.css +0 -7
  216. data/lib/rhoconnect/console/app/public/reset.css +0 -76
  217. data/lib/rhoconnect/console/app/public/style.css +0 -2201
  218. data/lib/rhoconnect/console/app/public/text.txt +0 -0
  219. data/lib/rhoconnect/console/app/routes/adapter.rb +0 -28
  220. data/lib/rhoconnect/console/app/routes/auth.rb +0 -29
  221. data/lib/rhoconnect/console/app/routes/client.rb +0 -31
  222. data/lib/rhoconnect/console/app/routes/docs.rb +0 -145
  223. data/lib/rhoconnect/console/app/routes/heroku.rb +0 -19
  224. data/lib/rhoconnect/console/app/routes/home.rb +0 -63
  225. data/lib/rhoconnect/console/app/routes/timing.rb +0 -242
  226. data/lib/rhoconnect/console/app/routes/user.rb +0 -122
  227. data/lib/rhoconnect/console/app/views/adapter.erb +0 -16
  228. data/lib/rhoconnect/console/app/views/client.erb +0 -30
  229. data/lib/rhoconnect/console/app/views/content.erb +0 -14
  230. data/lib/rhoconnect/console/app/views/doc.erb +0 -8
  231. data/lib/rhoconnect/console/app/views/docdata.erb +0 -28
  232. data/lib/rhoconnect/console/app/views/docs.erb +0 -30
  233. data/lib/rhoconnect/console/app/views/edituser.erb +0 -13
  234. data/lib/rhoconnect/console/app/views/headermenu.erb +0 -40
  235. data/lib/rhoconnect/console/app/views/home.erb +0 -24
  236. data/lib/rhoconnect/console/app/views/index.erb +0 -58
  237. data/lib/rhoconnect/console/app/views/jqplot.erb +0 -52
  238. data/lib/rhoconnect/console/app/views/layout.erb +0 -153
  239. data/lib/rhoconnect/console/app/views/login.erb +0 -26
  240. data/lib/rhoconnect/console/app/views/newuser.erb +0 -17
  241. data/lib/rhoconnect/console/app/views/ping.erb +0 -40
  242. data/lib/rhoconnect/console/app/views/result.erb +0 -11
  243. data/lib/rhoconnect/console/app/views/rightboxlinks.erb +0 -15
  244. data/lib/rhoconnect/console/app/views/select_doc.erb +0 -17
  245. data/lib/rhoconnect/console/app/views/upload_doc.erb +0 -23
  246. data/lib/rhoconnect/console/app/views/user.erb +0 -29
  247. data/lib/rhoconnect/console/app/views/users.erb +0 -19
  248. data/lib/rhoconnect/server/views/index.erb +0 -13
@@ -37,9 +37,9 @@ def build_type
37
37
  when 'beta'
38
38
  'beta-packages'
39
39
  when 'release'
40
- 'release-packages'
40
+ 'packages'
41
41
  else
42
- 'nightly-packages'
42
+ 'packages'
43
43
  end #case
44
44
  end #build_type
45
45
 
@@ -60,28 +60,28 @@ def compile_stack_info
60
60
  # Append the rest of the file name according to distribution
61
61
  if @user == 'ubuntu'
62
62
 
63
- @dist = { :flavor => "ubuntu",
64
- :package => "rhoconnect_#{Constants::RC_VERSION}_all.deb",
65
- :local_file => "#{local_file}rhoconnect_#{Constants::RC_VERSION}_all.deb",
66
- :pkg_mgr => 'dpkg',
67
- :pkg_type => 'DEB',
68
- :pkg_repo => 'apt-get',
69
- :deps => Constants::DEB_DEPS,
63
+ @dist = { :flavor => "ubuntu",
64
+ :package => "rhoconnect_#{Constants::RC_VERSION}_all.deb",
65
+ :local_file => "#{local_file}rhoconnect_#{Constants::RC_VERSION}_all.deb",
66
+ :pkg_mgr => 'dpkg',
67
+ :pkg_type => 'DEB',
68
+ :pkg_repo => 'apt-get',
69
+ :deps => Constants::DEB_DEPS,
70
70
  :repo_src_file => '/etc/apt/sources.list',
71
- :repo_str => '\n' +
72
- '# This is the repository for rhoconnect packages\n' +
71
+ :repo_str => '\n' +
72
+ '# This is the repository for rhoconnect packages\n' +
73
73
  "deb http://#{BUCKET}.s3.amazonaws.com/#{channel}/deb rhoconnect main" }
74
74
  elsif @user == 'root'
75
- @dist = { :flavor => "centos",
76
- :package => "rhoconnect-#{Constants::RC_VERSION}.noarch.rpm",
77
- :local_file => "#{local_file}rhoconnect-#{Constants::RC_VERSION}.noarch.rpm",
78
- :pkg_mgr => 'rpm',
79
- :pkg_type => 'RPM',
80
- :pkg_repo => 'yum',
81
- :deps => Constants::RPM_DEPS,
75
+ @dist = { :flavor => "centos",
76
+ :package => "rhoconnect-#{Constants::RC_VERSION}.noarch.rpm",
77
+ :local_file => "#{local_file}rhoconnect-#{Constants::RC_VERSION}.noarch.rpm",
78
+ :pkg_mgr => 'rpm',
79
+ :pkg_type => 'RPM',
80
+ :pkg_repo => 'yum',
81
+ :deps => Constants::RPM_DEPS,
82
82
  :repo_src_file => '/etc/yum.repos.d/rhoconnect.repo',
83
- :repo_str => '[rhoconnect]\n' +
84
- 'name=Rhoconnect\n' +
83
+ :repo_str => '[rhoconnect]\n' +
84
+ 'name=Rhoconnect\n' +
85
85
  "baseurl=http://#{BUCKET}.s3.amazonaws.com/#{channel}/rpm" +
86
86
  '\nenabled=1\n' +
87
87
  'gpgcheck=0\n' }
@@ -112,9 +112,9 @@ end #get_access_keys
112
112
  def make_fog
113
113
  get_access_keys
114
114
  @fog = Fog::Compute.new(
115
- :provider => 'AWS',
116
- :region => Constants::REGION,
117
- :aws_access_key_id => @access_key,
115
+ :provider => 'AWS',
116
+ :region => Constants::REGION,
117
+ :aws_access_key_id => @access_key,
118
118
  :aws_secret_access_key => @secret_access_key
119
119
  )
120
120
  end #make_fog
@@ -138,7 +138,7 @@ def start_new_instance
138
138
  puts
139
139
 
140
140
  # save important instance information
141
- @host = @server.dns_name
141
+ @host = @server.dns_name
142
142
  @server_id = @server.id
143
143
  else
144
144
  puts "Server timed out."
@@ -162,11 +162,11 @@ end #destroy_ec2_instance
162
162
  # prepare_sources
163
163
  # Prepares the remote machine's repo source list to be able to download rhoconnect
164
164
  def prepare_sources
165
- puts "preparing sources..."
165
+ puts "preparing sources..."
166
166
 
167
167
  ssh_cmd "sudo touch #{@dist[:repo_src_file]}" if @dist[:flavor] == 'centos'
168
168
  filename = @dist[:repo_src_file]
169
- src_str = @dist[:repo_str]
169
+ src_str = @dist[:repo_str]
170
170
 
171
171
  # Create file for yum rhoconnect sources
172
172
  # Get current permissions of file
@@ -186,7 +186,7 @@ end #prepare_sources
186
186
  # Issues commands to the remote machine to start the installation
187
187
  def install_package
188
188
  prepare_sources
189
- puts "Installing rhoconnect package.\n" +
189
+ puts "Installing rhoconnect package.\n" +
190
190
  "This may take a while...\n\n"
191
191
  ssh_cmd "yes | sudo #{@dist[:pkg_repo]} install rhoconnect"
192
192
  end #install_package
@@ -197,7 +197,7 @@ def start_servers
197
197
  max_attempts = 100
198
198
  puts
199
199
 
200
- ['Redis', 'Nginx'].each do |program|
200
+ ['Redis', 'Nginx', 'thin'].each do |program|
201
201
  attempts = 0
202
202
  while @ssh.run("pgrep #{program.downcase}")[0].stdout.strip == "" and
203
203
  attempts < max_attempts
@@ -221,14 +221,15 @@ def check_rc_service
221
221
  puts "Host: #{@host}"
222
222
 
223
223
  puts "Checking RC service."
224
- request = nil #Defined outside block as to not limit the scope of request to the do block.
224
+ request = nil #Defined outside block as to not limit the scope of request to the do block.
225
225
  2.times do
226
226
  request = Net::HTTP.get_response(@host, '/')
227
227
  end #do
228
228
 
229
229
  puts "Code: #{request.code} Message: #{request.message}"
230
230
 
231
- if request.code == '200'
231
+ if request.code == '200' or
232
+ request.code == '302'
232
233
  puts "Rhoconnect service up!"
233
234
  else
234
235
  puts "Failed to connect to rhoconnect service."
@@ -261,7 +262,7 @@ Constants::STACKS.each do |stack|
261
262
  start_time = Time.now
262
263
 
263
264
  begin
264
- @stack = stack
265
+ @stack = stack
265
266
  compile_stack_info
266
267
 
267
268
  puts "\n" +
@@ -4,4 +4,4 @@ namespace :rc_pkg do
4
4
  # Run installation test
5
5
  ruby "installer/utils/nix_install_test.rb"
6
6
  end #:test
7
- end #:rc_pkg
7
+ end #:rc_pkg
@@ -18,18 +18,20 @@ task "build:repos", :build_type, :build_number do |t, args|
18
18
 
19
19
  # CONSTANTS
20
20
 
21
- PKG_DIR = case build_type
22
- when 'release'
23
- '/packages'
24
- when 'test'
25
- '/test-packages'
26
- when 'beta'
27
- '/beta-packages'
28
- else 'nightly'
29
- '/nightly-packages'
30
- end #case
31
-
32
- BUCKET = 'rhoconnect'
21
+ RHOCONNECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..'))
22
+
23
+ PKG_DIR = case build_type
24
+ when 'release'
25
+ '/packages'
26
+ when 'test'
27
+ '/test-packages'
28
+ when 'beta'
29
+ '/beta-packages'
30
+ else 'nightly'
31
+ '/nightly-packages'
32
+ end #case
33
+
34
+ BUCKET = 'rhoconnect'
33
35
 
34
36
  def cmd(cmd)
35
37
  puts cmd
@@ -70,6 +72,8 @@ task "build:repos", :build_type, :build_number do |t, args|
70
72
  end #prepare_destination
71
73
 
72
74
  def copy_files
75
+ # Move back into rhoconnect repo root first
76
+ Dir.chdir RHOCONNECT_ROOT
73
77
  # Copy the packages to their respective directory
74
78
  Find.find('./pkg') do |file|
75
79
  if !FileTest.directory?(file)
@@ -88,25 +92,25 @@ task "build:repos", :build_type, :build_number do |t, args|
88
92
  end #copy_files
89
93
 
90
94
  prepare_destination
91
-
95
+
92
96
  copy_files
93
97
 
94
- if build_type != "release" &&
95
- build_type != "test"
96
- # Change name of packages to include build number
97
- ['deb', 'rpm'].each do |arch|
98
- Find.find("#{PKG_DIR}") do |file|
99
- if !File.directory?(file) &&
100
- file =~ /#{arch}$/
101
- file_to_rename = File.open(file, 'r')
102
- old_name = File.expand_path(file)
103
- puts "Old Name:\t#{old_name}"
104
- new_name = old_name.gsub(/(#{arch})$/, "build-#{build_number.to_s}.\\1" )
105
- File.rename(old_name, new_name)
106
- end #if
107
- end #do
108
- end #do
109
- end #if
98
+ # if build_type != "release" &&
99
+ # build_type != "test"
100
+ # # Change name of packages to include build number
101
+ # ['deb', 'rpm'].each do |arch|
102
+ # Find.find("#{PKG_DIR}") do |file|
103
+ # if !File.directory?(file) &&
104
+ # file =~ /#{arch}$/
105
+ # file_to_rename = File.open(file, 'r')
106
+ # old_name = File.expand_path(file)
107
+ # puts "Old Name:\t#{old_name}"
108
+ # new_name = old_name.gsub(/(#{arch})$/, "build-#{build_number.to_s}.\\1" )
109
+ # File.rename(old_name, new_name)
110
+ # end #if
111
+ # end #do
112
+ # end #do
113
+ # end #if
110
114
 
111
115
  # REPOIFY!
112
116
  cmd "sudo reprepro -b #{PKG_DIR}/deb includedeb rhoconnect #{PKG_DIR}/deb/#{@deb_pkg}"
@@ -121,4 +125,4 @@ task "build:repos", :build_type, :build_number do |t, args|
121
125
  cmd "sudo ruby ./installer/utils/package_upload/s3_upload.rb #{PKG_DIR}/#{dir} #{BUCKET}"
122
126
  end #do
123
127
  cmd "sudo ruby ./installer/utils/package_upload/s3_upload.rb #{PKG_DIR}/SHA1 #{BUCKET}"
124
- end #build:repos
128
+ end #build:repos
@@ -7,7 +7,7 @@ require 'find'
7
7
  # CONSTANTS
8
8
 
9
9
  START_DIR = ARGV[0]
10
- BUCKET = ARGV[1]
10
+ BUCKET = ARGV[1]
11
11
  USER_DATA = `wget -q -O - http://169.254.169.254/latest/user-data`.split("\n")
12
12
 
13
13
  # METHODS
@@ -42,7 +42,7 @@ end #check_params
42
42
 
43
43
  # Retrieves S3 credential information
44
44
  def get_keys
45
- access_key = USER_DATA[0].to_s.strip
45
+ access_key = USER_DATA[0].to_s.strip
46
46
  secret_access_key = USER_DATA[1].to_s.strip
47
47
  keys = { :access_key_id => access_key,
48
48
  :secret_access_key => secret_access_key}
@@ -66,7 +66,7 @@ def upload(file)
66
66
  end #upload
67
67
 
68
68
  # Traverses list of file to upload and calls Upload to upload them
69
- def upload_files
69
+ def upload_files
70
70
  # Get list of files do be added
71
71
  number_of_files = 0
72
72
  paths = []
@@ -0,0 +1,10 @@
1
+ Server.api :fast_delete, :source do |params,user|
2
+ source = Source.load(params[:source_id],{:app_id=>APP_NAME,:user_id=>params[:user_id]})
3
+ # if source does not exist create one for dynamic adapter
4
+ source = Source.create({:name => params[:source_id]},{:app_id => APP_NAME,:user_id=>params[:user_id]}) unless source
5
+ source_sync = SourceSync.new(source)
6
+ timeout = params[:timeout] || 10
7
+ raise_on_expire = params[:raise_on_expire] || false
8
+ source_sync.fast_delete(params[:data], timeout,raise_on_expire)
9
+ 'done'
10
+ end
@@ -0,0 +1,10 @@
1
+ Server.api :fast_insert, :source do |params,user|
2
+ source = Source.load(params[:source_id],{:app_id=>APP_NAME,:user_id=>params[:user_id]})
3
+ # if source does not exist create one for dynamic adapter
4
+ source = Source.create({:name => params[:source_id]},{:app_id => APP_NAME,:user_id=>params[:user_id]}) unless source
5
+ source_sync = SourceSync.new(source)
6
+ timeout = params[:timeout] || 10
7
+ raise_on_expire = params[:raise_on_expire] || false
8
+ source_sync.fast_insert(params[:data], timeout,raise_on_expire)
9
+ 'done'
10
+ end
@@ -0,0 +1,10 @@
1
+ Server.api :fast_update, :source do |params,user|
2
+ source = Source.load(params[:source_id],{:app_id=>APP_NAME,:user_id=>params[:user_id]})
3
+ # if source does not exist create one for dynamic adapter
4
+ source = Source.create({:name => params[:source_id]},{:app_id => APP_NAME,:user_id=>params[:user_id]}) unless source
5
+ source_sync = SourceSync.new(source)
6
+ timeout = params[:timeout] || 10
7
+ raise_on_expire = params[:raise_on_expire] || false
8
+ source_sync.fast_update(params[:delete_data], params[:data],timeout,raise_on_expire)
9
+ 'done'
10
+ end
@@ -1,3 +1,3 @@
1
1
  Server.api :get_source_params, :source do |params,user|
2
- Source.load(params[:source_id],{:app_id => APP_NAME,:user_id => '*'}).to_array.to_json
2
+ Source.load(params[:source_id],{:app_id => APP_NAME,:user_id => "*"}).to_array.to_json
3
3
  end
@@ -1,12 +1,12 @@
1
1
  Server.api :list_sources, :source do |params,user|
2
2
  sources = App.load(APP_NAME).sources
3
- if params[:partition_type].nil? or params[:partition_type] == 'all'
3
+ if params['partition_type'].nil? or params['partition_type'] == 'all'
4
4
  sources.to_json
5
5
  else
6
6
  res = []
7
7
  sources.each do |name|
8
8
  s = Source.load(name,{:app_id => APP_NAME,:user_id => '*'})
9
- if s.partition_type and s.partition_type == params[:partition_type].to_sym
9
+ if s and s.partition_type and s.partition_type == params['partition_type'].to_sym
10
10
  res << name
11
11
  end
12
12
  end
@@ -1,3 +1,3 @@
1
1
  Server.api :save_adapter, :source do |params,user|
2
- Rhoconnect.appserver = params[:attributes]['adapter_url']
2
+ Rhoconnect.appserver = params['adapter_url']
3
3
  end
@@ -0,0 +1,6 @@
1
+ Server.api :update_source_params, :source do |params,user|
2
+ source = Source.load(params[:source_name],
3
+ {:app_id => APP_NAME, :user_id => params[:user_name]})
4
+ source.update_fields(params[:data])
5
+ ''
6
+ end
@@ -0,0 +1,82 @@
1
+ require 'rack/fiber_pool'
2
+ require 'async-rack'
3
+ require 'eventmachine'
4
+
5
+ module Rhoconnect
6
+ module Synchrony
7
+ def setup_sessions(builder)
8
+ options = {}
9
+ if settings.respond_to?(:fiberpool_size)
10
+ options[:size] = settings.fiberpool_size
11
+ end
12
+ options[:rescue_exception] = handle_exception
13
+ builder.use Rack::FiberPool, options unless test?
14
+ super
15
+ end
16
+
17
+ def handle_exception
18
+ Proc.new do |env, e|
19
+ if settings.show_exceptions?
20
+ request = Sinatra::Request.new(env)
21
+ printer = Sinatra::ShowExceptions.new(proc{ raise e })
22
+ s, h, b = printer.call(env)
23
+ [s, h, b]
24
+ else
25
+ [500, {}, ""]
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ module AsyncHelpers
32
+ def self.included(klass)
33
+ (klass.instance_methods & self.instance_methods).each do |method|
34
+ klass.instance_eval{remove_method method.to_sym}
35
+ end
36
+ end
37
+
38
+ def catch_all
39
+ res = nil
40
+ begin
41
+ res = catch(:halt) { yield }
42
+ rescue ApiException => ae
43
+ res = [ae.error_code, ae.message]
44
+ rescue Exception => e
45
+ log e.message + e.backtrace.join("\n")
46
+ res = [500, e.message]
47
+ end
48
+ res
49
+ end
50
+
51
+ def execute_api_call(client_call = false)
52
+ f = Fiber.current
53
+ operation = proc {
54
+ if client_call or check_api_token
55
+ catch_all do
56
+ res = yield params, (client_call ? current_user : api_user), self
57
+ if params.has_key? :warning
58
+ Rhoconnect.log params[:warning]
59
+ response.headers['Warning'] = params[:warning]
60
+ end
61
+ res
62
+ end
63
+ else
64
+ [422, "No API token provided"]
65
+ end
66
+ }
67
+ result = nil
68
+ callback = proc { |proc_res| result = proc_res; f.resume }
69
+
70
+ EventMachine.defer operation, callback
71
+ Fiber.yield
72
+ # we can not throw exceptions across threads
73
+ # so we analyze it in the main thread after the
74
+ # request has been processed and if result
75
+ # has error code - then we throw :halt here
76
+ if Array === result and Fixnum === result.first
77
+ throw :halt, result
78
+ end
79
+ result
80
+ end
81
+ end
82
+ end
@@ -54,7 +54,11 @@ module Rhoconnect
54
54
  end
55
55
  true
56
56
  end
57
-
57
+
58
+ def delete_files
59
+ FileUtils.rm Dir.glob(File.join(Rhoconnect.base_directory, "#{self.url}*"))
60
+ end
61
+
58
62
  class << self
59
63
  def create(fields={})
60
64
  fields[:id] = fields[:name]
@@ -261,14 +261,14 @@ module Rhoconnect
261
261
  raise ArgumentError.new(UNKNOWN_CLIENT) unless client
262
262
  name = BulkData.get_name(partition,client.user_id)
263
263
  data = BulkData.load(name)
264
-
264
+
265
265
  sources = client.app.partition_sources(partition,client.user_id)
266
266
  return {:result => :nop} if sources.length <= 0
267
-
267
+
268
268
  do_bd_sync = data.nil?
269
269
  do_bd_sync = (data.completed? and
270
270
  (data.refresh_time <= Time.now.to_i or !data.dbfiles_exist?)) unless do_bd_sync
271
-
271
+
272
272
  if do_bd_sync
273
273
  data.delete if data
274
274
  data = BulkData.create(:name => name,
@@ -281,6 +281,21 @@ module Rhoconnect
281
281
 
282
282
  if data and data.completed? and data.dbfiles_exist?
283
283
  client.update_clientdoc(sources)
284
+ sources.each do |src|
285
+ s = Source.load(src, {:user_id => client.user_id, :app_id => client.app_id})
286
+ errordoc = s.docname(:errors)
287
+ errors = {}
288
+ Store.lock(errordoc) do
289
+ errors = Store.get_data(errordoc)
290
+ end
291
+ unless errors.empty?
292
+ # FIXME: :result => :bulk_sync_error, :errors => "#{errors}"
293
+ log "Bulk sync errors are found in #{src}: #{errors}"
294
+ # Delete all related bulk files
295
+ data.delete_files
296
+ return {:result => :url, :url => ''}
297
+ end
298
+ end
284
299
  {:result => :url, :url => data.url}
285
300
  elsif data
286
301
  {:result => :wait}
@@ -29,7 +29,7 @@ module RhoconnectApi
29
29
  Server.save_adapter({:attributes => {'adapter_url' => adapter_url}},nil)
30
30
  else
31
31
  RestClient.post("#{server}/api/source/save_adapter",
32
- {:api_token => token,:attributes => {:adapter_url => adapter_url}}.to_json,
32
+ {:api_token => token,:adapter_url => adapter_url}.to_json,
33
33
  :content_type => :json)
34
34
  end
35
35
  end
@@ -37,7 +37,7 @@ module RhoconnectApi
37
37
  def create_user(server,token,login,password)
38
38
  if directcall?(server) and verify_token(token)
39
39
  Server.create_user({:attributes => {'login' => login, 'password' => password}},nil)
40
- else
40
+ else
41
41
  RestClient.post("#{server}/api/user/create_user",
42
42
  {:api_token => token,:attributes => {:login => login, :password => password}}.to_json,
43
43
  :content_type => :json)
@@ -1,32 +1,5 @@
1
- $:.unshift File.dirname(__FILE__)
2
- require 'rubygems'
3
- require 'sinatra/base'
4
- require 'erb'
5
- require 'json'
6
- require 'rhoconnect_api'
7
-
8
- module RhoconnectConsole
9
- class << self
10
- ROOT_DIR = File.dirname(File.expand_path(__FILE__)) unless defined? ROOT_DIR
11
- def root_path(*args)
12
- File.join(ROOT_DIR, *args)
13
- end
14
- end
15
-
16
- class Server < Sinatra::Base
17
- set :views, RhoconnectConsole::root_path("app","views")
18
- set :public_folder, RhoconnectConsole::root_path("app","public")
19
- set :static, true
20
- use Rack::Session::Cookie
21
- HEROKU_NAV = ENV['INSTANCE_ID'] ? RestClient.get('http://nav.heroku.com/v1/providers/header') : nil
22
- before do
23
- headers['Expires'] = 'Sun, 19 Nov 1978 05:00:00 GMT'
24
- headers['Cache-Control'] = 'no-store, no-cache, must-revalidate'
25
- headers['Pragma'] = 'no-cache'
26
- end
27
- end
28
- end
29
-
30
- Dir[File.join(File.dirname(__FILE__),"app/**/*.rb")].each do |file|
31
- require file
32
- end
1
+ puts "\nDEPRECATION WARNING: 'rhoconnect/console/server' will be removed in 4.0. Please change your config.ru:\n\n"
2
+ puts "require 'rhoconnect/console/server'"
3
+ puts "\nto the following:\n\n"
4
+ puts "require 'rhoconnect/web-console/server'\n\n"
5
+ require 'rhoconnect/web-console/server'
@@ -1,3 +1,3 @@
1
- path = File.join(File.dirname(__FILE__),'..','..','lib')
1
+ path = File.join(File.dirname(__FILE__), '..')
2
2
  $:.unshift path
3
- ROOT_PATH = File.expand_path(File.dirname(__FILE__))
3
+ ROOT_PATH = Dir.pwd