elabinelab-xen.ns 8.3 KB
Newer Older
1
#
2
# Copyright (c) 2004-2017 University of Utah and the Flux Group.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
22 23 24 25 26 27 28 29 30
#

#
# This file is intended to be included into another NS file. It is not
# a stand alone file.
# 
set myboss [$ns node]
set myops  [$ns node]

Mike Hibler's avatar
Mike Hibler committed
31 32 33
set srvtype  pcvm
set nodetype pcslow

34 35 36 37
tb-set-node-inner-elab-role $myboss boss+router
tb-set-node-inner-elab-role $myops  ops+fs
tb-set-colocate-factor 2

38 39 40
tb-set-node-failure-action $myboss "nonfatal"
tb-set-node-failure-action $myops  "nonfatal"

41 42 43 44 45
if {[info exists ::TBCOMPAT::elabinelab_hardware("boss")]} {
    namespace eval TBCOMPAT {
        tb-set-hardware $myboss $elabinelab_hardware("boss")
    }
} else {
Mike Hibler's avatar
Mike Hibler committed
46
    tb-set-hardware $myboss $srvtype
47 48 49 50 51 52
}
if {[info exists ::TBCOMPAT::elabinelab_hardware("ops")]} {
    namespace eval TBCOMPAT {
        tb-set-hardware $myops $elabinelab_hardware("ops")
    }
} else {
Mike Hibler's avatar
Mike Hibler committed
53
    tb-set-hardware $myops $srvtype
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
}

if {[info exists ::TBCOMPAT::elabinelab_fixnodes("boss")]} {
    namespace eval TBCOMPAT {
        tb-fix-node $myboss $elabinelab_fixnodes("boss")
    }
}
if {[info exists ::TBCOMPAT::elabinelab_fixnodes("ops")]} {
    namespace eval TBCOMPAT {
        tb-fix-node $myops $elabinelab_fixnodes("ops")
    }
}

# Deal with tarfiles
set myboss_tarfiles ""
set myops_tarfiles  ""

if {${::TBCOMPAT::elabinelab_source_tarfile} != ""} {
    append myboss_tarfiles "/usr/src ${::TBCOMPAT::elabinelab_source_tarfile}"
    append myops_tarfiles  "/usr/src ${::TBCOMPAT::elabinelab_source_tarfile}"
}

if {[info exists ::TBCOMPAT::elabinelab_tarfiles("boss")]} {
    if {$myboss_tarfiles != ""} {
	append myboss_tarfiles " "
    }
    namespace eval TBCOMPAT {
	append myboss_tarfiles $elabinelab_tarfiles("boss")
    }
}
if {[info exists ::TBCOMPAT::elabinelab_tarfiles("ops")]} {
    if {$myops_tarfiles != ""} {
	append myops_tarfiles " "
    }
    namespace eval TBCOMPAT {
	append myops_tarfiles $elabinelab_tarfiles("ops")
    }
}
if {$myboss_tarfiles != ""} {
    tb-set-node-tarfiles $myboss $myboss_tarfiles
}
if {$myops_tarfiles != ""} {
    tb-set-node-tarfiles $myops $myops_tarfiles
}

#
# This is passed in by the parser, when wrapping an existing experiment.
# The parser wrapper gets info about the wrapped experiment and passes it
# along in the TBCOMPAT namespace.
#
if { ${::TBCOMPAT::elabinelab_maxpcs} != 0 } {
    set maxpcs ${::TBCOMPAT::elabinelab_maxpcs}
} else {
    set maxpcs 0
}

set lanstr "myboss myops "
for {set i 1} {$i <= $maxpcs} {incr i} {
	set name "mypc${i}"
	set $name [$ns node]
	append lanstr "[set $name] "
	tb-set-node-inner-elab-role [set $name] node

	if {[info exists ::TBCOMPAT::elabinelab_nodeos($name)]} {
	    namespace eval TBCOMPAT {
        	tb-set-node-os [set $name] $elabinelab_nodeos($name)
	    }
	}

Leigh B Stoller's avatar
Leigh B Stoller committed
123 124 125
	#
	# This does not work! I have no idea why, I hate TCL!
	# 
126 127 128 129 130 131 132 133 134
	if {[info exists ::TBCOMPAT::elabinelab_fixnodes($name)]} {
	    namespace eval TBCOMPAT {
        	tb-fix-node [set $name] $elabinelab_fixnodes($name)
	    }
        } elseif {[info exists ::TBCOMPAT::elabinelab_hardware($name)]} {
	    namespace eval TBCOMPAT {
		tb-set-hardware [set $name] $elabinelab_hardware($name)
	    }
	} else {
Mike Hibler's avatar
Mike Hibler committed
135
	    tb-set-hardware [set $name] $nodetype
136 137 138 139 140 141 142 143 144 145 146 147 148 149
	}
}

if { ${::GLOBALS::elabinelab_singlenet} == 0 } {
    set publiclan [$ns make-lan $lanstr 100Mb 0ms]

    tb-set-ip-lan $myboss $publiclan 10.200.1.252
    tb-set-ip-lan $myops  $publiclan 10.200.1.253
    for {set i 1} {$i <= $maxpcs} {incr i} {
	set name "mypc${i}"
	tb-set-ip-lan [set $name] $publiclan 10.200.1.$i
    }
}

150
set xenos XEN44-64-STD
151 152 153 154 155 156
if {[info exists ::TBCOMPAT::elabinelab_nodeos("xenhost")]} {
    namespace eval TBCOMPAT {
	set xenos $elabinelab_nodeos("xenhost")
    }
}

157 158
if {[info exists ::TBCOMPAT::elabinelab_nodeos("boss")]} {
    namespace eval TBCOMPAT {
159
        tb-set-node-os $myboss $elabinelab_nodeos("boss") $xenos
160 161
    }
} else {
162
    tb-set-node-os $myboss FBSD102-64-STD $xenos
163 164 165 166
}

if {[info exists ::TBCOMPAT::elabinelab_nodeos("ops")]} {
    namespace eval TBCOMPAT {
167
        tb-set-node-os $myops $elabinelab_nodeos("ops") $xenos
168 169
    }
} else {
170
    tb-set-node-os $myops FBSD102-64-STD $xenos
171 172 173 174 175 176 177 178 179
}

#
# Special stuff to set the IP and mask for the xen nodes. Temporary
# until we have a well defined method to assign publically routable
# addresses to containers.
#
set bossip [tb-get-elabinelab-role-attribute "boss" "BOSS_JAILIP"]
if { $bossip != {} } {
180 181 182 183 184 185 186 187 188 189
    set bossipmask [tb-get-elabinelab-role-attribute "boss" "BOSS_JAILIPMASK"]
    if { $bossipmask != {} } {
	$myboss add-attribute "jailip" $bossip
	$myboss add-attribute "jailipmask" $bossipmask
    }
} else {
    set routable [tb-get-elabinelab-role-attribute "boss" "ROUTABLE_IP"]
    if { $routable != {} } {
	$myboss add-attribute "routable_control_ip" "true"
    }
190 191 192
}
set opsip [tb-get-elabinelab-role-attribute "ops" "OPS_JAILIP"]
if { $opsip != {} } {
193 194 195 196 197 198 199 200 201 202
    set opsipmask [tb-get-elabinelab-role-attribute "ops" "OPS_JAILIPMASK"]
    if { $opsipmask != {} } {
	$myops add-attribute "jailip" $opsip
	$myops add-attribute "jailipmask" $opsipmask
    }
} else {
    set routable [tb-get-elabinelab-role-attribute "ops" "ROUTABLE_IP"]
    if { $routable != {} } {
	$myops add-attribute "routable_control_ip" "true"
    }
203 204
}

205 206 207 208 209 210 211 212 213
set bossfw [tb-get-elabinelab-role-attribute "boss" "CONFIG_FIREWALL_BOSS"]
if { $bossfw != {} } {
   $myboss add-attribute XEN_IPFWKERNEL yes
}
set opsfw [tb-get-elabinelab-role-attribute "ops" "CONFIG_FIREWALL_OPS"]
if { $opsfw != {} } {
   $myops add-attribute XEN_IPFWKERNEL yes
}

214 215 216
#
# We need to tell the XEN host to add some disks to the guests. 
#
217 218 219 220 221 222 223 224 225 226 227 228 229
# There is no particular reason to be conservative here. We use only
# dedicated nodes for elabinelab VMs, and at a minimum we should have
# 120GB of disk available.
#
# Boss: 
#  disk1: 10G  (/usr/testbed)
#  disk2: 40G  (/usr/testbed/data, primarily images)
#  disk3: 10G  (/usr/testbed/log)
# Ops:
#  disk1: 10G  (/usr/testbed)
#  disk2: 40G  (/q, including users/proj/groups)
#  disk3: 10G  (/share)
#
230 231 232 233
set bossdisks [tb-get-elabinelab-role-attribute "boss" "XEN_EXTRADISKS"]
if { $bossdisks != {} } {
    $myboss add-attribute XEN_EXTRADISKS $bossdisks
} else {
234
    $myboss add-attribute XEN_EXTRADISKS "disk1:10G,disk2:40G,disk3:10G"
235 236 237 238 239
}
set opsdisks [tb-get-elabinelab-role-attribute "ops" "XEN_EXTRADISKS"]
if { $opsdisks != {} } {
    $myops add-attribute XEN_EXTRADISKS $opsdisks
} else {
240
    $myops add-attribute XEN_EXTRADISKS "disk1:10G,disk2:40G,disk3:10G"
241
}
242

243
#
244 245
# CPUs.
# XXX can only support more than 1 right now with FreeBSD 10.0.
246
#
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
set bosscpus [tb-get-elabinelab-role-attribute "boss" "XEN_CORES"]
if { $bosscpus != {} } {
   $myboss add-attribute XEN_CORES $bosscpus
} else {
   $myboss add-attribute XEN_CORES 1
}
set opscpus [tb-get-elabinelab-role-attribute "ops" "XEN_CORES"]
if { $opscpus != {} } {
   $myops add-attribute XEN_CORES $opscpus
} else {
   $myops add-attribute XEN_CORES 1
}

#
# Memory.
# XXX note default of 1000 rather than 1024 so it maps on pc3000?
#
set bossmem [tb-get-elabinelab-role-attribute "boss" "XEN_MEMSIZE"]
if { $bossmem != {} } {
    $myboss add-attribute XEN_MEMSIZE $bossmem
} else {
    $myboss add-attribute XEN_MEMSIZE 1000
}
set opsmem [tb-get-elabinelab-role-attribute "ops" "XEN_MEMSIZE"]
if { $opsmem != {} } {
    $myops add-attribute XEN_MEMSIZE $opsmem
} else {
    $myops add-attribute XEN_MEMSIZE 1000
}
276

277 278 279 280 281 282 283
#
# Tell ElabinElab setup (rc.mkelab) as well.
#
# XXX The use of specific devices like da2 is not the best approach.
# Note that the FreeBSD guest starts with the root disk on da0 and the
# swap disk on da1. So we start at da2 ...
#
284 285
tb-set-elabinelab-role-attribute "boss" "EXTRADISKS" "da1:/usr/testbed,da2:/usr/testbed/data,da3:/usr/testbed/log"
tb-set-elabinelab-role-attribute "ops"  "EXTRADISKS" "da1:/usr/testbed,da2:/q,da3:/share"