Skip to content
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

Fix the issue of New-AzureRmDisk, New-AzureRmSnapshot, Update-AzureRm… #4314

Merged
merged 1 commit into from
Jul 14, 2017
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 @@ -19,6 +19,7 @@
// Changes to this file may cause incorrect behavior and will be lost if the
// code is regenerated.

using AutoMapper;
using Microsoft.Azure.Commands.Compute.Automation.Models;
using Microsoft.Azure.Management.Compute;
using Microsoft.Azure.Management.Compute.Models;
Expand Down Expand Up @@ -117,16 +118,20 @@ public partial class NewAzureRmDisk : ComputeAutomationBaseCmdlet
{
protected override void ProcessRecord()
{
ComputeAutomationAutoMapperProfile.Initialize();
ExecuteClientAction(() =>
{
if (ShouldProcess(this.ResourceGroupName, VerbsCommon.New))
{
string resourceGroupName = this.ResourceGroupName;
string diskName = this.DiskName;
PSDisk disk = this.Disk;

Disk disk = new Disk();
Mapper.Map<PSDisk, Disk>(this.Disk, disk);
var result = DisksClient.CreateOrUpdate(resourceGroupName, diskName, disk);
WriteObject(result);

PSDisk psResult = new PSDisk();
Mapper.Map<Disk, PSDisk>(result, psResult);
WriteObject(psResult);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,23 @@ public partial class UpdateAzureRmDisk : ComputeAutomationBaseCmdlet
{
protected override void ProcessRecord()
{
ComputeAutomationAutoMapperProfile.Initialize();
ExecuteClientAction(() =>
{
if (ShouldProcess(this.ResourceGroupName, VerbsData.Update))
{

string resourceGroupName = this.ResourceGroupName;
string diskName = this.DiskName;
PSDiskUpdate disk = this.DiskUpdate;
PSDisk diskOrg = this.Disk;

var result = (disk == null)
? DisksClient.CreateOrUpdate(resourceGroupName, diskName, diskOrg)
: DisksClient.Update(resourceGroupName, diskName, disk);
Disk diskObj = new Disk();
Mapper.Map<PSDisk, Disk>(this.Disk, diskObj);

DiskUpdate diskUpdateObj= new DiskUpdate();
Mapper.Map<PSDiskUpdate, DiskUpdate>(this.DiskUpdate, diskUpdateObj);

var result = (this.DiskUpdate == null)
? DisksClient.CreateOrUpdate(resourceGroupName, diskName, diskObj)
: DisksClient.Update(resourceGroupName, diskName, diskUpdateObj);

var psObject = new PSDisk();
Mapper.Map<Disk, PSDisk>(result, psObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ protected override void Configure()
Mapper.CreateMap<FROM.DiskUpdate, FROM.Disk>();
Mapper.CreateMap<FROM.Snapshot, FROM.SnapshotUpdate>();
Mapper.CreateMap<FROM.SnapshotUpdate, FROM.Snapshot>();
Mapper.CreateMap<FROM.Disk, TO.PSDisk>();
Mapper.CreateMap<TO.PSDisk, FROM.Disk>();
Mapper.CreateMap<FROM.DiskUpdate, TO.PSDiskUpdate>();
Mapper.CreateMap<TO.PSDiskUpdate, FROM.DiskUpdate>();
Mapper.CreateMap<FROM.Snapshot, TO.PSSnapshot>();
Mapper.CreateMap<TO.PSSnapshot, FROM.Snapshot>();
Mapper.CreateMap<FROM.SnapshotUpdate, TO.PSSnapshotUpdate>();
Mapper.CreateMap<TO.PSSnapshotUpdate, FROM.SnapshotUpdate>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// Changes to this file may cause incorrect behavior and will be lost if the
// code is regenerated.

using AutoMapper;
using Microsoft.Azure.Commands.Compute.Automation.Models;
using Microsoft.Azure.Management.Compute;
using Microsoft.Azure.Management.Compute.Models;
Expand Down Expand Up @@ -117,16 +118,21 @@ public partial class NewAzureRmSnapshot : ComputeAutomationBaseCmdlet
{
protected override void ProcessRecord()
{
ComputeAutomationAutoMapperProfile.Initialize();
ExecuteClientAction(() =>
{
if (ShouldProcess(this.ResourceGroupName, VerbsCommon.New))
{
string resourceGroupName = this.ResourceGroupName;
string snapshotName = this.SnapshotName;
PSSnapshot snapshot = this.Snapshot;
Snapshot snapshot = new Snapshot();
Mapper.Map<PSSnapshot, Snapshot>(this.Snapshot, snapshot);

var result = SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshot);
WriteObject(result);

PSSnapshot psResult = new PSSnapshot();
Mapper.Map<Snapshot, PSSnapshot>(result, psResult);
WriteObject(psResult);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,23 @@ public partial class UpdateAzureRmSnapshot : ComputeAutomationBaseCmdlet
{
protected override void ProcessRecord()
{
ComputeAutomationAutoMapperProfile.Initialize();
ExecuteClientAction(() =>
{
if (ShouldProcess(this.ResourceGroupName, VerbsData.Update))
{

string resourceGroupName = this.ResourceGroupName;
string snapshotName = this.SnapshotName;
PSSnapshotUpdate snapshot = this.SnapshotUpdate;
PSSnapshot snapshotOrg = this.Snapshot;

var result = (snapshot == null)
? SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshotOrg)
: SnapshotsClient.Update(resourceGroupName, snapshotName, snapshot);
Snapshot snapshotObj = new Snapshot();
Mapper.Map<PSSnapshot, Snapshot>(this.Snapshot, snapshotObj);

SnapshotUpdate snapshotUpdateObj = new SnapshotUpdate();
Mapper.Map<PSSnapshotUpdate, SnapshotUpdate>(this.SnapshotUpdate, snapshotUpdateObj);

var result = (this.SnapshotUpdate == null)
? SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshotObj)
: SnapshotsClient.Update(resourceGroupName, snapshotName, snapshotUpdateObj);

var psObject = new PSSnapshot();
Mapper.Map<Snapshot, PSSnapshot>(result, psObject);
Expand Down