示例#1
0
        protected override void Run()
        {
            if (_vbdMode != _vbd.mode)
            {
                VBD.set_mode(Session, _vbd.opaque_ref, _vbdMode);
            }

            if (_priority != _vbd.GetIoNice())
            {
                _vbd.SetIoNice(_priority);
                VBD.set_qos_algorithm_params(Session, _vbd.opaque_ref, _vbd.qos_algorithm_params);
            }

            if (!_changeDevicePosition)
            {
                return;
            }

            if (_other != null)
            {
                // We're going to have to do a swap

                SetUserDevice(Session, VM, _other, _vbd.userdevice, false);
                SetUserDevice(Session, VM, _vbd, _devicePosition, true);

                if (VM.power_state == vm_power_state.Running && _other.allowed_operations.Contains(vbd_operations.plug))
                {
                    VBD.plug(Session, _other.opaque_ref);
                }
            }
            else
            {
                SetUserDevice(Session, VM, _vbd, _devicePosition, false);
            }
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="session"></param>
        /// <param name="vm"></param>
        /// <param name="vbd"></param>
        /// <param name="userdevice"></param>
        /// <param name="plug"></param>
        /// <returns>True if it warned the user, so you don't warn twice</returns>
        private static void SetUserDevice(Session session, VM vm, VBD vbd, String userdevice, bool plug)
        {
            //Program.AssertOffEventThread();


            if (vm.power_state == vm_power_state.Running &&
                vbd.currently_attached &&
                vbd.allowed_operations.Contains(vbd_operations.unplug))
            {
                VBD.unplug(session, vbd.opaque_ref);
            }

            VBD.set_userdevice(session, vbd.opaque_ref, userdevice);

            if (plug && vbd.allowed_operations.Contains(vbd_operations.plug) && vm.power_state == vm_power_state.Running)
            {
                VBD.plug(session, vbd.opaque_ref);
            }
        }
示例#3
0
        private AsyncAction getActivateVBDAction(VBD vbd)
        {
            VDI    vdi       = vbd.Connection.Resolve <VDI>(vbd.VDI);
            VM     vm        = vbd.Connection.Resolve <VM>(vbd.VM);
            String title     = String.Format(Messages.ACTION_DISK_ACTIVATING_TITLE, vdi.Name(), vm.Name());
            String startDesc = Messages.ACTION_DISK_ACTIVATING;
            String endDesc   = Messages.ACTION_DISK_ACTIVATED;

            AsyncAction action = new DelegatedAsyncAction(vbd.Connection,
                                                          title, startDesc, endDesc, session => VBD.plug(session, vbd.opaque_ref), "vbd.plug");

            action.VM = vm;
            return(action);
        }