Skip to content

Commit

Permalink
Merge pull request #116 from EMCECS/develop
Browse files Browse the repository at this point in the history
Merge Develop to Master
  • Loading branch information
APeter0807 committed Apr 12, 2016
2 parents 6e22a9c + 1553359 commit 9bab22e
Show file tree
Hide file tree
Showing 8 changed files with 346 additions and 29 deletions.
2 changes: 1 addition & 1 deletion ecs-multi-node/step1_ecs_multinode_install.py
Expand Up @@ -261,7 +261,7 @@ def prepare_data_disk_func(disks):
subprocess.call(["mkdir", "-p", "/ecs/{}".format(uuid_name)])

# mount /dev/sdc1 /ecs/uuid-1
logger.info("Mount attached /dev{} to /ecs/{} volume.".format(device_name, uuid_name))
logger.info("Mount attached {} to /ecs/{} volume.".format(device_name, uuid_name))
subprocess.call(["mount", device_name, "/ecs/{}".format(uuid_name), "-o", "noatime,seclabel,attr2,inode64,noquota"])

# add entry to fstab if not pre-existing
Expand Down
97 changes: 69 additions & 28 deletions ecs-single-node/step1_ecs_singlenode_install.py
Expand Up @@ -273,8 +273,8 @@ def prepare_data_disk_func(disks):
subprocess.call(["mkdir", "-p", "/ecs/{}".format(uuid_name)])

# mount /dev/sdc1 /ecs/uuid-1
logger.info("Mount attached /dev{} to /ecs/{} volume.".format(device_name, uuid_name))
subprocess.call(["mount", device_name, "/ecs/{}".format(uuid_name), "-o", "rw,noatime,seclabel,attr2,inode64,noquota"])
logger.info("Mount attached {} to /ecs/{} volume.".format(device_name, uuid_name))
subprocess.call(["mount", device_name, "/ecs/{}".format(uuid_name), "-o", "noatime,seclabel,attr2,inode64,noquota"])

# add entry to fstab if not pre-existing
fstab = "/etc/fstab"
Expand Down Expand Up @@ -394,21 +394,22 @@ def set_docker_configuration_func():
logger.fatal("Aborting program! Please review log")


def execute_docker_func(docker_image_name):
def execute_docker_func(docker_image_name, use_urandom=False):
'''
Execute Docker Container
'''
try:

# docker run -d -e SS_GENCONFIG=1 -v /ecs:/disks -v /host:/host -v /var/log/vipr/emcvipr-object:/opt/storageos/logs -v /data:/data:rw --net=host emccode/ecsstandalone:v2.0 --name=ecsstandalone
docker_command = ["docker", "run", "-d", "-e", "SS_GENCONFIG=1"]
if use_urandom:
docker_command.extend(["-v", "/dev/urandom:/dev/random"])
docker_command.extend(["-v", "/ecs:/dae", "-v", "/host:/host", "-v", "/var/log/vipr/emcvipr-object:/opt/storageos/logs", "-v", "/data:/data:rw", "--net=host",
"--name=ecsstandalone", "{}".format(docker_image_name)])
logger.info("Execute the Docker Container.")
command_line = ["docker", "run", "-d", "-e", "SS_GENCONFIG=1", "-v", "/ecs:/dae", "-v", "/host:/host", "-v",
"/var/log/vipr/emcvipr-object:/opt/storageos/logs", "-v", "/data:/data:rw", "--net=host",
"--name=ecsstandalone",
"{}".format(docker_image_name)]
command_line[1:1] = DockerCommandLineFlags
logger.info(" ".join(command_line))
subprocess.call(command_line)
docker_command[1:1] = DockerCommandLineFlags
logger.info(" ".join(docker_command))
subprocess.call(docker_command)

# docker ps
logger.info("Check the Docker processes.")
Expand All @@ -435,7 +436,7 @@ def cmdline(command):
return process.communicate()[0]


def modify_container_conf_func():
def modify_container_conf_func(no_internet):
try:
logger.info("Backup object properties files")
os.system(
Expand Down Expand Up @@ -498,19 +499,21 @@ def modify_container_conf_func():
os.system(
"docker "+' '.join(DockerCommandLineFlags)+" exec -t ecsstandalone cp /host/ssm.object.properties /opt/storageos/conf/ssm.object.properties")

logger.info("Adding python setuptools to container")
os.system("docker "+' '.join(DockerCommandLineFlags)+" exec -t ecsstandalone wget https://bootstrap.pypa.io/ez_setup.py")
os.system("docker "+' '.join(DockerCommandLineFlags)+" exec -t ecsstandalone python ez_setup.py")

logger.info("Adding python requests library to container")
os.system(
"docker "+' '.join(DockerCommandLineFlags)+" exec -t ecsstandalone curl -OL https://github.com/kennethreitz/requests/tarball/master")
os.system("docker "+' '.join(DockerCommandLineFlags)+" exec -t ecsstandalone tar zxvf master -C /tmp")
os.system("docker "+' '.join(DockerCommandLineFlags)+" exec -t -i ecsstandalone bash -c \"cd /tmp/kennethreitz-requests-* && python setup.py install\"")
os.system("docker "+' '.join(DockerCommandLineFlags)+" exec -t ecsstandalone wget https://bootstrap.pypa.io/ez_setup.py")
logger.info("Cleaning up python packages")
os.system("docker "+' '.join(DockerCommandLineFlags)+" exec -t ecsstandalone rm master")
os.system("docker "+' '.join(DockerCommandLineFlags)+" exec -t ecsstandalone rm setuptools-20.0.zip")
if not no_internet:
logger.info("Adding python setuptools to container")
os.system("docker "+' '.join(DockerCommandLineFlags)+" exec -t ecsstandalone wget https://bootstrap.pypa.io/ez_setup.py")
os.system("docker "+' '.join(DockerCommandLineFlags)+" exec -t ecsstandalone python ez_setup.py")

logger.info("Adding python requests library to container")
os.system(
"docker "+' '.join(DockerCommandLineFlags)+" exec -t ecsstandalone curl -OL https://github.com/kennethreitz/requests/tarball/master")
os.system("docker "+' '.join(DockerCommandLineFlags)+" exec -t ecsstandalone tar zxvf master -C /tmp")
os.system("docker "+' '.join(DockerCommandLineFlags)+" exec -t -i ecsstandalone bash -c \"cd /tmp/kennethreitz-requests-* && python setup.py install\"")
os.system("docker "+' '.join(DockerCommandLineFlags)+" exec -t ecsstandalone wget https://bootstrap.pypa.io/ez_setup.py")
logger.info("Cleaning up python packages")
os.system("docker "+' '.join(DockerCommandLineFlags)+" exec -t ecsstandalone rm master")
os.system("docker "+' '.join(DockerCommandLineFlags)+" exec -t ecsstandalone rm setuptools-20.0.zip")

logger.info("Flush VNeST data")
os.system("docker "+' '.join(DockerCommandLineFlags)+" exec -t ecsstandalone rm -rf /data/vnest/vnest-main/*")
Expand Down Expand Up @@ -554,6 +557,19 @@ def getAuthToken(ECSNode, User, Password):

logger.fatal("Authentication service not yet started.")

def docker_load_image(imagefile):
"""
Loads the specified docker image file.
"""
try:
logger.info("Loading docker image file %s" % imagefile)
res = subprocess.check_output("docker load -i \"%s\"" % imagefile, shell=True)
except Exception as ex:
logger.exception(ex)
logger.fatal("Error loading docker image file %s" % imagefile)
sys.exit(13)



def docker_cleanup_old_images():
"""
Expand Down Expand Up @@ -667,10 +683,21 @@ def main():
parser.add_argument('--imagetag', dest='imagetag', nargs='?',
help='If present, pulls a specific version of the target image from DockerHub. Defaults to latest',
required=False)
parser.add_argument('--use-urandom', dest='use_urandom', action='store_true', default=False,
help='If present, /dev/random will be mapped to /dev/urandom on the host. If you container starts up slow the first time could help.',
required=False)
parser.add_argument('--no-internet', dest='no_internet', action='store_true', default=False,
help='When specified, do not perform any actions that require an Internet connection.',
required=False)
parser.add_argument('--load-image', dest='image_file', nargs='?',
help='If present, gives the name of a docker image file to load.',
required=False)

parser.set_defaults(container_config=False)
parser.set_defaults(cleanup=False)
parser.set_defaults(imagename="emccorp/ecs-software-2.2")
parser.set_defaults(imagetag="latest")
parser.set_defaults(image_file=False)
args = parser.parse_args()


Expand All @@ -686,6 +713,16 @@ def main():
print("Disk[s]: %s" % args.disks)
print("Docker Image Name: %s" % args.imagename)
print("Docker Image Tag: %s" % args.imagetag)
if(args.image_file):
print("Docker Image File: %s" % args.image_file)

print("Use Internet to download image and packages: %s" % (not args.no_internet))

# If loading an image, make sure it exists.
if args.image_file and not os.path.exists(args.image_file):
logger.error("The specified docker image file %s does not exist." % args.image_file)
sys.exit(12)


# Check if only wants to run the Container Configuration section
if args.container_config:
Expand Down Expand Up @@ -730,20 +767,24 @@ def main():

logger.info("Starting Step 1: Configuration of Host Machine to run the ECS Docker Container: {}".format(docker_image_name))

yum_func()
package_install_func()
if not args.no_internet:
yum_func()
package_install_func()
update_selinux_os_configuration()
prep_file_func()
docker_pull_func(docker_image_name)
if args.image_file:
docker_load_image(args.image_file)
if not args.no_internet:
docker_pull_func(docker_image_name)
hosts_file_func(args.hostname, ethernet_adapter_name)
network_file_func(ethernet_adapter_name)
seeds_file_func(ethernet_adapter_name)
prepare_data_disk_func(args.disks)
run_additional_prep_file_func(args.disks)
directory_files_conf_func()
set_docker_configuration_func()
execute_docker_func(docker_image_name)
modify_container_conf_func()
execute_docker_func(docker_image_name, args.use_urandom)
modify_container_conf_func(args.no_internet)
getAuthToken(ip_address,"root","ChangeMe")
logger.info(
"Step 1 Completed. Navigate to the administrator website that is available from any of the ECS data nodes. \
Expand Down
13 changes: 13 additions & 0 deletions patches/2.2.0.3/Dockerfile
@@ -0,0 +1,13 @@
# Four fixes to the default 2.2.0.3 image.
FROM emcvipr/object:2.2.0.0-75761.8c6090f-reduced

# Fix disk partitioning script
ADD storageserver-partition-config.sh /opt/storageos/bin/
# Make vnest use separate thread pools to prevent deadlock
ADD vnest.object.properties /opt/storageos/conf/
# Reduce timeout for systems that are shutdown for a while
ADD coordinator.properties /opt/storageos/conf/
# Increase memory for transformsvc
ADD transformsvc /opt/storageos/bin/
# Patch for small disk footprint disk allocation
ADD storageos-ssm.jar /opt/storageos/lib/
13 changes: 13 additions & 0 deletions patches/2.2.0.3/coordinator.properties
@@ -0,0 +1,13 @@
# genconfig will set flag based on control node vs. data node
coordinator.useExternalConfig=true
coordinator.serverClientPort=2181
coordinator.dataDir=/data/zk
coordinator.serverConfigFile=/data/vnest/vnest-main/configuration/coord-server
coordinator.clientConfigFile=/data/vnest/vnest-main/configuration/coord-client
coordinator.lastServedFile=/data/vnest/vnest-main/configuration/coord-last-served
# if node down for this long, wait to see if still member before proceeding
coordinator.lastServedThreshSecs=3600
# if lastServedThreshSecs exceeded, wait this long for config to be updated
coordinator.lastServedTimeoutSecs=5
# how often to touch last served file
coordinator.lastServedUpdateSecs=120
Binary file added patches/2.2.0.3/storageos-ssm.jar
Binary file not shown.
119 changes: 119 additions & 0 deletions patches/2.2.0.3/storageserver-partition-config.sh
@@ -0,0 +1,119 @@
#!/bin/bash
# Copyright (c) 2013 EMC Corporation
# All Rights Reserved
#
# This software contains the intellectual property of EMC Corporation
# or is licensed to EMC Corporation from third parties. Use of this
# software and the intellectual property contained therein is expressly
# limited to the terms and conditions of the License Agreement under which
# it is provided by or on behalf of EMC.
#

date

# This script will generate the partition file (ss-partition-conf.json) to be used on this server if one is not found.
# Also a general configuration file will be generated with main parameters and a ss uuid.
# Assumes this is running on gen 3 hardware or a vipr data test node using disks mounted with a
# /dae/uuid-58f917ab-23ba-457f-a9df-d0f4b0597e2d type pattern or will look for /data (vipr)

export configdir="/opt/storageos/conf"

export p_configfile="$configdir/storageserver-partition-conf.json"
export configfile="$configdir/storageserver.conf"

blockbinsizegb=10
vm_bb_cout=5
vm_part_count=5

function setopt() {
opt=$1
val=$2
if grep -q "$opt" "$configfile" ; then
sed -i "s#$opt=.*#$opt=$val#g" "$configfile"
else
echo "$opt=$val" >> $configfile
fi

}

echo "creating main config file: $configfile"
if [ ! -e "$configfile" ]; then
echo "creating $configfile"
mkdir -p "$configdir"
cat << EOF > "$configfile"
listenaddress=0.0.0.0
port=9099
iothreads=100
blockbinsizegb=$blockbinsizegb
debugenabled=false
logtoconsole=false
logtosyslog=true
maxoutstandingrequests=0
initblockbins=0
netserverListenPort=9069
netserverLogLevel=INFO
ioThreadNumber=200
perfCountEnabled=true
maxMemThresholdKb=3145728
sendQHighWaterMark=1000
recvThreadNicePriority=-15
sendThreadNicePriority=-15
enableAffinity=true
partitionroot=/dae
agentUrlEndPoint=/host/data/agent.json
agentDisksRestFragment=/v1/agent/node/storage/disk/disks
trustStore=/host/data/security/truststore.pem
verifyCerts=true
dbusEnabled=false
EOF
else
echo "$configfile already exists, no action taken"
fi

if grep -q -E 'VMware.*Virtual.*disk' /proc/scsi/sg/device_strs && [ ! -e /data/is_community_edition ]
then
# this a virtual datanode, creating a json file with predefined values
echo "virtual node detected - using json config file"
setopt partitionconfig $p_configfile
setopt partitionroot=/dae
root="/data/storageserver"

for part in $(seq 1 $vm_part_count); do
for bb in $(seq 1 $vm_bb_cout); do
bb=$(printf "%0*d\n" 4 $bb)
mkdir -m 777 -p $root/uuid-$part
fallocate -l${blockbinsizegb}G $root/uuid-$part/$bb
chmod 777 $root/uuid-$part/$bb
done
done

if [ ! -e "$p_configfile" ]; then
echo "creating $p_configfile"
mkdir -p "$configdir"

printf '{\n%2s"disks": [\n' > $p_configfile
for part in $(seq 1 "$vm_part_count"); do
printf '%4s{\n%6s"uuid": "'$part'",\n%6s"health": "Good"\n%4s}' >> $p_configfile
[ "$part" -lt "$vm_part_count" ] && echo "," >> $p_configfile || echo "" >> $p_configfile
done
printf '%2s]\n}' >> $p_configfile

else
echo "$p_configfile already exists, no action taken"
fi
else
# this is a commodity hardware node. do not generate a json file - ss will use dbus to obtain partitions
echo "commodity node detected - using dbus api"
fi

if ! grep --quiet "uuid" "$configfile"; then
echo "generating server uuid"
uuidgen="$(which uuidgen)"
if [ ! -z "$uuidgen" ]; then
uuid="$(uuidgen)"
else
echo "warning: uuidgen utility was not found on your system. using timestamp as a uuid"
uuid="$(date +%s)"
fi
setopt uuid "$uuid"
fi

0 comments on commit 9bab22e

Please sign in to comment.