Skip to content

Commit a1dfa0d

Browse files
committed
install.sh: complete deployment but not zone deployment
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 8baf7ac commit a1dfa0d

1 file changed

Lines changed: 49 additions & 6 deletions

File tree

install.sh

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ CS_VERSION=4.18
2929
INTERFACE=
3030
BRIDGE=cloudbr0
3131
HOST_IP=
32+
GATEWAY=
3233

3334
# --- helper functions for logs ---
3435
info()
@@ -69,7 +70,7 @@ warn "Work in progress, try again while this is being hacked"
6970
### Setup Prerequisites ###
7071
info "Installing dependencies"
7172
#apt-get update
72-
apt-get install -y openssh-server sudo vim htop tar bridge-utils
73+
apt-get install -y openssh-server sudo wget jq htop tar nmap bridge-utils
7374

7475
### Setup Bridge ###
7576

@@ -215,14 +216,52 @@ deploy_cloudstack() {
215216
cloudstack-setup-management
216217
}
217218

218-
setup_completed() {
219+
install_completed() {
219220
info "CloudStack installation completed!"
220-
info "Access CloudStack UI at: http://$HOST_IP:8080/client (username: admin, password: password)"
221+
info "Access CloudStack UI at: http://$HOST_IP:8080/client with username 'admin' and password 'password'"
221222
echo
222223
}
223224

224225
deploy_zone() {
225226
info "Deploying CloudStack Zone"
227+
wget -q https://github.com/apache/cloudstack-cloudmonkey/releases/download/6.4.0/cmk.linux.x86-64 -O /usr/bin/cmk > /dev/null
228+
chmod +x /usr/bin/cmk
229+
cmk set username admin
230+
cmk set password password
231+
cmk set display json
232+
cmk sync
233+
234+
zone_id=$(cmk create zone dns1=8.8.8.8 internaldns1=$GATEWAY name=AdvZone1 networktype=Advanced | jq '.zone.id')
235+
info "Created CloudStack Zone with ID $zone_id"
236+
237+
phy_id=$(cmk create physicalnetwork name=cloudbr0 zoneid=$zone_id | jq '.physicalnetwork.id')
238+
cmk add traffictype traffictype=Management physicalnetworkid=$phy_id
239+
cmk add traffictype traffictype=Public physicalnetworkid=$phy_id
240+
cmk add traffictype traffictype=Guest physicalnetworkid=$phy_id
241+
cmk update physicalnetwork state=Enabled id=$phy_id
242+
info "Created CloudStack Physical Network in zone with ID $phy_id"
243+
244+
nsp_id=$(cmk list networkserviceproviders name=VirtualRouter physicalnetworkid=$phy_id | jq -r '.networkserviceprovider[0].id')
245+
vre_id=$(cmk list virtualrouterelements nspid=$nsp_id | jq -r '.virtualrouterelement[0].id')
246+
cmk configure virtualrouterelement enabled=true id=$vre_id
247+
cmk update networkserviceprovider state=Enabled id=$nsp_id
248+
info "Configured VR Network Service Provider for zone"
249+
250+
nsp_id=$(cmk list networkserviceproviders name=Internallbvm physicalnetworkid=$phy_id | jq -r '.networkserviceprovider[0].id')
251+
ilbvm_id=$(cmk list internalloadbalancerelements nspid=$nsp_id | jq -r '.internalloadbalancerelement[0].id')
252+
cmk configure internalloadbalancerelement enabled=true id=$ilbvm_id
253+
cmk update networkserviceprovider state=Enabled id=$nsp_id
254+
info "Configured ILBVM Network Service Provider for zone"
255+
256+
nsp_id=$(cmk list networkserviceproviders name=VpcVirtualRouter physicalnetworkid=$phy_id | jq -r '.networkserviceprovider[0].id')
257+
vpcvre_id=$(cmk list virtualrouterelements nspid=$nsp_id | jq -r '.virtualrouterelement[0].id')
258+
cmk configure virtualrouterelement enabled=true id=$vpcvre_id
259+
cmk update networkserviceprovider state=Enabled id=$nsp_id
260+
info "Configured VPC VR Network Service Provider for zone"
261+
262+
RANGE=$(echo $GATEWAY | sed 's/\..$//g')
263+
264+
pod_id=$(cmk create pod name=AdvPod1 zoneid=$zone_id gateway=$GATEWAY netmask=255.255.255.0 startip=$pod_start endip=$pod_end | jq '.pod.id')
226265
}
227266

228267
display_url() {
@@ -241,7 +280,8 @@ Password: password
241280
### Installer: Setup ###
242281

243282
setup_bridge
244-
HOST_IP=$(ip -f inet addr show $BRIDGE | sed -En -e 's/.*inet ([0-9.]+).*/\1/p')
283+
export HOST_IP=$(ip -f inet addr show $BRIDGE | sed -En -e 's/.*inet ([0-9.]+).*/\1/p')
284+
export GATEWAY=$(ip route show 0.0.0.0/0 dev $BRIDGE | cut -d\ -f3)
245285
info "Bridge $BRIDGE is setup with IP $HOST_IP"
246286

247287
configure_repo
@@ -250,10 +290,13 @@ configure_mysql
250290
configure_storage
251291
configure_host
252292
deploy_cloudstack
253-
setup_completed
293+
294+
install_completed
254295

255296
### Installer: Deploy Zone ###
256297

257-
deploy_zone
298+
#deploy_zone
299+
300+
### Installer: Finish ###
258301

259302
display_url

0 commit comments

Comments
 (0)