Permalink
Browse files

replace VMC_* env vars by VCAP_*

Change-Id: Ia4bff3107a85e359c6d66de21071bad141379bf6
Signed-off-by: michael zhang <zhangcheng@rbcon.com>
  • Loading branch information...
1 parent 3ab2e1b commit 74c72d86a3140b9567f6b17ad7c0caef26e5a84d michael zhang committed Sep 7, 2012
Showing with 188 additions and 131 deletions.
  1. +2 −2 bad_apps/cpu/cpu.rb
  2. +2 −2 bad_apps/disk/diskhog.rb
  3. +2 −2 bad_apps/fd/fdhog.rb
  4. +2 −2 bad_apps/mem/memhog.rb
  5. +2 −2 java_web/java_tiny_app/src/main/java/com/vmware/appcloud/testapps/javatinyapp/MainServlet.java
  6. +1 −1 mochiweb/mochiweb_test/README
  7. +1 −1 mochiweb/mochiweb_test/src/mochiweb_test_sup.erl
  8. +10 −8 node/app_node_service/main.js
  9. +1 −1 node/node_chat/app.js
  10. +11 −4 rack/app_rack_service/main.rb
  11. +1 −1 rack/app_rack_service_autoconfig/app.rb
  12. +1 −1 rack/autoconfig_disabled_by_file/app.rb
  13. +1 −1 rack/autoconfig_disabled_by_gem/app.rb
  14. +1 −1 rack/autoconfig_ruby19/app.rb
  15. +12 −5 rails3/app_rails_service/app/controllers/service_controller.rb
  16. +2 −2 rails3/app_rails_service/app/views/root/index.html.erb
  17. +11 −5 rails3/app_rails_service/config/initializers/mongo.rb
  18. +11 −5 rails3/app_rails_service/config/initializers/redis.rb
  19. +1 −1 rails3/app_rails_service_autoconfig/app/controllers/service_controller.rb
  20. +2 −2 rails3/app_rails_service_autoconfig/app/views/root/index.html.erb
  21. +1 −1 rails3/autoconfig_disabled_by_file/app/controllers/service_controller.rb
  22. +2 −2 rails3/autoconfig_disabled_by_file/app/views/root/index.html.erb
  23. +1 −1 rails3/autoconfig_disabled_by_gem/app/controllers/service_controller.rb
  24. +2 −2 rails3/autoconfig_disabled_by_gem/app/views/root/index.html.erb
  25. +2 −2 rails3/hello_vcap/app/views/root/index.html.erb
  26. +2 −2 rails3/rails3_app/app/views/root/index.html.erb
  27. +1 −1 sinatra/amqp_autoconfig/app.rb
  28. +11 −4 sinatra/app_sinatra_service/main.rb
  29. +1 −1 sinatra/app_sinatra_service_autoconfig/app.rb
  30. +18 −9 sinatra/app_sinatra_service_quota/main.rb
  31. +12 −10 sinatra/atmos_app/server.rb
  32. +1 −1 sinatra/autoconfig_disabled_by_file/app.rb
  33. +1 −1 sinatra/autoconfig_disabled_by_gem/app.rb
  34. +1 −1 sinatra/autoconfig_unsupported_carrot_version/app.rb
  35. +1 −1 sinatra/autoconfig_unsupported_versions/app.rb
  36. +2 −2 sinatra/broken_app/broken.rb
  37. +2 −2 sinatra/elasticsearch_app/elasticsearch.rb
  38. +10 −9 sinatra/env_test_app/env_test.rb
  39. +1 −1 sinatra/gem_groups/main.rb
  40. +2 −2 sinatra/hello_vcap/foo.rb
  41. +2 −2 sinatra/memcached_app/memcached.rb
  42. +2 −2 sinatra/modified_simple_app/foo.rb
  43. +16 −13 sinatra/redis_lb_app/redis_lb.rb
  44. +2 −2 sinatra/simple_db_app/simple_db_app.rb
  45. +11 −4 sinatra/windows_gemfile/main.rb
  46. +1 −1 standalone/ruby_app/main.rb
  47. +1 −1 standalone/ruby_autoconfig/app.rb
  48. +1 −1 standalone/ruby_autoconfig_disabled_by_file/app.rb
  49. +1 −1 standalone/ruby_autoconfig_disabled_by_gem/app.rb
View
@@ -4,8 +4,8 @@
BLOWUP_MEM = 512
get '/' do
- host = ENV['VMC_APP_HOST']
- port = ENV['VMC_APP_PORT']
+ host = ENV['VCAP_APP_HOST']
+ port = ENV['VCAP_APP_PORT']
msg = "<h1>Hello from CpuHog! via: #{host}:#{port} </h1>"
msg += "<h2>Visit /evil to trigger bad behavior to create processes to peg the cpu!.</h2>"
msg += "<h1><font weight=bold color=red>DO NOT DO THIS ON A NON-SECURE DEA!</font></h1>"
@@ -7,8 +7,8 @@
MB = KB * 1024
get '/' do
- host = ENV['VMC_APP_HOST']
- port = ENV['VMC_APP_PORT']
+ host = ENV['VCAP_APP_HOST']
+ port = ENV['VCAP_APP_PORT']
msg = "<h1>Hello from DiskHog! via: #{host}:#{port} </h1>"
msg += "<h2>Visit /largefile to trigger bad behavior</h2>"
end
@@ -2,8 +2,8 @@
require 'sinatra'
get '/' do
- host = ENV['VMC_APP_HOST']
- port = ENV['VMC_APP_PORT']
+ host = ENV['VCAP_APP_HOST']
+ port = ENV['VCAP_APP_PORT']
msg = "<h1>Hello from FDHog! via: #{host}:#{port} </h1>"
msg += "<h2>Visit /evil to trigger bad behavior.</h2>"
msg += "<h1><font weight=bold color=red>DO NOT DO THIS ON A NON-SECURE DEA!</font></h1>"
@@ -4,8 +4,8 @@
BLOWUP_MEM = 512
get '/' do
- host = ENV['VMC_APP_HOST']
- port = ENV['VMC_APP_PORT']
+ host = ENV['VCAP_APP_HOST']
+ port = ENV['VCAP_APP_PORT']
msg = "<h1>Hello from MemHog! via: #{host}:#{port} </h1>"
msg += "<h2>Visit /evil to trigger bad behavior to create array of #{BLOWUP_MEM} Millions elements.</h2>"
msg += "<h1><font weight=bold color=red>DO NOT DO THIS ON A NON-SECURE DEA!</font></h1>"
@@ -24,8 +24,8 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
response.setStatus(200);
PrintWriter writer = response.getWriter();
writer.println("It just needed to be restarted!");
- writer.println("My instance id: " + System.getenv("VMC_APP_ID"));
- writer.println("My location: " + System.getenv("VMC_DEA_HOST") + ":" + System.getenv("VMC_DEA_PORT"));
+ writer.println("My instance id: " + System.getenv("VCAP_APP_ID"));
+ writer.println("My location: " + System.getenv("VCAP_DEA_HOST") + ":" + System.getenv("VCAP_DEA_PORT"));
writer.close();
}
}
@@ -6,7 +6,7 @@ using the Mochiweb "make app" command, and the only modification was to change:
Web = web_specs(mochiweb_test_web, 8080),
to:
Web = web_specs(mochiweb_test_web,
- case os:getenv("VMC_APP_PORT") of
+ case os:getenv("VCAP_APP_PORT") of
false -> 9090;
P -> list_to_integer(P)
end),
@@ -42,7 +42,7 @@ upgrade() ->
%% @doc supervisor callback.
init([]) ->
Web = web_specs(mochiweb_test_web,
- case os:getenv("VMC_APP_PORT") of
+ case os:getenv("VCAP_APP_PORT") of
false -> 9090;
P -> list_to_integer(P)
end),
@@ -10,7 +10,7 @@ var nerve = require( './lib/nerve/lib/nerve' ),
var msg_value="";
-var port = process.env.VMC_APP_PORT || 8080;
+var port = process.env.VCAP_APP_PORT || 8080;
var getBody = function(req, callback){
var body = '';
req.on('data', function(chunk){
@@ -22,7 +22,7 @@ var getBody = function(req, callback){
var app = [
[get(/^\/env$/), function(req, res, name) {
- var services = eval('(' + process.env.VMC_SERVICES + ')');
+ var services = eval('(' + process.env.VCAP_SERVICES + ')');
res.respond('env: '+ sys.inspect(services));
}],
[get(/^\/$/), function(req, res, name) {
@@ -279,13 +279,15 @@ function mysql_services(){
}
function load_service(service_name){
- var services = eval('(' + process.env.VMC_SERVICES + ')');
+ var services = eval('(' + process.env.VCAP_SERVICES + ')');
var service = null;
- services.forEach(function(s){
- if(s.vendor.toLowerCase() === service_name.toLowerCase()){
- service = s.options;
- }
- });
+ for (i in services) {
+ services[i].forEach(function(s) {
+ if(i.split('-')[0].toLowerCase() === service_name.toLowerCase()){
+ service = s.credentials;
+ }
+ });
+ }
return service;
}
@@ -120,7 +120,7 @@ setInterval(function () {
}
}, 1000);
-fu.listen(Number(process.env.VMC_APP_PORT || PORT), HOST);
+fu.listen(Number(process.env.VCAP_APP_PORT || PORT), HOST);
fu.get("/", fu.staticHandler("index.html"));
fu.get("/style.css", fu.staticHandler("style.css"));
@@ -9,7 +9,7 @@
class RackServiceApp < Sinatra::Base
get '/env' do
- ENV['VMC_SERVICES']
+ ENV['VCAP_SERVICES']
end
get '/rack/env' do
@@ -143,9 +143,16 @@ def load_postgresql
end
def load_service(service_name)
- services = JSON.parse(ENV['VMC_SERVICES'])
- service = services.find {|service| service["vendor"].downcase == service_name}
- service = service["options"] if service
+ services = JSON.parse(ENV['VCAP_SERVICES'])
+ service = nil
+ services.each do |k, v|
+ v.each do |s|
+ if k.split('-')[0].downcase == service_name.downcase
+ service = s["credentials"]
+ end
+ end
+ end
+ service
end
def rabbit_service
@@ -9,7 +9,7 @@
class RackAutoConfigApp < Sinatra::Base
get '/env' do
- ENV['VMC_SERVICES']
+ ENV['VCAP_SERVICES']
end
get '/' do
@@ -9,7 +9,7 @@
class RackAutoConfigApp < Sinatra::Base
get '/env' do
- ENV['VMC_SERVICES']
+ ENV['VCAP_SERVICES']
end
get '/' do
@@ -9,7 +9,7 @@
class RackAutoConfigApp < Sinatra::Base
get '/env' do
- ENV['VMC_SERVICES']
+ ENV['VCAP_SERVICES']
end
get '/' do
@@ -5,7 +5,7 @@
class RackAutoConfigApp < Sinatra::Base
get '/env' do
- ENV['VMC_SERVICES']
+ ENV['VCAP_SERVICES']
end
get '/' do
@@ -5,7 +5,7 @@ def hello
end
def env
- render :text => ENV['VMC_SERVICES']
+ render :text => ENV['VCAP_SERVICES']
end
def crash
@@ -54,9 +54,16 @@ def service
private
def load_service(service_name)
- services = JSON.parse(ENV['VMC_SERVICES'])
- service = services.find {|service| service["vendor"].downcase == service_name}
- service = service["options"] if service
+ services = JSON.parse(ENV['VCAP_SERVICES'])
+ service = nil
+ services.each do |k, v|
+ v.each do |s|
+ if k.split('-')[0].downcase == service_name.downcase
+ service = s["credentials"]
+ end
+ end
+ end
+ service
end
def rabbit_srs_service
@@ -86,4 +93,4 @@ def rabbit_service
service = load_service('rabbitmq')
Carrot.new( :host => service['hostname'], :port => service['port'], :user => service['user'], :pass => service['pass'], :vhost => service['vhost'] )
end
-end
+end
@@ -1,5 +1,5 @@
-<%- host = ENV['VMC_APP_HOST'] %>
-<%- port = ENV['VMC_APP_PORT'] %>
+<%- host = ENV['VCAP_APP_HOST'] %>
+<%- port = ENV['VCAP_APP_PORT'] %>
<h1>
Hello from VCAP! via: <%=host%>:<%=port%>
</h1>
@@ -1,12 +1,18 @@
-if ENV['VMC_SERVICES']
- services = JSON.parse(ENV['VMC_SERVICES'])
+if ENV['VCAP_SERVICES']
+ services = JSON.parse(ENV['VCAP_SERVICES'])
if services
- mongodb_service = services.find {|service| service["vendor"].downcase == "mongodb"}
+ mongodb_service = nil
+ services.each do |k, v|
+ v.each do |s|
+ if k.split('-')[0].downcase == 'mongodb'
+ mongodb_service = s["credentials"]
+ end
+ end
+ end
if mongodb_service
- mongodb_service = mongodb_service["options"]
MongoMapper.connection = Mongo::Connection.new(mongodb_service['hostname'], mongodb_service['port'])
MongoMapper.database = mongodb_service['db']
MongoMapper.database.authenticate(mongodb_service['username'], mongodb_service['password'])
end
end
-end
+end
@@ -1,10 +1,16 @@
-if ENV['VMC_SERVICES']
- services = JSON.parse(ENV['VMC_SERVICES'])
+if ENV['VCAP_SERVICES']
+ services = JSON.parse(ENV['VCAP_SERVICES'])
if services
- redis_service = services.find {|service| service["vendor"].downcase == "redis"}
+ redis_service = nil
+ services.each do |k, v|
+ v.each do |s|
+ if k.split('-')[0].downcase == 'redis'
+ redis_service = s["credentials"]
+ end
+ end
+ end
if redis_service
- redis_service = redis_service["options"]
$redis = Redis.new({:host => redis_service["hostname"], :port => redis_service["port"], :password => redis_service["password"]})
end
end
-end
+end
@@ -5,7 +5,7 @@ def hello
end
def env
- render :text => ENV['VMC_SERVICES']
+ render :text => ENV['VCAP_SERVICES']
end
def crash
@@ -1,5 +1,5 @@
-<%- host = ENV['VMC_APP_HOST'] %>
-<%- port = ENV['VMC_APP_PORT'] %>
+<%- host = ENV['VCAP_APP_HOST'] %>
+<%- port = ENV['VCAP_APP_PORT'] %>
<h1>
Hello from VCAP! via: <%=host%>:<%=port%>
</h1>
@@ -5,7 +5,7 @@ def hello
end
def env
- render :text => ENV['VMC_SERVICES']
+ render :text => ENV['VCAP_SERVICES']
end
def service
@@ -1,5 +1,5 @@
-<%- host = ENV['VMC_APP_HOST'] %>
-<%- port = ENV['VMC_APP_PORT'] %>
+<%- host = ENV['VCAP_APP_HOST'] %>
+<%- port = ENV['VCAP_APP_PORT'] %>
<h1>
Hello from VCAP! via: <%=host%>:<%=port%>
</h1>
@@ -5,7 +5,7 @@ def hello
end
def env
- render :text => ENV['VMC_SERVICES']
+ render :text => ENV['VCAP_SERVICES']
end
def service
@@ -1,5 +1,5 @@
-<%- host = ENV['VMC_APP_HOST'] %>
-<%- port = ENV['VMC_APP_PORT'] %>
+<%- host = ENV['VCAP_APP_HOST'] %>
+<%- port = ENV['VCAP_APP_PORT'] %>
<h1>
Hello from VCAP! via: <%=host%>:<%=port%>
</h1>
@@ -1,5 +1,5 @@
-<%- host = ENV['VMC_APP_HOST'] %>
-<%- port = ENV['VMC_APP_PORT'] %>
+<%- host = ENV['VCAP_APP_HOST'] %>
+<%- port = ENV['VCAP_APP_PORT'] %>
<h1>
Hello from VCAP! via: <%=host%>:<%=port%>
</h1>
@@ -1,5 +1,5 @@
-<%- host = ENV['VMC_APP_HOST'] %>
-<%- port = ENV['VMC_APP_PORT'] %>
+<%- host = ENV['VCAP_APP_HOST'] %>
+<%- port = ENV['VCAP_APP_PORT'] %>
<h1>
Hello from VCAP! via: <%=host%>:<%=port%>
</h1>
@@ -4,7 +4,7 @@
require 'amqp'
get '/env' do
- ENV['VMC_SERVICES']
+ ENV['VCAP_SERVICES']
end
get '/' do
@@ -9,7 +9,7 @@
require 'pg'
get '/env' do
- ENV['VMC_SERVICES']
+ ENV['VCAP_SERVICES']
end
get '/rack/env' do
@@ -252,9 +252,16 @@ def load_vblob
end
def load_service(service_name)
- services = JSON.parse(ENV['VMC_SERVICES'])
- service = services.find {|service| service["vendor"].downcase == service_name}
- service = service["options"] if service
+ services = JSON.parse(ENV['VCAP_SERVICES'])
+ service = nil
+ services.each do |k, v|
+ v.each do |s|
+ if k.split('-')[0].downcase == service_name.downcase
+ service = s["credentials"]
+ end
+ end
+ end
+ service
end
def rabbit_service
@@ -8,7 +8,7 @@
require 'pg'
get '/env' do
- ENV['VMC_SERVICES']
+ ENV['VCAP_SERVICES']
end
get '/' do
Oops, something went wrong.

0 comments on commit 74c72d8

Please sign in to comment.