Skip to content

Commit 9ef9080

Browse files
committed
Made changes to logic such that customer can terminate cmdlet while cmdlet trying to get more data
1 parent acc35fa commit 9ef9080

File tree

7 files changed

+401
-297
lines changed

7 files changed

+401
-297
lines changed

src/ResourceManager/Automation/Commands.Automation/Cmdlet/GetAzureAutomationConfiguration.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,23 @@ public override void ExecuteCmdlet()
4848
{
4949
this.AutomationClient.GetConfiguration(this.ResourceGroupName, this.AutomationAccountName, this.Name)
5050
};
51+
52+
this.GenerateCmdletOutput(ret);
5153
}
5254
else if (this.ParameterSetName == AutomationCmdletParameterSets.ByAll)
5355
{
54-
ret = this.AutomationClient.ListDscConfigurations(this.ResourceGroupName, this.AutomationAccountName);
55-
}
56+
var nextLink = string.Empty;
5657

57-
this.GenerateCmdletOutput(ret);
58+
do
59+
{
60+
ret = this.AutomationClient.ListDscConfigurations(this.ResourceGroupName, this.AutomationAccountName, ref nextLink);
61+
if (ret != null)
62+
{
63+
this.GenerateCmdletOutput(ret);
64+
}
65+
66+
} while (!string.IsNullOrEmpty(nextLink));
67+
}
5868
}
5969
}
6070
}

src/ResourceManager/Automation/Commands.Automation/Cmdlet/GetAzureAutomationDscCompilationJob.cs

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,39 @@ protected override void AutomationProcessRecord()
7676
{
7777
// ByJobId
7878
jobs = new List<CompilationJob> { this.AutomationClient.GetCompilationJob(this.ResourceGroupName, this.AutomationAccountName, this.Id) };
79+
80+
this.GenerateCmdletOutput(jobs);
7981
}
8082
else if (this.ConfigurationName != null)
8183
{
82-
// ByConfiguration
83-
jobs = this.AutomationClient.ListCompilationJobsByConfigurationName(this.ResourceGroupName, this.AutomationAccountName, this.ConfigurationName, this.StartTime, this.EndTime, this.Status);
84+
var nextLink = string.Empty;
85+
86+
do
87+
{
88+
// ByConfiguration
89+
jobs = this.AutomationClient.ListCompilationJobsByConfigurationName(this.ResourceGroupName, this.AutomationAccountName, this.ConfigurationName, this.StartTime, this.EndTime, this.Status, ref nextLink);
90+
if (jobs != null)
91+
{
92+
this.GenerateCmdletOutput(jobs);
93+
}
94+
95+
} while (!string.IsNullOrEmpty(nextLink));
8496
}
8597
else
8698
{
87-
// ByAll
88-
jobs = this.AutomationClient.ListCompilationJobs(this.ResourceGroupName, this.AutomationAccountName, this.StartTime, this.EndTime, this.Status);
89-
}
99+
var nextLink = string.Empty;
100+
101+
do
102+
{
103+
// ByAll
104+
jobs = this.AutomationClient.ListCompilationJobs(this.ResourceGroupName, this.AutomationAccountName, this.StartTime, this.EndTime, this.Status, ref nextLink);
105+
if (jobs != null)
106+
{
107+
this.GenerateCmdletOutput(jobs);
108+
}
90109

91-
this.WriteObject(jobs, true);
110+
} while (!string.IsNullOrEmpty(nextLink));
111+
}
92112
}
93113
}
94114
}

src/ResourceManager/Automation/Commands.Automation/Cmdlet/GetAzureAutomationDscNode.cs

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,38 +85,66 @@ public override void ExecuteCmdlet()
8585
{
8686
this.AutomationClient.GetDscNodeById(this.ResourceGroupName, this.AutomationAccountName, this.Id)
8787
};
88+
89+
this.GenerateCmdletOutput(ret);
8890
}
8991
else if (this.ParameterSetName == AutomationCmdletParameterSets.ByName)
9092
{
91-
ret = this.AutomationClient.ListDscNodesByName(
92-
this.ResourceGroupName,
93-
this.AutomationAccountName,
94-
this.Name,
95-
nodeStatus);
93+
var nextLink = string.Empty;
94+
95+
do
96+
{
97+
ret = this.AutomationClient.ListDscNodesByName(this.ResourceGroupName, this.AutomationAccountName, this.Name, nodeStatus, ref nextLink);
98+
if (ret != null)
99+
{
100+
this.GenerateCmdletOutput(ret);
101+
}
102+
103+
} while (!string.IsNullOrEmpty(nextLink));
96104
}
97105
else if (this.ParameterSetName == AutomationCmdletParameterSets.ByNodeConfiguration)
98106
{
99-
ret = this.AutomationClient.ListDscNodesByNodeConfiguration(
100-
this.ResourceGroupName,
101-
this.AutomationAccountName,
102-
this.NodeConfigurationName,
103-
nodeStatus);
107+
var nextLink = string.Empty;
108+
109+
do
110+
{
111+
ret = this.AutomationClient.ListDscNodesByNodeConfiguration(this.ResourceGroupName, this.AutomationAccountName, this.NodeConfigurationName, nodeStatus, ref nextLink);
112+
if (ret != null)
113+
{
114+
this.GenerateCmdletOutput(ret);
115+
}
116+
117+
} while (!string.IsNullOrEmpty(nextLink));
104118
}
105119
else if (this.ParameterSetName == AutomationCmdletParameterSets.ByConfiguration)
106120
{
107-
ret = this.AutomationClient.ListDscNodesByConfiguration(
108-
this.ResourceGroupName,
109-
this.AutomationAccountName,
110-
this.ConfigurationName,
111-
nodeStatus);
121+
var nextLink = string.Empty;
122+
123+
do
124+
{
125+
ret = this.AutomationClient.ListDscNodesByNodeConfiguration(this.ResourceGroupName, this.AutomationAccountName, this.ConfigurationName, nodeStatus, ref nextLink);
126+
if (ret != null)
127+
{
128+
this.GenerateCmdletOutput(ret);
129+
}
130+
131+
} while (!string.IsNullOrEmpty(nextLink));
112132
}
113133
else
114134
{
115-
// ByAll
116-
ret = this.AutomationClient.ListDscNodes(this.ResourceGroupName, this.AutomationAccountName, nodeStatus);
117-
}
135+
var nextLink = string.Empty;
118136

119-
this.GenerateCmdletOutput(ret);
137+
do
138+
{
139+
// ByAll
140+
ret = this.AutomationClient.ListDscNodes(this.ResourceGroupName, this.AutomationAccountName, nodeStatus, ref nextLink);
141+
if (ret != null)
142+
{
143+
this.GenerateCmdletOutput(ret);
144+
}
145+
146+
} while (!string.IsNullOrEmpty(nextLink));
147+
}
120148
}
121149
}
122150
}

src/ResourceManager/Automation/Commands.Automation/Cmdlet/GetAzureAutomationDscNodeConfiguration.cs

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,39 @@ protected override void AutomationProcessRecord()
5959
if (this.Name != null)
6060
{
6161
nodeConfigurations = new List<NodeConfiguration> { this.AutomationClient.GetNodeConfiguration(this.ResourceGroupName, this.AutomationAccountName, this.Name, this.RollupStatus) };
62+
this.GenerateCmdletOutput(nodeConfigurations);
6263
}
6364
else if (this.ConfigurationName != null)
6465
{
65-
// ByConfiguration
66-
nodeConfigurations = this.AutomationClient.ListNodeConfigurationsByConfigurationName(this.ResourceGroupName, this.AutomationAccountName, this.ConfigurationName, this.RollupStatus);
66+
var nextLink = string.Empty;
67+
68+
do
69+
{
70+
// ByConfiguration
71+
nodeConfigurations = this.AutomationClient.ListNodeConfigurationsByConfigurationName(this.ResourceGroupName, this.AutomationAccountName, this.ConfigurationName, this.RollupStatus, ref nextLink);
72+
if (nodeConfigurations != null)
73+
{
74+
this.GenerateCmdletOutput(nodeConfigurations);
75+
}
76+
77+
} while (!string.IsNullOrEmpty(nextLink));
78+
6779
}
6880
else
6981
{
70-
// ByAll
71-
nodeConfigurations = this.AutomationClient.ListNodeConfigurations(this.ResourceGroupName, this.AutomationAccountName, this.RollupStatus);
72-
}
82+
var nextLink = string.Empty;
7383

74-
this.WriteObject(nodeConfigurations, true);
84+
do
85+
{
86+
// ByAll
87+
nodeConfigurations = this.AutomationClient.ListNodeConfigurations(this.ResourceGroupName, this.AutomationAccountName, this.RollupStatus, ref nextLink);
88+
if (nodeConfigurations != null)
89+
{
90+
this.GenerateCmdletOutput(nodeConfigurations);
91+
}
92+
93+
} while (!string.IsNullOrEmpty(nextLink));
94+
}
7595
}
7696
}
7797
}

src/ResourceManager/Automation/Commands.Automation/Cmdlet/GetAzureAutomationDscNodeReport.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,25 +78,32 @@ public override void ExecuteCmdlet()
7878
{
7979
this.AutomationClient.GetLatestDscNodeReport(this.ResourceGroupName, this.AutomationAccountName, this.NodeId)
8080
};
81+
82+
this.GenerateCmdletOutput(ret);
8183
}
8284
else if (this.ParameterSetName == AutomationCmdletParameterSets.ById)
8385
{
8486
ret = new List<DscNodeReport>
8587
{
8688
this.AutomationClient.GetDscNodeReportByReportId(this.ResourceGroupName, this.AutomationAccountName, this.NodeId, this.Id)
8789
};
90+
91+
this.GenerateCmdletOutput(ret);
8892
}
8993
else
9094
{
91-
ret = this.AutomationClient.ListDscNodeReports(
92-
this.ResourceGroupName,
93-
this.AutomationAccountName,
94-
this.NodeId,
95-
this.StartTime,
96-
this.EndTime);
97-
}
95+
var nextLink = string.Empty;
9896

99-
this.GenerateCmdletOutput(ret);
97+
do
98+
{
99+
ret = this.AutomationClient.ListDscNodeReports(this.ResourceGroupName, this.AutomationAccountName, this.NodeId, this.StartTime, this.EndTime, ref nextLink);
100+
if (ret != null)
101+
{
102+
this.GenerateCmdletOutput(ret);
103+
}
104+
105+
} while (!string.IsNullOrEmpty(nextLink));
106+
}
100107
}
101108
}
102109
}

0 commit comments

Comments
 (0)