Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dougal Ballantyne
committed
Jun 9, 2014
1 parent
42ac99f
commit 31b2d90
Showing
64 changed files
with
6,121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
*.pyc | ||
*.pyo | ||
*.class | ||
*~ | ||
*# | ||
dist/ | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
Amazon Software License | ||
|
||
This Amazon Software License (“License”) governs your use, reproduction, and distribution of the accompanying software | ||
as specified below. | ||
|
||
1. Definitions | ||
|
||
“Licensor” means any person or entity that distributes its Work. | ||
|
||
“Software” means the original work of authorship made available under this License. | ||
|
||
“Work” means the Software and any additions to or derivative works of the Software that are made available under | ||
this License. | ||
|
||
The terms “reproduce,” “reproduction,” “derivative works,” and “distribution” have the meaning as provided under | ||
U.S. copyright law; provided, however, that for the purposes of this License, derivative works shall not include | ||
works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work. | ||
|
||
Works, including the Software, are “made available” under this License by including in or with the Work either | ||
(a) a copyright notice referencing the applicability of this License to the Work, or (b) a copy of this License. | ||
|
||
2. License Grants | ||
|
||
2.1 Copyright Grant. Subject to the terms and conditions of this License, each Licensor grants to you a perpetual, | ||
worldwide, non-exclusive, royalty-free, copyright license to reproduce, prepare derivative works of, publicly | ||
display, publicly perform, sublicense and distribute its Work and any resulting derivative works in any form. | ||
|
||
2.2 Patent Grant. Subject to the terms and conditions of this License, each Licensor grants to you a perpetual, | ||
worldwide, non-exclusive, royalty-free patent license to make, have made, use, sell, offer for sale, import, and | ||
otherwise transfer its Work, in whole or in part. The foregoing license applies only to the patent claims licensable | ||
by Licensor that would be infringed by Licensor’s Work (or portion thereof) individually and excluding any | ||
combinations with any other materials or technology. | ||
|
||
3. Limitations | ||
|
||
3.1 Redistribution. You may reproduce or distribute the Work only if (a) you do so under this License, (b) you | ||
include a complete copy of this License with your distribution, and (c) you retain without modification any | ||
copyright, patent, trademark, or attribution notices that are present in the Work. | ||
|
||
3.2 Derivative Works. You may specify that additional or different terms apply to the use, reproduction, and | ||
distribution of your derivative works of the Work (“Your Terms”) only if (a) Your Terms provide that the use | ||
limitation in Section 3.3 applies to your derivative works, and (b) you identify the specific derivative works that | ||
are subject to Your Terms. Notwithstanding Your Terms, this License (including the redistribution requirements in | ||
Section 3.1) will continue to apply to the Work itself. | ||
|
||
3.3 Use Limitation. The Work and any derivative works thereof only may be used or intended for use with the web | ||
services, computing platforms or applications provided by Amazon.com, Inc. or its affiliates, including Amazon Web | ||
Services, Inc. | ||
|
||
3.4 Patent Claims. If you bring or threaten to bring a patent claim against any Licensor (including any claim, | ||
cross-claim or counterclaim in a lawsuit) to enforce any patents that you allege are infringed by any Work, then | ||
your rights under this License from such Licensor (including the grants in Sections 2.1 and 2.2) will terminate | ||
immediately. | ||
|
||
3.5 Trademarks. This License does not grant any rights to use any Licensor’s or its affiliates’ names, logos, or | ||
trademarks, except as necessary to reproduce the notices described in this License. | ||
|
||
3.6 Termination. If you violate any term of this License, then your rights under this License (including the grants | ||
in Sections 2.1 and 2.2) will terminate immediately. | ||
|
||
4. Disclaimer of Warranty. | ||
|
||
THE WORK IS PROVIDED “AS IS” WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING | ||
WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE OR NON-INFRINGEMENT. YOU BEAR | ||
THE RISK OF UNDERTAKING ANY ACTIVITIES UNDER THIS LICENSE. SOME STATES’ CONSUMER LAWS DO NOT ALLOW EXCLUSION OF AN | ||
IMPLIED WARRANTY, SO THIS DISCLAIMER MAY NOT APPLY TO YOU. | ||
|
||
5. Limitation of Liability. | ||
|
||
EXCEPT AS PROHIBITED BY APPLICABLE LAW, IN NO EVENT AND UNDER NO LEGAL THEORY, WHETHER IN TORT (INCLUDING | ||
NEGLIGENCE), CONTRACT, OR OTHERWISE SHALL ANY LICENSOR BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY DIRECT, INDIRECT, | ||
SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATED TO THIS LICENSE, THE USE OR INABILITY TO USE | ||
THE WORK (INCLUDING BUT NOT LIMITED TO LOSS OF GOODWILL, BUSINESS INTERRUPTION, LOST PROFITS OR DATA, COMPUTER | ||
FAILURE OR MALFUNCTION, OR ANY OTHER COMMERCIAL DAMAGES OR LOSSES), EVEN IF THE LICENSOR HAS BEEN ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGES. | ||
|
||
Effective Date – April 18, 2008 © 2008 Amazon.com, Inc. or its affiliates. All rights reserved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
cfncluster | ||
Copyright 2013-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
us-west-2 ami-ed7503dd | ||
us-east-1 ami-5cdd3f34 | ||
eu-west-1 ami-df9657a8 | ||
ap-northeast-1 ami-1b57111a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
SHELL = /bin/sh | ||
PREFIX ?= /opt/cfncluster | ||
|
||
install: | ||
install -d -m 755 $(DESTDIR) | ||
install -d -m 755 $(DESTDIR)/scripts | ||
install -d -m 755 $(DESTDIR)/templates | ||
cp -r src/scripts/* $(DESTDIR)/scripts | ||
cp -r src/templates/* $(DESTDIR)/templates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
This as the bootstrap scripts deployed in an AMI that is launched by the | ||
CfnCluster CloudFormation template. They are called by cfn-init. They are | ||
typically installed in /opt/cfncluster | ||
|
||
Install | ||
------- | ||
|
||
As root: | ||
|
||
# tar xf CfnClusterBootstrap.tar.gz | ||
# make install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2013-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Amazon Software License (the "License"). You may not use this file except in compliance with the | ||
# License. A copy of the License is located at | ||
# | ||
# http://aws.amazon.com/asl/ | ||
# | ||
# or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES | ||
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -x | ||
|
||
. /opt/cfncluster/cfnconfig | ||
|
||
function error_exit () { | ||
script=`basename $0` | ||
echo "cfncluster: $script - $1" | ||
logger -t cfncluster "$script - $1" | ||
exit 1 | ||
} | ||
|
||
# Run preinstall script if defined | ||
RC=0 | ||
if [ "${cfn_preinstall}" != "NONE" ]; then | ||
wget -qO- ${cfn_preinstall} | /bin/sh || RC=1 | ||
fi | ||
if [ $RC -ne 0 ]; then | ||
error_exit "Failed to run boot_as_compute preinstall" | ||
fi | ||
|
||
# Run boot as compute for a specific scheduler | ||
RC=0 | ||
/opt/cfncluster/scripts/${cfn_scheduler}/boot_as_compute >/var/log/cfncluster.log 2>&1 || RC=1 | ||
if [ $RC -ne 0 ]; then | ||
error_exit "Failed to run boot_as_compute for ${cfn_scheduler}" | ||
fi | ||
|
||
# Run postinstall script if defined | ||
RC=0 | ||
if [ "${cfn_postinstall}" != "NONE" ]; then | ||
wget -qO- ${cfn_postinstall} | /bin/sh || RC=1 | ||
fi | ||
if [ $RC -ne 0 ]; then | ||
error_exit "Failed to run boot_as_compute postinstall" | ||
fi | ||
|
||
# Notify compute is ready | ||
instance_id_url="http://169.254.169.254/latest/meta-data/instance-id" | ||
instance_id=$(curl --retry 3 --retry-delay 0 --silent --fail ${instance_id_url}) | ||
aws --region ${cfn_region} sqs send-message --queue-url ${cfn_sqs_url} --message-body '{"Type" : "Notification", "Message" : "{\"StatusCode\":\"Complete\",\"Description\":\"Succesfully launched '${instance_id}'\",\"Event\":\"cfncluster:COMPUTE_READY\",\"EC2InstanceId\":\"'${instance_id}'\"}"}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2013-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Amazon Software License (the "License"). You may not use this file except in compliance with the | ||
# License. A copy of the License is located at | ||
# | ||
# http://aws.amazon.com/asl/ | ||
# | ||
# or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES | ||
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -x | ||
|
||
. /opt/cfncluster/cfnconfig | ||
|
||
function error_exit () { | ||
script=`basename $0` | ||
echo "cfncluster: $script - $1" | ||
logger -t cfncluster "$script - $1" | ||
exit 1 | ||
} | ||
|
||
# Run preinstall script if defined | ||
RC=0 | ||
if [ "${cfn_preinstall}" != "NONE" ]; then | ||
wget -qO- ${cfn_preinstall} | /bin/sh || RC=1 | ||
fi | ||
if [ $RC -ne 0 ]; then | ||
error_exit "Failed to run boot_as_master preinstall" | ||
fi | ||
|
||
# Run boot as master for a specific scheduler | ||
RC=0 | ||
/opt/cfncluster/scripts/${cfn_scheduler}/boot_as_master >/var/log/cfncluster.log 2>&1 || RC=1 | ||
if [ $RC -ne 0 ]; then | ||
error_exit "Failed to run boot_as_master for ${cfn_scheduler}" | ||
fi | ||
|
||
# Start sqswatcher | ||
cd /opt/cfncluster/sqswatcher && ./sqswatcher.py 2>&1 | ||
|
||
# Run postinstall script if defined | ||
RC=0 | ||
if [ "${cfn_postinstall}" != "NONE" ]; then | ||
wget -qO- ${cfn_postinstall} | /bin/sh || RC=1 | ||
fi | ||
if [ $RC -ne 0 ]; then | ||
error_exit "Failed to run boot_as_master postinstall" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2013-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Amazon Software License (the "License"). You may not use this file except in compliance with the | ||
# License. A copy of the License is located at | ||
# | ||
# http://aws.amazon.com/asl/ | ||
# | ||
# or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES | ||
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -x | ||
|
||
. /opt/cfncluster/cfnconfig | ||
|
||
function error_exit () { | ||
script=`basename $0` | ||
echo "cfncluster: $script - $1" | ||
logger -t cfncluster "$script - $1" | ||
exit 1 | ||
} | ||
|
||
if [ "x$cfn_master" == "x" ]; then | ||
error_exit 'No master server specified.' | ||
usage | ||
fi | ||
|
||
myhostname=$(hostname -s) | ||
if [ $? != 0 ]; then | ||
error_exit 'Failed to determine short hostname.' | ||
fi | ||
|
||
# Determine instance type | ||
instance_type=`curl --retry 3 --retry-delay 0 --silent --fail http://169.254.169.254/latest/meta-data/instance-type` | ||
instance_type=$(echo $instance_type| tr '.' '_') | ||
|
||
# Setup resources | ||
resources="cs $instance_type $cfn_resources" | ||
|
||
# Mount NFS exports | ||
function mount_nfs () { | ||
RC=0 | ||
echo "$cfn_master:/home /home nfs hard,intr,noatime,vers=3,_netdev 0 0" >> /etc/fstab || RC=1 | ||
echo "$cfn_master:/shared /shared nfs hard,intr,noatime,vers=3,_netdev 0 0" >> /etc/fstab || RC=1 | ||
mount -v /home || RC=1 | ||
mount -v /shared || RC=1 | ||
if [ $RC -ne 0 ]; then | ||
error_exit "Failed during during NFS mounts" | ||
fi | ||
} | ||
|
||
# Configure ganglia | ||
function configure_ganglia () { | ||
RC=0 | ||
location=`curl --retry 3 --retry-delay 0 --silent --fail http://169.254.169.254/latest/meta-data/placement/availability-zone` || RC=1 | ||
cd /etc/ganglia || RC=1 | ||
/bin/cp -f /opt/cfncluster/templates/os/gmond.conf.COMPUTE gmond.conf || RC=1 | ||
sed -i "s/<master>/$cfn_master/" gmond.conf || RC=1 | ||
sed -i "s/<location>/$location/" gmond.conf || RC=1 | ||
sed -i "s/<stack_name>/$stack_name/" gmond.conf || RC=1 | ||
chkconfig gmond on || RC=1 | ||
service gmond start || RC=1 | ||
if [ $RC -ne 0 ]; then | ||
error_exit "Failed during Ganglia setup" | ||
fi | ||
} | ||
|
||
# Configure openlava | ||
function configure_openlava () { | ||
RC=0 | ||
cd /opt/openlava-2.2/etc || RC=1 | ||
/bin/cp -f /opt/cfncluster/templates/openlava/lsf.conf.COMPUTE lsf.conf || RC=1 | ||
/bin/cp -f /opt/cfncluster/templates/openlava/lsf.cluster.openlava.COMPUTE lsf.cluster.openlava || RC=1 | ||
sed -i "s/<master>/$cfn_master/" lsf.conf || RC=1 | ||
sed -i "s/<master>/$cfn_master/" lsf.cluster.openlava || RC=1 | ||
sed -i "s/<compute>/$myhostname/" lsf.cluster.openlava || RC=1 | ||
ln -s /opt/openlava-2.2/etc/openlava.sh /etc/profile.d/openlava.sh || RC=1 | ||
ln -s /opt/openlava-2.2/etc/openlava.csh /etc/profile.d/openlava.csh || RC=1 | ||
if [ $RC -ne 0 ]; then | ||
error_exit "Failed during Openlava configuration" | ||
fi | ||
} | ||
|
||
# Start openlava | ||
function start_openlava () { | ||
RC=0 | ||
chkconfig openlava on || RC=1 | ||
service openlava start || RC=1 | ||
if [ $RC -ne 0 ]; then | ||
error_exit "Failed to start openlava" | ||
fi | ||
} | ||
|
||
# Adding nodewatcher to crontab | ||
function add_nodewatcher () { | ||
RC=0 | ||
crontab -l > /tmp/root.crontab | ||
echo "* * * * * cd /opt/cfncluster/nodewatcher && ./nodewatcher.py >> nodewatcher.log 2>&1" >> /tmp/root.crontab || RC=1 | ||
crontab /tmp/root.crontab || RC=1 | ||
if [ $RC -ne 0 ]; then | ||
error_exit "Failed to nodewatcher crontab" | ||
fi | ||
} | ||
|
||
function minimal_install () { | ||
mount_nfs | ||
configure_ganglia | ||
configure_openlava | ||
start_openlava | ||
add_nodewatcher | ||
} | ||
|
||
## Main script | ||
case $cfn_install_type in | ||
minimal) | ||
minimal_install | ||
;; | ||
|
||
*) | ||
error_exit "Unkown install type: $cfn_install_type" | ||
|
||
esac | ||
|
||
|
||
script=`basename $0` | ||
echo "cfncluster: $script - SUCCESS - Booted as cfncluster Compute connected to Master - $cfn_master" | ||
logger -t cfncluster "$script - SUCCESS - Booted as cfncluster Compute connected to Master - $cfn_master" |
Oops, something went wrong.