Skip to content

Add Opt-out for DSC Extension DataCollection #1749

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from Jan 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Microsoft.WindowsAzure.Storage.Blob;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Management.Automation;
Expand Down Expand Up @@ -207,6 +208,17 @@ public class SetAzureVMDscExtensionCommand : VirtualMachineExtensionBaseCmdlet
[ValidateSetAttribute(new[] { "4.0", "latest", "5.0PP" })]
public string WmfVersion { get; set; }

/// <summary>
/// The Extension Data Collection state
/// </summary>
[Parameter(ValueFromPipelineByPropertyName = true,
HelpMessage = "Enables or Disables Data Collection in the extension. It is enabled if it is not specified. " +
"The value is persisted in the extension between calls.")
]
[ValidateSet("Enable", "Disable")]
[AllowNull]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between giving 'null' value for this parameter and not giving this parameter at all?
Since this parameter is optional, I think it is better not to allow 'null'.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Null would leave the VM extension in the current state. Not giving this parameter and null are equivalent.

public string DataCollection { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually it should be using SwitchParameter.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need three states enable, disable and not specified. a switch parameter does not allow all three states, or possible future states.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Thanks.


//Private Variables
private const string VersionRegexExpr = @"^(([0-9])\.)\d+$";

Expand Down Expand Up @@ -309,6 +321,11 @@ private void CreateConfiguration()

publicSettings.SasToken = configurationUris.SasToken;
publicSettings.ModulesUrl = configurationUris.ModulesUrl;

Hashtable privacySetting = new Hashtable();
privacySetting.Add("DataCollection", DataCollection);
publicSettings.Privacy = privacySetting;

publicSettings.ConfigurationFunction = string.Format(
CultureInfo.InvariantCulture,
"{0}\\{1}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14089,6 +14089,13 @@ Set-AzureRmVMDiskEncryptionExtension -ResourceGroupName $rgname -VMName $vmName
</maml:description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>DataCollection</maml:name>
<maml:description>
<maml:para>Enables or Disables Data Collection in the extension. It is enabled if it is not specified. The value is persisted in the extension between calls. Allowed Values are: Enable and Disable</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
Expand Down Expand Up @@ -14287,6 +14294,18 @@ Set-AzureRmVMDiskEncryptionExtension -ResourceGroupName $rgname -VMName $vmName
</dev:type>
<dev:defaultValue>latest</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>DataCollection</maml:name>
<maml:description>
<maml:para>Enables or Disables Data Collection in the extension. It is enabled if it is not specified. The value is persisted in the extension between calls. Allowed Values are: Enable and Disable</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
<dev:type>
<maml:name>string</maml:name>
<maml:uri/>
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>InformationAction</maml:name>
<maml:description>
Expand Down Expand Up @@ -17670,4 +17689,4 @@ PS C:\&gt; $VirtualMachine07 = Set-AzureRmVMSourceImage -VM $VirtualMachine07 -I
<maml:relatedLinks>
</maml:relatedLinks>
</command:command>
</helpItems>
</helpItems>
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ public class Property
/// </summary>
public Property[] Properties { get; set; }

/// <summary>
/// Privacy parameters
/// </summary>
public Hashtable Privacy { get; set; }

/// <summary>
/// Version of the protocol (DscExtensionPublicSettings and DscExtensionPrivateSettings mostly).
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using Microsoft.WindowsAzure.Storage.Blob;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Management.Automation;
Expand Down Expand Up @@ -156,6 +157,17 @@ public class SetAzureVMDscExtension : VirtualMachineExtensionCmdletBase
[ValidateSetAttribute(new[] { "4.0", "latest", "5.0PP" })]
public string WmfVersion { get; set; }

/// <summary>
/// The Extension Data Collection state
/// </summary>
[Parameter(ValueFromPipelineByPropertyName = true,
HelpMessage = "Enables or Disables Data Collection in the extension. It is enabled if it is not specified. " +
"The value is persisted in the extension between calls.")
]
[ValidateSet("Enable", "Disable")]
[AllowNull]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as my above comment.

public string DataCollection { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually it should be using SwitchParameter.


/// <summary>
/// Credentials used to access Azure Storage
/// </summary>
Expand Down Expand Up @@ -389,6 +401,11 @@ private void CreateConfiguration()

publicSettings.SasToken = configurationUris.SasToken;
publicSettings.ModulesUrl = configurationUris.ModulesUrl;

Hashtable privacySetting = new Hashtable();
privacySetting.Add("DataCollection",DataCollection);
publicSettings.Privacy = privacySetting;

publicSettings.ConfigurationFunction = string.Format(
CultureInfo.InvariantCulture,
"{0}\\{1}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36528,6 +36528,13 @@ PS C:\&gt; Update-AzureVM -ServiceName $Service_Name -Name $VM_Name -VM $VM_Upda
</maml:description>
<command:parameterValue required="true" variableLength="false">IPersistentVM</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>DataCollection</maml:name>
<maml:description>
<maml:para>Enables or Disables Data Collection in the extension. It is enabled if it is not specified. The value is persisted in the extension between calls. Allowed Values are: Enable and Disable</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>Confirm</maml:name>
<maml:description>
Expand Down Expand Up @@ -36695,6 +36702,18 @@ PS C:\&gt; Update-AzureVM -ServiceName $Service_Name -Name $VM_Name -VM $VM_Upda
</dev:type>
<dev:defaultValue>none</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>DataCollection</maml:name>
<maml:description>
<maml:para>Enables or Disables Data Collection in the extension. It is enabled if it is not specified. The value is persisted in the extension between calls. Allowed Values are: Enable and Disable</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
<dev:type>
<maml:name>string</maml:name>
<maml:uri/>
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>Confirm</maml:name>
<maml:description>
Expand Down