Ejemplo n.º 1
0
        /// <summary>
        /// Creates a host handle
        /// </summary>
        /// <returns>true if succeeded, otherwise false</returns>
        public bool Connect(string hostName, string userName, string password)
        {
            int hostType = string.IsNullOrEmpty(hostName) ?
                           VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_WORKSTATION :
                           VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_SERVER;

            int vixVersion = VixCOM.Constants.VIX_API_VERSION;

            vixVersion = 1; // Bugfix: http://communities.vmware.com/message/649925#649925

            //VixCOM.IJob jobHandle = vixLib.Connect(vixVersion, hostType, hostName, 0, userName, password, 0, null,  null);

            // for use with player: http://www.vmware.com/pdf/vix180_player_technote.pdf
            VixCOM.IJob jobHandle = vixLib.Connect(VixCOM.Constants.VIX_API_VERSION, VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_PLAYER, null, 0, null, null, VixCOM.Constants.VIX_INVALID_HANDLE, null, null);

            int[] propertyIds = new int[1] {
                VixCOM.Constants.VIX_PROPERTY_JOB_RESULT_HANDLE
            };
            object results = new object();

            m_vixError = jobHandle.Wait(propertyIds, ref results);

            if (m_vixError == VixCOM.Constants.VIX_OK)
            {
                object[] objectArray = (object[])results;
                m_hostHandle = (VixCOM.IHost)objectArray[0];
                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
0
        public void OpenVM(string path)
        {
            object results = null;

            VixCOM.IJob job = _vmwareHost.OpenVM(path, null);
            UInt64      err = job.Wait(new int[] { VixCOM.Constants.VIX_PROPERTY_JOB_RESULT_HANDLE }, ref results);

            if (lib.ErrorIndicatesFailure(err))
            {
                short  errCode = lib.ErrorCode(err);
                string errMsg;
                errMsg = lib.GetErrorText(err, null);

                throw new Exception("OpenVM:" + errMsg);
            }

            _virtualMachine = (VixCOM.IVM)((object[])results)[0];
        }
Ejemplo n.º 3
0
        public void Connect()
        {
            object results = null;

            VixCOM.IJob job  = lib.Connect(VixCOM.Constants.VIX_API_VERSION, VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_WORKSTATION, "", 0, "", "", 0, null, null);
            object[]    data = { VixCOM.Constants.VIX_PROPERTY_JOB_RESULT_HANDLE };
            UInt64      err  = job.Wait(new int[] { VixCOM.Constants.VIX_PROPERTY_JOB_RESULT_HANDLE }, ref results);

            if (lib.ErrorIndicatesFailure(err))
            {
                short  errCode = lib.ErrorCode(err);
                string errMsg;
                errMsg = lib.GetErrorText(err, null);

                throw new Exception("Connect: " + errMsg);
            }

            _vmwareHost = (VixCOM.IHost)((object[])results)[0];
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a host handle
        /// </summary>
        /// <returns>true if succeeded, otherwise false</returns>
        public bool Connect(string hostName, string userName, string password, int serviceProvider)
        {
            int hostType = -1;

            // Edited by Mitchell Lutz
            if (serviceProvider == 1)
            {
                hostType = VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_WORKSTATION;
            }
            else if (serviceProvider == 2)
            {
                hostType = VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_SERVER;
            }
            //int hostType = string.IsNullOrEmpty(hostName) ?
            //    VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_WORKSTATION :
            //    VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_SERVER;

            int vixVersion = VixCOM.Constants.VIX_API_VERSION;

            vixVersion = 1; // Bugfix: http://communities.vmware.com/message/649925#649925

            VixCOM.IJob jobHandle = vixLib.Connect(vixVersion,
                                                   hostType, hostName, 0, userName, password, 0, null, null);

            int[] propertyIds = new int[1] {
                VixCOM.Constants.VIX_PROPERTY_JOB_RESULT_HANDLE
            };
            object results = new object();

            m_vixError = jobHandle.Wait(propertyIds, ref results);

            if (m_vixError == VixCOM.Constants.VIX_OK)
            {
                object[] objectArray = (object[])results;
                m_hostHandle = (VixCOM.IHost)objectArray[0];
                return(true);
            }

            return(false);
        }