Skip to content

Instantly share code, notes, and snippets.

@ynojima
Created May 6, 2014 00:56
Show Gist options
  • Save ynojima/c30e1d5d08e500e49e64 to your computer and use it in GitHub Desktop.
Save ynojima/c30e1d5d08e500e49e64 to your computer and use it in GitHub Desktop.
#!/bin/bash
cli="cloudmonkey -c <cloudmonkey config>"
dns_ext=<please fill config that fits your env.>
dns_int=<please fill config that fits your env.>
gw=<please fill config that fits your env.>
nmask=<please fill config that fits your env.>
hpvr=KVM
public_ip_start=<please fill config that fits your env.>
public_ip_end=<please fill config that fits your env.>
guest_cidr=<please fill config that fits your env.>
vlan_range=<please fill config that fits your env.>
system_gw=<please fill config that fits your env.>
system_nmask=<please fill config that fits your env.>
pod_start=<please fill config that fits your env.>
pod_end=<please fill config that fits your env.>
storage_start=<please fill config that fits your env.>
storage_end=<please fill config that fits your env.>
#Put space separated host ips in following
host_ips=<please fill config that fits your env.>
host_user=<please fill config that fits your env.>
host_passwd=<please fill config that fits your env.>
prm_storage=<please fill config that fits your env.>
sec_storage=<please fill config that fits your env.>
zone_id=`$cli create zone dns1=$dns_ext internaldns1=$dns_int name=Zone$RANDOM networktype=Advanced guestcidraddress=$guest_cidr | grep ^id\ = | awk '{print $3}'`
echo "Created zone" $zone_id
phynet1_id=`$cli create physicalnetwork name=PhyNetwork1 zoneid=$zone_id isolationmethods=VLAN | grep ^id\ = | awk '{print $3}'`
echo "Created physical network1" $phy_id
phynet2_id=`$cli create physicalnetwork name=PhyNetwork2 zoneid=$zone_id isolationmethods=VXLAN vlan=$vlan_range | grep ^id\ = | awk '{print $3}'`
echo "Created physical network2" $phy_id
$cli add traffictype traffictype=Management physicalnetworkid=$phynet1_id kvmnetworklabel=cloudbr0
echo "Added mgmt traffic"
$cli add traffictype traffictype=Public physicalnetworkid=$phynet1_id kvmnetworklabel=cloudbr1
echo "Added public traffic"
$cli add traffictype traffictype=Storage physicalnetworkid=$phynet1_id kvmnetworklabel=cloudbr0
echo "Added storage traffic"
$cli add traffictype traffictype=Guest physicalnetworkid=$phynet2_id kvmnetworklabel=cloudbr0
echo "Added guest traffic"
$cli update physicalnetwork state=Enabled id=$phynet1_id
echo "Enabled physicalnetwork" $phynet1_id
phynet2_id=`$cli update physicalnetwork state=Enabled id=$phynet2_id | grep ^id\ = | awk '{print $3}'`
echo "Enabled physicalnetwork" $phynet2_id
for phynet_id in $phynet1_id $phynet2_id;
do
guest_nsp_id=`$cli list networkserviceproviders name=VirtualRouter physicalNetworkId=$phynet_id | grep ^id\ = | awk '{print $3}'`
echo "Enabled vr networkserviceprovider" $guest_nsp_id
vpc_nsp_id=`$cli list networkserviceproviders name=VPCVirtualRouter physicalNetworkId=$phynet_id | grep ^id\ = | awk '{print $3}'`
echo "Enabled vpc vr networkserviceprovider" $vpc_nsp_id
for nsp_id in $guest_nsp_id $vpc_nsp_id;
do
echo "configure nsp" $nsp_id
vrelem_id=`$cli list virtualrouterelements nspid=$nsp_id | grep ^id\ = | awk '{print $3}'`
$cli configure virtualrouterelement id=$vrelem_id enabled=true
echo "configured virtualrouterelement" $vrelem_id
done;
$cli update networkserviceprovider id=$guest_nsp_id state=Enabled
$cli update networkserviceprovider id=$vpc_nsp_id state=Enabled
internal_lb_nsp_id=`$cli list networkserviceproviders name=InternalLbVm physicalNetworkId=$phynet2_id | grep ^id\ = | awk '{print $3}'`
echo "Enabled internal lb networkserviceprovider" $internal_lb_nsp_id
internal_lb_elem_id=`$cli list internalloadbalancerelements nspid=$internal_lb_nsp_id | grep ^id\ = | awk '{print $3}'`
$cli configure internalloadbalancerelement id=$internal_lb_elem_id enabled=true
echo "configured internalloadbalancerelement" $internal_lb_elem_id
$cli update networkserviceprovider id=$internal_lb_nsp_id state=Enabled
done;
pod_id=`$cli create pod name=Pod1 zoneid=$zone_id gateway=$system_gw netmask=$system_nmask startip=$pod_start endip=$pod_end | grep ^id\ = | awk '{print $3}'`
echo "Created pod" $pod_id
$cli create vlaniprange zoneid=$zone_id gateway=$gw netmask=$nmask startip=$public_ip_start endip=$public_ip_end forvirtualnetwork=true #vlan=untagged
echo "Created IP ranges for instances"
$cli create storagenetworkiprange podid=$pod_id gateway=$system_gw netmask=$system_nmask startip=$storage_start endip=$storage_end
cluster_id=`$cli add cluster zoneid=$zone_id hypervisor=$hpvr clustertype=CloudManaged podid=$pod_id clustername=Cluster1 | grep ^id\ = | awk '{print $3}'`
echo "Created cluster" $cluster_id
for host_ip in $host_ips;
do
host=`$cli add host zoneid=$zone_id podid=$pod_id clusterid=$cluster_id hypervisor=$hpvr username=$host_user password=$host_passwd url=http://$host_ip`
echo "Added host" $host;
done;
storage_pool_id=`$cli create storagepool zoneid=$zone_id podid=$pod_id clusterid=$cluster_id name=Primary1 provider=nfs url=$prm_storage`
echo "Added primary storage" $storagepool
secondarystorage_id=`$cli add secondarystorage zoneid=$zone_id name=Secondary1 url=$sec_storage | grep ^id\ = | awk '{print $3}'`
echo "Added secondary storage" $secondarystorage_id
$cli update zone allocationstate=Enabled id=$zone_id
echo "Advanced zone deloyment completed!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment