Package VMBuilder :: Package plugins :: Package vmware :: Module vm
[frames] | no frames]

Source Code for Module VMBuilder.plugins.vmware.vm

 1  # 
 2  #    Uncomplicated VM Builder 
 3  #    Copyright (C) 2007-2008 Canonical Ltd. 
 4  #     
 5  #    See AUTHORS for list of contributors 
 6  # 
 7  #    This program is free software: you can redistribute it and/or modify 
 8  #    it under the terms of the GNU General Public License as published by 
 9  #    the Free Software Foundation, either version 3 of the License, or 
10  #    (at your option) any later version. 
11  # 
12  #    This program is distributed in the hope that it will be useful, 
13  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
14  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
15  #    GNU General Public License for more details. 
16  # 
17  #    You should have received a copy of the GNU General Public License 
18  #    along with this program.  If not, see <http://www.gnu.org/licenses/>. 
19  # 
20  from   VMBuilder import register_hypervisor, Hypervisor 
21  import VMBuilder 
22  import VMBuilder.hypervisor 
23  import os 
24  import os.path 
25  import stat 
26   
27 -class VMWare(Hypervisor):
28 filetype = 'vmdk' 29 preferred_storage = VMBuilder.hypervisor.STORAGE_DISK_IMAGE 30 needs_bootloader = True 31
32 - def finalize(self):
33 self.imgs = [] 34 for disk in self.vm.disks: 35 img_path = disk.convert(self.vm.destdir, self.filetype) 36 self.imgs.append(img_path) 37 self.vm.result_files.append(img_path)
38
39 - def deploy(self):
40 vmdesc = VMBuilder.util.render_template('vmware', self.vm, 'vmware', { 'vmhwversion' : self.vmhwversion, 'mem' : self.vm.mem, 'hostname' : self.vm.hostname, 'arch' : self.vm.arch, 'guestos' : (self.vm.arch == 'amd64' and 'ubuntu-64' or 'ubuntu') }) 41 42 vmx = '%s/%s.vmx' % (self.vm.destdir, self.vm.hostname) 43 fp = open(vmx, 'w') 44 fp.write(vmdesc) 45 fp.close() 46 os.chmod(vmx, stat.S_IRWXU | stat.S_IRWXU | stat.S_IROTH | stat.S_IXOTH) 47 self.vm.result_files.append(vmx)
48
49 -class VMWareWorkstation6(VMWare):
50 name = 'VMWare Workstation 6' 51 arg = 'vmw6' 52 vmhwversion = 6
53
54 -class VMWareServer(VMWare):
55 name = 'VMWare Server' 56 arg = 'vmserver' 57 vmhwversion = 4
58 59 register_hypervisor(VMWareServer) 60 register_hypervisor(VMWareWorkstation6) 61