@@ -1358,15 +1358,15 @@ public NodeConfigurationDeployment StartNodeConfigurationDeployment(string resou
1358
1358
} ) . JobSchedule ;
1359
1359
}
1360
1360
1361
- return new NodeConfigurationDeployment ( resourceGroupName , automationAccountName , nodeConfiguraionName , job ) ;
1361
+ return new NodeConfigurationDeployment ( resourceGroupName , automationAccountName , nodeConfiguraionName , job , jobSchedule ) ;
1362
1362
}
1363
1363
1364
1364
public NodeConfigurationDeployment GetNodeConfigurationDeployment ( string resourceGroupName , string automationAccountName , Guid jobId )
1365
1365
{
1366
1366
Requires . Argument ( "ResourceGroupName" , resourceGroupName ) . NotNullOrEmpty ( ) ;
1367
1367
Requires . Argument ( "AutomationAccountName" , automationAccountName ) . NotNullOrEmpty ( ) . ValidAutomationAccountName ( ) ;
1368
1368
1369
- var nodesList = new List < IList < string > > ( ) ;
1369
+ var nodeLists = new List < IList < string > > ( ) ;
1370
1370
var nodesStatus = new List < IDictionary < string , string > > ( ) ;
1371
1371
Job job = null ;
1372
1372
string nodeConfigurationName = null ;
@@ -1375,24 +1375,18 @@ public NodeConfigurationDeployment GetNodeConfigurationDeployment(string resourc
1375
1375
{
1376
1376
job = this . automationManagementClient . Jobs . Get ( resourceGroupName , automationAccountName , jobId ) . Job ;
1377
1377
1378
- nodeConfigurationName = PowerShellJsonConverter . Serialize ( job . Properties . Parameters [ "NodeConfigurationName" ] ) ;
1378
+ nodeConfigurationName = PowerShellJsonConverter
1379
+ . Deserialize ( job . Properties . Parameters [ "NodeConfigurationName" ] ) . ToString ( ) ;
1379
1380
1380
1381
// Fetch Nodes from the Param List.
1381
1382
var nodesJsonArray = PowerShellJsonConverter . Serialize ( job . Properties . Parameters [ "ListOfNodeNames" ] ) ;
1382
- var stringArray = Newtonsoft . Json . Linq . JArray . Parse ( JsonConvert . DeserializeObject < string > ( nodesJsonArray ) ) ;
1383
+ var stringArray =
1384
+ Newtonsoft . Json . Linq . JArray . Parse ( JsonConvert . DeserializeObject < string > ( nodesJsonArray ) ) ;
1383
1385
1384
- foreach ( var jt in stringArray )
1385
- {
1386
- var nodes = new List < string > ( ) ;
1387
- foreach ( var node in jt )
1388
- {
1389
- nodes . Add ( node . ToString ( ) ) ;
1390
- }
1391
- nodesList . Add ( nodes ) ;
1392
- }
1386
+ nodeLists . AddRange ( stringArray . Select ( jt => jt . Select ( node => node . ToString ( ) ) . ToList ( ) ) ) ;
1393
1387
1394
1388
// Fetch the status of each node.
1395
- foreach ( var nodeList in nodesList )
1389
+ foreach ( var nodeList in nodeLists )
1396
1390
{
1397
1391
IDictionary < string , string > dscNodeGroup = new Dictionary < string , string > ( ) ;
1398
1392
foreach ( var node in nodeList )
@@ -1401,14 +1395,18 @@ public NodeConfigurationDeployment GetNodeConfigurationDeployment(string resourc
1401
1395
IEnumerable < Model . DscNode > dscNodes ;
1402
1396
do
1403
1397
{
1404
- dscNodes = this . ListDscNodesByName ( resourceGroupName , automationAccountName , node , null , ref nextLink ) ;
1398
+ dscNodes = this . ListDscNodesByName ( resourceGroupName , automationAccountName , node , null ,
1399
+ ref nextLink ) ;
1405
1400
} while ( ! string . IsNullOrEmpty ( nextLink ) ) ;
1406
- var dscNode = dscNodes . First ( ) ;
1407
- dscNodeGroup . Add ( node , dscNode . Status ) ;
1401
+ dscNodeGroup . Add ( node , dscNodes . First ( ) . Status ) ;
1408
1402
}
1409
1403
nodesStatus . Add ( dscNodeGroup ) ;
1410
1404
}
1411
1405
}
1406
+ else
1407
+ {
1408
+ throw new ArgumentNullException ( nameof ( jobId ) , Resources . NoJobIdPassedToGetJobInformationCall ) ;
1409
+ }
1412
1410
return new NodeConfigurationDeployment ( resourceGroupName , automationAccountName , nodeConfigurationName , job , nodesStatus ) ;
1413
1411
}
1414
1412
@@ -1474,19 +1472,12 @@ public IEnumerable<NodeConfigurationDeployment> ListNodeConfigurationDeployment(
1474
1472
1475
1473
public IEnumerable < NodeConfigurationDeploymentSchedule > ListNodeConfigurationDeploymentSchedules ( string resourceGroupName , string automationAccountName , ref string nextLink )
1476
1474
{
1477
- JobScheduleListResponse response ;
1478
1475
const string runbookName = "Deploy-NodeConfigurationToAutomationDscNodesV1" ;
1479
1476
1480
- if ( string . IsNullOrEmpty ( nextLink ) )
1481
- {
1482
- response = this . automationManagementClient . JobSchedules . List ( resourceGroupName , automationAccountName ) ;
1483
- }
1484
- else
1485
- {
1486
- response = this . automationManagementClient . JobSchedules . ListNext ( nextLink ) ;
1487
- }
1477
+ var response = string . IsNullOrEmpty ( nextLink ) ? this . automationManagementClient . JobSchedules . List ( resourceGroupName , automationAccountName ) : this . automationManagementClient . JobSchedules . ListNext ( nextLink ) ;
1488
1478
1489
1479
nextLink = response . NextLink ;
1480
+
1490
1481
return response . JobSchedules . Where ( js => string . Equals ( js . Properties . Runbook . Name , runbookName , StringComparison . OrdinalIgnoreCase ) ) .
1491
1482
Select ( js => new NodeConfigurationDeploymentSchedule ( resourceGroupName , automationAccountName , js ) ) ;
1492
1483
}
0 commit comments