Skip to content
This repository has been archived by the owner on Dec 9, 2018. It is now read-only.

Commit

Permalink
Use the cloudfoundry-client gem instead of the vmc gem
Browse files Browse the repository at this point in the history
  • Loading branch information
frodenas committed Dec 7, 2011
1 parent b9cf774 commit 8509968
Show file tree
Hide file tree
Showing 118 changed files with 8,326 additions and 6,242 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -3,8 +3,10 @@
.idea
.rbenv-version
.sass-cache/
Gemfile.lock
bin/
db/*.sqlite3
doc/coverage/
log/*.log
tmp/
vendor/bundle/ruby/
Expand Down
1 change: 1 addition & 0 deletions .rspec
@@ -1 +1,2 @@
--colour
--format=nested
20 changes: 9 additions & 11 deletions Gemfile
@@ -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
Expand All @@ -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
144 changes: 0 additions & 144 deletions Gemfile.lock

This file was deleted.

52 changes: 46 additions & 6 deletions README.md
Expand Up @@ -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
Expand Down Expand Up @@ -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/).
14 changes: 8 additions & 6 deletions app/controllers/application_controller.rb
@@ -1,3 +1,5 @@
require 'cloudfoundry'

class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :require_login
Expand All @@ -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
2 changes: 1 addition & 1 deletion app/controllers/apps_controller.rb
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/services_controller.rb
Expand Up @@ -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)
Expand Down
18 changes: 9 additions & 9 deletions app/controllers/sessions_controller.rb
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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

0 comments on commit 8509968

Please sign in to comment.