Beispiel #1
0
        /// <summary>
        /// This function is responsible to retrieve the SystemInfo for the connection.
        /// </summary>
        protected override void DoODLVSEMCmdlet()
        {
            var JavaScriptSerializer = new JavaScriptSerializer();

            JavaScriptSerializer.MaxJsonLength = int.MaxValue;
            ODLVSEMETW.EventWriteDoCmdlet(this.CmdletName,
                                          "Retrieving system information.",
                                          string.Empty);
            NetworkServiceSystemInformation info = null;
            TransactionManager txnMng            = new TransactionManager();

            txnMng.StartTransaction();
            var operation = TransactionManager.Operation.None;

            try {
                info = this.conn.GetVSEMSystemInfo(txnMng);
                ODLVSEMETW.EventWriteReturnLibrary("System information is retrieved.", string.Empty);

                if (info == null)
                {
                    ODLVSEMETW.EventWriteProcessCmdletWarning(this.CmdletName,
                                                              "System information not found.");
                    this.WriteWarning("System information not found.");
                }
                else
                {
                    this.WriteObject(info);
                }
            } catch (Exception ex) {
                Exception exception = VSEMODLExceptionUtil.ConvertExceptionToVSEMException(ex);
                ODLVSEMETW.EventWriteFailedCmdlet(this.CmdletName, exception.GetType() + " : " + ex.Message);
                operation = TransactionManager.Operation.Rollback;
                throw exception;
            } finally {
                txnMng.EndTransaction(operation);
                string output = "\"NetworkServiceSystemInformation\":" + JavaScriptSerializer.Serialize(info);
                ODLVSEMETW.EventWriteEndCmdlet(this.CmdletName, output);
            }
        }
        /// <summary>
        /// Create VSEM system info object.
        /// </summary>
        /// <returns>VSEMSystemInfo instance.</returns>
        private static NetworkServiceSystemInformation CreateSystemInfo()
        {
            NetworkServiceSystemInformation sysInfo = new NetworkServiceSystemInformation();
            sysInfo.Id = VSEMODLConstants.SYSTEM_INFO_ID;
            sysInfo.Name = VSEMODLConstants.SYSTEM_INFO_NAME;
            sysInfo.Description = VSEMODLConstants.SYSTEM_INFO_DESCRIPTION;
            sysInfo.Manufacturer = VSEMODLConstants.SYSTEM_INFO_MANUFACTURER;
            sysInfo.Model = VSEMODLConstants.SYSTEM_INFO_MODEL;
            sysInfo.Version = VSEMODLConstants.SYSTEM_INFO_VERSION;
            sysInfo.NetworkDataInformation = new NetworkManagerCapabilities {
                ReceiveFabricNetworkEntitiesOnRefresh = VSEMODLConstants.RECEIVE_FABRIC_NETWORK_ENTITIES_ON_REFRESH,
                ReceiveFabricNetworkEntitiesOnUpdate = VSEMODLConstants.RECEIVE_FABRIC_NETWORK_ENTITIES_ON_UPDATE,
                ReceiveVMNetworkEntitiesOnRefresh = VSEMODLConstants.RECEIVE_VM_NETWORK_ENTITIES_ON_REFRESH,
                ReceiveVMNetworkEntitiesOnUpdate = VSEMODLConstants.RECEIVE_VM_NETWORK_ENTITIES_ON_UPDATE,
                SupportsIPAddressUsageInformation = VSEMODLConstants.SUPPORTS_IP_ADDRESS_USAGE_INFORMATION
            };

            sysInfo.DeviceId = VSEMODLConstants.SYSTEM_INFO_DEVICE_ID;
            sysInfo.SwitchExtensionManagementInformation = new VSEMCapabilities {
                SupportsVMNetworkOperations = VSEMODLConstants.SYSTEM_INFO_SUPPORTS_VM_NETWORK_OPERATIONS,
                VendorId = VSEMODLConstants.SYSTEM_INFO_VENDOR_ID,
                SwitchExtensionInfoIds = new Guid[1] { VSEMODLConstants.SWITCH_EXTENSION_INFO_ID }
            };

            return sysInfo;
        }