OpenSecurity/bin/vmmanager.py
changeset 33 79ed9495fa88
parent 26 0b784719a211
child 35 ba1ca3e5870b
     1.1 --- a/OpenSecurity/bin/vmmanager.py	Fri Dec 06 14:32:35 2013 +0100
     1.2 +++ b/OpenSecurity/bin/vmmanager.py	Tue Dec 10 13:50:13 2013 +0100
     1.3 @@ -42,12 +42,25 @@
     1.4      cygwin_path = 'c:\\cygwin64\\bin\\'
     1.5      vboxManage = 'VBoxManage'
     1.6      
     1.7 +    _instance = None
     1.8 +    #def __new__(cls, *args, **kwargs):
     1.9 +    #    if not cls._instance:
    1.10 +    #        cls._instance = super(VMManager, cls).__new__(cls, *args, **kwargs)
    1.11 +    #    return cls._instance
    1.12 +    
    1.13      def __init__(self):
    1.14          self.cygwin_path = os.path.join(Cygwin.root(), 'bin')
    1.15          self.vboxManage = os.path.join(self.getVBoxManagePath(), 'VBoxManage')
    1.16          self.systemProperties = self.getSystemProperties()
    1.17          return
    1.18 -         
    1.19 +    
    1.20 +    #@classmethod
    1.21 +    @staticmethod
    1.22 +    def getInstance():
    1.23 +        if VMManager._instance == None:
    1.24 +            VMManager._instance = VMManager()
    1.25 +        return VMManager._instance
    1.26 +             
    1.27      def execute(self, cmd):
    1.28          if DEBUG:
    1.29              print('trying to launch: ' + cmd)
    1.30 @@ -117,7 +130,7 @@
    1.31                                          re.search(r"\((?P<rev>[0-9A-Fa-f]+)\)", props['Revision']).groupdict()['rev'] )
    1.32                  rsds[props['UUID']] = usb_filter;
    1.33                  if DEBUG:
    1.34 -                    print filter
    1.35 +                    print usb_filter
    1.36          return rsds
    1.37  
    1.38      # list all existing VMs registered with VBox
    1.39 @@ -162,11 +175,11 @@
    1.40          #self.execute(cmd)
    1.41          #cmd = 'vboxmanage hostonlyif create'
    1.42          #self.execute(cmd)
    1.43 -        cmd = 'vboxmanage hostonlyif ipconfig \"VirtualBox Host-Only Ethernet Adapter\" --ip 192.168.56.1 --netmask 255.255.255.0'
    1.44 +        cmd = 'VBoxManage hostonlyif ipconfig \"VirtualBox Host-Only Ethernet Adapter\" --ip 192.168.56.1 --netmask 255.255.255.0'
    1.45          self.execute(cmd)
    1.46          #cmd = 'vboxmanage dhcpserver add'
    1.47          #self.execute(cmd)
    1.48 -        cmd = 'vboxmanage dhcpserver modify --ifname \"VirtualBox Host-Only Ethernet Adapter\" --ip 192.168.56.1 --netmask 255.255.255.0 --lowerip 192.168.56.100 --upperip 192.168.56.255'
    1.49 +        cmd = 'VBoxManage dhcpserver modify --ifname \"VirtualBox Host-Only Ethernet Adapter\" --ip 192.168.56.100 --netmask 255.255.255.0 --lowerip 192.168.56.101 --upperip 192.168.56.200'
    1.50          self.execute(cmd)
    1.51      
    1.52      #create new virtual machine instance based on template vm named SecurityDVM (\SecurityDVM\SecurityDVM.vmdk)
    1.53 @@ -319,23 +332,20 @@
    1.54          return self.execute(cmd)
    1.55          
    1.56      
    1.57 -if __name__ == '__main__':
    1.58 -    man = VMManager()
    1.59 -    man.cygwin_path = 'c:\\cygwin64\\bin\\'
    1.60 +#if __name__ == '__main__':
    1.61 +    #man = VMManager()
    1.62 +    #man.cygwin_path = 'c:\\cygwin64\\bin\\'
    1.63      #man.handleDeviceChange()
    1.64      #print man.listSDVM()
    1.65      #man.configureHostNetworking()
    1.66 -    new_vm = man.generateSDVMName()
    1.67 -    man.createVM(new_vm)
    1.68 -    man.genCertificateISO(new_vm)
    1.69 -    man.attachCertificateISO(new_vm)
    1.70 +    #new_vm = man.generateSDVMName()
    1.71 +    #man.createVM(new_vm)
    1.72 +    #man.genCertificateISO(new_vm)
    1.73 +    #man.attachCertificateISO(new_vm)
    1.74      
    1.75      #man.attachCertificateISO(vm_name)
    1.76      #man.sshGuestExecute(vm_name, "ls")
    1.77      #man.sshGuestX11Execute(vm_name, "iceweasel")
    1.78      #cmd = "c:\\cygwin64\\bin\\bash.exe --login -c \"/bin/ls\""
    1.79      #man.execute(cmd)
    1.80 -    
    1.81 -    
    1.82 -
    1.83 -    
    1.84 +    
    1.85 \ No newline at end of file