brightbox-boxgrinder-plugins 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/LICENSE +165 -0
- data/Manifest +10 -0
- data/README.md +30 -0
- data/Rakefile +36 -0
- data/brightbox-boxgrinder-plugins.gemspec +33 -0
- data/lib/bbcloud-boxgrinder-plugins.rb +22 -0
- data/lib/delivery/bbcloud-delivery-plugin.rb +89 -0
- data/lib/os/sl-plugin.rb +57 -0
- data/lib/platform/bbcloud-platform-plugin.rb +116 -0
- data/lib/platform/src/rc_local +19 -0
- metadata +105 -0
data/CHANGELOG
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
2
|
+
Version 3, 29 June 2007
|
3
|
+
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
6
|
+
of this license document, but changing it is not allowed.
|
7
|
+
|
8
|
+
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
11
|
+
License, supplemented by the additional permissions listed below.
|
12
|
+
|
13
|
+
0. Additional Definitions.
|
14
|
+
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
17
|
+
General Public License.
|
18
|
+
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
20
|
+
other than an Application or a Combined Work as defined below.
|
21
|
+
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
25
|
+
of using an interface provided by the Library.
|
26
|
+
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
28
|
+
Application with the Library. The particular version of the Library
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
30
|
+
Version".
|
31
|
+
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
35
|
+
based on the Application, and not on the Linked Version.
|
36
|
+
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
38
|
+
object code and/or source code for the Application, including any data
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
41
|
+
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
43
|
+
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
46
|
+
|
47
|
+
2. Conveying Modified Versions.
|
48
|
+
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
51
|
+
that uses the facility (other than as an argument passed when the
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
53
|
+
version:
|
54
|
+
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
56
|
+
ensure that, in the event an Application does not supply the
|
57
|
+
function or data, the facility still operates, and performs
|
58
|
+
whatever part of its purpose remains meaningful, or
|
59
|
+
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
61
|
+
this License applicable to that copy.
|
62
|
+
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
64
|
+
|
65
|
+
The object code form of an Application may incorporate material from
|
66
|
+
a header file that is part of the Library. You may convey such object
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
68
|
+
material is not limited to numerical parameters, data structure
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
71
|
+
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
73
|
+
Library is used in it and that the Library and its use are
|
74
|
+
covered by this License.
|
75
|
+
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
77
|
+
document.
|
78
|
+
|
79
|
+
4. Combined Works.
|
80
|
+
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
82
|
+
taken together, effectively do not restrict modification of the
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
85
|
+
the following:
|
86
|
+
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
88
|
+
the Library is used in it and that the Library and its use are
|
89
|
+
covered by this License.
|
90
|
+
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
92
|
+
document.
|
93
|
+
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
95
|
+
execution, include the copyright notice for the Library among
|
96
|
+
these notices, as well as a reference directing the user to the
|
97
|
+
copies of the GNU GPL and this license document.
|
98
|
+
|
99
|
+
d) Do one of the following:
|
100
|
+
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
102
|
+
License, and the Corresponding Application Code in a form
|
103
|
+
suitable for, and under terms that permit, the user to
|
104
|
+
recombine or relink the Application with a modified version of
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
107
|
+
Corresponding Source.
|
108
|
+
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
111
|
+
a copy of the Library already present on the user's computer
|
112
|
+
system, and (b) will operate properly with a modified version
|
113
|
+
of the Library that is interface-compatible with the Linked
|
114
|
+
Version.
|
115
|
+
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
117
|
+
be required to provide such information under section 6 of the
|
118
|
+
GNU GPL, and only to the extent that such information is
|
119
|
+
necessary to install and execute a modified version of the
|
120
|
+
Combined Work produced by recombining or relinking the
|
121
|
+
Application with a modified version of the Linked Version. (If
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
126
|
+
for conveying Corresponding Source.)
|
127
|
+
|
128
|
+
5. Combined Libraries.
|
129
|
+
|
130
|
+
You may place library facilities that are a work based on the
|
131
|
+
Library side by side in a single library together with other library
|
132
|
+
facilities that are not Applications and are not covered by this
|
133
|
+
License, and convey such a combined library under terms of your
|
134
|
+
choice, if you do both of the following:
|
135
|
+
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
137
|
+
on the Library, uncombined with any other library facilities,
|
138
|
+
conveyed under the terms of this License.
|
139
|
+
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
141
|
+
is a work based on the Library, and explaining where to find the
|
142
|
+
accompanying uncombined form of the same work.
|
143
|
+
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
145
|
+
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
148
|
+
versions will be similar in spirit to the present version, but may
|
149
|
+
differ in detail to address new problems or concerns.
|
150
|
+
|
151
|
+
Each version is given a distinguishing version number. If the
|
152
|
+
Library as you received it specifies that a certain numbered version
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
154
|
+
applies to it, you have the option of following the terms and
|
155
|
+
conditions either of that published version or of any later version
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
160
|
+
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
164
|
+
permanent authorization for you to choose that version for the
|
165
|
+
Library.
|
data/Manifest
ADDED
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# BoxGrinder Brightbox Plugins
|
2
|
+
|
3
|
+
This archive integrates the Boxgrinder project [boxgrinder.org](http://www.boxgrinder.org) with the [Brightbox cloud CLI tools] (http://github.com/brightbox/brightbox-cli)
|
4
|
+
|
5
|
+
### Supported OSes
|
6
|
+
|
7
|
+
Brightbox supports all the OSs that Boxgrinder can generate and adds a plugin to generate Scientific Linux images - so you can get Enterprise Linux version 6 today.
|
8
|
+
|
9
|
+
### Requirements
|
10
|
+
|
11
|
+
* A RPM based build machine - registering the boxgrinder appliance image with the Brightbox cloud works fine.
|
12
|
+
* This plugin gem installed.
|
13
|
+
|
14
|
+
### Installing
|
15
|
+
|
16
|
+
* `sudo gem install brightbox-boxgrinder-plugins` to install Brightbox CLI tools and the plugins onto the machine.
|
17
|
+
* `sudo brightbox-config client_add cli-xxxxx secretdetails` to add the api client details that allow access to the Brightbox cloud api.
|
18
|
+
|
19
|
+
### Usage
|
20
|
+
|
21
|
+
Create an appliance configuration file, then call the plugins as in the following example.
|
22
|
+
|
23
|
+
boxgrinder-build --plugins brightbox-boxgrinder-plugins sl-basic.appl -p bbcloud -d bbcloud
|
24
|
+
|
25
|
+
To build an i386 version use:
|
26
|
+
|
27
|
+
setarch i386 boxgrinder-build --plugins brightbox-boxgrinder-plugins sl-basic.appl -p bbcloud -d bbcloud
|
28
|
+
|
29
|
+
Obviously you are not limited to Scientific Linux and can create Fedora, RHEL or CentOS images as well.
|
30
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2010 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# This is free software; you can redistribute it and/or modify it
|
5
|
+
# under the terms of the GNU Lesser General Public License as
|
6
|
+
# published by the Free Software Foundation; either version 3 of
|
7
|
+
# the License, or (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This software is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
+
# Lesser General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU Lesser General Public
|
15
|
+
# License along with this software; if not, write to the Free
|
16
|
+
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
17
|
+
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
18
|
+
|
19
|
+
require 'rubygems'
|
20
|
+
|
21
|
+
begin
|
22
|
+
require 'rake/dsl'
|
23
|
+
rescue LoadError
|
24
|
+
end
|
25
|
+
|
26
|
+
require 'echoe'
|
27
|
+
|
28
|
+
Echoe.new("brightbox-boxgrinder-plugins") do |p|
|
29
|
+
p.project = "Brightbox Cloud"
|
30
|
+
p.author = "Neil Wilson"
|
31
|
+
p.email = "hello@brightbox.co.uk"
|
32
|
+
p.summary = "Brightbox Cloud support for Boxgrinder"
|
33
|
+
p.url = "http://beta.brightbox.com"
|
34
|
+
p.runtime_dependencies = ['bbcloud >=0.11.2']
|
35
|
+
end
|
36
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{brightbox-boxgrinder-plugins}
|
5
|
+
s.version = "0.0.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Neil Wilson"]
|
9
|
+
s.date = %q{2011-05-13}
|
10
|
+
s.description = %q{Brightbox Cloud support for Boxgrinder}
|
11
|
+
s.email = %q{hello@brightbox.co.uk}
|
12
|
+
s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README.md", "lib/bbcloud-boxgrinder-plugins.rb", "lib/delivery/bbcloud-delivery-plugin.rb", "lib/os/sl-plugin.rb", "lib/platform/bbcloud-platform-plugin.rb", "lib/platform/src/rc_local"]
|
13
|
+
s.files = ["CHANGELOG", "LICENSE", "Manifest", "README.md", "Rakefile", "lib/bbcloud-boxgrinder-plugins.rb", "lib/delivery/bbcloud-delivery-plugin.rb", "lib/os/sl-plugin.rb", "lib/platform/bbcloud-platform-plugin.rb", "lib/platform/src/rc_local", "brightbox-boxgrinder-plugins.gemspec"]
|
14
|
+
s.homepage = %q{http://beta.brightbox.com}
|
15
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Brightbox-boxgrinder-plugins", "--main", "README.md"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = %q{Brightbox Cloud}
|
18
|
+
s.rubygems_version = %q{1.3.7}
|
19
|
+
s.summary = %q{Brightbox Cloud support for Boxgrinder}
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
|
+
s.specification_version = 3
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
|
+
s.add_runtime_dependency(%q<bbcloud>, [">= 0.11.2"])
|
27
|
+
else
|
28
|
+
s.add_dependency(%q<bbcloud>, [">= 0.11.2"])
|
29
|
+
end
|
30
|
+
else
|
31
|
+
s.add_dependency(%q<bbcloud>, [">= 0.11.2"])
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Brightbox - Boxgrinder Plugins for Brightbox Cloud
|
2
|
+
# Copyright (c) 2011, Brightbox Systems
|
3
|
+
# Author: Neil Wilson
|
4
|
+
#
|
5
|
+
# This is free software; you can redistribute it and/or modify it
|
6
|
+
# under the terms of the GNU Lesser General Public License as
|
7
|
+
# published by the Free Software Foundation; either version 3 of
|
8
|
+
# the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This software is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with this software; if not, write to the Free
|
17
|
+
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
18
|
+
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
19
|
+
|
20
|
+
require 'delivery/bbcloud-delivery-plugin'
|
21
|
+
require 'platform/bbcloud-platform-plugin'
|
22
|
+
require 'os/sl-plugin'
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# Brightbox - Boxgrinder Delivery Plugin for Brightbox Cloud
|
2
|
+
# Copyright (c) 2011, Brightbox Systems
|
3
|
+
# Author: Neil Wilson
|
4
|
+
#
|
5
|
+
# This is free software; you can redistribute it and/or modify it
|
6
|
+
# under the terms of the GNU Lesser General Public License as
|
7
|
+
# published by the Free Software Foundation; either version 3 of
|
8
|
+
# the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This software is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with this software; if not, write to the Free
|
17
|
+
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
18
|
+
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
19
|
+
|
20
|
+
require 'boxgrinder-build/plugins/base-plugin'
|
21
|
+
|
22
|
+
module BoxGrinder
|
23
|
+
class BbcloudDeliveryPlugin < BasePlugin
|
24
|
+
|
25
|
+
def execute( type = :bbcloud )
|
26
|
+
@log.info "Adding '#{@appliance_config.name}' appliance to Brightbox Cloud..."
|
27
|
+
@log.info "Using Brightbox account id #{account}"
|
28
|
+
upload
|
29
|
+
register_image
|
30
|
+
end
|
31
|
+
|
32
|
+
def upload
|
33
|
+
@log.info "Uploading to #{ftp_hash['library_ftp_host']} with secure FTP"
|
34
|
+
if system curl_command
|
35
|
+
@log.info "Appliance #{@appliance_config.name} uploaded."
|
36
|
+
else
|
37
|
+
raise "An error occurred while uploading files."
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def register_image
|
42
|
+
@log.info "Registering appliance as #{image_id} under account #{account} with the name '#{appliance_name}'"
|
43
|
+
@log.info "Run 'brightbox-images show #{image_id}' to check registration progress"
|
44
|
+
end
|
45
|
+
|
46
|
+
def image_id
|
47
|
+
@image_id ||=
|
48
|
+
if @exec_helper.execute(register_image_command) =~ /img-\w{5}/
|
49
|
+
Regexp.last_match[0]
|
50
|
+
else
|
51
|
+
raise "Failed to obtain an image id from the registration command"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def account
|
56
|
+
@account ||= @exec_helper.execute("brightbox-accounts -s list").split[0]
|
57
|
+
rescue RuntimeError => e
|
58
|
+
@log.error e.message
|
59
|
+
raise PluginValidationError, "Make sure the that brightbox cloud API tools are installed. Use 'brightbox-config client_add' to add the api client details for your account."
|
60
|
+
end
|
61
|
+
|
62
|
+
def disk_image
|
63
|
+
@previous_deliverables[:disk]
|
64
|
+
end
|
65
|
+
|
66
|
+
def ftp_hash
|
67
|
+
@ftp_hash ||= Hash[*(@exec_helper.execute("brightbox-accounts -s reset_ftp_password #{account} 2>/dev/null").split)]
|
68
|
+
end
|
69
|
+
|
70
|
+
def target_name
|
71
|
+
File.basename(disk_image)
|
72
|
+
end
|
73
|
+
|
74
|
+
def curl_command
|
75
|
+
"curl -# -u #{ftp_hash['library_ftp_user']}:#{ftp_hash['library_ftp_password']} --ftp-ssl-control -T #{disk_image} ftp://#{ftp_hash['library_ftp_host']}/incoming/#{target_name}"
|
76
|
+
end
|
77
|
+
|
78
|
+
def appliance_name
|
79
|
+
"#{@appliance_config.name}-#{@appliance_config.version}.#{@appliance_config.release}-#{@appliance_config.os.name}-#{@appliance_config.os.version}-#{current_platform}"
|
80
|
+
end
|
81
|
+
|
82
|
+
def register_image_command
|
83
|
+
"brightbox-images register -a #{@appliance_config.hardware.arch} -s #{target_name} -n '#{appliance_name}' -d '#{@appliance_config.summary}'"
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
plugin :class => BoxGrinder::BbcloudDeliveryPlugin, :type => :delivery, :name => :bbcloud, :full_name => "Brightbox Cloud Image Registration Service"
|
data/lib/os/sl-plugin.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# Brightbox - Boxgrinder Scientific Linux OS Plugin
|
2
|
+
# Copyright (c) 2011, Brightbox Systems
|
3
|
+
# Author: Neil Wilson
|
4
|
+
#
|
5
|
+
# This is free software; you can redistribute it and/or modify it
|
6
|
+
# under the terms of the GNU Lesser General Public License as
|
7
|
+
# published by the Free Software Foundation; either version 3 of
|
8
|
+
# the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This software is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with this software; if not, write to the Free
|
17
|
+
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
18
|
+
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
19
|
+
|
20
|
+
require 'boxgrinder-build/plugins/os/rhel/rhel-plugin'
|
21
|
+
|
22
|
+
module BoxGrinder
|
23
|
+
class ScientificLinuxPlugin < RHELPlugin
|
24
|
+
|
25
|
+
SL_REPOS = {
|
26
|
+
"5" => {
|
27
|
+
"base" => {
|
28
|
+
"baseurl" => "http://ftp.scientificlinux.org/linux/scientific/#OS_VERSION#x/#BASE_ARCH#/SL/"
|
29
|
+
},
|
30
|
+
"updates" => {
|
31
|
+
"baseurl" => "http://ftp.scientificlinux.org/linux/scientific/#OS_VERSION#x/#BASE_ARCH#/updates/security/"
|
32
|
+
}
|
33
|
+
},
|
34
|
+
"6" => {
|
35
|
+
"base" => {
|
36
|
+
"baseurl" => "http://ftp.scientificlinux.org/linux/scientific/#OS_VERSION#x/#BASE_ARCH#/os/"
|
37
|
+
},
|
38
|
+
"updates" => {
|
39
|
+
"baseurl" => "http://ftp.scientificlinux.org/linux/scientific/#OS_VERSION#x/#BASE_ARCH#/updates/security/"
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
|
45
|
+
def after_init
|
46
|
+
super
|
47
|
+
register_supported_os('sl', ['5', '6'])
|
48
|
+
end
|
49
|
+
|
50
|
+
def execute(appliance_definition_file)
|
51
|
+
build_rhel(appliance_definition_file, SL_REPOS)
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
plugin :class => BoxGrinder::ScientificLinuxPlugin, :type => :os, :name => :sl, :full_name => "Scientific Linux", :versions => ["5", "6"]
|
@@ -0,0 +1,116 @@
|
|
1
|
+
# Brightbox - Boxgrinder Platform Plugin for Brightbox Cloud
|
2
|
+
# Copyright (c) 2011, Brightbox Systems
|
3
|
+
# Author: Neil Wilson
|
4
|
+
#
|
5
|
+
# This is free software; you can redistribute it and/or modify it
|
6
|
+
# under the terms of the GNU Lesser General Public License as
|
7
|
+
# published by the Free Software Foundation; either version 3 of
|
8
|
+
# the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This software is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with this software; if not, write to the Free
|
17
|
+
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
18
|
+
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
19
|
+
|
20
|
+
require 'boxgrinder-build/plugins/base-plugin'
|
21
|
+
require 'boxgrinder-build/helpers/linux-helper'
|
22
|
+
require 'tempfile'
|
23
|
+
|
24
|
+
module BoxGrinder
|
25
|
+
class BbcloudPlatformPlugin < BasePlugin
|
26
|
+
def after_init
|
27
|
+
register_deliverable(:disk => "#{deliverable_name}.gz")
|
28
|
+
|
29
|
+
register_supported_os('fedora', ['13', '14', '15'])
|
30
|
+
register_supported_os('centos', ['5'])
|
31
|
+
register_supported_os('rhel', ['5', '6'])
|
32
|
+
register_supported_os('sl', ['5', '6'])
|
33
|
+
end
|
34
|
+
|
35
|
+
def deliverable_name
|
36
|
+
"#{@appliance_config.name}-#{@appliance_config.version}.#{@appliance_config.release}-#{@appliance_config.os.name}-#{@appliance_config.os.version}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def execute
|
40
|
+
@linux_helper = LinuxHelper.new(:log => @log)
|
41
|
+
|
42
|
+
@log.info "Converting #{@appliance_config.name} appliance image to use Brightbox metadata services"
|
43
|
+
|
44
|
+
@image_helper.convert_disk(@previous_deliverables.disk, 'raw', uncompressed_disk_name)
|
45
|
+
|
46
|
+
@image_helper.customize([uncompressed_disk_name], :automount => true) do |guestfs, guestfs_helper|
|
47
|
+
upload_rc_local(guestfs)
|
48
|
+
add_default_user(guestfs)
|
49
|
+
disable_root_password(guestfs)
|
50
|
+
change_configuration(guestfs_helper)
|
51
|
+
execute_post(guestfs_helper)
|
52
|
+
end
|
53
|
+
|
54
|
+
@log.info "Image converted to Brightbox format, compressing"
|
55
|
+
@exec_helper.execute("gzip --fast -v #{uncompressed_disk_name}")
|
56
|
+
@log.info "Disk compressed"
|
57
|
+
end
|
58
|
+
|
59
|
+
def uncompressed_disk_name
|
60
|
+
@uncompressed_name ||= File.join(File.dirname(@deliverables.disk), File.basename(@deliverables.disk, '.gz'))
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
def execute_post(guestfs_helper)
|
65
|
+
if @appliance_config.post['bbcloud']
|
66
|
+
@appliance_config.post['bbcloud'].each do |cmd|
|
67
|
+
guestfs_helper.sh(cmd, :arch => @appliance_config.hardware.arch)
|
68
|
+
end
|
69
|
+
@log.debug "Post commands from appliance definition file executed."
|
70
|
+
else
|
71
|
+
@log.debug "No commands specified, skipping."
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def default_user
|
76
|
+
"brightbox"
|
77
|
+
end
|
78
|
+
|
79
|
+
def add_default_user(guestfs)
|
80
|
+
@log.debug "Adding #{default_user} user..."
|
81
|
+
guestfs.sh("useradd #{default_user}")
|
82
|
+
guestfs.sh("echo -e '#{default_user}\tALL=(ALL)\tNOPASSWD: ALL' >> /etc/sudoers")
|
83
|
+
@log.debug "User #{default_user} added."
|
84
|
+
end
|
85
|
+
|
86
|
+
def disable_root_password(guestfs)
|
87
|
+
@log.debug "Disabling root password"
|
88
|
+
guestfs.sh("usermod -L root")
|
89
|
+
@log.debug "root password disabled - use sudo from #{default_user} account"
|
90
|
+
end
|
91
|
+
|
92
|
+
def upload_rc_local(guestfs)
|
93
|
+
@log.debug "Uploading '/etc/rc.local' file..."
|
94
|
+
rc_local = Tempfile.new('rc_local')
|
95
|
+
rc_local << guestfs.read_file("/etc/rc.local") + File.read("#{File.dirname(__FILE__)}/src/rc_local")
|
96
|
+
rc_local.flush
|
97
|
+
|
98
|
+
guestfs.upload(rc_local.path, "/etc/rc.local")
|
99
|
+
|
100
|
+
rc_local.close
|
101
|
+
@log.debug "'/etc/rc.local' file uploaded."
|
102
|
+
end
|
103
|
+
|
104
|
+
def change_configuration(guestfs_helper)
|
105
|
+
guestfs_helper.augeas do
|
106
|
+
# disable password authentication
|
107
|
+
set("/etc/ssh/sshd_config", "PasswordAuthentication", "no")
|
108
|
+
|
109
|
+
# disable root login
|
110
|
+
set("/etc/ssh/sshd_config", "PermitRootLogin", "no")
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
plugin :class => BoxGrinder::BbcloudPlatformPlugin, :type => :platform, :name => :bbcloud, :full_name => "Brightbox Cloud"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
curl http://169.254.169.254/2009-04-04/meta-data/public-keys/0/openssh-key 2>/dev/null >/tmp/my-key
|
2
|
+
|
3
|
+
if [ $? -eq 0 ] ; then
|
4
|
+
for home in `find /home/* -maxdepth 0 -type d 2>/dev/null | tr '\n' ' '`; do
|
5
|
+
user=`echo $home | awk -F '/' '{ print $3 }'`
|
6
|
+
|
7
|
+
if [ ! -d $home/.ssh ] ; then
|
8
|
+
mkdir -p $home/.ssh
|
9
|
+
chmod 700 $home/.ssh
|
10
|
+
chown $user $home/.ssh
|
11
|
+
fi
|
12
|
+
|
13
|
+
cat /tmp/my-key >> $home/.ssh/authorized_keys
|
14
|
+
chmod 600 $home/.ssh/authorized_keys
|
15
|
+
chown $user $home/.ssh/authorized_keys
|
16
|
+
|
17
|
+
done
|
18
|
+
rm /tmp/my-key
|
19
|
+
fi
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: brightbox-boxgrinder-plugins
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Neil Wilson
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-05-13 00:00:00 +01:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: bbcloud
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 55
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 11
|
33
|
+
- 2
|
34
|
+
version: 0.11.2
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
description: Brightbox Cloud support for Boxgrinder
|
38
|
+
email: hello@brightbox.co.uk
|
39
|
+
executables: []
|
40
|
+
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files:
|
44
|
+
- CHANGELOG
|
45
|
+
- LICENSE
|
46
|
+
- README.md
|
47
|
+
- lib/bbcloud-boxgrinder-plugins.rb
|
48
|
+
- lib/delivery/bbcloud-delivery-plugin.rb
|
49
|
+
- lib/os/sl-plugin.rb
|
50
|
+
- lib/platform/bbcloud-platform-plugin.rb
|
51
|
+
- lib/platform/src/rc_local
|
52
|
+
files:
|
53
|
+
- CHANGELOG
|
54
|
+
- LICENSE
|
55
|
+
- Manifest
|
56
|
+
- README.md
|
57
|
+
- Rakefile
|
58
|
+
- lib/bbcloud-boxgrinder-plugins.rb
|
59
|
+
- lib/delivery/bbcloud-delivery-plugin.rb
|
60
|
+
- lib/os/sl-plugin.rb
|
61
|
+
- lib/platform/bbcloud-platform-plugin.rb
|
62
|
+
- lib/platform/src/rc_local
|
63
|
+
- brightbox-boxgrinder-plugins.gemspec
|
64
|
+
has_rdoc: true
|
65
|
+
homepage: http://beta.brightbox.com
|
66
|
+
licenses: []
|
67
|
+
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options:
|
70
|
+
- --line-numbers
|
71
|
+
- --inline-source
|
72
|
+
- --title
|
73
|
+
- Brightbox-boxgrinder-plugins
|
74
|
+
- --main
|
75
|
+
- README.md
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
hash: 3
|
84
|
+
segments:
|
85
|
+
- 0
|
86
|
+
version: "0"
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
hash: 11
|
93
|
+
segments:
|
94
|
+
- 1
|
95
|
+
- 2
|
96
|
+
version: "1.2"
|
97
|
+
requirements: []
|
98
|
+
|
99
|
+
rubyforge_project: Brightbox Cloud
|
100
|
+
rubygems_version: 1.3.7
|
101
|
+
signing_key:
|
102
|
+
specification_version: 3
|
103
|
+
summary: Brightbox Cloud support for Boxgrinder
|
104
|
+
test_files: []
|
105
|
+
|