Permalink
Browse files

Use the cloudfoundry-client gem instead of the vmc gem

  • Loading branch information...
1 parent b9cf774 commit 850996817261f8a67f807f3d88f8bb7c9c589109 @frodenas committed Dec 7, 2011
Showing with 8,326 additions and 6,242 deletions.
  1. +2 −0 .gitignore
  2. +1 −0 .rspec
  3. +9 −11 Gemfile
  4. +0 −144 Gemfile.lock
  5. +46 −6 README.md
  6. +8 −6 app/controllers/application_controller.rb
  7. +1 −1 app/controllers/apps_controller.rb
  8. +5 −1 app/controllers/services_controller.rb
  9. +9 −9 app/controllers/sessions_controller.rb
  10. +77 −113 app/models/app.rb
  11. +11 −26 app/models/service.rb
  12. +10 −5 app/models/system.rb
  13. +9 −14 app/models/user.rb
  14. +6 −0 config/initializers/json_patch.rb
  15. +1 −1 public/humans.txt
  16. +23 −23 spec/controllers/apps_controller_spec.rb
  17. +1 −1 spec/controllers/dashboard_controller_spec.rb
  18. +1 −2 spec/controllers/services_controller_spec.rb
  19. +23 −23 spec/controllers/sessions_controller_spec.rb
  20. +1 −1 spec/controllers/system_controller_spec.rb
  21. +7 −5 spec/controllers/users_controller_spec.rb
  22. +279 −0 spec/fixtures/controllers/admin/users.yml
  23. +318 −0 spec/fixtures/controllers/admin/users_create_action.yml
  24. +244 −0 spec/fixtures/controllers/admin/users_create_again_action.yml
  25. +234 −0 spec/fixtures/controllers/admin/users_delete_action.yml
  26. +242 −0 spec/fixtures/controllers/logged/apps.yml
  27. +336 −0 spec/fixtures/controllers/logged/dashboard.yml
  28. +404 −0 spec/fixtures/controllers/logged/services.yml
  29. +365 −0 spec/fixtures/controllers/logged/services_create_action.yml
  30. +238 −0 spec/fixtures/controllers/logged/services_delete_action.yml
  31. +258 −0 spec/fixtures/controllers/logged/sessions.yml
  32. +80 −0 spec/fixtures/controllers/logged/sessions_create_action.yml
  33. +447 −0 spec/fixtures/controllers/logged/system.yml
  34. +275 −0 spec/fixtures/controllers/logged/users.yml
  35. +83 −0 spec/fixtures/controllers/no_logged/apps.yml
  36. +83 −0 spec/fixtures/controllers/no_logged/dashboard.yml
  37. +83 −0 spec/fixtures/controllers/no_logged/services.yml
  38. +153 −0 spec/fixtures/controllers/no_logged/sessions.yml
  39. +80 −0 spec/fixtures/controllers/no_logged/sessions_create_action.yml
  40. +83 −0 spec/fixtures/controllers/no_logged/system.yml
  41. +83 −0 spec/fixtures/controllers/no_logged/users.yml
  42. +80 −0 spec/fixtures/models/admin/client.yml
  43. +44 −0 spec/fixtures/models/admin/user_create.yml
  44. +36 −0 spec/fixtures/models/admin/user_create_action.yml
  45. +44 −0 spec/fixtures/models/admin/user_delete.yml
  46. +96 −0 spec/fixtures/models/admin/user_delete_action.yml
  47. +483 −0 spec/fixtures/models/logged/app.yml
  48. +81 −0 spec/fixtures/models/logged/app_bind_invalid_service_action.yml
  49. +206 −0 spec/fixtures/models/logged/app_bind_service_action.yml
  50. +44 −0 spec/fixtures/models/logged/app_bind_service_binded_action.yml
  51. +42 −0 spec/fixtures/models/logged/app_create_action.yml
  52. +81 −0 spec/fixtures/models/logged/app_map_url_action.yml
  53. +44 −0 spec/fixtures/models/logged/app_map_url_mapped_action.yml
  54. +122 −0 spec/fixtures/models/logged/app_modify_var_action.yml
  55. +134 −0 spec/fixtures/models/logged/app_set_instances_action.yml
  56. +175 −0 spec/fixtures/models/logged/app_set_memory_action.yml
  57. +122 −0 spec/fixtures/models/logged/app_set_var_action.yml
  58. +159 −0 spec/fixtures/models/logged/app_unbind_service_action.yml
  59. +81 −0 spec/fixtures/models/logged/app_unmap_url_action.yml
  60. +122 −0 spec/fixtures/models/logged/app_unset_var_action.yml
  61. +80 −0 spec/fixtures/models/logged/client.yml
  62. +169 −0 spec/fixtures/models/logged/service_create.yml
  63. +87 −0 spec/fixtures/models/logged/service_create_action.yml
  64. +83 −0 spec/fixtures/models/logged/service_delete.yml
  65. +40 −0 spec/fixtures/models/logged/service_delete_action.yml
  66. +143 −0 spec/fixtures/models/logged/system.yml
  67. +110 −0 spec/fixtures/models/logged/user.yml
  68. +43 −0 spec/fixtures/models/no_logged/app.yml
  69. +43 −0 spec/fixtures/models/no_logged/client.yml
  70. +43 −0 spec/fixtures/models/no_logged/service.yml
  71. +83 −0 spec/fixtures/models/no_logged/system.yml
  72. +74 −0 spec/fixtures/models/no_logged/user.yml
  73. +17 −0 spec/helpers/application_helper_spec.rb
  74. +369 −233 spec/models/app_spec.rb
  75. +32 −24 spec/models/service_spec.rb
  76. +3 −3 spec/models/system_spec.rb
  77. +62 −40 spec/models/user_spec.rb
  78. +11 −0 spec/spec_helper.rb
  79. +18 −19 spec/support/cf_connection_helper.rb
  80. +1 −1 spec/support/vcr.rb
  81. +0 −363 spec/vcr_cassettes/controllers/admin/users.yml
  82. +0 −201 spec/vcr_cassettes/controllers/admin/users_create_action.yml
  83. +0 −119 spec/vcr_cassettes/controllers/admin/users_delete_action.yml
  84. +0 −402 spec/vcr_cassettes/controllers/logged/apps.yml
  85. +0 −489 spec/vcr_cassettes/controllers/logged/dashboard.yml
  86. +0 −458 spec/vcr_cassettes/controllers/logged/services.yml
  87. +0 −247 spec/vcr_cassettes/controllers/logged/services_create_action.yml
  88. +0 −162 spec/vcr_cassettes/controllers/logged/services_delete_action.yml
  89. +0 −160 spec/vcr_cassettes/controllers/logged/sessions.yml
  90. +0 −40 spec/vcr_cassettes/controllers/logged/sessions_create_action.yml
  91. +0 −272 spec/vcr_cassettes/controllers/logged/system.yml
  92. +0 −266 spec/vcr_cassettes/controllers/logged/users.yml
  93. +0 −39 spec/vcr_cassettes/controllers/no_logged/apps.yml
  94. +0 −39 spec/vcr_cassettes/controllers/no_logged/dashboard.yml
  95. +0 −39 spec/vcr_cassettes/controllers/no_logged/services.yml
  96. +0 −113 spec/vcr_cassettes/controllers/no_logged/sessions.yml
  97. +0 −40 spec/vcr_cassettes/controllers/no_logged/sessions_create_action.yml
  98. +0 −39 spec/vcr_cassettes/controllers/no_logged/system.yml
  99. +0 −39 spec/vcr_cassettes/controllers/no_logged/users.yml
  100. +0 −40 spec/vcr_cassettes/models/admin/client.yml
  101. +0 −88 spec/vcr_cassettes/models/admin/user_create.yml
  102. +0 −36 spec/vcr_cassettes/models/admin/user_create_action.yml
  103. +0 −40 spec/vcr_cassettes/models/admin/user_delete.yml
  104. +0 −80 spec/vcr_cassettes/models/admin/user_delete_action.yml
  105. +0 −713 spec/vcr_cassettes/models/logged/app.yml
  106. +0 −79 spec/vcr_cassettes/models/logged/app_started_map_external_url_action.yml
  107. +0 −80 spec/vcr_cassettes/models/logged/app_started_map_reserved_url_action.yml
  108. +0 −40 spec/vcr_cassettes/models/logged/client.yml
  109. +0 −130 spec/vcr_cassettes/models/logged/service_create.yml
  110. +0 −84 spec/vcr_cassettes/models/logged/service_create_action.yml
  111. +0 −40 spec/vcr_cassettes/models/logged/service_delete.yml
  112. +0 −125 spec/vcr_cassettes/models/logged/service_delete_action.yml
  113. +0 −151 spec/vcr_cassettes/models/logged/system.yml
  114. +0 −121 spec/vcr_cassettes/models/logged/user.yml
  115. +0 −39 spec/vcr_cassettes/models/no_logged/app.yml
  116. +0 −39 spec/vcr_cassettes/models/no_logged/service.yml
  117. +0 −39 spec/vcr_cassettes/models/no_logged/system.yml
  118. +0 −39 spec/vcr_cassettes/models/no_logged/user.yml
View
@@ -3,8 +3,10 @@
.idea
.rbenv-version
.sass-cache/
+Gemfile.lock
bin/
db/*.sqlite3
+doc/coverage/
log/*.log
tmp/
vendor/bundle/ruby/
View
@@ -1 +1,2 @@
--colour
+--format=nested
View
@@ -1,16 +1,13 @@
source 'http://rubygems.org'
-gem 'rails', '3.1.1'
-gem 'json', '~> 1.6.1'
-gem 'haml', '~> 3.1.3'
-gem 'vmc', '~> 0.3.12'
-gem 'coderay', '~> 1.0.1'
+gem 'rails', '3.1.3'
+gem 'haml', '~> 3.1.4'
+gem 'coderay', '~> 1.0.4'
+gem 'cloudfoundry-client', '~> 0.1.1'
group :assets do
- gem 'sass-rails', '~> 3.1.4'
- gem 'uglifier', '>= 1.0.4'
- #gem 'execjs', '~> 1.2.9'
- #gem 'therubyracer', '~> 0.9.8'
+ gem 'sass-rails', '~> 3.1.5'
+ gem 'uglifier', '>= 1.1.0'
end
# RSpec2 needs to be in the :development group to expose generators and rake tasks without having to type RAILS_ENV=test
@@ -19,6 +16,7 @@ group :development, :test do
end
group :test do
- gem "webmock", "~> 1.7.7"
- gem "vcr", "~> 2.0.0.beta1"
+ gem "webmock", "~> 1.7.8"
+ gem "vcr", "~> 2.0.0.beta2"
+ gem 'simplecov', "~> 0.5.4", :require => false
end
View
@@ -1,144 +0,0 @@
-GEM
- remote: http://rubygems.org/
- specs:
- actionmailer (3.1.1)
- actionpack (= 3.1.1)
- mail (~> 2.3.0)
- actionpack (3.1.1)
- activemodel (= 3.1.1)
- activesupport (= 3.1.1)
- builder (~> 3.0.0)
- erubis (~> 2.7.0)
- i18n (~> 0.6)
- rack (~> 1.3.2)
- rack-cache (~> 1.1)
- rack-mount (~> 0.8.2)
- rack-test (~> 0.6.1)
- sprockets (~> 2.0.2)
- activemodel (3.1.1)
- activesupport (= 3.1.1)
- builder (~> 3.0.0)
- i18n (~> 0.6)
- activerecord (3.1.1)
- activemodel (= 3.1.1)
- activesupport (= 3.1.1)
- arel (~> 2.2.1)
- tzinfo (~> 0.3.29)
- activeresource (3.1.1)
- activemodel (= 3.1.1)
- activesupport (= 3.1.1)
- activesupport (3.1.1)
- multi_json (~> 1.0)
- addressable (2.2.6)
- arel (2.2.1)
- builder (3.0.0)
- coderay (1.0.4)
- crack (0.3.1)
- diff-lcs (1.1.3)
- erubis (2.7.0)
- execjs (1.2.9)
- multi_json (~> 1.0)
- haml (3.1.3)
- highline (1.6.5)
- hike (1.2.1)
- i18n (0.6.0)
- json (1.6.1)
- json_pure (1.5.4)
- spruz (~> 0.2.8)
- mail (2.3.0)
- i18n (>= 0.4.0)
- mime-types (~> 1.16)
- treetop (~> 1.4.8)
- mime-types (1.17.2)
- multi_json (1.0.3)
- polyglot (0.3.3)
- rack (1.3.5)
- rack-cache (1.1)
- rack (>= 0.4)
- rack-mount (0.8.3)
- rack (>= 1.0.0)
- rack-ssl (1.3.2)
- rack
- rack-test (0.6.1)
- rack (>= 1.0)
- rails (3.1.1)
- actionmailer (= 3.1.1)
- actionpack (= 3.1.1)
- activerecord (= 3.1.1)
- activeresource (= 3.1.1)
- activesupport (= 3.1.1)
- bundler (~> 1.0)
- railties (= 3.1.1)
- railties (3.1.1)
- actionpack (= 3.1.1)
- activesupport (= 3.1.1)
- rack-ssl (~> 1.3.2)
- rake (>= 0.8.7)
- rdoc (~> 3.4)
- thor (~> 0.14.6)
- rake (0.9.2.2)
- rdoc (3.11)
- json (~> 1.4)
- rest-client (1.6.7)
- mime-types (>= 1.16)
- rspec (2.7.0)
- rspec-core (~> 2.7.0)
- rspec-expectations (~> 2.7.0)
- rspec-mocks (~> 2.7.0)
- rspec-core (2.7.1)
- rspec-expectations (2.7.0)
- diff-lcs (~> 1.1.2)
- rspec-mocks (2.7.0)
- rspec-rails (2.7.0)
- actionpack (~> 3.0)
- activesupport (~> 3.0)
- railties (~> 3.0)
- rspec (~> 2.7.0)
- rubyzip2 (2.0.1)
- sass (3.1.10)
- sass-rails (3.1.4)
- actionpack (~> 3.1.0)
- railties (~> 3.1.0)
- sass (>= 3.1.4)
- sprockets (~> 2.0.0)
- tilt (~> 1.3.2)
- sprockets (2.0.3)
- hike (~> 1.2)
- rack (~> 1.0)
- tilt (~> 1.1, != 1.3.0)
- spruz (0.2.13)
- terminal-table (1.4.3)
- thor (0.14.6)
- tilt (1.3.3)
- treetop (1.4.10)
- polyglot
- polyglot (>= 0.3.1)
- tzinfo (0.3.30)
- uglifier (1.0.4)
- execjs (>= 0.3.0)
- multi_json (>= 1.0.2)
- vcr (2.0.0.beta1)
- vmc (0.3.12)
- highline (~> 1.6.1)
- json_pure (~> 1.5.1)
- rest-client (>= 1.6.1, < 1.7.0)
- rubyzip2 (~> 2.0.1)
- terminal-table (~> 1.4.2)
- webmock (1.7.7)
- addressable (~> 2.2, > 2.2.5)
- crack (>= 0.1.7)
-
-PLATFORMS
- ruby
-
-DEPENDENCIES
- coderay (~> 1.0.1)
- haml (~> 3.1.3)
- json (~> 1.6.1)
- rails (= 3.1.1)
- rspec-rails (~> 2.7.0)
- sass-rails (~> 3.1.4)
- uglifier (>= 1.0.4)
- vcr (~> 2.0.0.beta1)
- vmc (~> 0.3.12)
- webmock (~> 1.7.7)
View
@@ -4,6 +4,9 @@ CF-Console
CF-Console is an easy-to-use web-based interface for [Cloud Foundry](http://cloudfoundry.org/),
the industry’s first open Platform as a Service (PaaS) offering.
+Continuous Integration
+----------------------
+
[![Build Status](https://secure.travis-ci.org/frodenas/cf-console.png)](http://travis-ci.org/frodenas/cf-console)
Demo
@@ -36,14 +39,51 @@ So just type:
rake spec
-Changelog
----------
-
-### v0.1: October 23, 2011
-* First commit to github
+Contributing
+------------
+In the spirit of [free software](http://www.fsf.org/licensing/essays/free-sw.html), **everyone** is encouraged to help
+improve this project.
+
+Here are some ways *you* can contribute:
+
+* by using alpha, beta, and prerelease versions
+* by reporting bugs
+* by suggesting new features
+* by writing or editing documentation
+* by writing specifications
+* by writing code (**no patch is too small**: fix typos, add comments, clean up inconsistent whitespace)
+* by refactoring code
+* by closing [issues](http://github.com/frodenas/cf-console/issues)
+* by reviewing patches
+
+
+Submitting an Issue
+-------------------
+We use the [GitHub issue tracker](http://github.com/frodenas/cf-console/issues) to track bugs and features.
+Before submitting a bug report or feature request, check to make sure it hasn't already been submitted. You can indicate
+support for an existing issue by voting it up. When submitting a bug report, please include a
+[Gist](http://gist.github.com/) that includes a stack trace and any details that may be necessary to reproduce the bug,
+including your gem version, Ruby version, and operating system. Ideally, a bug report should include a pull request with
+ failing specs.
+
+
+Submitting a Pull Request
+-------------------------
+1. Fork the project.
+2. Create a topic branch.
+3. Implement your feature or bug fix.
+4. Add specs for your feature or bug fix.
+5. Run <tt>rake spec</tt>. If your changes are not 100% covered, go back to step 4.
+6. Commit and push your changes.
+7. Submit a pull request.
+
+Authors
+-------
+By [Ferran Rodenas](http://www.rodenas.org/) <frodenas@gmail.com>
Copyright
---------
-Copyright (c) 2011 Ferran Rodenas. See LICENSE for details.
+See [LICENSE](https://github.com/frodenas/cf-console/blob/master/LICENSE) for details.
+Copyright (c) 2011 [Ferran Rodenas](http://www.rodenas.org/).
@@ -1,3 +1,5 @@
+require 'cloudfoundry'
+
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :require_login
@@ -6,27 +8,27 @@ class ApplicationController < ActionController::Base
def require_login
begin
- @cf_client = vmc_client(cookies[:vmc_target_url], cookies.signed[:vmc_auth_token])
+ @cf_client = cloudfoundry_client(cookies[:cf_target_url], cookies.signed[:cf_auth_token])
@cf_logged_in = @cf_client.logged_in?
rescue Exception => ex
@cf_logged_in = false
end
if @cf_logged_in
@cf_user = @cf_client.user
- @cf_target = @cf_client.target
+ @cf_target = @cf_client.target_url
begin
user = User.new(@cf_client)
@cf_admin_user = user.is_admin?(@cf_user)
- rescue VMC::Client::TargetError
+ rescue CloudFoundry::Client::Exception::Forbidden
@cf_admin_user = false
end
else
redirect_to login_url
end
end
- def vmc_client(vmc_target_url, vmc_auth_token = nil)
- vmc_target_url ||= VMC::DEFAULT_TARGET
- @client = VMC::Client.new(vmc_target_url, vmc_auth_token)
+ def cloudfoundry_client(cf_target_url, cf_auth_token = nil)
+ cf_target_url ||= CloudFoundry::Client::DEFAULT_TARGET
+ @client = CloudFoundry::Client.new({:target => cf_target_url, :auth_token => cf_auth_token})
end
end
@@ -27,7 +27,7 @@ def show
@available_instances = find_available_instances(@app[:state], @app[:resources][:memory], @app[:instances])
@available_memsizes = find_available_memsizes(@app[:state], @app[:resources][:memory], @app[:instances])
@available_services = find_available_services()
- rescue VMC::Client::NotFound => ex
+ rescue CloudFoundry::Client::Exception::NotFound => ex
flash[:alert] = ex.message
redirect_to apps_info_url
rescue Exception => ex
@@ -18,7 +18,11 @@ def create
if !@ss.nil? && !@ss.empty?
begin
service = Service.new(@cf_client)
- service_info = service.find(@name)
+ begin
+ service_info = service.find(@name)
+ rescue
+ service_info = nil
+ end
if service_info.nil?
service.create(@name, @ss)
service_info = service.find(@name)
@@ -2,10 +2,10 @@ class SessionsController < ApplicationController
skip_before_filter :require_login, :only => [:new, :create]
def new
- if cookies[:vmc_target_url]
- @target_url = cookies[:vmc_target_url]
+ if cookies[:cf_target_url]
+ @target_url = cookies[:cf_target_url]
else
- @target_url = VMC::DEFAULT_TARGET
+ @target_url = CloudFoundry::Client::DEFAULT_TARGET
end
end
@@ -15,19 +15,19 @@ def create
@target_url = params[:target_url]
@remember_me = params[:remember_me]
begin
- cf = vmc_client(@target_url)
+ cf = cloudfoundry_client(@target_url)
auth_token = cf.login(@email, @password)
rescue
auth_token = nil
end
if auth_token
if @remember_me
- cookies.permanent[:vmc_target_url] = @target_url
- cookies.permanent.signed[:vmc_auth_token] = auth_token
+ cookies.permanent[:cf_target_url] = @target_url
+ cookies.permanent.signed[:cf_auth_token] = auth_token
else
- cookies[:vmc_target_url] = @target_url
- cookies.signed[:vmc_auth_token] = auth_token
+ cookies[:cf_target_url] = @target_url
+ cookies.signed[:cf_auth_token] = auth_token
end
redirect_to root_url
else
@@ -37,7 +37,7 @@ def create
end
def destroy
- cookies.delete(:vmc_auth_token)
+ cookies.delete(:cf_auth_token)
redirect_to root_url
end
end
Oops, something went wrong.

0 comments on commit 8509968

Please sign in to comment.