-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3197 from kc284/master
Merge feature/cdn-updates to master + CA-381216
- Loading branch information
Showing
145 changed files
with
15,313 additions
and
2,628 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ | |
* SUCH DAMAGE. | ||
*/ | ||
|
||
def XENADMIN_BRANDING_TAG = 'v4.17' | ||
def XENADMIN_BRANDING_TAG = 'v5.0' | ||
|
||
@Library(['PacmanSharedLibrary', "[email protected]"]) | ||
import com.citrix.pipeline.xencenter.* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/* Copyright (c) Cloud Software Group, Inc. | ||
* | ||
* Redistribution and use in source and binary forms, | ||
* with or without modification, are permitted provided | ||
* that the following conditions are met: | ||
* | ||
* * Redistributions of source code must retain the above | ||
* copyright notice, this list of conditions and the | ||
* following disclaimer. | ||
* * Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the | ||
* following disclaimer in the documentation and/or other | ||
* materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND | ||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
* SUCH DAMAGE. | ||
*/ | ||
|
||
using System.Collections.Generic; | ||
using System.Linq; | ||
using XenAdmin.Core; | ||
using XenAdmin.Network; | ||
using XenAPI; | ||
|
||
namespace XenAdmin.Actions.GUIActions | ||
{ | ||
internal class ConfigYumRepoAction : AsyncAction | ||
{ | ||
private readonly RepoDescriptor _repoToEnable; | ||
private readonly Repository _introducedRepo; | ||
private readonly List<Repository> _oldEnabledRepos; | ||
private readonly Pool _pool; | ||
|
||
public ConfigYumRepoAction(IXenConnection connection, RepoDescriptor repoDescriptor) | ||
: base(connection, string.Empty) | ||
{ | ||
Title = Description = string.Format(Messages.YUM_REPO_ACTION_CONFIG_TITLE, connection.Name, repoDescriptor.FriendlyName); | ||
|
||
_repoToEnable = repoDescriptor; | ||
|
||
_introducedRepo = connection.Cache.Repositories.FirstOrDefault(r => _repoToEnable.MatchesRepository(r)); | ||
|
||
_pool = Helpers.GetPoolOfOne(Connection); | ||
|
||
_oldEnabledRepos = (from XenRef<Repository> repoRef in _pool.repositories | ||
let repo = Connection.Resolve(repoRef) | ||
where !_repoToEnable.MatchesRepository(repo) | ||
select repo).ToList(); | ||
|
||
#region RBAC | ||
|
||
if (_oldEnabledRepos.Count > 0) | ||
ApiMethodsToRoleCheck.Add("Pool.remove_repository"); | ||
|
||
if (_introducedRepo == null) | ||
ApiMethodsToRoleCheck.Add("Repository.introduce"); | ||
|
||
ApiMethodsToRoleCheck.Add("Pool.add_repository"); | ||
|
||
#endregion | ||
} | ||
|
||
protected override void Run() | ||
{ | ||
foreach (var repo in _oldEnabledRepos) | ||
{ | ||
var repoName = RepoDescriptor.AllRepos.FirstOrDefault(r => r.MatchesRepository(repo))?.FriendlyName ?? string.Empty; | ||
Description = string.Format(Messages.YUM_REPO_ACTION_CONFIG_DESCRIPTION_DISABLE, repoName); | ||
Pool.remove_repository(Session, _pool.opaque_ref, repo.opaque_ref); | ||
} | ||
|
||
XenRef<Repository> repoRef; | ||
|
||
if (_introducedRepo == null) | ||
{ | ||
var baseRepo = RepoDescriptor.BaseRepo; | ||
|
||
if (!Connection.Cache.Repositories.Any(r => baseRepo.MatchesRepository(r))) | ||
{ | ||
Description = string.Format(Messages.YUM_REPO_ACTION_CONFIG_DESCRIPTION_INTRODUCE, baseRepo.FriendlyName); | ||
|
||
Repository.introduce(Session, baseRepo.Key, baseRepo.FriendlyName, baseRepo.BinUrl, baseRepo.SourceUrl, false, ""); | ||
} | ||
|
||
Description = string.Format(Messages.YUM_REPO_ACTION_CONFIG_DESCRIPTION_INTRODUCE, _repoToEnable.FriendlyName); | ||
|
||
repoRef = Repository.introduce(Session, _repoToEnable.Key, _repoToEnable.FriendlyName, | ||
_repoToEnable.BinUrl, _repoToEnable.SourceUrl, true, ""); | ||
} | ||
else | ||
{ | ||
repoRef = new XenRef<Repository>(_introducedRepo.opaque_ref); | ||
} | ||
|
||
Description = string.Format(Messages.YUM_REPO_ACTION_CONFIG_DESCRIPTION_ENABLE, _repoToEnable.FriendlyName); | ||
|
||
Pool.add_repository(Session, _pool.opaque_ref, repoRef); | ||
|
||
//wait until the cache has been updated so that the config panel can show | ||
//the new value if the action was triggered by hitting the Apply button | ||
|
||
Connection.WaitFor(() => _pool.repositories.Contains(repoRef), null); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* Copyright (c) Cloud Software Group, Inc. | ||
* | ||
* Redistribution and use in source and binary forms, | ||
* with or without modification, are permitted provided | ||
* that the following conditions are met: | ||
* | ||
* * Redistributions of source code must retain the above | ||
* copyright notice, this list of conditions and the | ||
* following disclaimer. | ||
* * Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the | ||
* following disclaimer in the documentation and/or other | ||
* materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND | ||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
* SUCH DAMAGE. | ||
*/ | ||
|
||
using System; | ||
using System.Diagnostics; | ||
using System.Xml; | ||
using XenAPI; | ||
|
||
|
||
namespace XenAdmin.Alerts | ||
{ | ||
public class CssExpiryAlert : MessageAlert | ||
{ | ||
private readonly DateTime? _cssExpiryDate; | ||
private readonly string _title; | ||
private readonly string _description; | ||
|
||
public CssExpiryAlert(Message m) | ||
: base(m) | ||
{ | ||
try | ||
{ | ||
var doc = new XmlDocument(); | ||
doc.LoadXml(m.body); | ||
var nodes = doc.GetElementsByTagName("date"); | ||
|
||
if (nodes.Count > 0 && Util.TryParseIso8601DateTime(nodes[0].InnerText, out var result)) | ||
_cssExpiryDate = result; | ||
} | ||
catch | ||
{ | ||
//ignore | ||
} | ||
|
||
switch (Message.Type) | ||
{ | ||
case Message.MessageType.UPDATES_FEATURE_EXPIRED: | ||
_title = Messages.ALERT_CSS_EXPIRED_TITLE; | ||
_description = string.Format(Messages.ALERT_CSS_EXPIRED_DESCIRPTION, AlertExtensions.GetGuiDate(_cssExpiryDate)); | ||
break; | ||
|
||
case Message.MessageType.UPDATES_FEATURE_EXPIRING_CRITICAL: | ||
case Message.MessageType.UPDATES_FEATURE_EXPIRING_MAJOR: | ||
case Message.MessageType.UPDATES_FEATURE_EXPIRING_WARNING: | ||
|
||
if (_cssExpiryDate.HasValue && _cssExpiryDate.Value > Timestamp) | ||
{ | ||
var eta = _cssExpiryDate.Value - Timestamp; | ||
|
||
if (eta.TotalDays >= 1) | ||
_title = string.Format(Messages.ALERT_CSS_EXPIRING_TITLE_DAYS, Math.Round(eta.TotalDays, MidpointRounding.AwayFromZero)); | ||
|
||
else if (eta.TotalHours >= 1) | ||
_title = string.Format(Messages.ALERT_CSS_EXPIRING_TITLE_HOURS, Math.Round(eta.TotalHours, MidpointRounding.AwayFromZero)); | ||
|
||
else if (eta.TotalMinutes >= 1) | ||
_title = string.Format(Messages.ALERT_CSS_EXPIRING_TITLE_MINUTES, Math.Round(eta.TotalMinutes, MidpointRounding.AwayFromZero)); | ||
} | ||
else | ||
{ | ||
_title = Messages.ALERT_CSS_EXPIRED_TITLE; | ||
} | ||
|
||
_description = string.Format(Messages.ALERT_CSS_EXPIRING_DESCRIPTION, AlertExtensions.GetGuiDate(_cssExpiryDate)); | ||
break; | ||
} | ||
} | ||
|
||
public override string Title => string.IsNullOrEmpty(_title) ? base.Title : _title; | ||
|
||
public override string Description => string.IsNullOrEmpty(_description) ? base.Title : _description; | ||
|
||
public override Action FixLinkAction => () => Process.Start(InvisibleMessages.CSS_URL); | ||
|
||
public override string FixLinkText => Messages.ALERT_CSS_EXPIRED_LINK_TEXT; | ||
|
||
public override string HelpID => "CssExpiryAlert"; | ||
|
||
public override string HelpLinkText => Messages.ALERT_GENERIC_HELP; | ||
} | ||
} |
Oops, something went wrong.