forked from Azure/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from MabOneSdk/csm-panbha1
Csm panbha1
- Loading branch information
Showing
7 changed files
with
155 additions
and
22 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackUpRestoreBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// 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.Management.Automation; | ||
using System.Collections.Generic; | ||
using System.Xml; | ||
using Microsoft.WindowsAzure.Commands.Utilities.Common; | ||
using Microsoft.Azure.Common.Authentication; | ||
using Microsoft.Azure.Common.Authentication.Models; | ||
using System.Threading; | ||
using Hyak.Common; | ||
using Microsoft.Azure.Commands.AzureBackup.Properties; | ||
using System.Net; | ||
using Microsoft.Azure.Commands.AzureBackup.Models; | ||
using Microsoft.Azure.Commands.AzureBackup.Cmdlets; | ||
|
||
namespace Microsoft.Azure.Commands.AzureBackup | ||
{ | ||
public abstract class AzureBackupRestoreBase : AzureBackupCmdletBase | ||
{ | ||
// ToDO: | ||
// Correct Help message and other attributes related to paameters | ||
[Parameter(Position = 0, Mandatory = true, HelpMessage = AzureBackupCmdletHelpMessage.AzureBackUpRecoveryPoint, ValueFromPipeline = true)] | ||
[ValidateNotNullOrEmpty] | ||
public AzureBackupRecoveryPoint RecoveryPoint { get; set; } | ||
|
||
public override void ExecuteCmdlet() | ||
{ | ||
base.ExecuteCmdlet(); | ||
|
||
WriteDebug(String.Format("Cmdlet called for ResourceGroupName: {0}, ResourceName: {1}", RecoveryPoint.ResourceGroupName, RecoveryPoint.ResourceName)); | ||
InitializeAzureBackupCmdlet(RecoveryPoint.ResourceGroupName, RecoveryPoint.ResourceName); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Restore/TriggerRestore.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// 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.Management.Automation; | ||
using System.Collections.Generic; | ||
using System.Xml; | ||
using System.Linq; | ||
using Microsoft.Azure.Management.BackupServices.Models; | ||
using MBS = Microsoft.Azure.Management.BackupServices; | ||
|
||
namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets | ||
{ | ||
/// <summary> | ||
/// Trigger Restore Job | ||
/// </summary> | ||
[Cmdlet(VerbsData.Restore, "AzureBackupItem"), OutputType(typeof(Guid))] | ||
public class RestoreAzureBackup : AzureBackupRestoreBase | ||
{ | ||
[Parameter(Position = 1, Mandatory = true, HelpMessage = AzureBackupCmdletHelpMessage.StorageAccountName)] | ||
[ValidateNotNullOrEmpty] | ||
public string StorageAccountName { get; set; } | ||
|
||
public override void ExecuteCmdlet() | ||
{ | ||
base.ExecuteCmdlet(); | ||
|
||
ExecutionBlock(() => | ||
{ | ||
WriteVerbose("Making client call"); | ||
Guid jobId = Guid.NewGuid(); | ||
WriteDebug("Triggered Restore. Converting response"); | ||
/* | ||
AzureIaaSVMRecoveryInputsCSMObject azureIaaSVMRecoveryInputsCSMObject = new AzureIaaSVMRecoveryInputsCSMObject() | ||
{ | ||
CloudServiceName = string.Empty, | ||
VmName = string.Empty, | ||
CreateNewCloudService = false, | ||
ContinueProtection = false, | ||
InputStorageAccountName = StorageAccountName, | ||
AffinityGroup = "", | ||
Region = RecoveryPoint.Location, | ||
}; | ||
JavaScriptSerializer serializer = new JavaScriptSerializer(); | ||
string azureIaaSVMRecoveryInputsCSMObjectString = serializer.Serialize(azureIaaSVMRecoveryInputsCSMObject); | ||
CSMRestoreRequest csmRestoreRequest = new CSMRestoreRequest() | ||
{ | ||
Properties = new CSMRestoreRequestProperties() | ||
{ | ||
TypeOfRecovery = RecoveryType.RestoreDisks.ToString(), | ||
RecoveryDSTypeSpecificInputs = azureIaaSVMRecoveryInputsCSMObjectString, | ||
}, | ||
}; | ||
Guid operationId = AzureBackupClient.TriggerRestore(RecoveryPoint.ContainerUniqueName, RecoveryPoint.ItemName, RecoveryPoint.RecoveryPointName, csmRestoreRequest); | ||
WriteDebug("Triggered Restore. Converting response"); | ||
var operationStatus = TrackOperation(operationId); | ||
WriteObject(GetCreatedJobs(new Models.AzurePSBackupVault(RecoveryPoint.ResourceGroupName, RecoveryPoint.ResourceName, RecoveryPoint.Location), operationStatus.Jobs).FirstOrDefault()); | ||
* */ | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters