forked from kaparora/continuous-delivery-pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Kapil Arora
authored and
Kapil Arora
committed
Dec 27, 2015
1 parent
898bb0f
commit ec04007
Showing
13 changed files
with
2,857 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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# continuous-delivery-pipeline | ||
Simple DevOps Continous Delivery Pipleine for a Ruby and MySQL app using Docker, docker-compose, Jenkins, GitLab, Docker Registry and Snap Creator. | ||
|
||
Change docker registry from 10.65.57.126:5000 in all files to your registry |
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 @@ | ||
Download NetApp NMSDK from https://mysupport.netapp.com/documentation/productlibrary/index.html?productID=60427 | ||
Copy the contents under /lib/ruby/NetApp to netapp_sdk/lib/NetApp |
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,3 @@ | ||
#! /bin/bash | ||
docker-compose stop | ||
yes | docker-compose rm |
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,20 @@ | ||
#!/bin/bash | ||
echo "Reading config...." | ||
source database.config | ||
echo "HOST: $HOST" | ||
echo "VOLUME_PROD: $VOLUME_PROD" | ||
echo "VOLUME_CLONE_NAME: $VOLUME_CLONE_NAME" | ||
echo "MOUNT_AT: $MOUNT_AT" | ||
echo "MYSQL_PASSWORD: $MYSQL_PASSWORD" | ||
echo "STORGAE_HOST: $STORGAE_HOST" | ||
echo "STORGAE_USER: $STORGAE_USER" | ||
echo "STORAGE_PASSWORD: $STORAGE_PASSWORD" | ||
cd netapp_sdk | ||
echo "deleting existing clone" | ||
if ruby flexClone.rb $STORGAE_HOST $STORGAE_USER $STORAGE_PASSWORD delete $VOLUME_CLONE_NAME;then | ||
echo "deleted" | ||
else | ||
echo "delete failed" | ||
fi | ||
echo "creating new clone" | ||
ruby flexClone.rb $STORGAE_HOST $STORGAE_USER $STORAGE_PASSWORD create $VOLUME_CLONE_NAME $VOLUME_PROD |
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 @@ | ||
HOST=<nfs export IP or host> | ||
VOLUME_PROD=mysql_data_prod | ||
VOLUME_CLONE_NAME=mysql_data_prod_clone | ||
MOUNT_AT=/mnt/mysql_data_prod_clone | ||
MYSQL_PASSWORD=<mysql password> | ||
STORGAE_HOST=<cDot SVM IP or host> | ||
STORGAE_USER=vsadmin | ||
STORAGE_PASSWORD=<svm password> | ||
|
14 changes: 14 additions & 0 deletions
14
ruby-mysql-web-test-with-prod-clone-data/docker-compose.yml
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,14 @@ | ||
ruby_web: | ||
image: 10.65.57.126:5000/ruby-mysql-web:0.0.1-SNAPSHOT | ||
environment: | ||
PORT: 9595 | ||
ports: | ||
- "9595:9595" | ||
links: | ||
- mysql_db:mysql_host | ||
mysql_db: | ||
image: mysql:latest | ||
volumes: | ||
- /mnt/mysql_data_prod_clone:/var/lib/mysql | ||
environment: | ||
MYSQL_ROOT_PASSWORD: netapp01 |
21 changes: 21 additions & 0 deletions
21
ruby-mysql-web-test-with-prod-clone-data/executeAppAndTestWebService.sh
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,21 @@ | ||
#! /bin/bash | ||
|
||
TEST_PORT=9595 | ||
|
||
echo "Staring application with docker compose" | ||
docker-compose up -d | ||
echo "Sleeping for 10 seconds for web service to start" | ||
sleep 10s | ||
echo "calling the webservice to see if it is active and returns http code 200" | ||
#curl -s --head --request GET http://localhost:9292/locandtweet/netapp | grep "200 OK" > /dev/null | ||
httpCode=`curl -sL -w "%{http_code}\\n" "http://10.65.57.126:$TEST_PORT/table/employees" -o /dev/null` | ||
echo "Http code returned: $httpCode" | ||
if [ $httpCode == 200 ] | ||
then | ||
echo "test passed!" | ||
exit 0 | ||
else | ||
echo "test failed" | ||
exit 1 | ||
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,17 @@ | ||
#!/bin/bash | ||
if [ "$(id -u)" != "0" ]; then | ||
echo "This script must be run as root" 1>&2 | ||
exit 1 | ||
fi | ||
echo "Reading config...." | ||
source database.config | ||
echo "HOST: $HOST" | ||
echo "VOLUME_PROD: $VOLUME_PROD" | ||
echo "VOLUME_CLONE_NAME: $VOLUME_CLONE_NAME" | ||
echo "MOUNT_AT: $MOUNT_AT" | ||
echo "creating $MOUNT_AT dir if not exist already" | ||
mkdir -p $MOUNT_AT | ||
echo "trying Umount volume" | ||
umount $MOUNT_AT | ||
echo "Mounting volume $HOST:/$VOLUME_CLONE_NAME at location $MOUNT_AT" | ||
mount -t nfs $HOST:/$VOLUME_CLONE_NAME $MOUNT_AT |
121 changes: 121 additions & 0 deletions
121
ruby-mysql-web-test-with-prod-clone-data/netapp_sdk/flexClone.rb
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,121 @@ | ||
$:.unshift 'lib/NetApp' | ||
require 'NaServer' | ||
|
||
|
||
def print_usage | ||
print("Usage:flexClone.rb <storage> <user> <password> <command> <clone-volname>") | ||
print(" [<volume>]\n") | ||
print("<storage> -- Storage system name\n") | ||
print("<user> -- User name\n") | ||
print("<password> -- Password\n") | ||
print("<command> -- Possible commands are:\n") | ||
print(" create - to create a new clone\n") | ||
print(" delete - to destroy a clone\n") | ||
print("<clone-volname> -- clone volume name \n") | ||
print("[<parent-volname] -- name of the parent volume to create the clone. \n") | ||
exit | ||
end | ||
|
||
|
||
args = ARGV.length | ||
if(args < 5) | ||
print_usage() | ||
end | ||
$storage = ARGV[0] | ||
$user = ARGV[1] | ||
$pw = ARGV[2] | ||
$command = ARGV[3] | ||
$clone_name = ARGV[4] | ||
$parent_vol = nil | ||
if(args > 5) | ||
$parent_vol = ARGV[5] | ||
end | ||
|
||
|
||
|
||
def create_flexclone() | ||
clone_in = NaElement.new("volume-clone-create") | ||
clone_in.child_add_string("parent-volume", $parent_vol) | ||
clone_in.child_add_string("volume", $clone_name) | ||
# Invoke volume-clone-create API | ||
out = $s.invoke_elem(clone_in) | ||
if(out.results_status() == "failed") | ||
print(out.results_reason() + "\n") | ||
exit | ||
end | ||
end | ||
|
||
def delete_flexclone() | ||
clone_destroy_in = NaElement.new("volume-destroy") | ||
clone_destroy_in.child_add_string("name", $clone_name) | ||
# Invoke volume-destroy API | ||
out = $s.invoke_elem(clone_destroy_in) | ||
if(out.results_status() == "failed") | ||
print(out.results_reason() + "\n") | ||
exit | ||
end | ||
end | ||
|
||
def mount_flexclone() | ||
clone_mount_in = NaElement.new("volume-mount") | ||
clone_mount_in.child_add_string("volume-name", $clone_name) | ||
clone_mount_in.child_add_string("export-policy-override", "true") | ||
clone_mount_in.child_add_string("junction-path", "/"+$clone_name) | ||
# Invoke volume-destroy API | ||
out = $s.invoke_elem(clone_mount_in) | ||
if(out.results_status() == "failed") | ||
print(out.results_reason() + "\n") | ||
exit | ||
end | ||
end | ||
|
||
def unmount_flexclone() | ||
clone_unmount_in = NaElement.new("volume-unmount") | ||
clone_unmount_in.child_add_string("volume-name", $clone_name) | ||
out = $s.invoke_elem(clone_unmount_in) | ||
if(out.results_status() == "failed") | ||
print(out.results_reason() + "\n") | ||
exit | ||
end | ||
end | ||
|
||
def volume_offline() | ||
clone_offline_in = NaElement.new("volume-offline") | ||
clone_offline_in.child_add_string("name", $clone_name) | ||
# Invoke volume-destroy API | ||
out = $s.invoke_elem(clone_offline_in) | ||
if(out.results_status() == "failed") | ||
print(out.results_reason() + "\n") | ||
exit | ||
end | ||
end | ||
|
||
|
||
def main | ||
if(not (($command == "create") or ($command == "delete"))) | ||
print($command+" is not a valid command\n") | ||
print_usage() | ||
end | ||
if (($command == "create") and ($parent_vol == nil)) | ||
print($command+" operation requires <parent-volname>\n") | ||
print("Usage: flexclone.py <storage> <user> <password>"+$command+" <clone-volname> <parent-volname>\n") | ||
exit | ||
end | ||
$s = NaServer.new($storage, 1, 3) | ||
$s.set_admin_user($user, $pw) | ||
if($command == "create") | ||
create_flexclone() | ||
mount_flexclone() | ||
elsif($command == "delete") | ||
unmount_flexclone() | ||
volume_offline() | ||
delete_flexclone() | ||
else | ||
print("Invalid operation\n") | ||
print_usage() | ||
end | ||
end | ||
|
||
|
||
main() | ||
|
Oops, something went wrong.