openshift-origin-node 1.3.1

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-node might be problematic. Click here for more details.

Files changed (51) hide show
  1. data/COPYRIGHT +1 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE +11 -0
  4. data/README.md +3 -0
  5. data/Rakefile +28 -0
  6. data/bin/oo-add-alias +93 -0
  7. data/bin/oo-app-create +110 -0
  8. data/bin/oo-app-destroy +100 -0
  9. data/bin/oo-app-state-show +74 -0
  10. data/bin/oo-authorized-ssh-key-add +83 -0
  11. data/bin/oo-authorized-ssh-key-remove +82 -0
  12. data/bin/oo-broker-auth-key-add +84 -0
  13. data/bin/oo-broker-auth-key-remove +72 -0
  14. data/bin/oo-cartridge-info +70 -0
  15. data/bin/oo-cartridge-list +70 -0
  16. data/bin/oo-connector-execute +94 -0
  17. data/bin/oo-env-var-add +81 -0
  18. data/bin/oo-env-var-remove +78 -0
  19. data/bin/oo-get-quota +64 -0
  20. data/bin/oo-remove-alias +93 -0
  21. data/bin/oo-set-quota +59 -0
  22. data/conf/node.conf +30 -0
  23. data/conf/resource_limits.template +67 -0
  24. data/lib/openshift-origin-node.rb +29 -0
  25. data/lib/openshift-origin-node/config.rb +21 -0
  26. data/lib/openshift-origin-node/environment.rb +26 -0
  27. data/lib/openshift-origin-node/model/application_container.rb +298 -0
  28. data/lib/openshift-origin-node/model/frontend_httpd.rb +346 -0
  29. data/lib/openshift-origin-node/model/node.rb +134 -0
  30. data/lib/openshift-origin-node/model/unix_user.rb +738 -0
  31. data/lib/openshift-origin-node/plugins/unix_user_observer.rb +86 -0
  32. data/lib/openshift-origin-node/utils/shell_exec.rb +115 -0
  33. data/lib/openshift-origin-node/version.rb +23 -0
  34. data/misc/bin/oo-admin-ctl-cgroups +482 -0
  35. data/misc/bin/oo-cgroup-read +25 -0
  36. data/misc/bin/oo-get-mcs-level +29 -0
  37. data/misc/bin/oo-trap-user +248 -0
  38. data/misc/bin/rhcsh +155 -0
  39. data/misc/bin/setup_pam_fs_limits.sh +146 -0
  40. data/misc/bin/teardown_pam_fs_limits.sh +73 -0
  41. data/misc/doc/cgconfig.conf +26 -0
  42. data/misc/etc/openshift-run.conf +1 -0
  43. data/misc/init/openshift-cgroups +56 -0
  44. data/misc/services/openshift-cgroups.service +14 -0
  45. data/openshift-origin-node.gemspec +31 -0
  46. data/rubygem-openshift-origin-node.spec +263 -0
  47. data/test/test_helper.rb +20 -0
  48. data/test/unit/frontend_httpd_test.rb +144 -0
  49. data/test/unit/unix_user_test.rb +95 -0
  50. data/test/unit/version_test.rb +45 -0
  51. metadata +230 -0
@@ -0,0 +1 @@
1
+ Copyright 2012 Red Hat, Inc. and/or its affiliates.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in openshift-origin-node.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,11 @@
1
+ Licensed under the Apache License, Version 2.0 (the "License");
2
+ you may not use this file except in compliance with the License.
3
+ You may obtain a copy of the License at
4
+
5
+ http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
@@ -0,0 +1,3 @@
1
+ Notice of Export Control Law
2
+
3
+ This software distribution includes cryptographic software that is subject to the U.S. Export Administration Regulations (the "*EAR*") and other U.S. and foreign laws and may not be exported, re-exported or transferred (a) to any country listed in Country Group E:1 in Supplement No. 1 to part 740 of the EAR (currently, Cuba, Iran, North Korea, Sudan & Syria); (b) to any prohibited destination or to any end user who has been prohibited from participating in U.S. export transactions by any federal agency of the U.S. government; or (c) for use in connection with the design, development or production of nuclear, chemical or biological weapons, or rocket systems, space launch vehicles, or sounding rockets, or unmanned air vehicle systems.You may not download this software or technical information if you are located in one of these countries or otherwise subject to these restrictions. You may not provide this software or technical information to individuals or entities located in one of these countries or otherwise subject to these restrictions. You are also responsible for compliance with foreign law requirements applicable to the import, export and use of this software and technical information.
@@ -0,0 +1,28 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/clean'
4
+ require 'rake/testtask'
5
+
6
+ desc "Print environment to run from checkout - eval $( rake local_env | tail -n +1 )"
7
+ task :local_env do
8
+ pwd = Dir.pwd
9
+ puts "RUBYLIB='#{pwd}/lib/'; export RUBYLIB"
10
+ puts "PATH='#{pwd}/bin/:#{ENV['PATH']}'; export PATH"
11
+ puts "SS_CONFIG_DIR='#{pwd}/conf'; export SS_CONFIG_DIR"
12
+ end
13
+
14
+ desc "Unit tests"
15
+ Rake::TestTask.new(:unit_test) do |t|
16
+ t.libs << File.expand_path('../lib', __FILE__)
17
+ t.libs << File.expand_path('../test', __FILE__)
18
+ t.libs << File.expand_path('../test/unit', __FILE__)
19
+ t.pattern = 'test/unit/**/*_test.rb'
20
+ end
21
+
22
+ task :test => [:unit_test] do
23
+ end
24
+
25
+ desc "Generate RDoc"
26
+ task :doc do
27
+ sh "rdoc ."
28
+ end
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env oo-ruby
2
+ #--
3
+ # Copyright 2010 Red Hat, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #++
17
+
18
+ def usage
19
+ puts <<USAGE
20
+ == Synopsis
21
+
22
+ #{$0}: Add a frontend httpd alias to a gear.
23
+ This command must be run as root.
24
+
25
+ == Usage
26
+
27
+ #{$0} --with-container-uuid UUID \\
28
+ --with-container-name NAME \\
29
+ --with-namespace NAMESPACE \\
30
+ --with-alias-name ALIAS
31
+
32
+ == List of arguments
33
+ -a|--with-alias-name alias Alias to add to the gear
34
+ -c|--with-container-uuid gear_uuid Unique identifier for the gear(required)
35
+ |--with-namespace namespace Namespace of the application (required)
36
+ |--with-container-name gear_name Name of the gear
37
+ -n|--dry-run Don't make changes, just do a dry run.
38
+ -q|--porcelain TODO: what does this do?
39
+ -d|--debug Enable debug mode
40
+ -h|--help Print this message
41
+
42
+ USAGE
43
+ exit 255
44
+ end
45
+
46
+ require 'rubygems'
47
+ require 'openshift-origin-node'
48
+ opts = GetoptLong.new(
49
+ ["--with-alias-name", "-a", GetoptLong::REQUIRED_ARGUMENT],
50
+ ["--with-container-uuid", "-c", GetoptLong::REQUIRED_ARGUMENT],
51
+ ["--with-namespace", GetoptLong::REQUIRED_ARGUMENT],
52
+ ["--with-container-name", GetoptLong::REQUIRED_ARGUMENT],
53
+ ["--dry-run", "-n", GetoptLong::NO_ARGUMENT],
54
+ ["--porcelain", "-q", GetoptLong::NO_ARGUMENT],
55
+ ["--debug", "-d", GetoptLong::NO_ARGUMENT],
56
+ ["--help", "-?", GetoptLong::NO_ARGUMENT]
57
+ )
58
+
59
+ args = {}
60
+ begin
61
+ opts.each{ |k,v| args[k]=v }
62
+ rescue GetoptLong::Error => e
63
+ usage
64
+ end
65
+
66
+ if args["--help"]
67
+ usage
68
+ end
69
+
70
+ alias_name = args['--with-alias-name']
71
+ container_uuid = args['--with-container-uuid']
72
+ container_name = args['--with-container-name']
73
+ namespace = args['--with-namespace']
74
+
75
+ $dry_run = true if args['--dry-run']
76
+ $oo_debug = true if args['--debug']
77
+ $porcelain = args['--porcelain'] ? true : false
78
+
79
+ unless container_uuid
80
+ usage
81
+ end
82
+
83
+ begin
84
+ frontend = OpenShift::FrontendHttpServer.new(container_uuid, container_name, namespace)
85
+ out, err, rc = frontend.add_alias(alias_name)
86
+ rescue Exception => e
87
+ $stderr.puts(e.message)
88
+ exit -1
89
+ else
90
+ $stdout.puts(out) if out != ""
91
+ $stderr.puts(err) if err != ""
92
+ exit rc
93
+ end
@@ -0,0 +1,110 @@
1
+ #!/usr/bin/env oo-ruby
2
+ #--
3
+ # Copyright 2010 Red Hat, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #++
17
+
18
+ def usage
19
+ puts <<USAGE
20
+ == Synopsis
21
+
22
+ #{$0}: Creates a new application container.
23
+ This command must be run as root.
24
+
25
+ == Usage
26
+
27
+ #{$0} --with-app-uuid e335712492e011e1bae700262df50034 \\
28
+ --with-container-uuid 1c3a5f7a92e111e188d800262df50034 \\
29
+ --with-namespace mydomain \\
30
+ --with-app-name myapp
31
+
32
+ == List of arguments
33
+ -a|--with-app-uuid app_uuid Unique application identifier (required)
34
+ -c|--with-container-uuid gear_uuid Unique identifier for the gear(required)
35
+ |--with-app-name name Name of the application (required)
36
+ |--with-namespace namespace Namespace of the application (required)
37
+ |--with-container-name gear_name Name of the gear
38
+ -i|--with-uid uid User ID to use (will create a user with
39
+ this uid in /etc/passwd
40
+ |--with-quota-blocks blocks Number of blocks to allow
41
+ |--with-quota-files num_files Number of files to allow
42
+ -n|--dry-run Don't make changes, just do a dry run.
43
+ -q|--porcelain TODO: what does this do?
44
+ -d|--debug Enable debug mode
45
+ -h|--help Print this message
46
+
47
+ USAGE
48
+ exit 255
49
+ end
50
+
51
+ require 'rubygems'
52
+ require 'openshift-origin-node'
53
+ opts = GetoptLong.new(
54
+ ["--with-app-uuid", "-a", GetoptLong::REQUIRED_ARGUMENT],
55
+ ["--with-container-uuid", "-c", GetoptLong::REQUIRED_ARGUMENT],
56
+ ["--with-uid", "-i", GetoptLong::REQUIRED_ARGUMENT],
57
+ ["--with-app-name", GetoptLong::REQUIRED_ARGUMENT],
58
+ ["--with-namespace", GetoptLong::REQUIRED_ARGUMENT],
59
+ ["--with-quota-blocks", GetoptLong::REQUIRED_ARGUMENT],
60
+ ["--with-quota-files", GetoptLong::REQUIRED_ARGUMENT],
61
+ ["--dry-run", "-n", GetoptLong::NO_ARGUMENT],
62
+ ["--with-container-name", GetoptLong::OPTIONAL_ARGUMENT],
63
+ ["--porcelain", "-q", GetoptLong::NO_ARGUMENT],
64
+ ["--debug", "-d", GetoptLong::NO_ARGUMENT],
65
+ ["--help", "-?", GetoptLong::NO_ARGUMENT]
66
+ )
67
+
68
+ args = {}
69
+ begin
70
+ opts.each{ |k,v| args[k]=v }
71
+ rescue GetoptLong::Error => e
72
+ usage
73
+ end
74
+
75
+ if args["--help"]
76
+ usage
77
+ end
78
+
79
+ app_uuid = args['--with-app-uuid']
80
+ gear_uuid = args['--with-container-uuid']
81
+ uid = args['--with-uid']
82
+ uid = nil if uid && uid.empty?
83
+ quota_blocks = args['--with-quota-blocks']
84
+ quota_files = args['--with-quota-files']
85
+ app_name = args['--with-app-name']
86
+ gear_name = args['--with-container-name']
87
+ gear_name = app_name if (gear_name && gear_name.empty?) || !gear_name
88
+ namespace = args['--with-namespace']
89
+ $dry_run = true if args['--dry-run']
90
+ $oo_debug = true if args['--debug']
91
+ $porcelain = args['--porcelain'] ? true : false
92
+
93
+ unless gear_uuid
94
+ usage
95
+ end
96
+
97
+ begin
98
+ container = OpenShift::ApplicationContainer.new(app_uuid, gear_uuid, uid,
99
+ app_name, gear_name, namespace, quota_blocks,
100
+ quota_files)
101
+ container.create
102
+ rescue OpenShift::UserCreationException => e
103
+ $stderr.puts(e.message)
104
+ exit 129
105
+ rescue Exception => e
106
+ $stderr.puts(e.message)
107
+ exit -1
108
+ else
109
+ exit 0
110
+ end
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env oo-ruby
2
+ #--
3
+ # Copyright 2010 Red Hat, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #++
17
+
18
+ def usage
19
+ puts <<USAGE
20
+ == Synopsis
21
+
22
+ #{$0}: Deletes an application container.
23
+ This command must be run as root.
24
+
25
+ == Usage
26
+
27
+ #{$0} --with-container-uuid UUID \\
28
+ --with-container-name NAME \\
29
+ --with-app-uuid APP_UUID \\
30
+ --with-app-name APP_NAME \\
31
+ --with-namespace NAMESPACE
32
+
33
+ == List of arguments
34
+ -a|--with-app-uuid app_uuid Unique application identifier (required)
35
+ -c|--with-container-uuid gear_uuid Unique identifier for the gear(required)
36
+ |--with-app-name name Name of the application (required)
37
+ |--with-namespace namespace Namespace of the application (required)
38
+ |--with-container-name gear_name Name of the gear
39
+ |--skip-hooks Skip running pre and post hooks for cartridge destroy
40
+ -n|--dry-run Don't make changes, just do a dry run.
41
+ -q|--porcelain TODO: what does this do?
42
+ -d|--debug Enable debug mode
43
+ -h|--help Print this message
44
+
45
+ USAGE
46
+ exit 255
47
+ end
48
+
49
+ require 'rubygems'
50
+ require 'openshift-origin-node'
51
+ opts = GetoptLong.new(
52
+ ["--with-app-uuid", "-a", GetoptLong::REQUIRED_ARGUMENT],
53
+ ["--with-container-uuid", "-c", GetoptLong::REQUIRED_ARGUMENT],
54
+ ["--with-app-name", GetoptLong::REQUIRED_ARGUMENT],
55
+ ["--with-namespace", GetoptLong::REQUIRED_ARGUMENT],
56
+ ["--with-container-name", GetoptLong::OPTIONAL_ARGUMENT],
57
+ ["--dry-run", "-n", GetoptLong::NO_ARGUMENT],
58
+ ["--porcelain", "-q", GetoptLong::NO_ARGUMENT],
59
+ ["--skip-hooks", GetoptLong::NO_ARGUMENT],
60
+ ["--debug", "-d", GetoptLong::NO_ARGUMENT],
61
+ ["--help", "-?", GetoptLong::NO_ARGUMENT]
62
+ )
63
+
64
+ args = {}
65
+ begin
66
+ opts.each{ |k,v| args[k]=v }
67
+ rescue GetoptLong::Error => e
68
+ usage
69
+ end
70
+
71
+ if args["--help"]
72
+ usage
73
+ end
74
+
75
+ app_uuid = args['--with-app-uuid']
76
+ app_name = args['--with-app-name']
77
+ container_uuid = args['--with-container-uuid']
78
+ container_name = args['--with-container-name'] || args['--with-app-name']
79
+ namespace = args['--with-namespace']
80
+ skip_hooks = true if args['--skip-hooks']
81
+ $dry_run = true if args['--dry-run']
82
+ $oo_debug = true if args['--debug']
83
+ $porcelain = args['--porcelain'] ? true : false
84
+
85
+ unless container_uuid
86
+ usage
87
+ end
88
+
89
+ begin
90
+ container = OpenShift::ApplicationContainer.new(app_uuid, container_uuid, nil, app_name,
91
+ container_name, namespace, nil, nil)
92
+ out, err, rc = container.destroy(skip_hooks)
93
+ rescue Exception => e
94
+ $stderr.puts(e.message)
95
+ exit -1
96
+ else
97
+ $stdout.puts(out) if out != ""
98
+ $stderr.puts(err) if err != ""
99
+ exit rc
100
+ end
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env oo-ruby
2
+ #--
3
+ # Copyright 2010 Red Hat, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #++
17
+
18
+ def usage
19
+ puts <<USAGE
20
+ == Synopsis
21
+
22
+ #{$0}: Returns the application state on the gear.
23
+ This command must be run as root.
24
+
25
+ == Usage
26
+
27
+ #{$0} --with-app-uuid APP_UUID \\
28
+ --with-container-uuid UUID
29
+
30
+ Options:
31
+ -h|--help:
32
+ Prints this message
33
+
34
+ UUID: Unique identifier for the application
35
+
36
+ USAGE
37
+ exit 255
38
+ end
39
+
40
+ require 'rubygems'
41
+ require 'openshift-origin-node'
42
+ require 'openshift-origin-node/utils/shell_exec'
43
+ opts = GetoptLong.new(
44
+ ["--with-app-uuid", "-a", GetoptLong::REQUIRED_ARGUMENT],
45
+ ["--with-container-uuid", "-c", GetoptLong::REQUIRED_ARGUMENT]
46
+ )
47
+
48
+ args = {}
49
+ begin
50
+ opts.each{ |k,v| args[k]=v }
51
+ rescue GetoptLong::Error => e
52
+ usage
53
+ end
54
+
55
+ container_uuid = args['--with-container-uuid']
56
+ app_uuid = args['--with-app-uuid']
57
+
58
+ if args["--help"]
59
+ usage
60
+ end
61
+
62
+ unless container_uuid and app_uuid
63
+ usage
64
+ end
65
+
66
+ begin
67
+ container = OpenShift::ApplicationContainer.new(app_uuid, container_uuid)
68
+ print container.get_app_state()
69
+ rescue Exception => e
70
+ $stderr.puts(e.message)
71
+ exit -1
72
+ else
73
+ exit 0
74
+ end
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env oo-ruby
2
+ #--
3
+ # Copyright 2010 Red Hat, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #++
17
+
18
+ def usage
19
+ puts <<USAGE
20
+ == Synopsis
21
+
22
+ #{$0}: Adds an authorized ssh key to the app.
23
+ This command must be run as root.
24
+
25
+ == Usage
26
+
27
+ #{$0} \\
28
+ --with-app-uuid APP_UUID \\
29
+ --with-container-uuid UUID \\
30
+ --with-ssh-key KEY \\
31
+ --with-ssh-key-type KEY_TYPE
32
+
33
+ Options:
34
+ -h|--help:
35
+ Prints this message
36
+
37
+ UUID: Unique identifier for the application
38
+ SSH_KEY: The ssh key to add
39
+
40
+ USAGE
41
+ exit 255
42
+ end
43
+
44
+ require 'rubygems'
45
+ require 'openshift-origin-node'
46
+ opts = GetoptLong.new(
47
+ ["--with-app-uuid", "-a", GetoptLong::REQUIRED_ARGUMENT],
48
+ ["--with-container-uuid", "-c", GetoptLong::REQUIRED_ARGUMENT],
49
+ ["--with-ssh-key", "-s", GetoptLong::REQUIRED_ARGUMENT],
50
+ ["--with-ssh-key-type", "-t", GetoptLong::REQUIRED_ARGUMENT],
51
+ ["--with-ssh-key-comment", "-m", GetoptLong::REQUIRED_ARGUMENT]
52
+ )
53
+
54
+ args = {}
55
+ begin
56
+ opts.each{ |k,v| args[k]=v }
57
+ rescue GetoptLong::Error => e
58
+ usage
59
+ end
60
+
61
+ if args["--help"]
62
+ usage
63
+ end
64
+
65
+ uuid = args['--with-container-uuid']
66
+ app_uuid = args['--with-app-uuid']
67
+ ssh_key = args['--with-ssh-key']
68
+ key_type = args['--with-ssh-key-type']
69
+ comment = args['--with-ssh-key-comment']
70
+
71
+ unless uuid and ssh_key
72
+ usage
73
+ end
74
+
75
+ begin
76
+ container = OpenShift::ApplicationContainer.new(uuid,uuid)
77
+ container.user.add_ssh_key(ssh_key, key_type, comment)
78
+ rescue Exception => e
79
+ $stderr.puts(e.message)
80
+ exit -1
81
+ else
82
+ exit 0
83
+ end