raise CodeError('"%s" on "control %s create %s'
% (err, machine.name, cdtype))
-def createVm(username, state, owner, contact, name, description, memory, disksize, machine_type, cdrom, autoinstall):
+def createVm(username, state, owner, contact, name, description, memory, disksize, machine_type, nic_type, cdrom, autoinstall):
"""Create a VM and put it in the database"""
# put stuff in the table
session.begin()
"Contact %s." % config.contact)
nic.machine = machine
nic.hostname = name
+ nic.nic_type = nic_type
session.add(nic)
session.add(disk)
cache_acls.refreshMachine(machine)
access the serial console of these machines, you can SSH with Kerberos
to %s, using the name of the machine as your
username.""" % config.console.hostname,
+ 'Network Device': """
+While we recommend you use the Intel e1000 NIC, we've provided you the
+option of using the AMD PCnet NIC if you are using an old enough OS
+that doesn't have support for the e1000 NIC.
+""",
'HVM/ParaVM': """
HVM machines use the virtualization features of the processor, while
ParaVM machines rely on a modified kernel to communicate directly with
def parseCreate(self, fields):
kws = dict([(kw, fields[kw]) for kw in
- 'name description owner memory disksize vmtype cdrom autoinstall'.split()
+ 'name description owner memory disksize vmtype cdrom nictype autoinstall'.split()
if fields[kw]])
validate = validation.Validate(cherrypy.request.login,
cherrypy.request.state,
description=validate.description, memory=validate.memory,
disksize=validate.disksize, owner=validate.owner,
machine_type=getattr(validate, 'vmtype', Defaults.type),
+ nic_type=getattr(validate, 'nictype', Defaults.nic),
cdrom=getattr(validate, 'cdrom', None),
autoinstall=getattr(validate, 'autoinstall', None))
description = ''
administrator = ''
type = 'linux-hvm'
+ nic = 'e1000'
def __init__(self, max_memory=None, max_disk=None, **kws):
if max_memory is not None:
nic_fields_template = [('nic%s_hostname', 'NIC %s Hostname'),
('nic%s_mac', 'NIC %s MAC Addr'),
('nic%s_ip', 'NIC %s IP'),
+ ('nic%s_type', 'NIC %s Type'),
]
nic_fields = []
for i in range(len(machine.nics)):
data_dict['nic%s_hostname' % i] = getHostname(machine.nics[i])
data_dict['nic%s_mac' % i] = machine.nics[i].mac_addr
data_dict['nic%s_ip' % i] = machine.nics[i].ip
+ data_dict['nic%s_type' % i] = machine.nics[i].nic_type
if len(machine.nics) == 1:
nic_fields = [(x, y.replace('NIC 0 ', '')) for x, y in nic_fields]
return nic_fields
if hasattr(validate, 'memory'):
machine.memory = validate.memory
+ if hasattr(validate, 'nictype'):
+ for i in range(len(machine.nics)):
+ machine.nics[i] = validate.nictype
+
if hasattr(validate, 'vmtype'):
machine.type = validate.vmtype
for name in 'machine_id name description administrator owner memory contact'.split():
if getattr(machine, name):
setattr(defaults, name, getattr(machine, name))
+ defaults.nic = machine.nics[0].nic_type
defaults.type = machine.type.type_id
defaults.disk = "%0.2f" % (machine.disks[0].size/1024.)
d = dict(user=username,
--- /dev/null
+var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65";
+document.onkeydown = function (e) {
+ kkeys.push(e.keyCode);
+ var idx = kkeys.toString().indexOf( konami );
+ if (idx >= 0 && idx != kkeys.toString().length - konami.length) {
+ kkeys = [];
+ window.location.assign("http://nyan.cat/");
+ }
+};
% endfor
</%def>
+<%def name="nicTypeList(default=None)">
+% for nictype in (('e1000', 'Intel e1000'), ('pcnet', 'AMD PCNet'), ):
+<label>
+ <input ${'checked="checked"' if default == vmtype[0] else '' | n} type="radio" name="nictype" id="nictype-${nictype[0]}" value="${nictype[0]}" />${nictype[1]}
+</label>
+% endfor
+</%def>
+
<%def name="errorRow(value, err)">
% if err and err.err_field == value:
<tr>
% if not on:
<tr><td>Machine Name:</td><td><input type="text" name="name" value="${defaults.name}"/>.${config.dns.domains[0]}</td></tr>
${self.fn.errorRow('name', err)}
+ <tr>
+ <td>Network Device${self.fn.helppopup('Network Device')}</td>
+ <td>
+ ${self.fn.nicTypeList(defaults.nic)}
+ </td>
+ </tr>
+${self.fn.errorRow('nictype', err)}
<tr>
<td>HVM/ParaVM${self.fn.helppopup('HVM/ParaVM')}</td>
<td>${self.fn.vmTypeList(defaults.type)}</td>
</tr>
${self.fn.errorRow('disk', err)}
<tr>
+ <td>Network Device${self.fn.helppopup('Network Device')}</td>
+ <td>
+ ${self.fn.nicTypeList(defaults.nic)}
+ </td>
+ </tr>
+ ${self.fn.errorRow('nictype', err)}
+
+ <tr>
<td>HVM/ParaVM${self.fn.helppopup('HVM/ParaVM')}</td>
<td>
${self.fn.vmTypeList(defaults.type)}
<link href="/static/favicon.ico" type="image/x-icon" rel="shortcut icon">
<link rel="stylesheet" href="/static/style.css" type="text/css" />
<link rel="stylesheet" href="/static/layout.css" type="text/css" media="screen" />
+ <script type="text/javascript" src="/static/nc.js"></script>
<script type="text/javascript" src="/static/prototype.js"></script>
<script type="text/javascript">
var helpWin = null;
class Validate:
def __init__(self, username, state, machine_id=None, name=None, description=None, owner=None,
admin=None, contact=None, memory=None, disksize=None,
- vmtype=None, cdrom=None, autoinstall=None, strict=False):
+ vmtype=None, nictype=None, cdrom=None, autoinstall=None, strict=False):
# XXX Successive quota checks aren't a good idea, since you
# can't necessarily change the locker and disk size at the
# same time.
self.disksize = validDisk(self.owner, state, disksize, machine)
if vmtype is not None:
self.vmtype = validVmType(vmtype)
+ if nictype is not None:
+ self.nictype = validNICType(nictype)
if cdrom is not None:
if not CDROM.query.get(cdrom):
raise CodeError("Invalid cdrom type '%s'" % cdrom)
raise CodeError("Invalid vm type '%s'" % vm_type)
return t
+def validNICType(nic_type):
+ if nic_type is None:
+ return None
+ t = nic_type
+ if not (t is "e1000" or t is "pcnet"):
+ raise CodeError("Invalid nic type '%s'" % nic_type)
+ return t
+
def testMachineId(user, state, machine_id, exists=True):
"""Parse, validate and check authorization for a given user and machine.
+invirt-web (0.1.40) precise; urgency=low
+
+ * Added nc into repo.
+
+ -- Steven Valdez <dvorak42@mit.edu> Tue, 03 Sep 2013 22:32:27 -0400
+
+invirt-web (0.1.39) precise; urgency=low
+
+ * Added NIC radiobox to website.
+
+ -- Steven Valdez <dvorak42@mit.edu> Mon, 26 Aug 2013 18:11:00 -0400
+
invirt-web (0.1.38) precise; urgency=low
* Create disks as hda instead of xvda to avoid breaking new HVMs