当前位置: 首页>>代码示例>>C#>>正文


C# XenRef类代码示例

本文整理汇总了C#中XenRef的典型用法代码示例。如果您正苦于以下问题:C# XenRef类的具体用法?C# XenRef怎么用?C# XenRef使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


XenRef类属于命名空间,在下文中一共展示了XenRef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        protected override void Run()
        {
            try
            {
                Description = string.Format(Messages.ARCHIVING_SNAPSHOT_X, _snapshot.Name);
                RelatedTask=new XenRef<Task>(VMPP.archive_now(Session, _snapshot.opaque_ref));
                PollToCompletion();
                Description = string.Format(Messages.ARCHIVED_SNAPSHOT_X, _snapshot.Name);
            }
            catch (Exception e)
            {
                Failure f = e as Failure;
                if (f != null)
                {
                    string msg = "";
                    if (f.ErrorDescription.Count > 3)
                    {
                        msg = XenAPI.Message.FriendlyName(f.ErrorDescription[3]);
                    }

                    throw new Exception(msg);

                }
                throw;
            }
        }
开发者ID:huizh,项目名称:xenadmin,代码行数:26,代码来源:ArchiveNowAction.cs

示例2: EvacuateHostPlanAction

 public EvacuateHostPlanAction(Host host)
     : base(host.Connection, string.Format(Messages.PLANACTION_VMS_MIGRATING, host.Name))
 {
     base.TitlePlan = string.Format(Messages.MIGRATE_VMS_OFF_SERVER, host.Name);
     this._host = new XenRef<Host>(host);
     currentHost = host;
 }
开发者ID:huizh,项目名称:xenadmin,代码行数:7,代码来源:EvacuateHostPlanAction.cs

示例3: BringBabiesBackAction

 public BringBabiesBackAction(List<XenRef<VM>> vms, Host host,bool enableOnly)
     : base(host.Connection, string.Format(Messages.UPDATES_WIZARD_EXITING_MAINTENANCE_MODE,host.Name))
 {
     base.TitlePlan = string.Format(Messages.EXIT_SERVER_FROM_MAINTENANCE_MODE,host.Name);
     this._host = new XenRef<Host>(host);
     this._vms = vms;
     this._enableOnly = enableOnly;
     currentHost = host;
 }
开发者ID:ChrisH4rding,项目名称:xenadmin,代码行数:9,代码来源:BringBabiesBackAction.cs

示例4: MeddlingAction

 public MeddlingAction(Task task)
     : base(ActionType.Meddling, task.MeddlingActionTitle ?? task.Title, task.Description, false, false)
 {
     RelatedTask = new XenRef<Task>(task.opaque_ref);
     Started = (task.created + task.Connection.ServerTimeOffset).ToLocalTime();
     SetAppliesToData(task);
     VM = VMFromAppliesTo(task);
     Connection = task.Connection;
     Update(task, false);
 }
开发者ID:ChrisH4rding,项目名称:xenadmin,代码行数:10,代码来源:MeddlingAction.cs

示例5: Run

 protected override void Run()
 {
     Description = string.Format(Messages.CREATING_VM_APPLIANCE, _record.Name);
     RelatedTask = VM_appliance.async_create(Session, _record);
     PollToCompletion();
     var vmApplianceRef = new XenRef<VM_appliance>(Result);
     Connection.WaitForCache(vmApplianceRef);
     foreach (var selectedVM in _vms)
     {
         VM.set_appliance(Session, selectedVM.opaque_ref, vmApplianceRef.opaque_ref);
     }
     Description = string.Format(Messages.CREATED_VM_APPLIANCE, _record.Name);
     PercentComplete = 100;
 }
开发者ID:huizh,项目名称:xenadmin,代码行数:14,代码来源:CreateVMApplianceAction.cs

示例6: MeddlingAction

        public MeddlingAction(Task task)
            : base(task.MeddlingActionTitle ?? task.Title, task.Description, false, false)
        {
            RelatedTask = new XenRef<Task>(task.opaque_ref);

            this.Host = task.Connection.Resolve(task.resident_on);

            if (this.Host == null)
                this.Host = Helpers.GetMaster(task.Connection);

            Started = (task.created + task.Connection.ServerTimeOffset).ToLocalTime();
            SetAppliesToData(task);
            VM = VMFromAppliesTo(task);
            Connection = task.Connection;
            Update(task, false);
        }
开发者ID:robhoes,项目名称:xenadmin,代码行数:16,代码来源:MeddlingAction.cs

示例7: Run

 protected override void Run()
 {
     Description = string.Format(Messages.CREATING_VMPP, _record.Name);
     RelatedTask = VMPP.async_create(Session, _record);
     PollToCompletion();
     var vmppref = new XenRef<VMPP>(Result);
     Connection.WaitForCache(vmppref);
     foreach (var selectedVM in _vms)
     {
         VM.set_protection_policy(Session, selectedVM.opaque_ref, vmppref.opaque_ref);
     }
     Description = string.Format(Messages.CREATED_VMPP, _record.Name);
     PercentComplete = 60;
     if (_runNow)
         VMPP.protect_now(Session, vmppref);
     PercentComplete = 100;
 }
开发者ID:huizh,项目名称:xenadmin,代码行数:17,代码来源:CreateVMPP.cs

示例8: LoadPoolMetadata

        private void LoadPoolMetadata(VDI vdi)
        {
            Session metadataSession = null;
            try
            {
                VdiLoadMetadataAction action = new VdiLoadMetadataAction(Connection, vdi);
                ActionProgressDialog dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee);
                dialog.ShowDialog(this); //Will block until dialog closes, action completed

                if (action.Succeeded && action.MetadataSession != null)
                {
                    metadataSession = action.MetadataSession;
                    XenRef<VDI> vdiRef = new XenRef<VDI>(vdi);
                    if (action.PoolMetadata != null && !allPoolMetadata.ContainsKey(vdiRef))
                    {
                        allPoolMetadata.Add(vdiRef, action.PoolMetadata);
                    }
                }

            }
            finally
            {
                if (metadataSession != null)
                    metadataSession.logout();
            }
        }
开发者ID:huizh,项目名称:xenadmin,代码行数:26,代码来源:DRFailoverWizardStoragePage.cs

示例9: PollTaskForResult

        private static String PollTaskForResult(IXenConnection connection, ref Session session,
            HTTP.FuncBool cancellingDelegate, XenRef<Task> task)
        {
            //Program.AssertOffEventThread();

            task_status_type status;

            do
            {
                if (cancellingDelegate != null && cancellingDelegate())
                    throw new XenAdmin.CancelledException();

                System.Threading.Thread.Sleep(500);

                status = (task_status_type)Task.DoWithSessionRetry(connection, ref session,
                    (Task.TaskStatusOp)Task.get_status, task.opaque_ref);
            }
            while (status == task_status_type.pending || status == task_status_type.cancelling);

            if (cancellingDelegate != null && cancellingDelegate())
                throw new XenAdmin.CancelledException();

            if (status == task_status_type.failure)
            {
                throw new Failure(Task.get_error_info(session, task));
            }
            else
            {
                return Task.get_result(session, task);
            }
        }
开发者ID:ChrisH4rding,项目名称:xenadmin,代码行数:31,代码来源:HTTPHelper.cs

示例10: Run

        protected override void Run()
        {
            log.Debug("Running SR Reconfigure Action");
            log.DebugFormat("SR uuid = '{0}'", sr.uuid);
            log.DebugFormat("name = '{0}'", name);
            log.DebugFormat("description = '{0}'", description);

            Description = Messages.ACTION_SR_ATTACHING;

            // Repair the SR with new PBDs for each host in the pool
            PBD pbdTemplate = new PBD();
            pbdTemplate.currently_attached = false;
            pbdTemplate.device_config = dconf;
            pbdTemplate.SR = new XenRef<SR>(sr.opaque_ref);

            int delta = 100 / (Connection.Cache.HostCount * 2);
            foreach (Host host in Connection.Cache.Hosts)
            {
                // Create the PBD
                log.DebugFormat("Creating PBD for host {0}", host.Name);
                this.Description = String.Format(Messages.ACTION_SR_REPAIR_CREATE_PBD, Helpers.GetName(host));
                pbdTemplate.host = new XenRef<Host>(host.opaque_ref);
                RelatedTask = PBD.async_create(this.Session, pbdTemplate);
                PollToCompletion(PercentComplete, PercentComplete + delta);
                XenRef<PBD> pbdRef = new XenRef<PBD>(this.Result);

                // Now plug the PBD
                log.DebugFormat("Plugging PBD for host {0}", host.Name);
                this.Description = String.Format(Messages.ACTION_SR_REPAIR_PLUGGING_PBD, Helpers.GetName(host));
                RelatedTask = PBD.async_plug(this.Session, pbdRef);
                PollToCompletion(PercentComplete, PercentComplete + delta);
            }

            // Update the name and description of the SR
            XenAPI.SR.set_name_label(Session, sr.opaque_ref, name);
            XenAPI.SR.set_name_description(Session, sr.opaque_ref, description);

            Description = Messages.ACTION_SR_ATTACH_SUCCESSFUL;
        }
开发者ID:ushamandya,项目名称:xenadmin,代码行数:39,代码来源:SrReattachAction.cs

示例11: Process

        public void Process(Session xenSession, EnvelopeType ovfObj, string pathToOvf, string passcode)
        {
            if (xenSession == null)
                throw new InvalidOperationException(Messages.ERROR_NOT_CONNECTED);

            string ovfname = Guid.NewGuid().ToString();

            vifDeviceIndex = 0;
            string encryptionVersion = null;

            #region CHECK ENCRYPTION
            if (OVF.HasEncryption(ovfObj))
            {
                if (passcode == null)
                {
                    throw new InvalidDataException(Messages.ERROR_NO_PASSWORD);
                }
                string fileuuids = null;
                SecuritySection_Type[] securitysection = OVF.FindSections<SecuritySection_Type>((ovfObj).Sections);
                if (securitysection != null && securitysection.Length >= 0)
                {
                    foreach (Security_Type securitytype in securitysection[0].Security)
                    {
                        if (securitytype.ReferenceList.Items != null && securitytype.ReferenceList.Items.Length > 0)
                        {
                            foreach (XenOvf.Definitions.XENC.ReferenceType dataref in securitytype.ReferenceList.Items)
                            {
                                if (dataref is DataReference)
                                {
                                    fileuuids += ":" + ((DataReference)dataref).ValueType;
                                }
                            }
                        }
                        if (securitytype.EncryptionMethod != null && securitytype.EncryptionMethod.Algorithm != null)
                        {
                            string algoname = (securitytype.EncryptionMethod.Algorithm.Split(new char[] { '#' }))[1].ToLower().Replace('-', '_');
                            object x = OVF.AlgorithmMap(algoname);
                            if (x != null)
                            {
                                EncryptionClass = (string)x;
                                EncryptionKeySize = Convert.ToInt32(securitytype.EncryptionMethod.KeySize);
                            }
                        }

                        if (!string.IsNullOrEmpty(securitytype.version))
                        {
                            encryptionVersion = securitytype.version;
                        }
                    }
                }
            }
            #endregion

            #region FIND DEFAULT SR
            Dictionary<XenRef<Pool>, Pool> pools = Pool.get_all_records(xenSession);
            foreach (XenRef<Pool> pool in pools.Keys)
            {
                DefaultSRUUID = pools[pool].default_SR;
                break;
            }
            #endregion

            //
            // So the process is the same below, change this
            //
            if (ovfObj.Item is VirtualSystem_Type)
            {
                VirtualSystem_Type vstemp = (VirtualSystem_Type)ovfObj.Item;
                ovfObj.Item = new VirtualSystemCollection_Type();
                ((VirtualSystemCollection_Type)ovfObj.Item).Content = new Content_Type[] { vstemp };
            }

            #region Create appliance

            XenRef<VM_appliance> applRef = null;
            if (ApplianceName != null)
            {
                var vmAppliance = new VM_appliance {name_label = ApplianceName, Connection = xenSession.Connection};
                applRef = VM_appliance.create(xenSession, vmAppliance);
            }

            #endregion

            foreach (VirtualSystem_Type vSystem in ((VirtualSystemCollection_Type)ovfObj.Item).Content)
            {
               //FIND/SET THE NAME OF THE VM
                ovfname = OVF.FindSystemName(ovfObj, vSystem.id);
                auditLog.DebugFormat("Import: {0}, {1}", ovfname, pathToOvf);

                VirtualHardwareSection_Type vhs = OVF.FindVirtualHardwareSectionByAffinity(ovfObj, vSystem.id, "xen");

                XenRef<VM> vmRef = DefineSystem(xenSession, vhs, ovfname);
                if (vmRef == null)
                {
                    log.Error(Messages.ERROR_CREATE_VM_FAILED);
                    throw new ImportException(Messages.ERROR_CREATE_VM_FAILED);
                }

                HideSystem(xenSession, vmRef);
                log.DebugFormat("OVF.Import.Process: DefineSystem completed ({0})", VM.get_name_label(xenSession, vmRef));
//.........这里部分代码省略.........
开发者ID:ushamandya,项目名称:xenadmin,代码行数:101,代码来源:Import.cs

示例12: AddResourceSettingData

        private void AddResourceSettingData(Session xenSession, XenRef<VM> vmRef, RASD_Type rasd, string pathToOvf, string filename, string compression, string version, string passcode)
        {
            switch (rasd.ResourceType.Value)
            {
                case 3: // Processor: Already set in DefineSystem
                case 4: // Memory: Already set in DefineSystem
                case 5: // Internal Disk Controller of one type or another.
                case 6:
                case 7:
                case 8:
                case 9:
                    {
                        // For Xen really nothing to do here, does not support the different
                        // controller types, therefore we must ensure
                        // via positional on controllers.
                        // IDE - #1
                        // SCSI - #2
                        // IDE 0 Disk  0 Goes to Xen: userdevice=0
                        // IDE 0 Disk  1 Goes to Xen: userdevice=1
                        // IDE 1 Disk  0 Goes to Xen: userdevice=2
                        // IDE 1 CDDVD 1 Goes to Xen: userdevice=3
                        // SCSI 0 Disk 0 Goes to Xen: userdevice=4
                        // SCSI 0 Disk 1 Goes to Xen: userdevice=5
                        // and so forth.
                        break;
                    }
                case 10: // Network
                    {
                        XenRef<Network> net = null;
                        XenRef<Network> netDefault = null;
                        string netuuid = null;

                        #region SELECT NETWORK
                        Dictionary<XenRef<Network>, Network> networks = Network.get_all_records(xenSession);
                        if (rasd.Connection != null && rasd.Connection.Length > 0)
                        {
                            if (!string.IsNullOrEmpty(rasd.Connection[0].Value))
                            {
                                // Ignore the NetworkSection/Network
                                // During Network Selection the UUID for Network was set in Connection Field
                                // Makes data self contained here.

                                if (rasd.Connection[0].Value.Contains(Properties.Settings.Default.xenNetworkKey) ||
                                    rasd.Connection[0].Value.Contains(Properties.Settings.Default.xenNetworkUuidKey))
                                {
                                    string[] s = rasd.Connection[0].Value.Split(new char[] { ',' });
                                    for (int i = 0; i < s.Length; i++)
                                    {
                                        if (s[i].StartsWith(Properties.Settings.Default.xenNetworkKey) ||
                                            s[i].StartsWith(Properties.Settings.Default.xenNetworkUuidKey))
                                        {
                                            string[] s1 = s[i].Split(new char[] { '=' } );
                                            netuuid = s1[1];
                                        }
                                    }
                                }
                                foreach (XenRef<Network> netRef in networks.Keys)
                                {
                                    // if its a UUID and we find it... use it..
                                    if (net == null && netuuid != null &&
                                        netuuid.Equals(networks[netRef].uuid))
                                    {
                                        net = netRef;
                                    }
                                    // Ok second is to match it as a NAME_LABEL
                                    else if (net == null && netuuid != null &&
                                        networks[netRef].name_label.ToLower().Contains(netuuid))
                                    {
                                        net = netRef;
                                    }
                                    // hhmm neither... is it a BRIDGE name?
                                    else if (net == null && netuuid != null &&
                                        networks[netRef].bridge.ToLower().Contains(netuuid))
                                    {
                                        net = netRef;
                                    }
                                    // ok find the default.
                                    if (networks[netRef].bridge.ToLower().Contains(Properties.Settings.Default.xenDefaultNetwork))
                                    {
                                        netDefault = netRef;
                                    }
                                }
                                if (net == null)
                                {
                                    net = netDefault;
                                }
                            }
                        }
                        #endregion

                        #region ATTACH NETWORK TO VM
                        Hashtable vifHash = new Hashtable();
                        // This is MAC address if available use it.
                        // needs to be in form:  00:00:00:00:00:00
                        if (Tools.ValidateProperty("Address", rasd))
                        {
                            StringBuilder networkAddress = new StringBuilder();
                            if (!rasd.Address.Value.Contains(":"))
                            {
                                for (int i = 0; i < rasd.Address.Value.Length; i++)
//.........这里部分代码省略.........
开发者ID:ushamandya,项目名称:xenadmin,代码行数:101,代码来源:Import.cs

示例13: ShowSystem

 private void ShowSystem(Session xenSession, XenRef<VM> vmRef)
 {
     VM.remove_from_other_config(xenSession, vmRef, "HideFromXenCenter");
 }
开发者ID:ushamandya,项目名称:xenadmin,代码行数:4,代码来源:Import.cs

示例14: RemoveSystem

 private void RemoveSystem(Session xenSession, XenRef<VM> vm)
 {
     try
     {
         VM.destroy(xenSession, vm);
     }
     catch (Exception ex)
     {
         log.ErrorFormat("{0} {1}", Messages.ERROR_REMOVE_VM_FAILED, ex.Message);
         throw new Exception(Messages.ERROR_REMOVE_VM_FAILED, ex);
     }
     return;
 }
开发者ID:ushamandya,项目名称:xenadmin,代码行数:13,代码来源:Import.cs

示例15: HideSystem

 private void HideSystem(Session xenSession, XenRef<VM> vmRef)
 {
     VM.add_to_other_config(xenSession, vmRef, "HideFromXenCenter", "true");
 }
开发者ID:ushamandya,项目名称:xenadmin,代码行数:4,代码来源:Import.cs


注:本文中的XenRef类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。