Skip to content

Commit e8ad769

Browse files
alias name changes
1 parent de018b4 commit e8ad769

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

a10vthunder-orchestrator/ImplementedStoreTypes/Ssl/Management.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -272,36 +272,36 @@ protected internal virtual void Replace(ManagementJobConfiguration config, Inven
272272
private string GenerateNewAlias(string originalAlias)
273273
{
274274
string timestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString();
275-
string newAlias;
276275

277-
// Match a Unix timestamp suffix pattern (e.g., _1234567890 at the end of the string)
278-
var match = System.Text.RegularExpressions.Regex.Match(originalAlias, @"_(\d{10})$");
276+
// Match the first Unix timestamp in the format _########## (10 digits)
277+
var match = System.Text.RegularExpressions.Regex.Match(originalAlias, @"^(.*?)(_?\d{10}).*$");
278+
279+
string newAlias;
279280

280281
if (match.Success)
281282
{
282-
// Replace the matched timestamp with the current one
283-
newAlias = originalAlias.Substring(0, match.Index) + "_" + timestamp;
283+
// Keep everything before the first timestamp, append new timestamp
284+
newAlias = $"{match.Groups[1].Value}_{timestamp}";
284285
}
285286
else
286287
{
288+
// No timestamp found, just append new one
287289
newAlias = $"{originalAlias}_{timestamp}";
288290
}
289291

290-
// Ensure the alias is no more than 240 characters
292+
// Ensure it's within the 240 character limit
291293
if (newAlias.Length > 240)
292294
{
293-
// Truncate the beginning to fit the length
294295
int maxBaseLength = 240 - (timestamp.Length + 1); // +1 for underscore
295-
string truncatedBase = originalAlias.Length > maxBaseLength
296-
? originalAlias.Substring(0, maxBaseLength)
297-
: originalAlias;
298-
newAlias = $"{truncatedBase}_{timestamp}";
296+
string basePart = newAlias.Substring(0, maxBaseLength);
297+
newAlias = $"{basePart}_{timestamp}";
299298
}
300299

301300
return newAlias;
302301
}
303302

304303

304+
305305
protected internal virtual void Remove(ManagementJobConfiguration configInfo, InventoryResult inventoryResult,
306306
ApiClient apiClient)
307307
{

0 commit comments

Comments
 (0)