コード例 #1
0
        public Veeam GetLicensingInformation(PerformContext performContext)
        {
            Veeam veeam = new Veeam();

            try
            {
                veeam.LicenseType = VeeamLicense.TypeEx;
            }
            catch (Exception ex)
            {
                Logger.Error(performContext, "There was an error while getting the license information from the registry. We'll therefore assume its an evaluation license.");
                Logger.Debug(performContext, ex.Message, ex);

                veeam.LicenseType = LicenseTypeEx.Evaluation;
            }

            veeam.ProgramVersion = GetVersion();

            Version programVersion = Version.Parse(veeam.ProgramVersion);

            var(vsphere, hyperv) = GetVirtualMachineCount(performContext, programVersion, veeam.LicenseType);
            veeam.vSphere        = vsphere;
            veeam.HyperV         = hyperv;

            veeam.ClientVersion  = SettingManagerHelper.ClientVersion;
            veeam.Edition        = VeeamLicense.Edition;
            veeam.ExpirationDate = VeeamLicense.ExpirationDate;
            veeam.Hostname       = Environment.MachineName;
            veeam.Id             = _authService.GetDevice();
            veeam.SupportId      = VeeamLicense.SupportId;
            veeam.TenantId       = Convert.ToInt32(_authService.GetAccount());

            return(veeam);
        }
コード例 #2
0
 public void UpdateValues(Veeam veeam)
 {
     ClientVersion  = veeam.ClientVersion;
     DeleterUserId  = null;
     DeletionTime   = null;
     Edition        = veeam.Edition;
     ExpirationDate = veeam.ExpirationDate;
     Hostname       = veeam.Hostname;
     HyperV         = veeam.HyperV;
     IsDeleted      = false;
     LicenseType    = veeam.LicenseType;
     ProgramVersion = veeam.ProgramVersion;
     SupportId      = veeam.SupportId;
     TenantId       = veeam.TenantId;
     vSphere        = veeam.vSphere;
 }
コード例 #3
0
        public static void Validate(this Veeam veeam)
        {
            if (veeam.ExpirationDate == default(DateTime))
            {
                throw new UserFriendlyException($"Invalid Expiration Date: {veeam.ExpirationDate}");
            }

            if (veeam.Id == default(Guid))
            {
                throw new UserFriendlyException($"Invalid Id: {veeam.Id}");
            }

            if (veeam.TenantId == default(int))
            {
                throw new UserFriendlyException($"Invalid Account: {veeam.TenantId}");
            }
        }
コード例 #4
0
        public override async Task StartAsync(PerformContext performContext)
        {
            await ExecuteAsync(performContext, async() =>
            {
                if (!_veeamManager.IsOnline())
                {
                    performContext?.WriteErrorLine("The Veeam server does not appear to be online. Please make sure all Veeam services are started before retrying this operation again.");
                    Logger.Error("Veeam server not online.");
                    return;
                }

                Logger.Info(performContext, "Collecting information...this could take some time.");

                Veeam payload = _veeamManager.GetLicensingInformation(performContext);
                Logger.Info(performContext, "done");

                Logger.Info(performContext, "Validating the payload...");
                var remoteVeeam = PortalService.GetVeeamServerById(AuthService.GetDevice());
                if (remoteVeeam.Count != 1)
                {
                    payload.Validate();
                    Logger.Info(performContext, "Payload is valid!");

                    DumpPayload(payload);

                    await PortalService.AddVeeamServerAsync(payload);

                    Logger.Info(performContext, "Successfully checked in.");

                    return;
                }

                remoteVeeam[0].UpdateValues(payload);
                remoteVeeam[0].Validate();

                Logger.Info(performContext, "Payload is valid!");

                DumpPayload(payload);

                await PortalService.UpdateVeeamServerAsync(remoteVeeam[0]);

                Logger.Info(performContext, "Successfully checked in.");
            });
        }
コード例 #5
0
        private void DumpPayload(Veeam payload)
        {
            var prettyPayload = new
            {
                Hostname       = payload.Hostname,
                Id             = payload.Id,
                Agent          = payload.ClientVersion,
                Tenant         = payload.TenantId,
                Edition        = payload.Edition.ToString(),
                LicenseType    = payload.LicenseType.ToString(),
                HyperV         = payload.HyperV,
                VMWare         = payload.vSphere,
                ExpirationDate = payload.ExpirationDate.ToString("o"),
                Program        = payload.ProgramVersion,
                SupportId      = payload.SupportId
            };

            Logger.Info($"Payload details: {JsonConvert.SerializeObject(prettyPayload, Formatting.Indented)}");
        }
コード例 #6
0
 public VPMScheduleOptions(Veeam.Backup.Model.ScheduleOptions scheduleOptions)
 {
     // TODO: Complete member initialization
     this._schedOptions = scheduleOptions;
 }
コード例 #7
0
 public async Task UpdateVeeamServerAsync(Veeam update)
 {
     _context.UpdateObject(update);
     await SaveChangesAsync();
 }
コード例 #8
0
 public async Task AddVeeamServerAsync(Veeam veeam)
 {
     _context.AddToVeeamServers(veeam);
     await SaveChangesAsync();
 }