stemcell_builder 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +20 -0
- data/.rvmrc +1 -0
- data/.travis.yml +1 -0
- data/Gemfile +14 -0
- data/LICENSE.txt +22 -0
- data/README.md +123 -0
- data/Rakefile +10 -0
- data/assets/box.ovf.erb +81 -0
- data/assets/stemcell_mf_schema.yaml +30 -0
- data/bin/stemcell_builder +138 -0
- data/lib/stemcell.rb +3 -0
- data/lib/stemcell/builder.rb +445 -0
- data/lib/stemcell/builders/centos.rb +33 -0
- data/lib/stemcell/builders/redhat.rb +34 -0
- data/lib/stemcell/builders/ubuntu.rb +36 -0
- data/lib/stemcell/const.rb +12 -0
- data/lib/stemcell/version.rb +10 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/stemcell_builder/builder_spec.rb +186 -0
- data/spec/stemcell_builder/centos_spec.rb +39 -0
- data/spec/stemcell_builder/redhat_spec.rb +53 -0
- data/spec/stemcell_builder/ubuntu_spec.rb +38 -0
- data/stemcell_builder.gemspec +42 -0
- data/templates/centos/_60-bosh-sysctl.conf +5 -0
- data/templates/centos/_empty_state.yml +9 -0
- data/templates/centos/_monitrc +8 -0
- data/templates/centos/_ntpdate +10 -0
- data/templates/centos/_runonce +46 -0
- data/templates/centos/_sysstat +18 -0
- data/templates/centos/_variables.sh.erb +31 -0
- data/templates/centos/base.sh +23 -0
- data/templates/centos/bosh_agent.sh +39 -0
- data/templates/centos/cleanup.sh +28 -0
- data/templates/centos/definition.rb.erb +37 -0
- data/templates/centos/harden.sh +8 -0
- data/templates/centos/ks.cfg +43 -0
- data/templates/centos/micro.sh +57 -0
- data/templates/centos/monit.sh +21 -0
- data/templates/centos/postinstall.sh +27 -0
- data/templates/centos/ruby.sh +42 -0
- data/templates/centos/setup-bosh.sh +20 -0
- data/templates/centos/sudo.sh +13 -0
- data/templates/centos/timestamp.sh +15 -0
- data/templates/centos/vmware-tools.sh +17 -0
- data/templates/centos/zerodisk.sh +9 -0
- data/templates/noop/erbtest.txt.erb +1 -0
- data/templates/noop/test.txt +1 -0
- data/templates/redhat/_60-bosh-sysctl.conf +5 -0
- data/templates/redhat/_empty_state.yml +9 -0
- data/templates/redhat/_monitrc +8 -0
- data/templates/redhat/_ntpdate +10 -0
- data/templates/redhat/_runonce +46 -0
- data/templates/redhat/_sysstat +18 -0
- data/templates/redhat/_variables.sh.erb +31 -0
- data/templates/redhat/base.sh +41 -0
- data/templates/redhat/bosh_agent.sh +37 -0
- data/templates/redhat/cleanup.sh +30 -0
- data/templates/redhat/definition.rb.erb +38 -0
- data/templates/redhat/harden.sh +8 -0
- data/templates/redhat/ks.cfg +86 -0
- data/templates/redhat/micro.sh +57 -0
- data/templates/redhat/monit.sh +21 -0
- data/templates/redhat/postinstall.sh +27 -0
- data/templates/redhat/rhnreg.sh.erb +15 -0
- data/templates/redhat/ruby.sh +42 -0
- data/templates/redhat/setup-bosh.sh +20 -0
- data/templates/redhat/sudo.sh +13 -0
- data/templates/redhat/timestamp.sh +15 -0
- data/templates/redhat/vmware-tools.sh +17 -0
- data/templates/redhat/zerodisk.sh +9 -0
- data/templates/ubuntu/_60-bosh-sysctl.conf +5 -0
- data/templates/ubuntu/_empty_state.yml +9 -0
- data/templates/ubuntu/_helpers.sh +40 -0
- data/templates/ubuntu/_monitrc +8 -0
- data/templates/ubuntu/_ntpdate +10 -0
- data/templates/ubuntu/_runonce +46 -0
- data/templates/ubuntu/_sysstat +18 -0
- data/templates/ubuntu/_variables.sh.erb +30 -0
- data/templates/ubuntu/apt-upgrade.sh +19 -0
- data/templates/ubuntu/base-stemcell.sh +95 -0
- data/templates/ubuntu/bosh_agent.sh +39 -0
- data/templates/ubuntu/definition.rb.erb +63 -0
- data/templates/ubuntu/harden.sh +9 -0
- data/templates/ubuntu/micro.sh +57 -0
- data/templates/ubuntu/monit.sh +22 -0
- data/templates/ubuntu/network-cleanup.sh +17 -0
- data/templates/ubuntu/postinstall.sh +45 -0
- data/templates/ubuntu/preseed.cfg +87 -0
- data/templates/ubuntu/ruby.sh +54 -0
- data/templates/ubuntu/setup-bosh.sh +14 -0
- data/templates/ubuntu/sudo.sh +14 -0
- data/templates/ubuntu/timestamp.sh +13 -0
- data/templates/ubuntu/vmware-tools.sh +22 -0
- data/templates/ubuntu/zero-disk.sh +10 -0
- metadata +375 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.9.3
|
data/.travis.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
language: ruby
|
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#if RUBY_VERSION =~ /1.9/
|
2
|
+
#Encoding.default_external = Encoding::UTF_8
|
3
|
+
#Encoding.default_internal = Encoding::UTF_8
|
4
|
+
#end
|
5
|
+
|
6
|
+
source 'https://rubygems.org'
|
7
|
+
|
8
|
+
# development and test dependencies
|
9
|
+
group :test do
|
10
|
+
gem 'rake'
|
11
|
+
end
|
12
|
+
|
13
|
+
# Specify your gem's dependencies in builder.gemspec
|
14
|
+
gemspec
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Ankur Chauhan
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
# BOSH Stemcell Builder [![Build Status](https://travis-ci.org/ankurcha/stemcell.png?branch=master)](https://travis-ci.org/ankurcha/stemcell)
|
2
|
+
|
3
|
+
The stemcell builder is a commandline tool to create new [BOSH](https://www.github.com/cloudfoundry/bosh) stemcells.
|
4
|
+
|
5
|
+
You can get more infomation about BOSH at [https://www.github.com/cloudfoundry/bosh](https://www.github.com/cloudfoundry/bosh).
|
6
|
+
|
7
|
+
This product is under active development and definitely needs work.
|
8
|
+
Expect things to broken and feel free to open bugs/issues. I will get to them as soon as possible.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
### Install virtualbox
|
13
|
+
|
14
|
+
Follow instructions on: https://www.virtualbox.org/wiki/Downloads
|
15
|
+
|
16
|
+
### Install veewee
|
17
|
+
|
18
|
+
$ gem install veewee --no-ri --no-rdoc
|
19
|
+
|
20
|
+
### Install vagrant
|
21
|
+
|
22
|
+
$ gem install vagrant --no-ri --no-rdoc
|
23
|
+
|
24
|
+
### Install stemcell builder
|
25
|
+
|
26
|
+
$ gem install stemcell_builder
|
27
|
+
|
28
|
+
### Checkout BOSH source
|
29
|
+
|
30
|
+
If you want to build the BOSH agent from source.
|
31
|
+
|
32
|
+
Checkout bosh
|
33
|
+
|
34
|
+
$ git clone git://github.com/cloudfoundry/bosh.git ~/bosh
|
35
|
+
|
36
|
+
Build the agent atrifacts using the following commands
|
37
|
+
|
38
|
+
$ bundle install
|
39
|
+
$ bundle exec rake all:finalize_release_directory
|
40
|
+
|
41
|
+
## Usage
|
42
|
+
|
43
|
+
The following is a listing of commands
|
44
|
+
```
|
45
|
+
Tasks:
|
46
|
+
stemcell_builder build SUBCOMMAND ...ARGS # Build a new stemcell
|
47
|
+
stemcell_builder help [TASK] # Describe available tasks or one specific task
|
48
|
+
stemcell_builder info <file> # Display stemcell information, it looks for stemcell file name <file>
|
49
|
+
stemcell_builder validate <file> # Validate stemcell, it looks for stemcell file name <file>
|
50
|
+
```
|
51
|
+
The `stemcell build` command gives the following options
|
52
|
+
|
53
|
+
```
|
54
|
+
Tasks:
|
55
|
+
stemcell_builder build centos # Build a new centos stemcell
|
56
|
+
stemcell_builder build help [COMMAND] # Describe subcommands or one specific subco...
|
57
|
+
stemcell_builder build redhat # Build a new redhat stemcell
|
58
|
+
stemcell_builder build ubuntu # Build a new ubuntu stemcell
|
59
|
+
|
60
|
+
Options:
|
61
|
+
[--name=<name>] # Name of the stemcell
|
62
|
+
[--prefix=<prefix>] # Directory to use as staging area for all the stemcell work
|
63
|
+
[--architecture=<architecture>] # Architecture of the OS
|
64
|
+
[--infrastructure=<infrastructure>] # Infrastructure hosting the vm
|
65
|
+
[--target=<target>] # Path for the final stemcell
|
66
|
+
[--agent-src-path=<agent_src_path>] # Bosh Agent Source path, this may be the gem or directory path of Bosh agent source
|
67
|
+
[--agent-version=<agent_version>] # Bosh Agent version being installed
|
68
|
+
[--agent-protocol=<agent_protocol_version>] # Bosh Agent Protocol Version being installed
|
69
|
+
[--iso=<iso file path>] # Path to the iso file to use
|
70
|
+
[--iso-md5=<MD5 of iso file>] # <MD5 hash>
|
71
|
+
[--gui=Run virtualbox in headed mode] # Run virtualbox headless
|
72
|
+
[--definitions-dir=<path to definitions>] # Absolute path to the definitions directory to use instead of the built in ones
|
73
|
+
[--log-level=DEBUG|INFO|WARN|ERROR|FATAL] # Level of verbosity for the logs, should match ruby logger levels: DEBUG < INFO < WARN < ERROR < FATAL
|
74
|
+
[--micro=convert to micro bosh] # Convert Stemcell into a micro Stemcell
|
75
|
+
[--release-manifest=<agent_src_path>] # Micro Bosh release manifest, generally <bosh_src_root>/release/micro/<infrastructure>.yml
|
76
|
+
[--release-tar=<precompiled_release_tar>] # Precompiled micro Bosh release tar archive
|
77
|
+
[--package-compiler=<package_compiler>] # Path to Bosh package compiler gems, generally <bosh_src_root>/release/src/bosh/package_compiler/
|
78
|
+
[--ssh-port=<ssh_host_port>] # Port to use for the ssh tunnel to the vm, if nothing is specified a random open port will be selected
|
79
|
+
```
|
80
|
+
|
81
|
+
In case of a redhat installation, the following additional options should also be provided
|
82
|
+
```
|
83
|
+
[--rhn-user=<rhn username>] # Redhat Network Username
|
84
|
+
[--rhn-pass=<rhn password>] # Redhat Network Password
|
85
|
+
```
|
86
|
+
|
87
|
+
## Examples
|
88
|
+
|
89
|
+
To create a Ubuntu stemcell
|
90
|
+
|
91
|
+
stemcell_builder build ubuntu --agent-src-path=~/bosh/release/src/bosh/bosh_agent/ --name=bosh-ubuntu-stemcell
|
92
|
+
|
93
|
+
To create a Centos stemcell
|
94
|
+
|
95
|
+
stemcell_builder build centos --agent-src-path=~/bosh/release/src/bosh/bosh_agent/ --name=bosh-centos-stemcell
|
96
|
+
|
97
|
+
To create a Redhat stemcell
|
98
|
+
|
99
|
+
stemcell_builder build redhat --agent-src-path=~/bosh/release/src/bosh/bosh_agent/ --name=bosh-rhel-stemcell --rhn-user=<RHN username> --rhn-password=<RHN password>
|
100
|
+
|
101
|
+
To create a Ubuntu MicroBOSH stemcell
|
102
|
+
|
103
|
+
stemcell_builder build ubuntu --micro --agent-src-path=~/bosh/release/src/bosh/bosh_agent/ --release-tar=~/bosh/release/dev_releases/micro-bosh-0.1-dev.tgz --release-manifest=~/bosh/release/micro/vsphere.yml --package-compiler=~/bosh/release/src/bosh/package_compiler/ --name=micro-bosh-stemcell
|
104
|
+
|
105
|
+
To create a Centos MicroBOSH stemcell
|
106
|
+
|
107
|
+
stemcell_builder build centos --micro --agent-src-path=~/bosh/release/src/bosh/bosh_agent/ --release-tar=~/bosh/release/dev_releases/micro-bosh-0.1-dev.tgz --release-manifest=~/bosh/release/micro/vsphere.yml --package-compiler=~/bosh/release/src/bosh/package_compiler/ --name=micro-bosh-stemcell
|
108
|
+
|
109
|
+
## TODO
|
110
|
+
This tool supports only a small subset of operations. Currently, the tool is targeted
|
111
|
+
to be able to create vsphere templates for ubuntu and centOS 6.x. The following is a list of things
|
112
|
+
that need to be done before we can call it ready for primetime (in order of priority).
|
113
|
+
* Add Micro cloudfoundry build support
|
114
|
+
* Support AWS
|
115
|
+
* Support Openstack
|
116
|
+
|
117
|
+
## Contributing
|
118
|
+
|
119
|
+
1. Fork it
|
120
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
121
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
122
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
123
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/assets/box.ovf.erb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<Envelope ovf:version="1.0" xml:lang="en-US" xmlns="http://schemas.dmtf.org/ovf/envelope/1" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:vmw="http://www.vmware.com/schema/ovf">
|
3
|
+
<References>
|
4
|
+
<File ovf:href="<%= @vmdk_filename %>" ovf:id="file1"/>
|
5
|
+
</References>
|
6
|
+
<DiskSection>
|
7
|
+
<Info>List of the virtual disks used in the package</Info>
|
8
|
+
<Disk ovf:capacity="10632560640" ovf:diskId="vmdisk1" ovf:fileRef="file1" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized"/>
|
9
|
+
</DiskSection>
|
10
|
+
<VirtualSystem ovf:id="<%= @vm_name %>">
|
11
|
+
<Info>A virtual machine</Info>
|
12
|
+
<OperatingSystemSection ovf:id="94" vmw:osType="otherLinux64Guest">
|
13
|
+
<Info>The kind of installed guest operating system</Info>
|
14
|
+
</OperatingSystemSection>
|
15
|
+
<VirtualHardwareSection>
|
16
|
+
<Info>Virtual hardware requirements for a virtual machine</Info>
|
17
|
+
<System>
|
18
|
+
<vssd:ElementName>Virtual Hardware Family</vssd:ElementName>
|
19
|
+
<vssd:InstanceID>0</vssd:InstanceID>
|
20
|
+
<vssd:VirtualSystemIdentifier><%= @vm_name %></vssd:VirtualSystemIdentifier>
|
21
|
+
<vssd:VirtualSystemType>vmx-07</vssd:VirtualSystemType>
|
22
|
+
</System>
|
23
|
+
<Item>
|
24
|
+
<rasd:Caption>1 virtual CPU</rasd:Caption>
|
25
|
+
<rasd:Description>Number of virtual CPUs</rasd:Description>
|
26
|
+
<rasd:ElementName>1 virtual CPU</rasd:ElementName>
|
27
|
+
<rasd:InstanceID>1</rasd:InstanceID>
|
28
|
+
<rasd:ResourceType>3</rasd:ResourceType>
|
29
|
+
<rasd:VirtualQuantity>1</rasd:VirtualQuantity>
|
30
|
+
</Item>
|
31
|
+
<Item>
|
32
|
+
<rasd:AllocationUnits>MegaBytes</rasd:AllocationUnits>
|
33
|
+
<rasd:Caption>512 MB of memory</rasd:Caption>
|
34
|
+
<rasd:Description>Memory Size</rasd:Description>
|
35
|
+
<rasd:ElementName>512 MB of memory</rasd:ElementName>
|
36
|
+
<rasd:InstanceID>2</rasd:InstanceID>
|
37
|
+
<rasd:ResourceType>4</rasd:ResourceType>
|
38
|
+
<rasd:VirtualQuantity>512</rasd:VirtualQuantity>
|
39
|
+
</Item>
|
40
|
+
<Item>
|
41
|
+
<rasd:Address>0</rasd:Address>
|
42
|
+
<rasd:Description>SCSI Controller</rasd:Description>
|
43
|
+
<rasd:ElementName>scsiController0</rasd:ElementName>
|
44
|
+
<rasd:InstanceID>3</rasd:InstanceID>
|
45
|
+
<rasd:ResourceSubType>lsilogic</rasd:ResourceSubType>
|
46
|
+
<rasd:ResourceType>6</rasd:ResourceType>
|
47
|
+
</Item>
|
48
|
+
<Item>
|
49
|
+
<rasd:Address>0</rasd:Address>
|
50
|
+
<rasd:Description>IDE Controller</rasd:Description>
|
51
|
+
<rasd:ElementName>ideController0</rasd:ElementName>
|
52
|
+
<rasd:InstanceID>4</rasd:InstanceID>
|
53
|
+
<rasd:ResourceType>5</rasd:ResourceType>
|
54
|
+
</Item>
|
55
|
+
<Item ovf:required="false">
|
56
|
+
<rasd:AddressOnParent>0</rasd:AddressOnParent>
|
57
|
+
<rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
|
58
|
+
<rasd:Description>Floppy Drive</rasd:Description>
|
59
|
+
<rasd:ElementName>floppy0</rasd:ElementName>
|
60
|
+
<rasd:InstanceID>5</rasd:InstanceID>
|
61
|
+
<rasd:ResourceType>14</rasd:ResourceType>
|
62
|
+
</Item>
|
63
|
+
<Item ovf:required="false">
|
64
|
+
<rasd:AddressOnParent>0</rasd:AddressOnParent>
|
65
|
+
<rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
|
66
|
+
<rasd:ElementName>cdrom1</rasd:ElementName>
|
67
|
+
<rasd:InstanceID>6</rasd:InstanceID>
|
68
|
+
<rasd:Parent>4</rasd:Parent>
|
69
|
+
<rasd:ResourceType>15</rasd:ResourceType>
|
70
|
+
</Item>
|
71
|
+
<Item>
|
72
|
+
<rasd:AddressOnParent>0</rasd:AddressOnParent>
|
73
|
+
<rasd:ElementName>disk1</rasd:ElementName>
|
74
|
+
<rasd:HostResource>ovf:/disk/vmdisk1</rasd:HostResource>
|
75
|
+
<rasd:InstanceID>7</rasd:InstanceID>
|
76
|
+
<rasd:Parent>3</rasd:Parent>
|
77
|
+
<rasd:ResourceType>17</rasd:ResourceType>
|
78
|
+
</Item>
|
79
|
+
</VirtualHardwareSection>
|
80
|
+
</VirtualSystem>
|
81
|
+
</Envelope>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
type: map
|
2
|
+
mapping:
|
3
|
+
"name":
|
4
|
+
type: str
|
5
|
+
required: yes
|
6
|
+
"version":
|
7
|
+
type: str
|
8
|
+
required: yes
|
9
|
+
"bosh_protocol":
|
10
|
+
type: int
|
11
|
+
required: yes
|
12
|
+
"sha1":
|
13
|
+
type: str
|
14
|
+
required: no
|
15
|
+
"cloud_properties":
|
16
|
+
type: map
|
17
|
+
required: yes
|
18
|
+
mapping:
|
19
|
+
"root_device_name":
|
20
|
+
type: str
|
21
|
+
required: no
|
22
|
+
default: "/dev/sda1"
|
23
|
+
"architecture":
|
24
|
+
type: str
|
25
|
+
enum: [x86_64, i386]
|
26
|
+
required: no
|
27
|
+
"infrastructure":
|
28
|
+
type: str
|
29
|
+
enum: [vsphere, aws, openstack]
|
30
|
+
required: no
|
@@ -0,0 +1,138 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$:.unshift File.join(__FILE__, "..", "..", "lib")
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'thor'
|
6
|
+
require 'kwalify'
|
7
|
+
require 'stemcell'
|
8
|
+
require 'digest'
|
9
|
+
|
10
|
+
module StemCellBuilderCLI
|
11
|
+
|
12
|
+
class Build < Thor
|
13
|
+
class_option :name, :banner => "<name>",
|
14
|
+
:desc => "Name of the stemcell"
|
15
|
+
class_option :prefix, :banner => "<prefix>",
|
16
|
+
:desc => "Directory to use as staging area for all the stemcell work"
|
17
|
+
class_option :architecture, :banner => "<architecture>",
|
18
|
+
:desc => "Architecture of the OS"
|
19
|
+
class_option :infrastructure, :banner => "<infrastructure>",
|
20
|
+
:desc => "Infrastructure hosting the vm"
|
21
|
+
class_option :target, :banner => "<target>",
|
22
|
+
:desc => "Path for the final stemcell"
|
23
|
+
class_option :agent_src_path, :banner => "<agent_src_path>",
|
24
|
+
:desc => "Bosh Agent Source path, this may be the gem or directory path of Bosh agent source"
|
25
|
+
class_option :agent_version, :banner => "<agent_version>",
|
26
|
+
:desc => "Bosh Agent version being installed"
|
27
|
+
class_option :agent_protocol, :banner => "<agent_protocol_version>",
|
28
|
+
:desc => "Bosh Agent Protocol Version being installed"
|
29
|
+
class_option :iso, :banner => "<iso file path>",
|
30
|
+
:desc => "Path to the iso file to use"
|
31
|
+
class_option :iso_md5, :banner => "<MD5 of iso file>",
|
32
|
+
:desc => "<MD5 hash>"
|
33
|
+
class_option :gui, :banner => "Run virtualbox in headed mode", :type => :boolean,
|
34
|
+
:desc => "Run virtualbox headless"
|
35
|
+
class_option :definitions_dir, :banner => "<path to definitions>",
|
36
|
+
:desc => "Absolute path to the definitions directory to use instead of the built in ones"
|
37
|
+
class_option :log_level, :banner => "DEBUG|INFO|WARN|ERROR|FATAL",
|
38
|
+
:desc => "Level of verbosity for the logs, should match ruby logger levels: DEBUG < INFO < WARN < ERROR < FATAL"
|
39
|
+
class_option :micro, :banner => "convert to micro bosh", :type => :boolean,
|
40
|
+
:desc => "Convert Stemcell into a micro Stemcell"
|
41
|
+
class_option :release_manifest, :banner => "<agent_src_path>",
|
42
|
+
:desc => "Micro Bosh release manifest, generally <bosh_src_root>/release/micro/<infrastructure>.yml"
|
43
|
+
class_option :release_tar, :banner => "<precompiled_release_tar>",
|
44
|
+
:desc => "Precompiled micro Bosh release tar archive"
|
45
|
+
class_option :package_compiler, :banner => "<package_compiler>",
|
46
|
+
:desc => "Path to Bosh package compiler gems, generally <bosh_src_root>/release/src/bosh/package_compiler/"
|
47
|
+
class_option :ssh_port, :banner => "<ssh_host_port>",
|
48
|
+
:desc => "Port to use for the ssh tunnel to the vm, if nothing is specified a random open port will be selected"
|
49
|
+
|
50
|
+
desc "ubuntu", "Build a new ubuntu stemcell"
|
51
|
+
def ubuntu
|
52
|
+
Bosh::Agent::StemCell::UbuntuBuilder.new(options.dup).run
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "redhat", "Build a new redhat stemcell"
|
56
|
+
method_option :rhn_user, :type => :string,
|
57
|
+
:banner => "<rhn username>",
|
58
|
+
:desc => "Redhat Network Username"
|
59
|
+
method_option :rhn_pass, :type => :string,
|
60
|
+
:banner => "<rhn password>",
|
61
|
+
:desc => "Redhat Network Password"
|
62
|
+
def redhat
|
63
|
+
Bosh::Agent::StemCell::RedhatBuilder.new(options.dup).run
|
64
|
+
end
|
65
|
+
|
66
|
+
desc "centos", "Build a new centos stemcell"
|
67
|
+
def centos
|
68
|
+
Bosh::Agent::StemCell::CentosBuilder.new(options.dup).run
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
class StemCellBuilder < Thor
|
74
|
+
|
75
|
+
desc "build SUBCOMMAND ...ARGS", "Build a new stemcell"
|
76
|
+
subcommand "build", Build
|
77
|
+
|
78
|
+
desc "info <file>", "Display stemcell information, it looks for stemcell file name <file>"
|
79
|
+
def info(file)
|
80
|
+
raise "File #{file} does not exist." unless File.exists? file
|
81
|
+
|
82
|
+
Kernel.system "tar -tvf #{file}"
|
83
|
+
|
84
|
+
dir = Dir.mktmpdir
|
85
|
+
Dir.chdir(dir) do
|
86
|
+
if Kernel.system("tar -xzf #{file} stemcell.MF")
|
87
|
+
puts File.open("stemcell.MF").read()
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
desc "validate <file>", "Validate stemcell, it looks for stemcell file name <file>"
|
93
|
+
def validate(file)
|
94
|
+
raise "File #{file} does not exist." unless File.exists? file
|
95
|
+
file = File.expand_path file
|
96
|
+
is_ok = true
|
97
|
+
dir = Dir.mktmpdir
|
98
|
+
Dir.chdir(dir) do
|
99
|
+
puts "Validating #{File.basename(file)} ... "
|
100
|
+
if Kernel.system("tar -xzf #{file}")
|
101
|
+
schema = YAML.load_file(File.join(File.dirname(__FILE__), "..", "assets", "stemcell_mf_schema.yaml"))
|
102
|
+
validator = Kwalify::Validator.new(schema)
|
103
|
+
stemcell_mf = YAML.load_file("stemcell.MF")
|
104
|
+
error_list = validator.validate(stemcell_mf)
|
105
|
+
if error_list.empty?
|
106
|
+
puts "stemcell.MF schema \t[OK]"
|
107
|
+
else
|
108
|
+
puts "stemcell.MF schema \t[FAIL]"
|
109
|
+
error_list.each do |error| # error is instance of Kwalify::ValidationError
|
110
|
+
puts "Error: [#{error.path}] #{error.message}"
|
111
|
+
end
|
112
|
+
is_ok = false
|
113
|
+
end
|
114
|
+
if stemcell_mf && stemcell_mf["sha1"]
|
115
|
+
image_sha1 = Digest::SHA1.file("image").hexdigest
|
116
|
+
if image_sha1 == stemcell_mf["sha1"]
|
117
|
+
puts "Image SHA \t[OK]"
|
118
|
+
else
|
119
|
+
puts "Image SHA \t[FAIL]"
|
120
|
+
puts "Error: SHA1 of the image does not match the one given in stemcell.MF - Expected: #{stemcell_mf["sha1"]} Actual: #{image_sha1}"
|
121
|
+
is_ok = false
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
if is_ok
|
127
|
+
puts "Stemcell: #{file} \t[OK]"
|
128
|
+
else
|
129
|
+
puts "Stemcell: #{file} \t[FAIL]"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
# Start StemcellBuilder
|
138
|
+
StemCellBuilderCLI::StemCellBuilder.start(ARGV)
|