diff --git a/src/ServiceManagement/Compute/Commands.ServiceManagement.Extensions.Test/Commands.ServiceManagement.Extensions.Test.csproj b/src/ServiceManagement/Compute/Commands.ServiceManagement.Extensions.Test/Commands.ServiceManagement.Extensions.Test.csproj
index 46dd90cd9d83..40f9d9c743b3 100644
--- a/src/ServiceManagement/Compute/Commands.ServiceManagement.Extensions.Test/Commands.ServiceManagement.Extensions.Test.csproj
+++ b/src/ServiceManagement/Compute/Commands.ServiceManagement.Extensions.Test/Commands.ServiceManagement.Extensions.Test.csproj
@@ -32,9 +32,12 @@
pdbonly
true
bin\Release\
- TRACE
+ TRACE;SIGN
prompt
4
+ true
+ true
+ MSSharedLibKey.snk
@@ -70,6 +73,10 @@
..\..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll
+
+ False
+ ..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.8.0.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll
+
..\..\..\packages\Microsoft.WindowsAzure.Management.4.0.0\lib\net40\Microsoft.WindowsAzure.Management.dll
@@ -91,6 +98,10 @@
..\..\..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Primitives.dll
+
+ False
+ ..\..\..\packages\xunit.1.9.2\lib\net20\xunit.dll
+
@@ -107,19 +118,29 @@
+
+
+ {5EE72C53-1720-4309-B54B-5FB79703195F}
+ Commands.Common
+
{C1BDA476-A5CC-4394-914D-48B0EC31A710}
Commands.ScenarioTests.Common
+
+ {4900EC4E-8DEB-4412-9108-0BC52F81D457}
+ Commands.Utilities
+
{e1ca72ba-8374-45f6-904d-fd34ecdf5b6f}
Commands.ServiceManagement
+
diff --git a/src/ServiceManagement/Compute/Commands.ServiceManagement.Extensions.Test/DSC/UnitTests/GetAzureVMDscExtensionStatusUnitTest.cs b/src/ServiceManagement/Compute/Commands.ServiceManagement.Extensions.Test/DSC/UnitTests/GetAzureVMDscExtensionStatusUnitTest.cs
new file mode 100644
index 000000000000..4c52d5675111
--- /dev/null
+++ b/src/ServiceManagement/Compute/Commands.ServiceManagement.Extensions.Test/DSC/UnitTests/GetAzureVMDscExtensionStatusUnitTest.cs
@@ -0,0 +1,272 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.Extensions;
+using Microsoft.WindowsAzure.Commands.ServiceManagement.Model;
+using Xunit;
+
+namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Extensions.Test.DSC.UnitTests
+{
+ using NSM = Management.Compute.Models;
+
+ public class GetAzureVmDscExtensionStatusUnitTest
+ {
+ private readonly GetAzureVmDscExtensionStatusCommand getAzureVmDscExtensionStatusCmdlet;
+ private const string ServiceName = "dsc-service";
+
+ public GetAzureVmDscExtensionStatusUnitTest()
+ {
+ getAzureVmDscExtensionStatusCmdlet = new GetAzureVmDscExtensionStatusCommand();
+ }
+
+ [Fact]
+ public void TestGetService()
+ {
+ //when service name is passed as argument in the cmdlet
+ getAzureVmDscExtensionStatusCmdlet.GetService(ServiceName, null);
+ Assert.Equal(ServiceName, getAzureVmDscExtensionStatusCmdlet.Service);
+
+ //when vm object is passed as argument in the cmdlet
+ getAzureVmDscExtensionStatusCmdlet.GetService("", GetAzureVM(ServiceName, ServiceName));
+ Assert.Equal(ServiceName, getAzureVmDscExtensionStatusCmdlet.Service);
+ }
+
+ [Fact]
+ public void TestGetVirtualMachineDscStatusContextListWithServiceName()
+ {
+ getAzureVmDscExtensionStatusCmdlet.Service = ServiceName;
+
+ // service has multiple vm's
+ var roles = new List {CreateRole("dscmachine01"), CreateRole("dscmachine02")};
+ var roleInstances = new List
+ {
+ CreateRoleInstance("dscmachine01"),
+ CreateRoleInstance("dscmachine02")
+ };
+
+ var deploymentResponse = CreateDeploymentGetResponse(ServiceName, roles, roleInstances);
+ var dscExtensionStatusContexts =
+ getAzureVmDscExtensionStatusCmdlet
+ .GetVirtualMachineDscStatusContextList(deploymentResponse);
+ Assert.Null(getAzureVmDscExtensionStatusCmdlet.Name);
+ Assert.Null(getAzureVmDscExtensionStatusCmdlet.VmName);
+ Assert.NotNull(dscExtensionStatusContexts);
+ Assert.Equal(dscExtensionStatusContexts.Count, 2);
+
+ }
+
+ [Fact]
+ public void TestGetVirtualMachineDscStatusContextListWithServiceNameAndVmName()
+ {
+ getAzureVmDscExtensionStatusCmdlet.Service = ServiceName;
+ getAzureVmDscExtensionStatusCmdlet.Name = "dscmachine01";
+
+ // service has multiple vm's
+ var roles = new List {CreateRole("dscmachine01"), CreateRole("dscmachine02")};
+ var roleInstances = new List
+ {
+ CreateRoleInstance("dscmachine01"),
+ CreateRoleInstance("dscmachine02")
+ };
+
+ var deploymentResponse = CreateDeploymentGetResponse(ServiceName, roles, roleInstances);
+ var dscExtensionStatusContexts =
+ getAzureVmDscExtensionStatusCmdlet
+ .GetVirtualMachineDscStatusContextList(deploymentResponse);
+ Assert.NotNull(getAzureVmDscExtensionStatusCmdlet.Name);
+ Assert.Null(getAzureVmDscExtensionStatusCmdlet.VmName);
+ Assert.NotNull(dscExtensionStatusContexts);
+ Assert.Equal(dscExtensionStatusContexts.Count, 1);
+
+ }
+
+ [Fact]
+ public void TestGetVirtualMachineDscStatusContextListWithServiceNameAndIncorrectVmName()
+ {
+ getAzureVmDscExtensionStatusCmdlet.Service = ServiceName;
+ getAzureVmDscExtensionStatusCmdlet.Name = "some-blah";
+
+ // service has multiple vm's
+ var roles = new List {CreateRole("dscmachine01"), CreateRole("dscmachine02")};
+ var roleInstances = new List
+ {
+ CreateRoleInstance("dscmachine01"),
+ CreateRoleInstance("dscmachine02")
+ };
+
+ var deploymentResponse = CreateDeploymentGetResponse(ServiceName, roles, roleInstances);
+ var dscExtensionStatusContexts =
+ getAzureVmDscExtensionStatusCmdlet
+ .GetVirtualMachineDscStatusContextList(deploymentResponse);
+ Assert.NotNull(getAzureVmDscExtensionStatusCmdlet.Name);
+ Assert.Null(getAzureVmDscExtensionStatusCmdlet.VmName);
+ Assert.Equal(dscExtensionStatusContexts.Count, 0);
+
+ }
+
+ [Fact]
+ public void TestGetVirtualMachineDscStatusContextListWithVm()
+ {
+ getAzureVmDscExtensionStatusCmdlet.Service = ServiceName;
+ getAzureVmDscExtensionStatusCmdlet.VmName = "dscmachine02";
+
+ // service has multiple vm's
+ var roles = new List {CreateRole("dscmachine02")};
+ var roleInstances = new List {CreateRoleInstance("dscmachine02")};
+
+ var deploymentResponse = CreateDeploymentGetResponse(ServiceName, roles, roleInstances);
+ var dscExtensionStatusContexts =
+ getAzureVmDscExtensionStatusCmdlet
+ .GetVirtualMachineDscStatusContextList(deploymentResponse);
+ Assert.Null(getAzureVmDscExtensionStatusCmdlet.Name);
+ Assert.NotNull(getAzureVmDscExtensionStatusCmdlet.VmName);
+ Assert.Equal(dscExtensionStatusContexts.Count, 1);
+ }
+
+ [Fact]
+ public void TestCreateDscStatusContext()
+ {
+ getAzureVmDscExtensionStatusCmdlet.Service = ServiceName;
+
+ var roles = new List {CreateRole("dscmachine02")};
+ var roleInstances = new List {CreateRoleInstance("dscmachine02")};
+ var context =
+ getAzureVmDscExtensionStatusCmdlet.CreateDscStatusContext(
+ roles[0], roleInstances[0]);
+ Assert.NotNull(context);
+ Assert.Equal(context.Name, "dscmachine02");
+ Assert.Equal(context.StatusCode, 1);
+ Assert.Equal(context.ServiceName, ServiceName);
+ Assert.Equal(context.Status, "Success");
+ Assert.Equal(context.StatusMessage, "Dsc Configuration was applied successful");
+ Assert.Equal(context.DscConfigurationLog.Count(), GetFormattedMessage().Count());
+ }
+
+ private IPersistentVM GetAzureVM(String roleName, String serviceName)
+ {
+ var vm = new PersistentVM {RoleName = roleName};
+ var vmContext = new PersistentVMRoleContext
+ {
+ DeploymentName = roleName,
+ Name = roleName,
+ ServiceName = serviceName,
+ VM = vm
+ };
+
+ return vmContext;
+ }
+
+ private NSM.DeploymentGetResponse CreateDeploymentGetResponse(string serviceName, IList roles,
+ IList roleInstances)
+ {
+ var response = new NSM.DeploymentGetResponse
+ {
+ Name = serviceName,
+ Configuration = "config",
+ Status = Management.Compute.Models.DeploymentStatus.Starting,
+ PersistentVMDowntime = new NSM.PersistentVMDowntime
+ {
+ EndTime = DateTime.Now,
+ StartTime = DateTime.Now,
+ Status = "",
+ },
+ LastModifiedTime = DateTime.Now,
+ Roles = roles,
+ RoleInstances = roleInstances
+ };
+
+ return response;
+ }
+
+ private NSM.RoleInstance CreateRoleInstance(String roleName)
+ {
+ var roleInstance = new NSM.RoleInstance
+ {
+ RoleName = roleName,
+ ResourceExtensionStatusList = CreateResourceExtensionStatus()
+ };
+ return roleInstance;
+ }
+
+ private NSM.Role CreateRole(String roleName)
+ {
+ var role = new NSM.Role
+ {
+ RoleName = roleName
+ };
+
+ return role;
+ }
+
+ private List CreateResourceExtensionStatus()
+ {
+ var resourceExtensionStatusList = new List();
+
+ var resourceBgiExtensionStatus = new NSM.ResourceExtensionStatus
+ {
+ HandlerName = "BGIInfo"
+ };
+ var resourceDscExtensionStatus = new NSM.ResourceExtensionStatus
+ {
+ HandlerName = "Microsoft.Powershell.DSC",
+ ExtensionSettingStatus = CreateExtensionSettingStatus()
+ };
+
+ resourceExtensionStatusList.Add(resourceBgiExtensionStatus);
+ resourceExtensionStatusList.Add(resourceDscExtensionStatus);
+
+ return resourceExtensionStatusList;
+ }
+
+ private NSM.ResourceExtensionConfigurationStatus CreateExtensionSettingStatus()
+ {
+ var extensionSettingStatus = new NSM.ResourceExtensionConfigurationStatus
+ {
+ Code = 1,
+ Status = "Success",
+ FormattedMessage = new NSM.GuestAgentFormattedMessage
+ {
+ Message = "Dsc Configuration was applied successful"
+ },
+ Timestamp = new DateTime(),
+ SubStatusList = CreateResourceExtensionSubStatus(1, CreateGuestAgentFormattedMessage())
+ };
+
+ return extensionSettingStatus;
+ }
+
+ private List CreateResourceExtensionSubStatus(int code,
+ NSM.GuestAgentFormattedMessage formattedMessage)
+ {
+ var resourceExtensionSubStatusList = new List();
+ var resourceExtensionSubStatus = new NSM.ResourceExtensionSubStatus
+ {
+ Code = code,
+ FormattedMessage = formattedMessage,
+ Status = "Success",
+ Name = "DSC Status"
+ };
+ resourceExtensionSubStatusList.Add(resourceExtensionSubStatus);
+ return resourceExtensionSubStatusList;
+ }
+
+ private NSM.GuestAgentFormattedMessage CreateGuestAgentFormattedMessage()
+ {
+ var formattedMessage = new NSM.GuestAgentFormattedMessage
+ {
+ Message =
+ "[ESPARMAR-2012R2]:LCM:[Start Set]\r\n[ESPARMAR-2012R2]:LCM:[Start Resource] " +
+ "[[WindowsFeature]IIS]\r\n[ESPARMAR-2012R2]:LCM:[Start Test] [[WindowsFeature]IIS]\r\n[ESPARMAR-2012R2]"
+ };
+ return formattedMessage;
+ }
+
+ private IEnumerable GetFormattedMessage()
+ {
+ const string message = "[ESPARMAR-2012R2]:LCM:[Start Set]\r\n[ESPARMAR-2012R2]:LCM:[Start Resource] " +
+ "[[WindowsFeature]IIS]\r\n[ESPARMAR-2012R2]:LCM:[Start Test] [[WindowsFeature]IIS]\r\n[ESPARMAR-2012R2]";
+
+ return message.Split(new[] {"\r\n", "\n"}, StringSplitOptions.None);
+ }
+ }
+}
diff --git a/src/ServiceManagement/Compute/Commands.ServiceManagement.Extensions.Test/MSSharedLibKey.snk b/src/ServiceManagement/Compute/Commands.ServiceManagement.Extensions.Test/MSSharedLibKey.snk
new file mode 100644
index 000000000000..695f1b38774e
Binary files /dev/null and b/src/ServiceManagement/Compute/Commands.ServiceManagement.Extensions.Test/MSSharedLibKey.snk differ
diff --git a/src/ServiceManagement/Compute/Commands.ServiceManagement/Commands.ServiceManagement.csproj b/src/ServiceManagement/Compute/Commands.ServiceManagement/Commands.ServiceManagement.csproj
index edf24aebccc9..45c2fdc2e4ec 100644
--- a/src/ServiceManagement/Compute/Commands.ServiceManagement/Commands.ServiceManagement.csproj
+++ b/src/ServiceManagement/Compute/Commands.ServiceManagement/Commands.ServiceManagement.csproj
@@ -206,6 +206,7 @@
+
@@ -216,6 +217,7 @@
+
diff --git a/src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/Extensions/DSC/GetAzureVMDscExtension.cs b/src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/Extensions/DSC/GetAzureVMDscExtension.cs
index abc52a38db9b..fc96cb5033a6 100644
--- a/src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/Extensions/DSC/GetAzureVMDscExtension.cs
+++ b/src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/Extensions/DSC/GetAzureVMDscExtension.cs
@@ -72,7 +72,7 @@ internal void ExecuteCommand()
State = r.State,
RoleName = VM.GetInstance().RoleName,
PublicConfiguration = PublicConfiguration,
- PrivateConfiguration = SecureStringHelper.GetSecureString(PrivateConfiguration),
+ PrivateConfiguration = SecureStringHelper.GetSecureString(PrivateConfiguration)
};
if (publicSettings == null)
@@ -99,6 +99,7 @@ protected override void ProcessRecord()
base.ProcessRecord();
ExecuteCommand();
}
+
}
}
diff --git a/src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/Extensions/DSC/GetAzureVMDscExtensionStatus.cs b/src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/Extensions/DSC/GetAzureVMDscExtensionStatus.cs
new file mode 100644
index 000000000000..1130dd1055f2
--- /dev/null
+++ b/src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/Extensions/DSC/GetAzureVMDscExtensionStatus.cs
@@ -0,0 +1,256 @@
+// ----------------------------------------------------------------------------------
+//
+// Copyright Microsoft Corporation
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// ----------------------------------------------------------------------------------
+
+using System;
+using System.Net;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Management.Automation;
+using Hyak.Common;
+using Microsoft.WindowsAzure.Commands.ServiceManagement.Model;
+using Microsoft.WindowsAzure.Commands.ServiceManagement.Properties;
+using Microsoft.WindowsAzure.Management.Compute;
+
+
+namespace Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.Extensions
+{
+ using NSM = Management.Compute.Models;
+
+ ///
+ /// This cmdlet is used to get the status of the DSC extension handler for all or for a given virtual machine(s)
+ /// in a cloud service. When a configuration is applied this cmdlet produces output consistent with Start-DscConfiguration.
+ ///
+ /// Not: To get detailed output -Verbose flag need to be specified
+ ///
+ /// Example Usage:
+ /// Get-AzureVMDscExtensionStatus -ServiceName service
+ /// Get-AzureVMDscExtensionStatus -ServiceName service -Name VM-name
+ /// Get-AzureVMDscExtensionStatus -VM vm
+ ///
+ [Cmdlet(
+ VerbsCommon.Get,
+ VirtualMachineDscStatusCmdletNoun,
+ DefaultParameterSetName = GetStatusByServiceAndVmNameParamSet),
+ OutputType(typeof(VirtualMachineDscExtensionStatusContext))]
+ public class GetAzureVmDscExtensionStatusCommand : IaaSDeploymentManagementCmdletBase
+ {
+ ///
+ /// Name of the cloud service for DSC Extension Status
+ ///
+ [Parameter(
+ ParameterSetName = GetStatusByServiceAndVmNameParamSet,
+ Position = 0,
+ Mandatory = true,
+ ValueFromPipelineByPropertyName = true,
+ HelpMessage = "Name of the cloud service for DSC Extension Status.")]
+ [ValidateNotNullOrEmpty]
+ public override string ServiceName { get; set; }
+
+ ///
+ /// Name of the VM in a cloud service for DSC Extension Status
+ ///
+ [Parameter(
+ ParameterSetName = GetStatusByServiceAndVmNameParamSet,
+ Position = 1,
+ ValueFromPipelineByPropertyName = true,
+ HelpMessage = "The name of the deployment for the status.")]
+ [ValidateNotNullOrEmpty]
+ public string Name { get; set; }
+
+ ///
+ /// VM object returned by Get-AzureVM cmdlet for DSC Extension Status
+ ///
+ [Parameter(
+ ParameterSetName = GetStatusByVmParamSet,
+ Mandatory = true,
+ ValueFromPipeline = true,
+ ValueFromPipelineByPropertyName = true,
+ HelpMessage = "Virtual machine object for the status.")]
+ [ValidateNotNullOrEmpty]
+ [Alias("InputObject")]
+ public IPersistentVM VM { get; set; }
+
+ protected const string VirtualMachineDscStatusCmdletNoun = "AzureVMDscExtensionStatus";
+ protected const string GetStatusByServiceAndVmNameParamSet = "GetStatusByServiceAndVMName";
+ protected const string GetStatusByVmParamSet = "GetStatusByVM";
+
+ internal string Service;
+ internal string VmName;
+
+ ///
+ /// This method is the entry point for this cmdlet. It gets the deployment information based on the service name
+ /// and/or vm name and returns the status information for the DSC Extension Handler.
+ ///
+ protected override void ExecuteCommand()
+ {
+ ServiceManagementProfile.Initialize();
+ GetService(ServiceName, VM);
+ GetCurrentDeployment();
+
+ if (CurrentDeploymentNewSM == null)
+ {
+ WriteWarning(
+ string.Format(CultureInfo.CurrentUICulture, Resources.NoDeploymentFoundInService, Service));
+ return;
+ }
+
+ var vmDscStatusContexts = GetVirtualMachineDscStatusContextList(CurrentDeploymentNewSM);
+ if (vmDscStatusContexts == null || vmDscStatusContexts.Count < 1)
+ {
+ WriteWarning(Resources.ResourceExtensionReferenceCannotBeFound);
+ }
+ WriteObject(vmDscStatusContexts, true);
+ }
+
+ ///
+ /// Retrieves service name from the cmdlet's service name or virtual machine parameter
+ ///
+ /// Name of the cloud service for DSC Extension Status
+ /// Name of the VM in a cloud service for DSC Extension Status
+ internal void GetService(String serviceName, IPersistentVM vm)
+ {
+ if (!string.IsNullOrEmpty(serviceName))
+ {
+ Service = serviceName;
+ }
+ else
+ {
+ //get the service name from the VM object
+ var vmRoleContext = vm as PersistentVMRoleContext;
+ if (vmRoleContext == null)
+ return;
+
+ Service = vmRoleContext.ServiceName;
+ VmName = vmRoleContext.Name;
+ }
+ }
+
+ ///
+ /// Retrieves deployment information for a cloud service from service api's
+ ///
+ internal void GetCurrentDeployment()
+ {
+ InvokeInOperationContext(() =>
+ {
+ try
+ {
+ if (string.IsNullOrEmpty(Service))
+ return;
+
+ CurrentDeploymentNewSM = ComputeClient.Deployments.GetBySlot(Service, NSM.DeploymentSlot.Production);
+ GetDeploymentOperationNewSM = GetOperationNewSM(CurrentDeploymentNewSM.RequestId);
+ WriteVerboseWithTimestamp(Resources.GetDeploymentCompletedOperation);
+ }
+ catch (CloudException ex)
+ {
+ if (ex.Response.StatusCode != HttpStatusCode.NotFound)
+ {
+ throw;
+ }
+ }
+ });
+ }
+
+ ///
+ /// Retrieves dsc extension status for all virtual machine's in a cloud service or a given virtual machine from the deployment object
+ ///
+ /// Deployment that exists in the service
+ ///
+ internal List GetVirtualMachineDscStatusContextList(NSM.DeploymentGetResponse deployment)
+ {
+ var vmDscStatusContexts = new List();
+
+ //filter the deployment info for a vm, if specified.
+ var vmRoles = new List(deployment.Roles.Where(
+ r => (string.IsNullOrEmpty(Name) && string.IsNullOrEmpty(VmName))
+ || r.RoleName.Equals(Name, StringComparison.InvariantCultureIgnoreCase)
+ || r.RoleName.Equals(VmName, StringComparison.InvariantCultureIgnoreCase)));
+
+ foreach (var vm in vmRoles)
+ {
+ var roleInstance = deployment.RoleInstances.FirstOrDefault(
+ r => r.RoleName == vm.RoleName);
+
+ if (roleInstance == null)
+ {
+ WriteWarning(
+ string.Format(CultureInfo.CurrentUICulture, Resources.RoleInstanceCanNotBeFoundWithName, vm.RoleName));
+ }
+
+ var vmDscStatusContext = CreateDscStatusContext(
+ vm,
+ roleInstance);
+
+ if (vmDscStatusContext != null)
+ vmDscStatusContexts.Add(vmDscStatusContext);
+ }
+
+ return vmDscStatusContexts;
+ }
+
+ ///
+ /// Creates dsc extension status object for a virtual machine
+ ///
+ /// Details of a role in the deployment
+ /// Details of a specific role instance
+ ///
+ internal VirtualMachineDscExtensionStatusContext CreateDscStatusContext(NSM.Role vmRole, NSM.RoleInstance roleInstance)
+ {
+ var message = string.Empty;
+ var extension = VirtualMachineDscExtensionCmdletBase.ExtensionPublishedNamespace + "."
+ + VirtualMachineDscExtensionCmdletBase.ExtensionPublishedName;
+ NSM.ResourceExtensionConfigurationStatus extensionSettingStatus = null;
+
+ if (roleInstance != null && roleInstance.ResourceExtensionStatusList != null)
+ {
+ foreach (var resourceExtensionStatus in
+ roleInstance.ResourceExtensionStatusList.Where(
+ resourceExtensionStatus => resourceExtensionStatus.HandlerName.Equals(
+ extension, StringComparison.InvariantCultureIgnoreCase)).
+ Where(resourceExtensionStatus => resourceExtensionStatus.ExtensionSettingStatus != null))
+ {
+ extensionSettingStatus = resourceExtensionStatus.ExtensionSettingStatus;
+
+ if (extensionSettingStatus.SubStatusList == null) continue;
+ var resourceExtensionSubStatusList = extensionSettingStatus.SubStatusList;
+ var resourceExtensionSubStatus = resourceExtensionSubStatusList.FirstOrDefault();
+ if (resourceExtensionSubStatus == null || resourceExtensionSubStatus.FormattedMessage == null ||
+ resourceExtensionSubStatus.FormattedMessage.Message == null) continue;
+ message = resourceExtensionSubStatus.FormattedMessage.Message.ToString(CultureInfo.CurrentUICulture);
+ break;
+ }
+ }
+
+ if (extensionSettingStatus == null)
+ return null;
+
+ var dscStatusContext = new VirtualMachineDscExtensionStatusContext
+ {
+ ServiceName = Service,
+ Name = vmRole == null ? string.Empty : vmRole.RoleName,
+ Status = extensionSettingStatus.Status ?? string.Empty,
+ StatusCode = extensionSettingStatus.Code ?? -1,
+ StatusMessage = (extensionSettingStatus.FormattedMessage == null ||
+ extensionSettingStatus.FormattedMessage.Message == null) ? string.Empty :
+ extensionSettingStatus.FormattedMessage.Message.ToString(CultureInfo.CurrentUICulture),
+ DscConfigurationLog = !string.Empty.Equals(message) ? message.Split(new[] { "\r\n", "\n" }, StringSplitOptions.None) : new List().ToArray(),
+ Timestamp = extensionSettingStatus.Timestamp == null ? DateTime.MinValue : extensionSettingStatus.Timestamp.Value
+ };
+ return dscStatusContext;
+ }
+
+ }
+}
+
diff --git a/src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/Extensions/DSC/VirtualMachineDscExtensionStatusContext.cs b/src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/Extensions/DSC/VirtualMachineDscExtensionStatusContext.cs
new file mode 100644
index 000000000000..fc9e646a3b42
--- /dev/null
+++ b/src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/Extensions/DSC/VirtualMachineDscExtensionStatusContext.cs
@@ -0,0 +1,16 @@
+
+using System;
+
+namespace Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.Extensions
+{
+ public class VirtualMachineDscExtensionStatusContext
+ {
+ public string ServiceName { get; set; }
+ public string Name { get; set; }
+ public string Status { get; set; }
+ public int StatusCode { get; set; }
+ public string StatusMessage { get; set; }
+ public string[] DscConfigurationLog { get; set; }
+ public DateTimeOffset Timestamp { get; set; }
+ }
+}
diff --git a/src/ServiceManagement/Compute/Commands.ServiceManagement/Microsoft.WindowsAzure.Commands.ServiceManagement.dll-Help.xml b/src/ServiceManagement/Compute/Commands.ServiceManagement/Microsoft.WindowsAzure.Commands.ServiceManagement.dll-Help.xml
index c14640929f68..409f7107d0b0 100644
--- a/src/ServiceManagement/Compute/Commands.ServiceManagement/Microsoft.WindowsAzure.Commands.ServiceManagement.dll-Help.xml
+++ b/src/ServiceManagement/Compute/Commands.ServiceManagement/Microsoft.WindowsAzure.Commands.ServiceManagement.dll-Help.xml
@@ -7974,60 +7974,65 @@ The default value is Production.
+
-
- Get-AzureVMDscExtension
+
+ Get-AzureVMDscExtension
+
Gets the settings of the DSC extension on a particular VM.
-
+
Get
AzureVMDscExtension
-
+
-
Gets the settings of the DSC extension on a particular VM.
+
Get-AzureVMDscExtension
-
- Version
-
- The specific version of the DSC extension that Get-AzureVMDSCExtension will get the settings from.
-
- String
-
-
+
VM
The Virtual Machine to get the settings from.
IPersistentVM
+
+ Version
+
+ The specific version of the DSC extension that Get-AzureVMDSCExtension will get the settings from.
+
+ string
+
+
-
+
Version
The specific version of the DSC extension that Get-AzureVMDSCExtension will get the settings from.
+
- String
+ string
- String
+ string
-
+
VM
The Virtual Machine to get the settings from.
+
IPersistentVM
@@ -8037,77 +8042,208 @@ The default value is Production.
+
-
-
-
+
-
+
+
+
+
+
+
- Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.Extensions.VirtualMachineDscExtensionContext
-
+ Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.Extensions.VirtualMachineDscExtensionContext
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Get-AzureVMDscExtensionStatus
+
+
+ Get the DSC Extension status for all the vm's deployed in a cloud service or for a particular vm in the service.
+
+
+
+
+ Get
+ AzureVMDscExtensionStatus
+
+
+
+ Get the DSC Extension status for all the vm's deployed in a cloud service or for a particular vm in the service.
+
+
+
+
+ Get-AzureVMDscExtensionStatus
+
+ ServiceName
-
+ Name of the service
+
+ string
+
+
+ Name
+
+ Name of the vm
+ string
+
+
+
+ Get-AzureVMDscExtensionStatus
+
+ VM
+
+ The persistent VM object.
+
+ PersistentVMRoleContext
+
+
+
+
+
+
+ Name
+
+ Name of the vm
+
+
+ string
+
+ string
+
-
-
-
-
-
+
+
+
+ ServiceName
+
+ Name of the service
+
+
+ string
+
+ string
+
+
+
+
+
+ VM
+
+ The persistent VM object.
+
+
+ PersistentVMRoleContext
+
+ PersistentVMRoleContext
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.Extensions.VirtualMachineDscExtensionStatusContext
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
- -------------------------- EXAMPLE 1 --------------------------
-
-
-
- PS C:\> Get-AzureVMDscExtension -VM $vm
-
- ModulesUrl : https://myaccount.blob.core.windows.net/windows-powershell-dsc/MyConfiguration.ps1.zip
- ConfigurationFunction : MyConfiguration.ps1\MyConfiguration
- Properties : {ServerName}
- ExtensionName : DSC
- Publisher : Microsoft.Powershell
- Version : 1.*
- PrivateConfiguration :
- PublicConfiguration : {
- "ModulesUrl": "https://myaccount.blob.core.windows.net/windows-powershell-dsc/MyConfiguration.ps1.zip",
- "ConfigurationFunction": "MyConfiguration.ps1\\MyConfiguration",
- "Properties": {
- "ServerName": "C:\\MyDirectory"
- }
- }
- ReferenceName : DSC
- State : Enable
- RoleName : my-vm
-
- Description
-
-
-
- -----------This command gets the settings of the DSC Extension on a VM.
-
-
-
+
- Unknown
-
+
+
diff --git a/src/ServiceManagement/Compute/Commands.ServiceManagement/Microsoft.WindowsAzure.Commands.ServiceManagement.format.ps1xml b/src/ServiceManagement/Compute/Commands.ServiceManagement/Microsoft.WindowsAzure.Commands.ServiceManagement.format.ps1xml
index 937c3db9c5c2..677a5117b11d 100644
--- a/src/ServiceManagement/Compute/Commands.ServiceManagement/Microsoft.WindowsAzure.Commands.ServiceManagement.format.ps1xml
+++ b/src/ServiceManagement/Compute/Commands.ServiceManagement/Microsoft.WindowsAzure.Commands.ServiceManagement.format.ps1xml
@@ -590,5 +590,87 @@
+
+ Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.Extensions.VirtualMachineDscExtensionContext
+
+ Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.Extensions.VirtualMachineDscExtensionContext
+
+
+
+
+
+
+
+ ExtensionName
+
+
+
+ Publisher
+
+
+
+ Version
+
+
+
+ ModulesUrl
+
+
+
+ ConfigurationFunction
+
+
+
+ Properties
+
+
+
+
+
+
+
+ Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.Extensions.VirtualMachineDscExtensionStatusContext
+
+ Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.Extensions.VirtualMachineDscExtensionStatusContext
+
+
+
+
+
+
+
+ ServiceName
+
+
+
+ Name
+
+
+
+ Status
+
+
+
+ StatusCode
+
+
+
+
+ $_.Timestamp.ToString("G")
+
+
+
+
+ StatusMessage
+
+
+
+ DscConfigurationLog
+
+
+
+
+
+
diff --git a/src/ServiceManagement/Compute/Commands.ServiceManagement/Properties/AssemblyInfo.cs b/src/ServiceManagement/Compute/Commands.ServiceManagement/Properties/AssemblyInfo.cs
index bf87e482d3c5..c76248029534 100644
--- a/src/ServiceManagement/Compute/Commands.ServiceManagement/Properties/AssemblyInfo.cs
+++ b/src/ServiceManagement/Compute/Commands.ServiceManagement/Properties/AssemblyInfo.cs
@@ -33,6 +33,8 @@
#if SIGN
[assembly: InternalsVisibleTo("Microsoft.WindowsAzure.Commands.ServiceManagement.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
+[assembly: InternalsVisibleTo("Microsoft.WindowsAzure.Commands.ServiceManagement.Extensions.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
#else
[assembly: InternalsVisibleTo("Microsoft.WindowsAzure.Commands.ServiceManagement.Test")]
+[assembly: InternalsVisibleTo("Microsoft.WindowsAzure.Commands.ServiceManagement.Extensions.Test")]
#endif