Skip to content

Commit f5a7698

Browse files
author
Alex Suraci & Matthew Boedicker
committed
Revert "remove framework/runtime"
This reverts commit 2ea74b8.
1 parent 2ea74b8 commit f5a7698

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+955
-63
lines changed

bin/document_api

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ module Docs
2020
VCAP::CloudController::User,
2121
VCAP::CloudController::Space,
2222
VCAP::CloudController::App,
23+
VCAP::CloudController::Runtime,
24+
VCAP::CloudController::Framework,
2325
VCAP::CloudController::Service,
2426
VCAP::CloudController::ServicePlan,
2527
VCAP::CloudController::ServiceInstance,

config/frameworks/myframework.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: "myframework"
3+
runtimes:
4+
- node:
5+
default: true
6+
- node06:
7+
default: false
8+
detection:
9+
- "*.js": '.'
10+
disabled: true

config/frameworks/node.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
name: "node"
3+
runtimes:
4+
- node:
5+
default: true
6+
- node06:
7+
default: false
8+
detection:
9+
- "*.js": '.'

config/frameworks/sinatra.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
name: "sinatra"
3+
runtimes:
4+
- ruby18:
5+
default: true
6+
environment:
7+
bundle_gemfile:
8+
- ruby19:
9+
environment:
10+
bundle_gemfile:
11+
- myruntime:
12+
default: false
13+
detection:
14+
- "*.rb": "require\\s+'sinatra'|require\\s+\"sinatra\"" # .rb files in the root dir containing a require?
15+
- "config.ru": false # use rack if it detects a config.ru
16+
- "config/environment.rb": false # and config/environment.rb must not exist
17+
18+
# vim: filetype=yaml

config/frameworks/spring.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
name: "spring"
3+
runtimes:
4+
- "java":
5+
default: true
6+
detection:
7+
- "*.war": true # TODO - this thinks everything with an XML file is Spring
8+
9+
# vim: filetype=yaml

config/frameworks/standalone.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: "standalone"
3+
runtimes:
4+
- python2:
5+
default: false
6+
- java:
7+
default: false
8+
- node:
9+
default: false
10+
- node06:
11+
default: false
12+
- erlangR14B02:
13+
default: false
14+
- php:
15+
default: false
16+
- ruby18:
17+
environment:
18+
bundle_gemfile:
19+
- ruby19:
20+
environment:
21+
bundle_gemfile:
22+
23+
# vim: filetype=yaml

config/runtimes.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
python2:
3+
version: "2.6.5"
4+
description: "Python 2.6.5"
5+
executable: python
6+
java:
7+
description: "Java 6"
8+
version: "1.6"
9+
executable: "java"
10+
node:
11+
version: "0.4.12"
12+
description: "Node.js"
13+
executable: node
14+
node06:
15+
version: "0.6.8"
16+
description: "Node.js"
17+
executable: node
18+
erlangR14B02:
19+
version: "R14B02"
20+
description: "Erlang R14B02"
21+
executable: /var/vcap/runtimes/erlang-R14B02/bin/erl
22+
php:
23+
description: "PHP 5"
24+
version: "5.3"
25+
executable: "php"
26+
ruby18:
27+
version: "1.8.7"
28+
description: "Ruby 1.8.7"
29+
executable: "/usr/bin/ruby"
30+
bundler: "bundle"
31+
environment:
32+
bundle_gemfile:
33+
ruby19:
34+
version: "1.9.2"
35+
description: "Ruby 1.9.2"
36+
executable: "ruby"
37+
bundler: "bundle"
38+
myruntime:
39+
version: "1.0"
40+
description: "My Runtime"
41+
disabled: true

db/migrations/20130323005501_remove_framework_and_runtime.rb

Lines changed: 0 additions & 13 deletions
This file was deleted.

lib/cloud_controller/api/app.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ module VCAP::CloudController
1515
attribute :production, Message::Boolean, :default => false
1616

1717
to_one :space
18+
to_one :runtime, :optional_in => :create
19+
to_one :framework, :optional_in => :create
1820
to_one :stack, :optional_in => :create
1921

2022
attribute :environment_json, Hash, :default => {}
@@ -35,7 +37,7 @@ module VCAP::CloudController
3537
to_many :routes
3638
end
3739

38-
query_parameters :name, :space_guid, :organization_guid
40+
query_parameters :name, :space_guid, :organization_guid, :framework_guid, :runtime_guid
3941

4042
def self.translate_validation_exception(e, attributes)
4143
space_and_name_errors = e.errors.on([:space_id, :name])

lib/cloud_controller/api/app_summary.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ def summary(id)
2020
:guid => app.guid,
2121
:name => app.name,
2222
:routes => app.routes.map(&:as_summary_json),
23+
:framework => app.framework.to_hash.merge(:guid => app.framework.guid),
24+
:runtime => app.runtime.to_hash.merge(:guid => app.runtime.guid),
2325
:running_instances => app.running_instances,
2426
:services => app.service_instances.map(&:as_summary_json),
2527
:available_domains => app.space.domains.map(&:as_summary_json)

lib/cloud_controller/api/framework.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) 2009-2012 VMware, Inc.
2+
3+
module VCAP::CloudController
4+
rest_controller :Framework do
5+
permissions_required do
6+
full Permissions::CFAdmin
7+
read Permissions::Authenticated
8+
end
9+
10+
define_attributes do
11+
attribute :name, String
12+
attribute :description, String
13+
attribute :internal_info, Hash
14+
to_many :apps
15+
end
16+
17+
query_parameters :name, :app_guid
18+
19+
def self.translate_validation_exception(e, attributes)
20+
name_errors = e.errors.on(:name)
21+
if name_errors && name_errors.include?(:unique)
22+
Errors::FrameworkNameTaken.new(attributes["name"])
23+
else
24+
Errors::FrameworkInvalid.new(e.errors.full_messages)
25+
end
26+
end
27+
end
28+
end

lib/cloud_controller/api/runtime.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright (c) 2009-2012 VMware, Inc.
2+
3+
module VCAP::CloudController
4+
rest_controller :Runtime do
5+
permissions_required do
6+
full Permissions::CFAdmin
7+
read Permissions::Authenticated
8+
end
9+
10+
define_attributes do
11+
attribute :name, String
12+
attribute :description, String
13+
attribute :internal_info, Hash
14+
15+
# version was really a v1 concept, but the yeti tests expect it
16+
attribute :version, String, :exclude_in => [:create, :update]
17+
to_many :apps, :default => []
18+
end
19+
20+
query_parameters :name, :app_guid
21+
22+
def self.translate_validation_exception(e, attributes)
23+
name_errors = e.errors.on(:name)
24+
if name_errors && name_errors.include?(:unique)
25+
Errors::RuntimeNameTaken.new(attributes["name"])
26+
else
27+
Errors::RuntimeInvalid.new(e.errors.full_messages)
28+
end
29+
end
30+
end
31+
end

lib/cloud_controller/api/space_summary.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ def app_summary(app)
4949
:urls => app.routes.map(&:fqdn),
5050
:routes => app.routes.map(&:as_summary_json),
5151
:service_count => app.service_bindings_dataset.count,
52+
:framework => { :name => app.framework.name },
53+
:runtime => { :name => app.runtime.name },
5254
:running_instances => 0,
5355
}.merge(app.to_hash)
5456
end

lib/cloud_controller/app_stager.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@ def destroy_upload_handle
195195
def staging_task_properties(app)
196196
{
197197
:services => app.service_bindings.map { |sb| service_binding_to_staging_request(sb) },
198+
:framework => app.framework.name,
199+
:framework_info => app.framework.internal_info,
200+
201+
:runtime => app.runtime.name,
202+
:runtime_info => app.runtime.internal_info.merge(
203+
:name => app.runtime.name
204+
),
198205

199206
:buildpack => app.buildpack,
200207

lib/cloud_controller/config.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class VCAP::CloudController::Config < VCAP::Config
4646
optional(:staging_manifests) => String,
4747
},
4848

49+
optional(:runtimes_file) => String,
4950
optional(:stacks_file) => String,
5051

5152
:db => {
@@ -167,6 +168,7 @@ def self.config_dir
167168
private
168169

169170
def self.merge_defaults(config)
171+
config[:runtimes_file] ||= File.join(config_dir, "runtimes.yml")
170172
config[:stacks_file] ||= File.join(config_dir, "stacks.yml")
171173

172174
config[:directories] ||= {}

lib/cloud_controller/dea/dea_client.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def start_instances_with_message(app, indices, message_override)
225225

226226
indices.each do |idx|
227227
msg[:index] = idx
228-
dea_id = dea_pool.find_dea(app.memory, app.stack.name)
228+
dea_id = dea_pool.find_dea(app.memory, app.runtime.name, app.stack.name)
229229
if dea_id
230230
dea_publish("#{dea_id}.start", msg.merge(message_override))
231231
else
@@ -313,6 +313,11 @@ def start_app_message(app)
313313
:droplet => app.guid,
314314
:name => app.name,
315315
:uris => app.uris,
316+
:runtime => app.runtime.name,
317+
:runtime_info => app.runtime.internal_info.merge(
318+
:name => app.runtime.name
319+
),
320+
:framework => app.framework.name,
316321
:prod => app.production,
317322
:sha1 => app.droplet_hash,
318323
:executableFile => "deprecated",

lib/cloud_controller/dea/dea_pool.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ def process_advertise_message(msg)
2929
end
3030
end
3131

32-
def find_dea(mem, stack)
32+
def find_dea(mem, runtime, stack)
3333
mutex.synchronize do
3434
@deas.keys.shuffle.each do |id|
3535
dea = @deas[id]
3636
if dea_expired?(dea)
3737
@deas.delete(id)
38-
elsif dea_meets_needs?(dea, mem, stack)
38+
elsif dea_meets_needs?(dea, mem, runtime, stack)
3939
return id
4040
end
4141
end
@@ -49,12 +49,17 @@ def dea_expired?(dea)
4949
(Time.now.to_i - dea[:last_update].to_i) > ADVERTISEMENT_EXPIRATION
5050
end
5151

52-
def dea_meets_needs?(dea, mem, stack)
52+
def dea_meets_needs?(dea, mem, runtime, stack)
5353
stats = dea[:advertisement]
5454

55+
has_runtime = stats[:runtimes].nil? || stats[:runtimes].include?(runtime)
5556
has_stack = stats[:stacks].include?(stack)
5657

57-
(stats[:available_memory] >= mem) && has_stack
58+
if stats[:available_memory] >= mem
59+
has_runtime && has_stack
60+
else
61+
false
62+
end
5863
end
5964

6065
def mutex

lib/cloud_controller/legacy_api/legacy_apps.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ def instances(name)
129129
def legacy_app_encoding(app)
130130
{
131131
:name => app.name,
132+
:staging => {
133+
:model => app.framework.name,
134+
:stack => app.runtime.name,
135+
},
132136
:uris => app.uris,
133137
:instances => app.instances,
134138
:runningInstances => app.running_instances,
@@ -211,6 +215,21 @@ def translate_legacy_create_json(hash)
211215
end
212216

213217
if staging = hash["staging"]
218+
framework = nil
219+
if framework_name = staging["framework"] || staging["model"]
220+
framework = Models::Framework.find(:name => framework_name)
221+
raise FrameworkInvalid.new(framework_name) unless framework
222+
req[:framework_guid] = framework.guid
223+
end
224+
225+
runtime_name = staging["runtime"] || staging["stack"]
226+
runtime_name ||= default_runtime_for_framework(framework)
227+
if runtime_name
228+
runtime = Models::Runtime.find(:name => runtime_name)
229+
raise RuntimeInvalid.new(runtime_name) unless runtime
230+
req[:runtime_guid] = runtime.guid
231+
end
232+
214233
req[:command] = staging["command"] if staging["command"]
215234
end
216235

@@ -273,6 +292,16 @@ def around_translate(old_json, &translate)
273292
Yajl::Encoder.encode(translated)
274293
end
275294

295+
def default_runtime_for_framework(framework)
296+
return unless framework
297+
framework.internal_info["runtimes"].each do |runtime|
298+
runtime.each do |runtime_name, runtime_info|
299+
return runtime_name if runtime_info["default"] == true
300+
end
301+
end
302+
nil
303+
end
304+
276305
def self.setup_routes
277306
get "/apps", :enumerate
278307
post "/apps", :create

lib/cloud_controller/legacy_api/legacy_bulk.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ class BulkResponse < JsonMessage
1010
{
1111
"id" => String,
1212
"instances" => Integer,
13+
"framework" => String,
14+
"runtime" => String,
1315
# FIXME: find the enum for this
1416
"state" => String,
1517
"memory" => Integer,
@@ -94,6 +96,8 @@ def bulk_apps
9496
end
9597
hash["id"] = app.guid
9698
hash["updated_at"] = app.updated_at || app.created_at
99+
hash["runtime"] = app.runtime.name
100+
hash["framework"] = app.framework.name
97101
apps[app.guid] = hash
98102
id_for_next_token = app.id
99103
end

0 commit comments

Comments
 (0)