• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# XenAPI.Session类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: create_new_blob

        /// <summary>
        /// Backward compatibility for SR.create_new_blob in XenServer 6.0.
        /// </summary>
        public static XenRef<Blob> create_new_blob(Session session, string _sr, string _name, string _mime_type)
        {
            if (Helper.APIVersionMeets(session, API_Version.API_1_10))
                System.Diagnostics.Debug.Assert(false, "Cannot use this call on XenServer 6.1 or newer.");

            return XenRef<Blob>.Create(session.proxy.sr_create_new_blob(session.uuid, (_sr != null) ? _sr : "", (_name != null) ? _name : "", (_mime_type != null) ? _mime_type : "").parse());
        }
开发者ID:ordenull,项目名称:skinnybox,代码行数:10,代码来源:SR2.cs


示例2: create

        // Backward compatibility for Bond.create in XenServer 6.0.
        public static XenRef<Bond> create(Session session, string _network, List<XenRef<PIF>> _members, string _mac, bond_mode _mode)
        {
            if (Helper.APIVersionMeets(session, API_Version.API_1_10))
                System.Diagnostics.Debug.Assert(false, "Cannot use this call on XenServer 6.1 or newer.");

            return XenRef<Bond>.Create(session.proxy.bond_create(session.uuid, (_network != null) ? _network : "", (_members != null) ? Helper.RefListToStringArray(_members) : new string[] { }, (_mac != null) ? _mac : "", bond_mode_helper.ToString(_mode)).parse());
        }
开发者ID:ordenull,项目名称:skinnybox,代码行数:8,代码来源:Bond2.cs


示例3: introduce

        /// <summary>
        /// Backward compatibility for VDI.introduce in XenServer 6.0.
        /// </summary>
        public static XenRef<VDI> introduce(Session session, string _uuid, string _name_label, string _name_description, string _sr, vdi_type _type, bool _sharable, bool _read_only, Dictionary<string, string> _other_config, string _location, Dictionary<string, string> _xenstore_data, Dictionary<string, string> _sm_config)
        {
            if (Helper.APIVersionMeets(session, API_Version.API_1_10))
                System.Diagnostics.Debug.Assert(false, "Cannot use this call on XenServer 6.1 or newer.");

            return XenRef<VDI>.Create(session.proxy.vdi_introduce(session.uuid, (_uuid != null) ? _uuid : "", (_name_label != null) ? _name_label : "", (_name_description != null) ? _name_description : "", (_sr != null) ? _sr : "", vdi_type_helper.ToString(_type), _sharable, _read_only, Maps.convert_to_proxy_string_string(_other_config), (_location != null) ? _location : "", Maps.convert_to_proxy_string_string(_xenstore_data), Maps.convert_to_proxy_string_string(_sm_config)).parse());
        }
开发者ID:ordenull,项目名称:skinnybox,代码行数:10,代码来源:VDI2.cs


示例4: RunWithSession

        protected override void RunWithSession(ref Session session)
        {
            List<VM> vmObjs = new List<VM>();
            foreach (XenRef<VM> vm in _vms)
                vmObjs.Add(TryResolveWithTimeout(vm));

            PBD.CheckAndPlugPBDsFor(vmObjs);

            int vmCount = _vms.Count;
            int i = 0;

            foreach (VM vm in vmObjs)
            {
                XenRef<Task> task = DoPerVM(session, vm);

                try
                {
                    PollTaskForResult(Connection, ref session, task, delegate(int progress)
                                                                                                 {
                                                                                                     PercentComplete = (progress / vmCount) + ((100 * i) / vmCount);
                                                                                                 });

                    i++;
                }
                finally
                {
                    Task.destroy(session, task);
                }
            }
        }
开发者ID:huizh,项目名称:xenadmin,代码行数:30,代码来源:VMsPlanAction.cs


示例5: SetSecretInfo

        public static void SetSecretInfo(Session session, Dictionary<string, string> config, string infoKey, string infoValue)
        {
            if (string.IsNullOrEmpty(infoKey))
                return;

            if (infoValue == null)
            {
                if (config.ContainsKey(infoKey))
                {
                    TryToDestroySecret(session, config[infoKey]);
                    config.Remove(infoKey);
                }
            }
            else if (config.ContainsKey(infoKey))
            {
                try
                {
                    string secretRef = Secret.get_by_uuid(session, config[infoKey]);
                    Secret.set_value(session, secretRef, infoValue);
                }
                catch (Failure)
                {
                    config[infoKey] = Secret.CreateSecret(session, infoValue);
                }
                catch (WebException)
                {
                    config[infoKey] = Secret.CreateSecret(session, infoValue);
                }
            }
            else
            {
                config[infoKey] = Secret.CreateSecret(session, infoValue);
            }
        }
开发者ID:robhoes,项目名称:xenadmin,代码行数:34,代码来源:SaveHealthCheckSettingsAction.cs


示例6: CreateSession

 public static Session CreateSession(Session session, IXenConnection connection, int timeout)
 {
     if (Helpers.DbProxyIsSimulatorUrl(session.Url))
         return new Session(session, DbProxy.GetProxy(connection, session.Url), connection);
     else
         return new Session(session, connection, timeout);
 }
开发者ID:huizh,项目名称:xenadmin,代码行数:7,代码来源:SessionFactory.cs


示例7: UserDetails

 /// <summary>
 /// Makes server calls, call off the event thread.
 /// </summary>
 /// <param name="session"></param>
 /// <param name="SID"></param>
 private UserDetails(Session session)
 {
     userSid = session.UserSid;
     userDisplayName = GetDisplayName(session);
     userName = GetName(session);
     GetGroupMembership(session);
 }
开发者ID:ChrisH4rding,项目名称:xenadmin,代码行数:12,代码来源:UserDetails.cs


示例8: Main

        public static void Main(string[] args)
        {
            if (args.Length < 3)
            {
                System.Console.WriteLine("Required arguments: host-ip username password\n");
                return;
            }

            // Host information necessary to get started
            string hostname = args[0];
            int port = 80; // default
            string username = args[1];
            string password = args[2];

            // Establish a session
            Session session = new Session(hostname, port);

            // Authenticate with username and password. The third parameter tells the server which API version we support.
            session.login_with_password(username, password, API_Version.API_1_3);

            List<XenRef<VM>> vmRefs = VM.get_all(session);
            foreach (XenRef<VM> vmRef in vmRefs)
            {
                VM vm = VM.get_record(session, vmRef);
                System.Console.WriteLine("Name: {0}\nvCPUs: {1}\nDescription: {2}\n-", vm.name_label, vm.VCPUs_at_startup, vm.name_description);
            }
        }
开发者ID:jonludlam,项目名称:xen-api-sdk,代码行数:27,代码来源:Program.cs


示例9: RunWithSession

 protected override void RunWithSession(ref Session session)
 {
     base.WaitForAgent(ref session, delegate(Session _session)
                                        {
                                            XenAPI.Host.async_restart_agent(_session, Host.opaque_ref);
                                        });
 }
开发者ID:ChrisH4rding,项目名称:xenadmin,代码行数:7,代码来源:RestartAgentPlanAction.cs


示例10: RunWithSession

        protected override void RunWithSession(ref Session session)
        {
            var master = Helpers.GetMaster(host.Connection);
            var mapping = mappings.Find(m => m.XenServerPatch.Equals(xenServerPatch)
                                             && m.MasterHost != null && master != null && m.MasterHost.uuid == master.uuid);

            if (mapping != null && (mapping.Pool_patch != null || mapping.Pool_update != null))
            {
                XenRef<Task> task = null;

                if (mapping.Pool_patch != null)
                {
                    task = Pool_patch.async_apply(session, mapping.Pool_patch.opaque_ref, host.opaque_ref);
                }
                else
                {
                    task = Pool_update.async_apply(session, mapping.Pool_update.opaque_ref, host.opaque_ref);
                }

                PollTaskForResultAndDestroy(Connection, ref session, task);
            }
            else
            {
                if (xenServerPatch != null && master != null)
                    log.ErrorFormat("Mapping not found for patch {0} on master {1}", xenServerPatch.Uuid, master.uuid);

                throw new Exception("Pool_patch or Pool_update not found.");
            }
        }
开发者ID:ushamandya,项目名称:xenadmin,代码行数:29,代码来源:ApplyXenServerPatchPlanAction.cs


示例11: RoleElevationDialog

        /// <summary>
        /// Displays a dialog informing the user they need a different role to complete the task, and offers the chance to switch user. Optionally logs 
        /// out the elevated session. If successful exposes the elevated session, password and username as fields.
        /// </summary>
        /// <param name="connection">The current server connection with the role information</param>
        /// <param name="session">The session on which we have been denied access</param>
        /// <param name="authorizedRoles">A list of roles that are able to complete the task</param>
        /// <param name="actionTitle">A description of the current action, if null or empty will not be displayed</param>
        public RoleElevationDialog(IXenConnection connection, Session session, List<Role> authorizedRoles, string actionTitle)
        {
            InitializeComponent();
            Image icon = SystemIcons.Exclamation.ToBitmap();
            pictureBox1.Image = icon;
            pictureBox1.Width = icon.Width;
            pictureBox1.Height = icon.Height;
            this.connection = connection;
            UserDetails ud = session.CurrentUserDetails;
            labelCurrentUserValue.Text = ud.UserDisplayName ?? ud.UserName ?? Messages.UNKNOWN_AD_USER;
            labelCurrentRoleValue.Text = Role.FriendlyCSVRoleList(session.Roles);
            authorizedRoles.Sort((r1, r2) => r2.CompareTo(r1));
            labelRequiredRoleValue.Text = Role.FriendlyCSVRoleList(authorizedRoles);
            labelServerValue.Text = Helpers.GetName(connection);
            labelServer.Text = Helpers.IsPool(connection) ? Messages.POOL_COLON : Messages.SERVER_COLON;
            originalUsername = session.Connection.Username;
            originalPassword = session.Connection.Password;

            if (string.IsNullOrEmpty(actionTitle))
            {
                labelCurrentAction.Visible = false;
                labelCurrentActionValue.Visible = false;
            }
            else
            {
                labelCurrentActionValue.Text = actionTitle;
            }

            this.authorizedRoles = authorizedRoles;
        }
开发者ID:huizh,项目名称:xenadmin,代码行数:38,代码来源:RoleElevationDialog.cs


示例12: db_introduce

        /// <summary>
        /// Backward compatibility for PIF.db_introduce in XenServer 6.0.
        /// </summary>
        public static XenRef<PIF> db_introduce(Session session, string _device, string _network, string _host, string _mac, long _mtu, long _vlan, bool _physical, ip_configuration_mode _ip_configuration_mode, string _ip, string _netmask, string _gateway, string _dns, string _bond_slave_of, string _vlan_master_of, bool _management, Dictionary<string, string> _other_config, bool _disallow_unplug)
        {
            if (Helper.APIVersionMeets(session, API_Version.API_1_10))
                System.Diagnostics.Debug.Assert(false, "Cannot use this call on XenServer 6.1 or newer.");

            return XenRef<PIF>.Create(session.proxy.pif_db_introduce(session.uuid, (_device != null) ? _device : "", (_network != null) ? _network : "", (_host != null) ? _host : "", (_mac != null) ? _mac : "", _mtu.ToString(), _vlan.ToString(), _physical, ip_configuration_mode_helper.ToString(_ip_configuration_mode), (_ip != null) ? _ip : "", (_netmask != null) ? _netmask : "", (_gateway != null) ? _gateway : "", (_dns != null) ? _dns : "", (_bond_slave_of != null) ? _bond_slave_of : "", (_vlan_master_of != null) ? _vlan_master_of : "", _management, Maps.convert_to_proxy_string_string(_other_config), _disallow_unplug).parse());
        }
开发者ID:ordenull,项目名称:skinnybox,代码行数:10,代码来源:PIF2.cs


示例13: RunWithSession

        protected override void RunWithSession(ref Session session)
        {

            XenRef<Task> task = Pool_patch.async_pool_clean(session, _patchRef.opaque_ref);

            PollTaskForResultAndDestroy(Connection, ref session, task);
        }
开发者ID:huizh,项目名称:xenadmin,代码行数:7,代码来源:RemoveUpdateFile.cs


示例14: RunWithSession

        protected override void RunWithSession(ref Session session)
        {
            this.visible = false;

            lock (patch)
            {
                this.visible = true;
                this._title = string.Format(Messages.PATCHINGWIZARD_DOWNLOADUPDATE_ACTION_TITLE_DOWNLOADING, patch.Name);

                if (Cancelling)
                    return;

                //if it has not been already downloaded
                if (!AllDownloadedPatches.Any(dp => dp.Key == patch && !string.IsNullOrEmpty(dp.Value))
                    || !File.Exists(AllDownloadedPatches[patch]))
                {
                    DownloadFile(ref session);
                }
                else
                {
                    this.visible = false;
                    this._title = string.Format(Messages.PATCHINGWIZARD_DOWNLOADUPDATE_ACTION_TITLE_SKIPPING, patch.Name);
                }
            }
        }
开发者ID:ushamandya,项目名称:xenadmin,代码行数:25,代码来源:DownloadPatchPlanAction.cs


示例15: WlbRecommendations

        /// <summary>
        /// Initializes a new instance of the <see cref="WlbRecommendations"/> class.
        /// </summary>
        /// <param name="vms">The VMs that the recommendations are required for.</param>
        /// <param name="session">The session.</param>
        public WlbRecommendations(IEnumerable<VM> vms, Session session)
        {
            Util.ThrowIfEnumerableParameterNullOrEmpty(vms, "vms");
            Util.ThrowIfParameterNull(session, "session");

            _vms = new ReadOnlyCollection<VM>(new List<VM>(vms));
            _session = session;
        }
开发者ID:huizh,项目名称:xenadmin,代码行数:13,代码来源:WlbRecommendations.cs


示例16: Apply

 public sealed override void Apply(Host host, Session session)
 {
     foreach (Hotfix hotfix in ComponentHotfixes)
     {
         if(hotfix.ShouldBeAppliedTo(host))
             hotfix.Apply(host, session);
     }
 }
开发者ID:huizh,项目名称:xenadmin,代码行数:8,代码来源:MultipleHotfix.cs


示例17: RunWithSession

 protected override void RunWithSession(ref Session session)
 {
     string value = XenAPI.Host.call_plugin(session, Host.opaque_ref, "prepare_host_upgrade.py", "main", _arguments);
     if (value.ToLower() == "true")
         base.RunWithSession(ref session);
     else
         throw new Exception(value);
 }
开发者ID:huizh,项目名称:xenadmin,代码行数:8,代码来源:UpgradeHostPlanAction.cs


示例18: AddCustomField

 public static void AddCustomField(Session session, IXenConnection connection, CustomFieldDefinition customField)
 {
     List<CustomFieldDefinition> customFields = customFieldsCache.GetCustomFields(connection);
     if (!customFields.Contains(customField))
     {
         customFields.Add(customField);
         SaveCustomFields(session, connection, customFields);
     }
 }
开发者ID:ushamandya,项目名称:xenadmin,代码行数:9,代码来源:CustomFieldsManager.cs


示例19: DestroyVM

        private static void DestroyVM(Session session, VM vm, List<VBD> deleteDisks, IEnumerable<VM> deleteSnapshots)
        {
            Exception caught = null;

            foreach (VM snapshot in deleteSnapshots)
            {
                VM snap = snapshot;
                BestEffort(ref caught, session.Connection.ExpectDisruption, () =>
                                           {
                                               if (snap.power_state == vm_power_state.Suspended)
                                               {
                                                   XenAPI.VM.hard_shutdown(session, snap.opaque_ref);
                                               }
                                               DestroyVM(session, snap, true);
                                           });
            }

            List<XenRef<VDI>> vdiRefs = new List<XenRef<VDI>>();

            foreach (XenRef<VBD> vbdRef in vm.VBDs)
            {
                VBD vbd = vm.Connection.Resolve(vbdRef);
                if (vbd == null)
                    continue;

                if (deleteDisks.Contains(vbd))
                {
                    if(vbd.Connection.Resolve(vbd.VDI)!=null)
                        vdiRefs.Add(vbd.VDI);
                }
            }

            //CA-91072: Delete Suspend image VDI
            VDI suspendVDI = vm.Connection.Resolve(vm.suspend_VDI);
            if (suspendVDI != null)
                vdiRefs.Add(vm.suspend_VDI);

            XenAPI.VM.destroy(session, vm.opaque_ref);

            foreach (XenRef<VDI> vdiRef in vdiRefs)
            {
                XenRef<VDI> vdi = vdiRef;
                BestEffort(ref caught, session.Connection.ExpectDisruption, () => XenAPI.VDI.destroy(session, vdi.opaque_ref));

                //CA-115249. XenAPI could have already deleted the VDI. Destroy suspended VM and destroy snapshot functions are affected.
                var failure = caught as Failure;
                if (failure != null && failure.ErrorDescription != null && failure.ErrorDescription.Count > 0 && failure.ErrorDescription[0] == "HANDLE_INVALID")
                {
                    log.InfoFormat("VDI:{0} has already been deleted -- ignoring exception.", vdi.opaque_ref);
                    caught = null;
                }
            }

            if (caught != null)
                throw caught;
        }
开发者ID:huizh,项目名称:xenadmin,代码行数:56,代码来源:VMDestroyAction.cs


示例20: bundleUpload

        public string bundleUpload(IXenConnection connection, Session session, string uploadToken, System.Threading.CancellationToken cancel)
        {
            // Collect the server status report and generate zip file to upload.
            XenServerHealthCheckBugTool bugTool = new XenServerHealthCheckBugTool();
            try
            {
                bugTool.RunBugtool(connection, session);
            }
            catch (Exception e)
            {
                if (session != null)
                    session.logout();
                session = null;
                log.Error(e, e);
                return "";
            }

            string bundleToUpload = bugTool.outputFile;
            if(string.IsNullOrEmpty(bundleToUpload) || !File.Exists(bundleToUpload))
            {
                log.ErrorFormat("Server Status Report is NOT collected");
                return "";
            }

            // Upload the zip file to CIS uploading server.
            string upload_url = Registry.HealthCheckUploadDomainName;
            log.InfoFormat("Upload report to {0}", upload_url);
            XenServerHealthCheckUpload upload = new XenServerHealthCheckUpload(uploadToken, VERBOSITY_LEVEL, upload_url, connection);

            string upload_uuid = "";
            try
            {
                upload_uuid = upload.UploadZip(bundleToUpload, null, cancel);
            }
            catch (Exception e)
            {
                if (session != null)
                    session.logout();
                session = null;
                log.Error(e, e);
                return "";
            }

            if (File.Exists(bundleToUpload))
                File.Delete(bundleToUpload);

            // Return the uuid of upload.
            if(string.IsNullOrEmpty(upload_uuid))
            {
                // Fail to upload the zip to CIS server.
                log.ErrorFormat("Fail to upload the Server Status Report {0} to CIS server", bundleToUpload);
                return "";
            }

            return upload_uuid;
        }
开发者ID:PlusCloudsOSS,项目名称:xenadmin,代码行数:56,代码来源:XenServerHealthCheckBundleUpload.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# XenAPI.VDI类代码示例发布时间:2022-05-26
下一篇:
C# XenAPI.Host类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap