Skip to content

Commit 143c608

Browse files
committed
Jobs base and IaaSVM DCs and basic translation
1 parent 5e9efae commit 143c608

File tree

6 files changed

+157
-5
lines changed

6 files changed

+157
-5
lines changed

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Helpers/Commands.RecoveryServices.Backup.Helpers.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<Reference Include="System.Xml" />
4343
</ItemGroup>
4444
<ItemGroup>
45+
<Compile Include="Conversions\JobConversions.cs" />
4546
<Compile Include="Validations\PolicyValidations.cs" />
4647
<Compile Include="Conversions\SchedulePolicyConversions.cs" />
4748
<Compile Include="Conversions\RetentionPolicyConversions.cs" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models;
16+
using Microsoft.Azure.Management.RecoveryServices.Backup.Models;
17+
18+
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Helpers
19+
{
20+
public class JobConversions
21+
{
22+
#region Hydra to PS convertors
23+
24+
public static AzureRmRecoveryServicesJobBase GetPSJob(JobResponse hydraJob)
25+
{
26+
AzureRmRecoveryServicesJobBase response = null;
27+
28+
if (hydraJob.Item.Properties.GetType() == typeof(AzureIaaSVMJob))
29+
{
30+
response = GetPSAzureVmJob(hydraJob);
31+
}
32+
33+
return response;
34+
}
35+
36+
public static AzureRmRecoveryServicesAzureVmJob GetPSAzureVmJob(JobResponse hydraJob)
37+
{
38+
AzureRmRecoveryServicesAzureVmJob response = new AzureRmRecoveryServicesAzureVmJob();
39+
40+
response.InstanceId = hydraJob.Item.Id;
41+
// TODO: Fill complete conversion
42+
43+
return response;
44+
}
45+
46+
#endregion
47+
}
48+
}

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.HydraAdapter/BMSAPIs/JobAPIs.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,20 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System;
16-
using System.Collections.Generic;
17-
using System.Linq;
18-
using System.Text;
19-
using System.Threading.Tasks;
15+
using Microsoft.Azure.Management.RecoveryServices.Backup.Models;
2016

2117
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.HydraAdapter
2218
{
2319
public partial class HydraAdapter
2420
{
21+
public JobResponse GetJob(string resourceGroupName, string resourceName, string jobId)
22+
{
23+
return BmsAdapter.Client.Job.GetAsync(
24+
resourceGroupName,
25+
resourceName,
26+
jobId,
27+
BmsAdapter.GetCustomRequestHeaders(),
28+
BmsAdapter.CmdletCancellationToken).Result;
29+
}
2530
}
2631
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System.Collections.Generic;
16+
17+
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
18+
{
19+
public class AzureRmRecoveryServicesAzureVmJob : AzureRmRecoveryServicesJobBase
20+
{
21+
public bool IsCancellable { get; set; }
22+
23+
public bool IsRetriable { get; set; }
24+
25+
public string VmVersion { get; set; }
26+
27+
public List<AzureRmRecoveryServicesAzureVmJobErrorInfo> ErrorDetails { get; set; }
28+
}
29+
30+
public class AzureRmRecoveryServicesAzureVmJobDetails : AzureRmRecoveryServicesAzureVmJob
31+
{
32+
/// <summary>
33+
/// Context sensitive error message that might be helpful in debugging the issue.
34+
/// Mostly this contains trace dumps from VM.
35+
/// </summary>
36+
public string DynamicErrorMessage { get; set; }
37+
38+
public Dictionary<string, string> Properties { get; set; }
39+
40+
public List<AzureRmRecoveryServicesAzureVmJobSubTask> SubTasks { get; set; }
41+
}
42+
43+
public class AzureRmRecoveryServicesAzureVmJobErrorInfo : AzureRmRecoveryServicesJobErrorInfoBase
44+
{
45+
public int ErrorCode { get; set; }
46+
}
47+
48+
public class AzureRmRecoveryServicesAzureVmJobSubTask : AzureRmRecoveryServicesJobSubTaskBase
49+
{
50+
}
51+
}

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Models/BaseObjects.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,50 @@ public override void Validate()
176176
{
177177
}
178178
}
179+
180+
public class AzureRmRecoveryServicesJobBase : AzureRmRecoveryServicesObjectBase
181+
{
182+
public string ActivityId { get; set; }
183+
184+
public string InstanceId { get; set; }
185+
186+
public string Operation { get; set; }
187+
188+
public string Status { get; set; }
189+
190+
public string WorkloadName { get; set; }
191+
192+
public string BackupManagementType { get; set; }
193+
194+
public DateTime StartTime { get; set; }
195+
196+
public DateTime? EndTime { get; set; }
197+
198+
public TimeSpan Duration { get; set; }
199+
200+
public override void Validate()
201+
{
202+
base.Validate();
203+
}
204+
}
205+
206+
/// <summary>
207+
/// This class is does not represent first class resource. So, we are not inheriting from the base class.
208+
/// </summary>
209+
public class AzureRmRecoveryServicesJobErrorInfoBase
210+
{
211+
public string ErrorMessage { get; set; }
212+
213+
public List<string> Recommendations { get; set; }
214+
}
215+
216+
/// <summary>
217+
/// This class is does not represent a first class resource. So, we are not inheriting from the common base class.
218+
/// </summary>
219+
public class AzureRmRecoveryServicesJobSubTaskBase
220+
{
221+
public string Name { get; set; }
222+
223+
public string Status { get; set; }
224+
}
179225
}

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Models/Commands.RecoveryServices.Backup.Models.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<Reference Include="System.Xml" />
4343
</ItemGroup>
4444
<ItemGroup>
45+
<Compile Include="AzureVmModels\AzureRmRecoveryServicesAzureVmJob.cs" />
4546
<Compile Include="BaseObjects.cs" />
4647
<Compile Include="CmdletParamEnums.cs" />
4748
<Compile Include="CommonModels\Utils.cs" />

0 commit comments

Comments
 (0)