Skip to content

Commit

Permalink
Merge pull request #5 from IBM/master
Browse files Browse the repository at this point in the history
Sync
  • Loading branch information
hongsenliu authored May 17, 2019
2 parents 9ec63ac + 78be0b6 commit d1ca15d
Show file tree
Hide file tree
Showing 36 changed files with 846 additions and 48 deletions.
24 changes: 23 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
*.sum

#Others
*.log
*.status
/bin
/grpc
/cache
/db
/dnsmasq
Expand All @@ -50,4 +53,23 @@ cloudland.sum
cloudland.tgz
ipcalc
cloudrc.local

sci/Makefile
/sci/config.h
/sci/libtool
/sci/scia/scia64
/sci/stamp-h1
/sci/usecase/dsh/ddsh_fe64
/sci/usecase/dsh/dsh_be64
/sci/usecase/dsh/dsh_fe64
/sci/usecase/dsh/edsh_fe64
/sci/usecase/dsh/gdsh_fe64
/sci/usecase/dsh_2/dsh_be64
/sci/usecase/dsh_2/dsh_fe64
/sci/usecase/dsh_2/edsh_fe64
/sci/usecase/dsh_2/gdsh_fe64
/sci/usecase/dsh_2/sdsh_fe64
/sci/usecase/dsh_filter/dsh_be64
/sci/usecase/dsh_filter/dsh_fe64
/sci/usecase/dsh_filter/dsh_tests64
/sci/usecase/dsh_filter2/dsh_be64
/sci/usecase/dsh_filter2/dsh_fe64
70 changes: 70 additions & 0 deletions deploy/allinone.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash

cland_root_dir=/opt/cloudland
cd $(dirname $0)

[ $PWD != "$cland_root_dir/deploy" ] && echo "Please clone cloudland into /opt" && exit 1

sudo chown -R centos.centos /opt/cloudland

# Install development tools
sudo yum install -y ansible vim git wget epel-release
sudo yum groupinstall -y "Development Tools"

# Install SCI
function inst_sci()
{
cd $cland_root_dir/sci
./configure
make
sudo make install
}

# Install GRPC
function inst_grpc() {
cd $cland_root_dir
git clone https://github.com/grpc/grpc.git
cd grpc
git submodule update --init
cd third_party/protobuf/
./autogen.sh
./configure
make
sudo make install
sudo bash -c 'echo /usr/local/lib > /etc/ld.so.conf.d/protobuf.conf'
sudo ldconfig
cd ../../
make
sudo make install
DIR=$PWD
cat > activate.sh <<EOF
export PATH=$PATH:/usr/local/bin:$DIR/bins/opt:$DIR/bins/opt/protobuf
export CPATH=$DIR/include:$DIR/third_party/protobuf/src
export LIBRARY_PATH=$DIR/libs/opt:$DIR/libs/opt/protobuf
export PKG_CONFIG_PATH=$DIR/libs/opt/pkgconfig:$DIR/third_party/protobuf
export LD_LIBRARY_PATH=$DIR/libs/opt
EOF
}

# Install web
function install_web()
{
sudo yum -y install golang postgresql
sudo chown -R centos.centos /usr/local
}

# Install cloudland
function inst_cland()
{
cd $cland_root_dir/src
source $cland_root_dir/grpc/activate.sh
make
make install
}

diff /opt/sci/lib64/libsci.so.0.0.0 $cland_root_dir/sci/libsci/.libs/libsci.so.0.0.0
[ $? -ne 0 ] && inst_sci
[ ! -f "$cland_root_dir/grpc/activate.sh" ] && inst_grpc
diff $cland_root_dir/bin/cloudland $cland_root_dir/src/cloudland
[ $? -ne 0 ] && inst_cland

16 changes: 4 additions & 12 deletions deploy/gluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,16 @@
gluster_infra_stripe_unit_size: 128
# Variables for creating volume group
gluster_infra_volume_groups:
- { vgname: 'vg_vdb', pvname: '/dev/vdb' }
- { vgname: 'vg_vdc', pvname: '/dev/vdc' }
- { vgname: 'vg_vdd', pvname: '/dev/vdd' }
- { vgname: 'vg_sdb', pvname: '/dev/sdb' }
# Create thinpools
gluster_infra_thinpools:
- {vgname: 'vg_vdb', thinpoolname: 'vdb_thinpool', thinpoolsize: '45G', poolmetadatasize: '1G'}
- {vgname: 'vg_vdc', thinpoolname: 'vdc_thinpool', thinpoolsize: '45G', poolmetadatasize: '1G'}
- {vgname: 'vg_vdd', thinpoolname: 'vdd_thinpool', thinpoolsize: '45G', poolmetadatasize: '1G'}
- {vgname: 'vg_sdb', thinpoolname: 'sdb_thinpool', thinpoolsize: '1500G', poolmetadatasize: '2G'}
# Create a thin volume
gluster_infra_lv_logicalvols:
- { vgname: 'vg_vdb', thinpool: 'vdb_thinpool', lvname: 'vg_vdb_thinlv', lvsize: '50G' }
- { vgname: 'vg_vdc', thinpool: 'vdc_thinpool', lvname: 'vg_vdc_thinlv', lvsize: '50G' }
- { vgname: 'vg_vdd', thinpool: 'vdd_thinpool', lvname: 'vg_vdd_thinlv', lvsize: '50G' }
- { vgname: 'vg_sdb', thinpool: 'sdb_thinpool', lvname: 'vg_sdb_thinlv', lvsize: '2000G' }
# Mount the devices
gluster_infra_mount_devices:
- { path: '/gluster/thinlv1', vgname: 'vg_vdb', lvname: 'vg_vdb_thinlv' }
- { path: '/gluster/thinlv2', vgname: 'vg_vdc', lvname: 'vg_vdc_thinlv' }
- { path: '/gluster/thinlv3', vgname: 'vg_vdd', lvname: 'vg_vdd_thinlv' }
- { path: '/gluster/thinlv1', vgname: 'vg_sdb', lvname: 'vg_sdb_thinlv' }
roles:
- ginfra

Expand Down
24 changes: 24 additions & 0 deletions scripts/backend/attach_volume.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

cd $(dirname $0)
source ../cloudrc

[ $# -lt 3 ] && echo "$0 <vm_ID> <volume_ID> <volume_path>" && exit -1

vm_ID=inst-$1
vol_ID=$2
vol_path=$gluster_volume/$3
vol_xml=$xml_dir/$vm_ID/disk-${vol_ID}.xml
cp $template_dir/volume.xml $vol_xml
count=$(virsh dumpxml $vm_ID | grep -c "<disk type='network' device='disk'>")
let letter=98+$count
device=vd$(printf "\\$(printf '%03o' "$letter")")
sed -i "s#VOLUME_SOURCE#$vol_path#g;s#VOLUME_TARGET#$device#g;" $vol_xml
virsh attach-device $vm_ID $vol_xml --config --persistent
if [ $? -eq 0 ]; then
echo "|:-COMMAND-:| $(basename $0) '$1' '$vol_ID' '$device'"
else
echo "|:-COMMAND-:| $(basename $0) '' '$vol_ID' ''"
fi
vm_xml=$xml_dir/$vm_ID/$vm_ID.xml
virsh dumpxml --security-info $vm_ID 2>/dev/null | sed "s/autoport='yes'/autoport='no'/g" > $vm_xml.dump && mv -f $vm_xml.dump $vm_xml
2 changes: 1 addition & 1 deletion scripts/backend/clear_router.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

cd `dirname $0`
cd $(dirname $0)
source ../cloudrc

[ $# -lt 2 ] && echo "$0 <router> <vrrp_vni>" && exit -1
Expand Down
4 changes: 2 additions & 2 deletions scripts/backend/clear_vm.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

cd `dirname $0`
cd $(dirname $0)
source ../cloudrc

[ $# -lt 1 ] && die "$0 <vm_ID>"
Expand Down Expand Up @@ -33,4 +33,4 @@ rm -f ${image_dir}/$vm_ID.disk
rm -f ${cache_dir}/meta/$vm_ID.iso
rm -rf $xml_dir/$vm_ID
sidecar span log $span "Callback: `basename $0` '$vm_ID'"
echo "|:-COMMAND-:| `basename $0` '$vm_ID'"
echo "|:-COMMAND-:| $(basename $0) '$vm_ID'"
11 changes: 11 additions & 0 deletions scripts/backend/clear_volume.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

cd $(dirname $0)
source ../cloudrc

[ $# -lt 2 ] && die "$0 <vol_ID> <path>"

vol_ID=$1
path=$2

rm -f $volume_dir/$path
2 changes: 1 addition & 1 deletion scripts/backend/create_link.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

cd `dirname $0`
cd $(dirname $0)
source ../cloudrc

[ $# -lt 1 ] && die "$0 <vlan>"
Expand Down
4 changes: 2 additions & 2 deletions scripts/backend/create_router.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

cd `dirname $0`
cd $(dirname $0)
source ../cloudrc

[ $# -lt 5 ] && echo "$0 <router> <ext_defaut_gw> <int_defaut_gw> <ext_gw_cidr> <int_gw_cidr> <vrrp_vni> <vrrp_ip> <role>" && exit -1
Expand Down Expand Up @@ -113,4 +113,4 @@ while [ $i -lt $n ]; do
done

ip netns exec $router bash -c "echo 1 >/proc/sys/net/ipv4/ip_forward"
echo "|:-COMMAND-:| `basename $0` '$1' '$SCI_CLIENT_ID' '$role'"
echo "|:-COMMAND-:| $(basename $0) '$1' '$SCI_CLIENT_ID' '$role'"
14 changes: 14 additions & 0 deletions scripts/backend/create_volume.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

cd $(dirname $0)
source ../cloudrc

[ $# -lt 2 ] && echo "$0 <vol_ID> <size>" && exit -1

vol_ID=$1
size=$2
state='error'

qemu-img create -f qcow2 -o cluster_size=2M $volume_dir/volume-${vol_ID}.disk ${size}G
[ $? -eq 0 ] && state='available'
echo "|:-COMMAND-:| $(basename $0) '$vol_ID' 'volume-${vol_ID}.disk' '$state'"
18 changes: 18 additions & 0 deletions scripts/backend/detach_volume.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

cd $(dirname $0)
source ../cloudrc

[ $# -lt 2 ] && echo "$0 <vm_ID> <volume_ID>" && exit -1

vm_ID=inst-$1
vol_ID=$2
vol_xml=$xml_dir/$vm_ID/disk-${vol_ID}.xml
virsh detach-device $vm_ID $vol_xml --config --persistent
if [ $? -eq 0 ]; then
echo "|:-COMMAND-:| $(basename $0) '$1' '$vol_ID'"
else
echo "|:-COMMAND-:| $(basename $0) '' '$vol_ID'"
fi
vm_xml=$xml_dir/$vm_ID/$vm_ID.xml
virsh dumpxml --security-info $vm_ID 2>/dev/null | sed "s/autoport='yes'/autoport='no'/g" > $vm_xml.dump && mv -f $vm_xml.dump $vm_xml
2 changes: 1 addition & 1 deletion scripts/backend/launch_vm.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

cd `dirname $0`
cd $(dirname $0)
source ../cloudrc

[ $# -lt 6 ] && die "$0 <vm_ID> <image> <name> <cpu> <memory> <disk_inc> [userdata] [pubkey]"
Expand Down
2 changes: 1 addition & 1 deletion scripts/cloudrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ localrc="${BASH_SOURCE[0]}.local"
source "$localrc"
cache_dir=/opt/cloudland/cache
cache_tmp_dir=$cache_dir/tmp
volume_dir=/opt/cloudland/volume
volume_dir=/opt/cloudland/cache/volume
image_dir=$cache_dir/instance
xml_dir=/opt/cloudland/cache/xml
template_dir=/opt/cloudland/scripts/xml
Expand Down
2 changes: 2 additions & 0 deletions scripts/cloudrc.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ vol_limit=100
disk_inc_limit=100
resolver_addr=192.168.1.125
use_lb=false
portmap_remote_ip=47.92.116.39
gluster_volume=virt-volume
8 changes: 8 additions & 0 deletions scripts/xml/volume.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<disk type='network' device='disk'>
<driver name='qemu' type='qcow2' cache='none'/>
<source protocol='gluster' name='VOLUME_SOURCE'>
<host name='localhost' port='24007'/>
</source>
<backingStore/>
<target dev='VOLUME_TARGET' bus='virtio'/>
</disk>
12 changes: 10 additions & 2 deletions src/remotexec/remotexec.grpc.pb.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 22 additions & 2 deletions src/remotexec/remotexec.grpc.pb.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/clui/.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e7acfeb
40d796c
Binary file modified web/clui/clui
Binary file not shown.
Loading

0 comments on commit d1ca15d

Please sign in to comment.