14
14
15
15
using System ;
16
16
using System . Collections . Generic ;
17
- using Microsoft . Azure . Commands . RecoveryServices . Backup . Cmdlets . Models ;
17
+ using Microsoft . Azure . Commands . RecoveryServices . Backup . Properties ;
18
18
using Microsoft . Azure . Management . RecoveryServices . Backup . Models ;
19
+ using CmdletModel = Microsoft . Azure . Commands . RecoveryServices . Backup . Cmdlets . Models ;
19
20
20
21
namespace Microsoft . Azure . Commands . RecoveryServices . Backup . Helpers
21
22
{
@@ -31,19 +32,19 @@ public class JobConversions
31
32
/// </summary>
32
33
/// <param name="hydraJob"></param>
33
34
/// <returns></returns>
34
- public static AzureRmRecoveryServicesBackupJobBase GetPSJob ( JobResponse hydraJob )
35
+ public static CmdletModel . AzureRmRecoveryServicesBackupJobBase GetPSJob ( JobResponse hydraJob )
35
36
{
36
37
return GetPSJob ( hydraJob . Item ) ;
37
38
}
38
39
39
- public static AzureRmRecoveryServicesBackupJobBase GetPSJob ( JobResource hydraJob )
40
+ public static CmdletModel . AzureRmRecoveryServicesBackupJobBase GetPSJob ( JobResource hydraJob )
40
41
{
41
- AzureRmRecoveryServicesBackupJobBase response = null ;
42
+ CmdletModel . AzureRmRecoveryServicesBackupJobBase response = null ;
42
43
43
44
// hydra doesn't initialize Properties if the type of job is not known to current version of hydra.
44
45
if ( hydraJob . Properties == null )
45
46
{
46
- // unsupported job type.
47
+ Logger . Instance . WriteWarning ( Resources . UnsupportedJobWarning ) ;
47
48
}
48
49
else if ( hydraJob . Properties . GetType ( ) == typeof ( AzureIaaSVMJob ) )
49
50
{
@@ -53,13 +54,13 @@ public static AzureRmRecoveryServicesBackupJobBase GetPSJob(JobResource hydraJob
53
54
return response ;
54
55
}
55
56
56
- public static void AddHydraJobsToPSList ( JobListResponse hydraJobs , List < AzureRmRecoveryServicesBackupJobBase > psJobs , ref int jobsCount )
57
+ public static void AddHydraJobsToPSList ( JobListResponse hydraJobs , List < CmdletModel . AzureRmRecoveryServicesBackupJobBase > psJobs , ref int jobsCount )
57
58
{
58
59
if ( hydraJobs . ItemList != null && hydraJobs . ItemList . Value != null )
59
60
{
60
61
foreach ( var job in hydraJobs . ItemList . Value )
61
62
{
62
- AzureRmRecoveryServicesBackupJobBase convertedJob = GetPSJob ( job ) ;
63
+ CmdletModel . AzureRmRecoveryServicesBackupJobBase convertedJob = GetPSJob ( job ) ;
63
64
if ( convertedJob != null )
64
65
{
65
66
jobsCount ++ ;
@@ -71,19 +72,19 @@ public static void AddHydraJobsToPSList(JobListResponse hydraJobs, List<AzureRmR
71
72
72
73
#region AzureVm job private helpers
73
74
74
- private static AzureRmRecoveryServicesBackupAzureVmJob GetPSAzureVmJob ( JobResource hydraJob )
75
+ private static CmdletModel . AzureRmRecoveryServicesBackupAzureVmJob GetPSAzureVmJob ( JobResource hydraJob )
75
76
{
76
- AzureRmRecoveryServicesBackupAzureVmJob response ;
77
+ CmdletModel . AzureRmRecoveryServicesBackupAzureVmJob response ;
77
78
78
79
AzureIaaSVMJob vmJob = hydraJob . Properties as AzureIaaSVMJob ;
79
80
80
81
if ( vmJob . ExtendedInfo != null )
81
82
{
82
- response = new AzureRmRecoveryServicesBackupAzureVmJobDetails ( ) ;
83
+ response = new CmdletModel . AzureRmRecoveryServicesBackupAzureVmJobDetails ( ) ;
83
84
}
84
85
else
85
86
{
86
- response = new AzureRmRecoveryServicesBackupAzureVmJob ( ) ;
87
+ response = new CmdletModel . AzureRmRecoveryServicesBackupAzureVmJob ( ) ;
87
88
}
88
89
89
90
response . JobId = GetLastIdFromFullId ( hydraJob . Id ) ;
@@ -94,12 +95,12 @@ private static AzureRmRecoveryServicesBackupAzureVmJob GetPSAzureVmJob(JobResour
94
95
response . VmVersion = vmJob . VirtualMachineVersion ;
95
96
response . WorkloadName = vmJob . EntityFriendlyName ;
96
97
response . ActivityId = vmJob . ActivityId ;
97
- response . BackupManagementType = EnumUtils . GetEnum < Microsoft . Azure . Commands . RecoveryServices . Backup . Cmdlets . Models . BackupManagementType > ( GetPSBackupManagementType ( vmJob . BackupManagementType ) ) ;
98
+ response . BackupManagementType = CmdletModel . EnumUtils . GetEnum < CmdletModel . BackupManagementType > ( GetPSBackupManagementType ( vmJob . BackupManagementType ) ) ;
98
99
response . Operation = vmJob . Operation ;
99
100
100
101
if ( vmJob . ErrorDetails != null )
101
102
{
102
- response . ErrorDetails = new List < AzureRmRecoveryServicesBackupAzureVmJobErrorInfo > ( ) ;
103
+ response . ErrorDetails = new List < CmdletModel . AzureRmRecoveryServicesBackupAzureVmJobErrorInfo > ( ) ;
103
104
foreach ( var vmError in vmJob . ErrorDetails )
104
105
{
105
106
response . ErrorDetails . Add ( GetPSAzureVmErrorInfo ( vmError ) ) ;
@@ -109,8 +110,8 @@ private static AzureRmRecoveryServicesBackupAzureVmJob GetPSAzureVmJob(JobResour
109
110
// fill extended info if present
110
111
if ( vmJob . ExtendedInfo != null )
111
112
{
112
- AzureRmRecoveryServicesBackupAzureVmJobDetails detailedResponse =
113
- response as AzureRmRecoveryServicesBackupAzureVmJobDetails ;
113
+ CmdletModel . AzureRmRecoveryServicesBackupAzureVmJobDetails detailedResponse =
114
+ response as CmdletModel . AzureRmRecoveryServicesBackupAzureVmJobDetails ;
114
115
115
116
detailedResponse . DynamicErrorMessage = vmJob . ExtendedInfo . DynamicErrorMessage ;
116
117
if ( vmJob . ExtendedInfo . PropertyBag != null )
@@ -124,10 +125,10 @@ private static AzureRmRecoveryServicesBackupAzureVmJob GetPSAzureVmJob(JobResour
124
125
125
126
if ( vmJob . ExtendedInfo . TasksList != null )
126
127
{
127
- detailedResponse . SubTasks = new List < AzureRmRecoveryServicesBackupAzureVmJobSubTask > ( ) ;
128
+ detailedResponse . SubTasks = new List < CmdletModel . AzureRmRecoveryServicesBackupAzureVmJobSubTask > ( ) ;
128
129
foreach ( var vmJobTask in vmJob . ExtendedInfo . TasksList )
129
130
{
130
- detailedResponse . SubTasks . Add ( new AzureRmRecoveryServicesBackupAzureVmJobSubTask ( )
131
+ detailedResponse . SubTasks . Add ( new CmdletModel . AzureRmRecoveryServicesBackupAzureVmJobSubTask ( )
131
132
{
132
133
Name = vmJobTask . TaskId ,
133
134
Status = vmJobTask . Status
@@ -139,9 +140,9 @@ private static AzureRmRecoveryServicesBackupAzureVmJob GetPSAzureVmJob(JobResour
139
140
return response ;
140
141
}
141
142
142
- private static AzureRmRecoveryServicesBackupAzureVmJobErrorInfo GetPSAzureVmErrorInfo ( AzureIaaSVMErrorInfo hydraError )
143
+ private static CmdletModel . AzureRmRecoveryServicesBackupAzureVmJobErrorInfo GetPSAzureVmErrorInfo ( AzureIaaSVMErrorInfo hydraError )
143
144
{
144
- AzureRmRecoveryServicesBackupAzureVmJobErrorInfo psErrorInfo = new AzureRmRecoveryServicesBackupAzureVmJobErrorInfo ( ) ;
145
+ CmdletModel . AzureRmRecoveryServicesBackupAzureVmJobErrorInfo psErrorInfo = new CmdletModel . AzureRmRecoveryServicesBackupAzureVmJobErrorInfo ( ) ;
145
146
psErrorInfo . ErrorCode = hydraError . ErrorCode ;
146
147
psErrorInfo . ErrorMessage = hydraError . ErrorString ;
147
148
if ( hydraError . Recommendations != null )
@@ -165,22 +166,22 @@ public static string GetLastIdFromFullId(string fullId)
165
166
166
167
#region Enum translators
167
168
168
- public static string GetJobTypeForService ( Microsoft . Azure . Commands . RecoveryServices . Backup . Cmdlets . Models . BackupManagementType mgmtType )
169
+ public static string GetJobTypeForService ( CmdletModel . BackupManagementType mgmtType )
169
170
{
170
171
switch ( mgmtType )
171
172
{
172
- case Microsoft . Azure . Commands . RecoveryServices . Backup . Cmdlets . Models . BackupManagementType . AzureVM :
173
- return Microsoft . Azure . Management . RecoveryServices . Backup . Models . BackupManagementType . AzureIaasVM . ToString ( ) ;
173
+ case CmdletModel . BackupManagementType . AzureVM :
174
+ return BackupManagementType . AzureIaasVM . ToString ( ) ;
174
175
default :
175
176
throw new Exception ( "Invalid BackupManagementType provided: " + mgmtType ) ;
176
177
}
177
178
}
178
179
179
180
public static string GetPSBackupManagementType ( string jobType )
180
181
{
181
- if ( jobType == Microsoft . Azure . Management . RecoveryServices . Backup . Models . BackupManagementType . AzureIaasVM . ToString ( ) )
182
+ if ( jobType == BackupManagementType . AzureIaasVM . ToString ( ) )
182
183
{
183
- return Microsoft . Azure . Commands . RecoveryServices . Backup . Cmdlets . Models . BackupManagementType . AzureVM . ToString ( ) ;
184
+ return CmdletModel . BackupManagementType . AzureVM . ToString ( ) ;
184
185
}
185
186
else
186
187
{
0 commit comments