openshift-origin-controller 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of openshift-origin-controller might be problematic. Click here for more details.
- data/COPYRIGHT +1 -0
- data/Gemfile +4 -0
- data/LICENSE +12 -0
- data/README.md +3 -0
- data/Rakefile +9 -0
- data/app/controllers/app_events_controller.rb +115 -0
- data/app/controllers/application_templates_controller.rb +19 -0
- data/app/controllers/applications_controller.rb +214 -0
- data/app/controllers/base_controller.rb +367 -0
- data/app/controllers/cartridges_controller.rb +48 -0
- data/app/controllers/descriptors_controller.rb +23 -0
- data/app/controllers/dns_resolvable_controller.rb +35 -0
- data/app/controllers/domains_controller.rb +156 -0
- data/app/controllers/emb_cart_controller.rb +276 -0
- data/app/controllers/emb_cart_events_controller.rb +52 -0
- data/app/controllers/environment_controller.rb +11 -0
- data/app/controllers/estimates_controller.rb +71 -0
- data/app/controllers/gear_groups_controller.rb +53 -0
- data/app/controllers/gears_controller.rb +70 -0
- data/app/controllers/keys_controller.rb +96 -0
- data/app/controllers/legacy_broker_controller.rb +510 -0
- data/app/controllers/quickstarts_controller.rb +29 -0
- data/app/controllers/user_controller.rb +38 -0
- data/app/helpers/cartridge_helper.rb +25 -0
- data/app/helpers/legacy_broker_helper.rb +21 -0
- data/app/helpers/user_action_logger.rb +38 -0
- data/app/models/application.rb +1718 -0
- data/app/models/application_template.rb +27 -0
- data/app/models/cartridge_cache.rb +51 -0
- data/app/models/cloud_user.rb +334 -0
- data/app/models/component_instance.rb +228 -0
- data/app/models/connection_endpoint.rb +10 -0
- data/app/models/district.rb +210 -0
- data/app/models/domain.rb +234 -0
- data/app/models/gear.rb +376 -0
- data/app/models/group_instance.rb +306 -0
- data/app/models/key.rb +20 -0
- data/app/models/legacy_reply.rb +15 -0
- data/app/models/legacy_request.rb +126 -0
- data/app/models/link.rb +11 -0
- data/app/models/message.rb +10 -0
- data/app/models/name_server_cache.rb +46 -0
- data/app/models/optional_param.rb +12 -0
- data/app/models/param.rb +13 -0
- data/app/models/remote_job.rb +57 -0
- data/app/models/rest_application.rb +126 -0
- data/app/models/rest_application10.rb +106 -0
- data/app/models/rest_application12.rb +124 -0
- data/app/models/rest_application_estimate.rb +12 -0
- data/app/models/rest_application_template.rb +20 -0
- data/app/models/rest_cartridge10.rb +41 -0
- data/app/models/rest_cartridge11.rb +151 -0
- data/app/models/rest_domain.rb +43 -0
- data/app/models/rest_domain10.rb +42 -0
- data/app/models/rest_estimates.rb +16 -0
- data/app/models/rest_gear.rb +14 -0
- data/app/models/rest_gear_group.rb +26 -0
- data/app/models/rest_key.rb +24 -0
- data/app/models/rest_reply.rb +31 -0
- data/app/models/rest_user.rb +43 -0
- data/app/models/result_io.rb +67 -0
- data/app/models/usage_record.rb +37 -0
- data/app/models/validators/app_validator.rb +30 -0
- data/app/models/validators/key_validator.rb +30 -0
- data/app/models/validators/namespace_validator.rb +18 -0
- data/config/routes.rb +36 -0
- data/lib/controller_engine.rb +7 -0
- data/lib/openshift-origin-controller.rb +14 -0
- data/lib/openshift/application_container_proxy.rb +241 -0
- data/lib/openshift/auth_service.rb +101 -0
- data/lib/openshift/data_store.rb +33 -0
- data/lib/openshift/dns_service.rb +41 -0
- data/lib/openshift/mongo_data_store.rb +671 -0
- data/openshift-origin-controller.gemspec +42 -0
- data/rubygem-openshift-origin-controller.spec +274 -0
- data/test/cucumber/application-estimate.feature +25 -0
- data/test/cucumber/cartridge-10gen-mms-agent.feature +28 -0
- data/test/cucumber/cartridge-cron.feature +32 -0
- data/test/cucumber/cartridge-haproxy.feature +31 -0
- data/test/cucumber/cartridge-jenkins-build.feature +12 -0
- data/test/cucumber/cartridge-jenkins-client.feature +10 -0
- data/test/cucumber/cartridge-lifecycle-diy.feature +21 -0
- data/test/cucumber/cartridge-lifecycle-jbossas.feature +61 -0
- data/test/cucumber/cartridge-lifecycle-jbosseap.feature +61 -0
- data/test/cucumber/cartridge-lifecycle-jbossews10.feature +61 -0
- data/test/cucumber/cartridge-lifecycle-jenkins.feature +41 -0
- data/test/cucumber/cartridge-lifecycle-nodejs.feature +59 -0
- data/test/cucumber/cartridge-lifecycle-perl.feature +40 -0
- data/test/cucumber/cartridge-lifecycle-php.feature +106 -0
- data/test/cucumber/cartridge-lifecycle-python.feature +40 -0
- data/test/cucumber/cartridge-lifecycle-ruby18.feature +49 -0
- data/test/cucumber/cartridge-lifecycle-ruby19.feature +41 -0
- data/test/cucumber/cartridge-mongodb.feature +31 -0
- data/test/cucumber/cartridge-mysql.feature +30 -0
- data/test/cucumber/cartridge-php.feature +14 -0
- data/test/cucumber/cartridge-phpmyadmin.feature +32 -0
- data/test/cucumber/cartridge-postgresql.feature +32 -0
- data/test/cucumber/cartridge-runtime-extended-db.feature +64 -0
- data/test/cucumber/cartridge-runtime-extended-jboss.feature +24 -0
- data/test/cucumber/cartridge-runtime-extended-nodejs.feature +21 -0
- data/test/cucumber/cartridge-runtime-extended-perl.feature +18 -0
- data/test/cucumber/cartridge-runtime-extended-php.feature +19 -0
- data/test/cucumber/cartridge-runtime-extended-python.feature +18 -0
- data/test/cucumber/cartridge-runtime-extended-ruby.feature +22 -0
- data/test/cucumber/cartridge-runtime-standard-diy.feature +6 -0
- data/test/cucumber/cartridge-runtime-standard-jbossas.feature +7 -0
- data/test/cucumber/cartridge-runtime-standard-jbosseap.feature +7 -0
- data/test/cucumber/cartridge-runtime-standard-jbossews10.feature +7 -0
- data/test/cucumber/cartridge-runtime-standard-jenkins.feature +8 -0
- data/test/cucumber/cartridge-runtime-standard-nodejs.feature +7 -0
- data/test/cucumber/cartridge-runtime-standard-perl.feature +6 -0
- data/test/cucumber/cartridge-runtime-standard-php.feature +6 -0
- data/test/cucumber/cartridge-runtime-standard-python.feature +6 -0
- data/test/cucumber/cartridge-runtime-standard-ruby.feature +19 -0
- data/test/cucumber/cartridge-switchyard.feature +36 -0
- data/test/cucumber/descriptor.feature +40 -0
- data/test/cucumber/embedded.feature +44 -0
- data/test/cucumber/idler.feature +75 -0
- data/test/cucumber/misc/descriptor/manifest.yml +22 -0
- data/test/cucumber/misc/php/db_test.php +21 -0
- data/test/cucumber/openshift-node.feature +21 -0
- data/test/cucumber/rest-application-templates.feature +31 -0
- data/test/cucumber/rest-applications.feature +431 -0
- data/test/cucumber/rest-cartridge-types.feature +16 -0
- data/test/cucumber/rest-domains.feature +276 -0
- data/test/cucumber/rest-gears.feature +38 -0
- data/test/cucumber/rest-keys.feature +247 -0
- data/test/cucumber/rest-quickstarts.feature +27 -0
- data/test/cucumber/rest-workflow.feature +64 -0
- data/test/cucumber/step_definitions/api_steps.rb +369 -0
- data/test/cucumber/step_definitions/application-estimate-steps.rb +51 -0
- data/test/cucumber/step_definitions/application_steps.rb +215 -0
- data/test/cucumber/step_definitions/cartridge-10gen-mms-agent_steps.rb +11 -0
- data/test/cucumber/step_definitions/cartridge-cron_steps.rb +51 -0
- data/test/cucumber/step_definitions/cartridge-haproxy_steps.rb +30 -0
- data/test/cucumber/step_definitions/cartridge-jenkins_steps.rb +93 -0
- data/test/cucumber/step_definitions/cartridge-lifecycle-nodejs_steps.rb +30 -0
- data/test/cucumber/step_definitions/cartridge-mongodb_steps.rb +60 -0
- data/test/cucumber/step_definitions/cartridge-mysql_steps.rb +56 -0
- data/test/cucumber/step_definitions/cartridge-php_steps.rb +72 -0
- data/test/cucumber/step_definitions/cartridge-postgresql_steps.rb +59 -0
- data/test/cucumber/step_definitions/cartridge-switchyard_steps.rb +29 -0
- data/test/cucumber/step_definitions/client_steps.rb +12 -0
- data/test/cucumber/step_definitions/descriptor_step.rb +32 -0
- data/test/cucumber/step_definitions/idler_steps.rb +37 -0
- data/test/cucumber/step_definitions/node_steps.rb +203 -0
- data/test/cucumber/step_definitions/runtime_steps.rb +547 -0
- data/test/cucumber/step_definitions/runtime_url_steps.rb +46 -0
- data/test/cucumber/step_definitions/trap-user-extended_steps.rb +14 -0
- data/test/cucumber/step_definitions/trap-user_steps.rb +58 -0
- data/test/cucumber/support/00_setup_helper.rb +106 -0
- data/test/cucumber/support/app_helper.rb +243 -0
- data/test/cucumber/support/assertions.rb +52 -0
- data/test/cucumber/support/command_helper.rb +453 -0
- data/test/cucumber/support/dns_helper.rb +54 -0
- data/test/cucumber/support/env.rb +5 -0
- data/test/cucumber/support/process_helper.rb +44 -0
- data/test/cucumber/support/runtime_support.rb +440 -0
- data/test/cucumber/support/unused.rb +27 -0
- data/test/cucumber/support/user_helper.rb +37 -0
- data/test/cucumber/trap-user-extended.feature +53 -0
- data/test/cucumber/trap-user.feature +34 -0
- data/test/ddns/1.168.192-rev.db.init +13 -0
- data/test/ddns/HOWTO.txt +207 -0
- data/test/ddns/Kexample.com.+157+06142.key +1 -0
- data/test/ddns/Kexample.com.+157+06142.private +7 -0
- data/test/ddns/authconfig.rb +14 -0
- data/test/ddns/example.com.db.init +23 -0
- data/test/ddns/example.com.key +4 -0
- data/test/ddns/named.ca +52 -0
- data/test/ddns/named.conf +48 -0
- data/test/ddns/named.empty +10 -0
- data/test/ddns/named.localhost +10 -0
- data/test/ddns/named.loopback +11 -0
- data/test/ddns/named.rfc1912.zones +42 -0
- data/test/ddns/named.root.key +5 -0
- data/test/ddns/named_service.rb +127 -0
- data/test/unit/bind_dns_service_test.rb +167 -0
- data/test/unit/broker_auth_test.rb +28 -0
- metadata +545 -0
data/app/models/key.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'validators/key_validator'
|
2
|
+
|
3
|
+
class Key < OpenShift::Model
|
4
|
+
attr_accessor :name, :type, :content
|
5
|
+
include ActiveModel::Validations
|
6
|
+
|
7
|
+
VALID_SSH_KEY_TYPES = ['ssh-rsa', 'ssh-dss', 'ecdsa-sha2-nistp256-cert-v01@openssh.com', 'ecdsa-sha2-nistp384-cert-v01@openssh.com',
|
8
|
+
'ecdsa-sha2-nistp521-cert-v01@openssh.com', 'ssh-rsa-cert-v01@openssh.com', 'ssh-dss-cert-v01@openssh.com',
|
9
|
+
'ssh-rsa-cert-v00@openssh.com', 'ssh-dss-cert-v00@openssh.com', 'ecdsa-sha2-nistp256', 'ecdsa-sha2-nistp384', 'ecdsa-sha2-nistp521']
|
10
|
+
DEFAULT_SSH_KEY_TYPE = "ssh-rsa" unless defined? DEFAULT_SSH_KEY_TYPE
|
11
|
+
DEFAULT_SSH_KEY_NAME = "default" unless defined? DEFAULT_SSH_KEY_NAME
|
12
|
+
|
13
|
+
validates_with KeyValidator
|
14
|
+
|
15
|
+
def initialize(name, type, content)
|
16
|
+
self.name = name
|
17
|
+
self.type = type
|
18
|
+
self.content = content
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class LegacyReply < OpenShift::Model
|
2
|
+
attr_accessor :api, :api_c, :broker_c, :debug, :messages, :result, :data, :exit_code
|
3
|
+
|
4
|
+
API_VERSION = "1.1.3"
|
5
|
+
API_CAPABILITY = %w(placeholder)
|
6
|
+
C_CAPABILITY = %w(namespace rhlogin ssh app_uuid debug alter cartridge cart_type action app_name api)
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@api = API_VERSION
|
10
|
+
@api_c = API_CAPABILITY
|
11
|
+
@broker_c = C_CAPABILITY
|
12
|
+
@debug = ""
|
13
|
+
@messages = nil
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
class LegacyRequest < OpenShift::Model
|
2
|
+
attr_accessor :namespace, :rhlogin, :ssh, :app_uuid, :app_name, :node_profile, :debug, :alter, :delete, :cartridge, :api, :cart_type, :action, :server_alias, :api, :key_name, :key_type
|
3
|
+
attr_reader :invalid_keys
|
4
|
+
|
5
|
+
APP_MAX_LENGTH = 32
|
6
|
+
NS_MAX_LENGTH = 16
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@invalid_keys = []
|
10
|
+
end
|
11
|
+
|
12
|
+
validates_each :invalid_keys do |record, attribute, val|
|
13
|
+
val.each do |key|
|
14
|
+
record.errors.add :base, {:message => "Unknown json key found: #{key}", :exit_code => 1}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
validates_each :rhlogin do |record, attribute, val|
|
19
|
+
if val =~ /["\$\^<>\|%\/;:,\\\*=~]/
|
20
|
+
record.errors.add attribute, {:message => "Invalid rhlogin: #{val}", :exit_code => 107}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
validates_each :key_name, :allow_nil =>true do |record, attribute, val|
|
25
|
+
if !(val =~ /\A[A-Za-z0-9]+\z/)
|
26
|
+
record.errors.add attribute, {:message => "Invalid key name: #{val}", :exit_code => 117}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
validates_each :key_type, :allow_nil =>true do |record, attribute, val|
|
31
|
+
if !Key::VALID_SSH_KEY_TYPES.include?(val)
|
32
|
+
record.errors.add attribute, {:message => "Invalid key type: #{val}", :exit_code => 116}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
validates_each :namespace, :allow_nil =>true do |record, attribute, val|
|
37
|
+
if !(val =~ /\A[A-Za-z0-9]+\z/)
|
38
|
+
record.errors.add attribute, {:message => "Invalid namespace: #{val}", :exit_code => 106}
|
39
|
+
end
|
40
|
+
if val and val.length > NS_MAX_LENGTH
|
41
|
+
record.errors.add attribute, {:message => "The supplied namespace '#{val}' is longer than the allowed length of #{NS_MAX_LENGTH} characters.", :exit_code => 106}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
validates_each :app_name, :allow_nil =>true do |record, attribute, val|
|
46
|
+
if !(val =~ /\A[A-Za-z0-9]+\z/)
|
47
|
+
record.errors.add attribute, {:message => "Invalid #{attribute} specified: #{val}", :exit_code => 105}
|
48
|
+
end
|
49
|
+
if val and val.length > APP_MAX_LENGTH
|
50
|
+
record.errors.add attribute, {:message => "The supplied application name '#{val}' is longer than the allowed length of #{APP_MAX_LENGTH} characters.", :exit_code => 105}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
validates_each :ssh, :allow_nil =>true do |record, attribute, val|
|
55
|
+
unless (val =~ /\A[A-Za-z0-9\+\/=]+\z/)
|
56
|
+
record.errors.add attribute, {:message => "Invalid ssh key: #{val}", :exit_code => 108}
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
validates_each :app_uuid, :allow_nil =>true do |record, attribute, val|
|
61
|
+
if !(val =~ /\A[a-f0-9]+\z/)
|
62
|
+
record.errors.add attribute, {:message => "Invalid application uuid: #{val}", :exit_code => 1}
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
validates_each :node_profile, :allow_nil =>true do |record, attribute, val|
|
67
|
+
end
|
68
|
+
|
69
|
+
validates_each :debug, :alter, :delete, :allow_nil =>true do |record, attribute, val|
|
70
|
+
if val != true && val != false && !(val =~ /\A(true|false)\z/)
|
71
|
+
record.errors.add attribute, {:message => "Invalid value for #{attribute} specified: #{val}", :exit_code => 1}
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
validates_each :cartridge, :allow_nil =>true do |record, attribute, val|
|
76
|
+
if !(val =~ /\A[\w\-\.]+\z/)
|
77
|
+
record.errors.add attribute, {:message => "Invalid cartridge specified: #{val}", :exit_code => 1}
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
validates_each :api, :allow_nil =>true do |record, attribute, val|
|
82
|
+
if !(val =~ /\A\d+\.\d+\.\d+\z/)
|
83
|
+
record.errors.add attribute, {:message => "Invalid API value specified: #{val}", :exit_code => 112}
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
validates_each :cart_type, :allow_nil =>true do |record, attribute, val|
|
88
|
+
if !(val =~ /\A(standalone|embedded)\z/)
|
89
|
+
record.errors.add attribute, {:message => "Invalid cart_type specified: #{val}", :exit_code => 109}
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
validates_each :action, :allow_nil =>true do |record, attribute, val|
|
94
|
+
if !(val =~ /\A[\w\-\.]+\z/)
|
95
|
+
record.errors.add attribute, {:message => "Invalid action specified: #{val}", :exit_code => 111}
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
validates_each :server_alias, :allow_nil =>true do |record, attribute, val|
|
100
|
+
if !(val =~ /\A[\w\-\.]+\z/) or (val =~ /#{Rails.configuration.openshift[:domain_suffix]}$/)
|
101
|
+
record.errors.add attribute, {:message => "Invalid ServerAlias specified: #{val}", :exit_code => 105}
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def alter
|
106
|
+
@alter == "true" || @alter == true
|
107
|
+
end
|
108
|
+
|
109
|
+
def debug
|
110
|
+
@debug == "true" || @debug == true
|
111
|
+
end
|
112
|
+
|
113
|
+
def delete
|
114
|
+
@delete == "true" || @delete == true
|
115
|
+
end
|
116
|
+
|
117
|
+
def attributes=(hash)
|
118
|
+
hash.each do |key,value|
|
119
|
+
begin
|
120
|
+
self.send("#{key}=",value)
|
121
|
+
rescue NoMethodError => e
|
122
|
+
@invalid_keys.push key
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
data/app/models/link.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
class Link < OpenShift::Model
|
2
|
+
attr_accessor :rel, :method, :href, :required_params, :optional_params
|
3
|
+
|
4
|
+
def initialize(rel, method, href, required_params=nil, optional_params=nil)
|
5
|
+
self.rel = rel
|
6
|
+
self.method = method
|
7
|
+
self.href = href.to_s
|
8
|
+
self.required_params = required_params || Array.new
|
9
|
+
self.optional_params = optional_params || Array.new
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class Message < OpenShift::Model
|
2
|
+
attr_accessor :severity, :text, :exit_code, :field
|
3
|
+
|
4
|
+
def initialize(severity=:info, text=nil, exit_code=nil, field=nil)
|
5
|
+
self.severity = severity
|
6
|
+
self.text = text
|
7
|
+
self.exit_code = exit_code
|
8
|
+
self.field = field
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'dnsruby'
|
3
|
+
|
4
|
+
class NameServerCache
|
5
|
+
|
6
|
+
def self.get_cached(key, opts={})
|
7
|
+
unless Rails.configuration.action_controller.perform_caching
|
8
|
+
if block_given?
|
9
|
+
return yield
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
val = Rails.cache.read(key)
|
14
|
+
unless val
|
15
|
+
if block_given?
|
16
|
+
val = yield
|
17
|
+
if val
|
18
|
+
Rails.cache.write(key, val, opts)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
return val
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.get_name_servers
|
27
|
+
dns = Dnsruby::DNS.new()
|
28
|
+
domain = Rails.application.config.openshift[:domain_suffix]
|
29
|
+
while domain && !domain.empty?
|
30
|
+
resources = dns.getresources(domain, Dnsruby::Types.NS)
|
31
|
+
unless resources.empty?
|
32
|
+
break
|
33
|
+
else
|
34
|
+
dp = domain.partition('.')
|
35
|
+
domain = dp[2]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
raise OpenShift::UserException.new("Unable to find nameservers for domain '#{Rails.application.config.openshift[:domain_suffix]}'",
|
39
|
+
141) if resources.empty?
|
40
|
+
@nameservers = []
|
41
|
+
resources.each do |resource|
|
42
|
+
@nameservers.push(resource.domainname.to_s)
|
43
|
+
end
|
44
|
+
get_cached("name_servers", :expires_in => 1.hour) {@nameservers}
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class OptionalParam < OpenShift::Model
|
2
|
+
attr_accessor :name, :type, :description, :valid_options, :default_value
|
3
|
+
|
4
|
+
def initialize(name=nil, type=nil, description=nil, valid_options=nil, default_value=nil)
|
5
|
+
self.name = name
|
6
|
+
self.type = type
|
7
|
+
self.description = description
|
8
|
+
valid_options = [valid_options] unless valid_options.kind_of?(Array)
|
9
|
+
self.valid_options = valid_options || Array.new
|
10
|
+
self.default_value = default_value
|
11
|
+
end
|
12
|
+
end
|
data/app/models/param.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
class Param < OpenShift::Model
|
2
|
+
attr_accessor :name, :type, :description, :valid_options, :invalid_options
|
3
|
+
|
4
|
+
def initialize(name=nil, type=nil, description=nil, valid_options=nil, invalid_options=nil)
|
5
|
+
self.name = name
|
6
|
+
self.type = type
|
7
|
+
self.description = description
|
8
|
+
self.valid_options = valid_options || Array.new
|
9
|
+
self.valid_options = [self.valid_options] unless self.valid_options.kind_of?(Array)
|
10
|
+
self.invalid_options = invalid_options || Array.new
|
11
|
+
self.invalid_options = [self.invalid_options] unless self.invalid_options.kind_of?(Array)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
|
2
|
+
class RemoteJob < OpenShift::Model
|
3
|
+
attr_accessor :cartridge, :action, :args
|
4
|
+
|
5
|
+
def initialize(target, action, args)
|
6
|
+
self.cartridge = target
|
7
|
+
self.action = action
|
8
|
+
self.args = args
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
def self.create_parallel_job
|
13
|
+
return { }
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.has_jobs(handle)
|
17
|
+
!handle.empty?
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.run_parallel_on_gears(gears, handle, &block)
|
21
|
+
gears.each { |gear|
|
22
|
+
block.call(handle, gear)
|
23
|
+
}
|
24
|
+
# now execute
|
25
|
+
begin
|
26
|
+
OpenShift::ApplicationContainerProxy.execute_parallel_jobs(handle)
|
27
|
+
rescue Exception=>e
|
28
|
+
Rails.logger.error e.message
|
29
|
+
Rails.logger.error e.inspect
|
30
|
+
Rails.logger.error e.backtrace.inspect
|
31
|
+
raise e
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.add_parallel_job(handle, tag, gear, rjob)
|
36
|
+
parallel_job = {
|
37
|
+
:tag => tag,
|
38
|
+
:gear => gear.uuid,
|
39
|
+
:job => { :cartridge => rjob.cartridge, :action => rjob.action, :args => rjob.args },
|
40
|
+
:result_stdout => "",
|
41
|
+
:result_stderr => "",
|
42
|
+
:result_exit_code => ""
|
43
|
+
}
|
44
|
+
job_list = handle[gear.get_proxy.id] || []
|
45
|
+
job_list << parallel_job
|
46
|
+
handle[gear.get_proxy.id] = job_list
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.get_parallel_run_results(handle, &block)
|
50
|
+
handle.each { |id, job_list|
|
51
|
+
job_list.each { |parallel_job|
|
52
|
+
block.call(parallel_job[:tag], parallel_job[:gear], parallel_job[:result_stdout], parallel_job[:result_exit_code])
|
53
|
+
}
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
class RestApplication < OpenShift::Model
|
2
|
+
attr_accessor :framework, :creation_time, :uuid, :embedded, :aliases, :name, :gear_count, :links, :domain_id,
|
3
|
+
:git_url, :app_url, :ssh_url, :gear_profile, :scalable, :health_check_path, :building_with, :building_app,
|
4
|
+
:build_job_url, :initial_git_url, :cartridges
|
5
|
+
include LegacyBrokerHelper
|
6
|
+
|
7
|
+
def initialize(app, url, nolinks=false)
|
8
|
+
self.framework = app.framework
|
9
|
+
self.name = app.name
|
10
|
+
self.creation_time = app.creation_time
|
11
|
+
self.uuid = app.uuid
|
12
|
+
self.aliases = app.aliases || Array.new
|
13
|
+
self.gear_count = (app.gears.nil?) ? 0 : app.gears.length
|
14
|
+
self.embedded = app.embedded
|
15
|
+
self.domain_id = app.domain.namespace
|
16
|
+
self.gear_profile = app.node_profile
|
17
|
+
self.scalable = app.scalable
|
18
|
+
self.git_url = "ssh://#{@uuid}@#{@name}-#{@domain_id}.#{Rails.configuration.openshift[:domain_suffix]}/~/git/#{@name}.git/"
|
19
|
+
self.app_url = "http://#{@name}-#{@domain_id}.#{Rails.configuration.openshift[:domain_suffix]}/"
|
20
|
+
self.ssh_url = "ssh://#{@uuid}@#{@name}-#{@domain_id}.#{Rails.configuration.openshift[:domain_suffix]}"
|
21
|
+
self.health_check_path = app.health_check_path
|
22
|
+
self.building_with = nil
|
23
|
+
self.building_app = nil
|
24
|
+
self.build_job_url = nil
|
25
|
+
self.initial_git_url = app.init_git_url
|
26
|
+
|
27
|
+
app.embedded.each { |cname, cinfo|
|
28
|
+
cart = CartridgeCache::find_cartridge(cname)
|
29
|
+
if cart.categories.include? "ci_builder"
|
30
|
+
self.building_with = cart.name
|
31
|
+
self.build_job_url = cinfo["job_url"]
|
32
|
+
break
|
33
|
+
end
|
34
|
+
}
|
35
|
+
app.user.applications.each { |user_app|
|
36
|
+
cart = CartridgeCache::find_cartridge(user_app.framework)
|
37
|
+
if cart.categories.include? "ci"
|
38
|
+
self.building_app = user_app.name
|
39
|
+
break
|
40
|
+
end
|
41
|
+
}
|
42
|
+
|
43
|
+
cart_type = "embedded"
|
44
|
+
cache_key = "cart_list_#{cart_type}"
|
45
|
+
unless nolinks
|
46
|
+
carts = nil
|
47
|
+
if app.scalable
|
48
|
+
carts = Application::SCALABLE_EMBEDDED_CARTS
|
49
|
+
else
|
50
|
+
carts = get_cached(cache_key, :expires_in => 21600.seconds) do
|
51
|
+
Application.get_available_cartridges("embedded")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
# Update carts list
|
55
|
+
# - remove already embedded carts
|
56
|
+
# - remove conflicting carts
|
57
|
+
app.embedded.keys.each do |cname|
|
58
|
+
carts -= [cname]
|
59
|
+
cinfo = CartridgeCache.find_cartridge(cname)
|
60
|
+
carts -= cinfo.conflicts_feature if defined?(cinfo.conflicts_feature)
|
61
|
+
end if !app.embedded.empty?
|
62
|
+
|
63
|
+
self.links = {
|
64
|
+
"GET" => Link.new("Get application", "GET", URI::join(url, "domains/#{@domain_id}/applications/#{@name}")),
|
65
|
+
"GET_DESCRIPTOR" => Link.new("Get application descriptor", "GET", URI::join(url, "domains/#{@domain_id}/applications/#{@name}/descriptor")),
|
66
|
+
"GET_GEARS" => Link.new("Get application gears", "GET", URI::join(url, "domains/#{@domain_id}/applications/#{@name}/gears")),
|
67
|
+
"GET_GEAR_GROUPS" => Link.new("Get application gear groups", "GET", URI::join(url, "domains/#{@domain_id}/applications/#{@name}/gear_groups")),
|
68
|
+
"START" => Link.new("Start application", "POST", URI::join(url, "domains/#{@domain_id}/applications/#{@name}/events"), [
|
69
|
+
Param.new("event", "string", "event", "start")
|
70
|
+
]),
|
71
|
+
"STOP" => Link.new("Stop application", "POST", URI::join(url, "domains/#{@domain_id}/applications/#{@name}/events"), [
|
72
|
+
Param.new("event", "string", "event", "stop")
|
73
|
+
]),
|
74
|
+
"RESTART" => Link.new("Restart application", "POST", URI::join(url, "domains/#{@domain_id}/applications/#{@name}/events"), [
|
75
|
+
Param.new("event", "string", "event", "restart")
|
76
|
+
]),
|
77
|
+
"FORCE_STOP" => Link.new("Force stop application", "POST", URI::join(url, "domains/#{@domain_id}/applications/#{@name}/events"), [
|
78
|
+
Param.new("event", "string", "event", "force-stop")
|
79
|
+
]),
|
80
|
+
"EXPOSE_PORT" => Link.new("Expose port", "POST", URI::join(url, "domains/#{@domain_id}/applications/#{@name}/events"), [
|
81
|
+
Param.new("event", "string", "event", "expose-port")
|
82
|
+
]),
|
83
|
+
"CONCEAL_PORT" => Link.new("Conceal port", "POST", URI::join(url, "domains/#{@domain_id}/applications/#{@name}/events"), [
|
84
|
+
Param.new("event", "string", "event", "conceal-port")
|
85
|
+
]),
|
86
|
+
"SHOW_PORT" => Link.new("Show port", "POST", URI::join(url, "domains/#{@domain_id}/applications/#{@name}/events"), [
|
87
|
+
Param.new("event", "string", "event", "show-port")
|
88
|
+
]),
|
89
|
+
"ADD_ALIAS" => Link.new("Add application alias", "POST", URI::join(url, "domains/#{@domain_id}/applications/#{@name}/events"), [
|
90
|
+
Param.new("event", "string", "event", "add-alias"),
|
91
|
+
Param.new("alias", "string", "The server alias for the application")
|
92
|
+
]),
|
93
|
+
"REMOVE_ALIAS" => Link.new("Remove application alias", "POST", URI::join(url, "domains/#{@domain_id}/applications/#{@name}/events"), [
|
94
|
+
Param.new("event", "string", "event", "remove-alias"),
|
95
|
+
Param.new("alias", "string", "The application alias to be removed")
|
96
|
+
]),
|
97
|
+
"SCALE_UP" => Link.new("Scale up application", "POST", URI::join(url, "domains/#{@domain_id}/applications/#{@name}/events"), [
|
98
|
+
Param.new("event", "string", "event", "scale-up")
|
99
|
+
]),
|
100
|
+
"SCALE_DOWN" => Link.new("Scale down application", "POST", URI::join(url, "domains/#{@domain_id}/applications/#{@name}/events"), [
|
101
|
+
Param.new("event", "string", "event", "scale-down")
|
102
|
+
]),
|
103
|
+
"TIDY" => Link.new("Tidy the application framework", "POST", URI::join(url, "domains/#{@domain_id}/applications/#{@name}/events"), [
|
104
|
+
Param.new("event", "string", "event", "tidy")
|
105
|
+
]),
|
106
|
+
"RELOAD" => Link.new("Reload the application", "POST", URI::join(url, "domains/#{@domain_id}/applications/#{@name}/events"), [
|
107
|
+
Param.new("event", "string", "event", "reload")
|
108
|
+
]),
|
109
|
+
"THREAD_DUMP" => Link.new("Trigger thread dump", "POST", URI::join(url, "domains/#{@domain_id}/applications/#{@name}/events"), [
|
110
|
+
Param.new("event", "string", "event", "thread-dump")
|
111
|
+
]),
|
112
|
+
"DELETE" => Link.new("Delete application", "DELETE", URI::join(url, "domains/#{@domain_id}/applications/#{@name}")),
|
113
|
+
"ADD_CARTRIDGE" => Link.new("Add embedded cartridge", "POST", URI::join(url, "domains/#{@domain_id}/applications/#{@name}/cartridges"),[
|
114
|
+
Param.new("cartridge", "string", "framework-type, e.g.: mongodb-2.2", carts)
|
115
|
+
]),
|
116
|
+
"LIST_CARTRIDGES" => Link.new("List embedded cartridges", "GET", URI::join(url, "domains/#{@domain_id}/applications/#{@name}/cartridges")),
|
117
|
+
"DNS_RESOLVABLE" => Link.new("Resolve DNS", "GET", URI::join(url, "domains/#{@domain_id}/applications/#{@name}/dns_resolvable"))
|
118
|
+
}
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def to_xml(options={})
|
123
|
+
options[:tag_name] = "application"
|
124
|
+
super(options)
|
125
|
+
end
|
126
|
+
end
|