'network': self.context.get_setting('network'), 'mac': self.context.get_setting('mac'), 'virtio_net': self.context.distro.use_virtio_net(), 'virtio_disk': self.context.distro.use_virtio_disk(), 'disks': self.context.disks, 'filesystems': self.context.filesystems, 'hostname': hostname, 'domain_type': self.context.libvirt_domain_type_name(), 'kernel': self.context.get_setting('kernel'), 'kernelopts': self.context.get_setting('kernelopts'), 'initrd': self.context.get_setting('initrd') } if self.context.preferred_storage == VMBuilder.hypervisor.STORAGE_FS_IMAGE: vmxml = VMBuilder.util.render_template('libvirt', self.context, 'libvirtxml_fsimage', tmpl_ctxt) else: vmxml = VMBuilder.util.render_template('libvirt', self.context, 'libvirtxml', tmpl_ctxt) if hostname in self.all_domains() and not self.context.overwrite: raise VMBuilderUserError('Domain %s already exists at %s' % (hostname, libvirt_uri)) else: self.conn.defineXML(vmxml) return True register_hypervisor_plugin(Libvirt)
hostname = self.context.distro.get_setting('hostname') tmpl_ctxt = { 'mem': self.context.get_setting('mem'), 'cpus': self.context.get_setting('cpus'), 'bridge' : self.context.get_setting('bridge'), 'mac' : self.context.get_setting('mac'), 'network' : self.context.get_setting('network'), 'mac' : self.context.get_setting('mac'), 'virtio_net' : self.context.distro.use_virtio_net(), 'virtio_disk' : self.context.distro.use_virtio_disk(), 'disks' : self.context.disks, 'filesystems' : self.context.filesystems, 'hostname' : hostname, 'domain_type' : self.context.libvirt_domain_type_name(), 'kernel': self.context.get_setting('kernel'), 'kernelopts': self.context.get_setting('kernelopts'), 'initrd': self.context.get_setting('initrd') } if self.context.preferred_storage == VMBuilder.hypervisor.STORAGE_FS_IMAGE: vmxml = VMBuilder.util.render_template('libvirt', self.context, 'libvirtxml_fsimage', tmpl_ctxt) else: vmxml = VMBuilder.util.render_template('libvirt', self.context, 'libvirtxml', tmpl_ctxt) if hostname in self.all_domains() and not self.context.overwrite: raise VMBuilderUserError('Domain %s already exists at %s' % (hostname, libvirt_uri)) else: self.conn.defineXML(vmxml) return True register_hypervisor_plugin(Libvirt)
if len(nics) > 0: nic = nics[0] ip = self.get_setting('ip') if ip == 'dhcp': nic.type = 'dhcp' else: nic.type = 'static' nic.ip = ip nic.network = self.context.get_setting('net') nic.netmask = self.context.get_setting('mask') nic.broadcast = self.context.get_setting('bcast') nic.gateway = self.context.get_setting('gw') nic.dns = self.context.get_setting('dns') ip6 = self.get_setting('ip6') if ip6 == 'dhcp': nic.type6 = 'dhcp' elif ip6 is None or ip6 == 'none': nic.type6 = 'none' else: nic.type6 = 'static' nic.ip6 = ip6 nic.gateway6 = self.context.get_setting('gw6') logging.debug("type6: %s" % nic.type6) logging.debug("ip6: %s" % nic.ip6) logging.debug("gw6: %s" % nic.gateway6) register_distro_plugin(NetworkDistroPlugin) register_hypervisor_plugin(NetworkHypervisorPlugin)