openshift-origin-node 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

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,82 @@
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}: Removes an authorized ssh key from 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-comment COMMENT]
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 remove
39
+
40
+ USAGE
41
+ exit 255
42
+ end
43
+
44
+ require 'rubygems'
45
+ require 'openshift-origin-node'
46
+ require 'openshift-origin-node/utils/shell_exec'
47
+ opts = GetoptLong.new(
48
+ ["--with-app-uuid", "-a", GetoptLong::REQUIRED_ARGUMENT],
49
+ ["--with-container-uuid", "-c", GetoptLong::REQUIRED_ARGUMENT],
50
+ ["--with-ssh-key", "-s", GetoptLong::REQUIRED_ARGUMENT],
51
+ ["--with-ssh-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
+ comment = args['--with-ssh-comment']
69
+
70
+ unless uuid and ssh_key
71
+ usage
72
+ end
73
+
74
+ begin
75
+ container = OpenShift::ApplicationContainer.new(uuid,uuid)
76
+ container.user.remove_ssh_key(ssh_key, comment)
77
+ rescue Exception => e
78
+ $stderr.puts(e.message)
79
+ exit -1
80
+ else
81
+ exit 0
82
+ end
@@ -0,0 +1,84 @@
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
+ oo-broker-auth-key-add: Adds broker auth key to the application.
23
+ #{$0}: Adds broker auth key to the application.
24
+ This command must be run as root.
25
+
26
+ == Usage
27
+
28
+ #{$0} \\
29
+ --with-app-uuid APP_UUID \\
30
+ --with-container-uuid UUID \\
31
+ --with-iv INITIALIZATION_VECTOR \\
32
+ --with-token TOKEN
33
+
34
+ Options:
35
+ -h|--help:
36
+ Prints this message
37
+
38
+ UUID: Unique identifier for the application
39
+ INITIALIZATION_VECTOR: Initialization vector to add
40
+ TOKEN: Token to add
41
+
42
+ USAGE
43
+ exit 255
44
+ end
45
+
46
+ require 'rubygems'
47
+ require 'openshift-origin-node'
48
+ require 'openshift-origin-node/utils/shell_exec'
49
+ opts = GetoptLong.new(
50
+ ["--with-app-uuid", "-a", GetoptLong::REQUIRED_ARGUMENT],
51
+ ["--with-container-uuid", "-c", GetoptLong::REQUIRED_ARGUMENT],
52
+ ["--with-iv", "-i", GetoptLong::REQUIRED_ARGUMENT],
53
+ ["--with-token", "-t", GetoptLong::REQUIRED_ARGUMENT]
54
+ )
55
+
56
+ args = {}
57
+ begin
58
+ opts.each{ |k,v| args[k]=v }
59
+ rescue GetoptLong::Error => e
60
+ usage
61
+ end
62
+
63
+ if args["--help"]
64
+ usage
65
+ end
66
+
67
+ uuid = args['--with-container-uuid']
68
+ app_uuid = args['--with-app-uuid']
69
+ iv = args['--with-iv']
70
+ token = args['--with-token']
71
+
72
+ unless uuid and iv and token
73
+ usage
74
+ end
75
+
76
+ begin
77
+ container = OpenShift::ApplicationContainer.new(uuid, uuid)
78
+ container.user.add_broker_auth(iv,token)
79
+ rescue Exception => e
80
+ $stderr.puts(e.message)
81
+ exit -1
82
+ else
83
+ exit 0
84
+ end
@@ -0,0 +1,72 @@
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
+ This command must be run as root.
23
+
24
+ == Usage
25
+
26
+ #{$0} --with-app-uuid APP_UUID --with-container-uuid UUID
27
+
28
+ Options:
29
+ -h|--help:
30
+ Prints this message
31
+
32
+ UUID: Unique identifier for the application
33
+
34
+ USAGE
35
+ exit 255
36
+ end
37
+
38
+ require 'rubygems'
39
+ require 'openshift-origin-node'
40
+ require 'openshift-origin-node/utils/shell_exec'
41
+ opts = GetoptLong.new(
42
+ ["--with-app-uuid", "-a", GetoptLong::REQUIRED_ARGUMENT],
43
+ ["--with-container-uuid", "-c", GetoptLong::REQUIRED_ARGUMENT]
44
+ )
45
+
46
+ args = {}
47
+ begin
48
+ opts.each{ |k,v| args[k]=v }
49
+ rescue GetoptLong::Error => e
50
+ usage
51
+ end
52
+
53
+ if args["--help"]
54
+ usage
55
+ end
56
+
57
+ uuid = args['--with-container-uuid']
58
+ app_uuid = args['--with-app-uuid']
59
+
60
+ unless uuid
61
+ usage
62
+ end
63
+
64
+ begin
65
+ container = OpenShift::ApplicationContainer.new(uuid, uuid)
66
+ container.user.remove_broker_auth
67
+ rescue Exception => e
68
+ $stderr.puts(e.message)
69
+ exit -1
70
+ else
71
+ exit 0
72
+ end
@@ -0,0 +1,70 @@
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}: Gets the descriptor for a given cartridge name
23
+
24
+ == Usage
25
+
26
+ #{$0} [CART]
27
+
28
+ Options:
29
+ -h|--help:
30
+ Prints this message
31
+
32
+ USAGE
33
+ exit 255
34
+ end
35
+
36
+ require 'rubygems'
37
+ require 'openshift-origin-node'
38
+ require 'openshift-origin-common'
39
+ opts = GetoptLong.new(
40
+ ["--porcelain", "-q", GetoptLong::NO_ARGUMENT],
41
+ ["--debug", "-d", GetoptLong::NO_ARGUMENT],
42
+ ["--help", "-?", GetoptLong::NO_ARGUMENT]
43
+ )
44
+
45
+ args = {}
46
+ begin
47
+ opts.each{ |k,v| args[k]=v }
48
+ rescue GetoptLong::Error => e
49
+ usage
50
+ end
51
+
52
+ if args["--help"]
53
+ usage
54
+ end
55
+
56
+ $oo_debug = true if args['--debug']
57
+ $porcelain = args['--porcelain'] ? true : false
58
+
59
+ cart_name = ARGV.shift
60
+ cart_found = false
61
+
62
+ begin
63
+ cart_info = OpenShift::Node.get_cartridge_info(cart_name, $porcelain, $oo_debug)
64
+ puts cart_info
65
+ rescue Exception => e
66
+ $stderr.puts(e.message)
67
+ exit -1
68
+ else
69
+ exit 0
70
+ end
@@ -0,0 +1,70 @@
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
+ require 'rubygems'
19
+ require 'openshift-origin-node'
20
+ require 'openshift-origin-common'
21
+
22
+ def usage
23
+ puts <<USAGE
24
+ == Synopsis
25
+
26
+ #{$0}: Lists all cartridges installed on the node
27
+
28
+ == Usage
29
+
30
+ #{$0} --with-descriptors [--porcelain]
31
+
32
+ Options:
33
+ -h|--help:
34
+ Prints this message
35
+
36
+ USAGE
37
+ exit 255
38
+ end
39
+
40
+ opts = GetoptLong.new(
41
+ ['--with-descriptors', '-a', GetoptLong::NO_ARGUMENT],
42
+ ['--porcelain', '-q', GetoptLong::NO_ARGUMENT],
43
+ ['--debug', '-d', GetoptLong::NO_ARGUMENT],
44
+ ['--help', '-?', GetoptLong::NO_ARGUMENT]
45
+ )
46
+
47
+ args = {}
48
+ begin
49
+ opts.each{ |k,v| args[k]=v }
50
+ rescue GetoptLong::Error => e
51
+ usage
52
+ end
53
+
54
+ if args["--help"]
55
+ usage
56
+ end
57
+
58
+ list_descriptors = true if args['--with-descriptors']
59
+ $oo_debug = true if args['--debug']
60
+ $porcelain = args['--porcelain'] ? true : false
61
+
62
+ begin
63
+ list = OpenShift::Node.get_cartridge_list(list_descriptors, $porcelain, $oo_debug)
64
+ puts list
65
+ rescue Exception => e
66
+ $stderr.puts(e.message)
67
+ exit -1
68
+ else
69
+ exit 0
70
+ end
@@ -0,0 +1,94 @@
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
+ require 'rubygems'
19
+ require 'openshift-origin-node'
20
+ require 'open4'
21
+ require 'shellwords'
22
+
23
+ def usage
24
+ puts <<USAGE
25
+ == Synopsis
26
+
27
+ #{$0}: Executes a connector on a cartridge component
28
+ This command must be run as root.
29
+
30
+ == Usage
31
+
32
+ #{$0} GEAR_UUID CART_NAME HOOK_NAME <args-to-connector>
33
+
34
+ Options:
35
+ -h|--help:
36
+ Prints this message
37
+
38
+ GEAR_UUID: Unique identifier for gear that the component is running on
39
+ CART_NAME: Unique identifier for the cartridge that the component belongs to
40
+ HOOK_NAME: Name of the connector to be executed
41
+
42
+ USAGE
43
+ exit 255
44
+ end
45
+
46
+ opts = GetoptLong.new(
47
+ ['--gear-uuid', '-g', GetoptLong::REQUIRED_ARGUMENT],
48
+ ['--cart-name', '-c', GetoptLong::REQUIRED_ARGUMENT],
49
+ ['--hook-name', '-h', GetoptLong::REQUIRED_ARGUMENT],
50
+ ['--porcelain', '-q', GetoptLong::NO_ARGUMENT],
51
+ ['--debug', '-d', GetoptLong::NO_ARGUMENT],
52
+ ['--help', '-?', GetoptLong::NO_ARGUMENT]
53
+ )
54
+
55
+ args = {}
56
+ begin
57
+ opts.each{ |k,v| args[k]=v }
58
+ rescue GetoptLong::Error => e
59
+ usage
60
+ end
61
+
62
+ if args["--help"]
63
+ usage
64
+ end
65
+
66
+ gear_uuid = args['--gear-uuid']
67
+ cart_name = args['--cart-name']
68
+ hook_name = args['--hook-name']
69
+ $oo_debug = true if args['--debug']
70
+ $porcelain = args['--porcelain'] ? true : false
71
+
72
+ config = OpenShift::Config.instance
73
+ unless gear_uuid
74
+ usage
75
+ end
76
+
77
+ exitcode = 0
78
+ begin
79
+ cart_dir = config.get('CARTRIDGE_BASE_PATH')
80
+ if File.exists? "#{cart_dir}/#{cart_name}/info/connection-hooks/#{hook_name}"
81
+ shellsafe_argv = ARGV.map { |arg| Shellwords::shellescape(arg) }
82
+ pid, stdin, stdout, stderr = Open4::popen4ext(true,
83
+ "#{cart_dir}/#{cart_name}/info/connection-hooks/#{hook_name} #{shellsafe_argv.join(' ')} 2>&1")
84
+ ignored, status = Process::waitpid2 pid
85
+ exitcode = status.exitstatus
86
+ zout = stdout.gets
87
+ zout = "" if zout.nil?
88
+ $stdout.puts zout
89
+ end
90
+ rescue Exception => e
91
+ $stderr.puts(e.message)
92
+ exit -1
93
+ end
94
+ exit exitcode