Ejemplo n.º 1
0
        public VMControllerByAPI(VMWareInfo.VMCoreTypes type)
        {
            try
            {
                _api = new VixLibClass();
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                throw new VMXServiceException(
                          "Unable to find Vix library!\n" + e.ToString());
            }

            int  core = GetVIXServiceProviderByType(type);
            IJob job  = _api.Connect(
                Constants.VIX_API_VERSION,
                core,
                null, 0, null, null, 0, null, null);

            _host = GetResult <IHost>(WaitForResults(job));
            if (_host == null)
            {
                throw new VMXServiceException("Connecting to VMWare provider was failed.");
            }

            CloseVixObject(job);
        }
Ejemplo n.º 2
0
        public Service(string vmx_file, VMWareInfo.VMCoreTypes vm_target)
            : base()
        {
            SetServiceBehavior();
            _vmx_file = vmx_file;

            try
            {
                if (IsUsingApi)
                {
                    _control = new VMControllerByAPI(vm_target);
                }
                else
                {
                    _control = new VMControllerByVMRun(vm_target);
                }
            }
            catch (VMXServiceException)
            {
                _invalid_state = true;
                WriteLog("Failed To Initialize VMWare controller!", EventLogEntryType.Error);
                return;
            }

            if (!File.Exists(_vmx_file))
            {
                WriteLog("Specified vmx file '{0}' does not exists!", EventLogEntryType.FailureAudit, _vmx_file);
                _invalid_state = true;
                return;
            }

            _timer          = new Timer(TimeSpan.FromSeconds(20).TotalMilliseconds);
            _timer.Elapsed += new ElapsedEventHandler(OnTimerEvent);
            _timer.Enabled  = false;
        }
Ejemplo n.º 3
0
        public VMControllerByVMRun(VMWareInfo.VMCoreTypes type)
        {
            VMWareInfo vm_info = new VMWareInfo();

            _vmware_core = GetTargetNameByType(type);
            _vmrun_path  = vm_info.PathToVMRun;
        }
Ejemplo n.º 4
0
 protected int GetVIXServiceProviderByType(VMWareInfo.VMCoreTypes type)
 {
     if (map_type_to_VIX_SERVICEPROVIDER.ContainsKey(type))
     {
         return(map_type_to_VIX_SERVICEPROVIDER[type]);
     }
     else
     {
         return(map_type_to_VIX_SERVICEPROVIDER[VMWareInfo.VMCoreTypes.UNKNOWN]);
     }
 }
Ejemplo n.º 5
0
 public string GetShortNameByType(VMWareInfo.VMCoreTypes type)
 {
     if (map_type_to_short_name.ContainsKey(type))
     {
         return(map_type_to_short_name[type]);
     }
     else
     {
         return(map_type_to_short_name[VMWareInfo.VMCoreTypes.UNKNOWN]);
     }
 }
Ejemplo n.º 6
0
 protected string GetTargetNameByType(VMWareInfo.VMCoreTypes type)
 {
     if (map_type_to_target.ContainsKey(type))
     {
         return(map_type_to_target[type]);
     }
     else
     {
         return(map_type_to_target[VMWareInfo.VMCoreTypes.UNKNOWN]);
     }
 }