Skip to content

Commit

Permalink
Merge pull request #17 from MabOneSdk/anudeeb
Browse files Browse the repository at this point in the history
DownloadVaultCredentials
  • Loading branch information
Samuel Anudeep committed Jun 9, 2015
2 parents d3cf619 + cf7435b commit 03afff0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ public override void ExecuteCmdlet()

ExecutionBlock(() =>
{
WriteVerbose(string.Format("Profile == null : {0}", (Profile == null).ToString()));
WriteVerbose(string.Format("Profile.DefaultSubscription == null : {0}", (Profile.DefaultSubscription == null).ToString()));
if (!Directory.Exists(TargetLocation))
{
throw new ArgumentException("The target location provided is not a directory. Please provide a directory.");
}
string subscriptionId = Profile.DefaultSubscription.Id.ToString();
string resourceType = "resourceType";
string displayName = subscriptionId + "_" + ResourceGroupName + "_" + ResourceName;
Expand All @@ -62,7 +65,6 @@ public override void ExecuteCmdlet()
DateTime.UtcNow.AddHours(this.GetCertificateExpiryInHours()));
AcsNamespace acsNamespace = new AcsNamespace();
string channelIntegrityKey = string.Empty;
try
{
Expand All @@ -80,8 +82,16 @@ public override void ExecuteCmdlet()
string vaultCredsFileContent = GenerateVaultCreds(cert, subscriptionId, resourceType, acsNamespace);
// prepare for download
string fileName = string.Format("{0}_{1}.VaultCredentials", displayName, DateTime.UtcNow.ToLongDateString());
string filePath = Path.Combine(Path.GetDirectoryName(TargetLocation), fileName);
string fileName = string.Format("{0}_{1}.VaultCredentials", displayName, DateTime.UtcNow.ToString("yyyy-dd-M--HH-mm-ss"));
string directoryPath = Path.GetDirectoryName(TargetLocation);
if (directoryPath == null)
{
// TargetLocation is a root path
directoryPath = TargetLocation;
}
string filePath = Path.Combine(directoryPath, fileName);
WriteVerbose(string.Format("Saving Vault Credentials to file : {0}", filePath));
File.WriteAllBytes(filePath, Encoding.UTF8.GetBytes(vaultCredsFileContent));
// Output filename back to user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="BackupManagementInterface, Version=1.0.523.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Resources\BackupManagementInterface.dll</HintPath>
</Reference>
<Reference Include="BMSCommonInterface, Version=1.0.523.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Resources\BMSCommonInterface.dll</HintPath>
</Reference>
<Reference Include="Hyak.Common">
<HintPath>..\..\..\packages\Hyak.Common.1.0.2\lib\portable-net403+win+wpa81\Hyak.Common.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -116,6 +124,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AzureBackupContainerCmdletBase.cs" />
<Compile Include="AzureBackupDSCmdletBase.cs" />
<Compile Include="AzureBackupVaultCmdletBase.cs" />
<Compile Include="AzureBackupCmdletBase.cs" />
Expand Down Expand Up @@ -170,6 +179,8 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Content Include="Resources\BackupManagementInterface.dll" />
<Content Include="Resources\BMSCommonInterface.dll" />
<Content Include="Resources\Microsoft.WindowsAzure.Management.Common.dll" />
<Content Include="Resources\Security.Cryptography.dll" />
</ItemGroup>
Expand Down

0 comments on commit 03afff0

Please sign in to comment.