-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathESATMUpdate.m
More file actions
182 lines (157 loc) · 9.14 KB
/
ESATMUpdate.m
File metadata and controls
182 lines (157 loc) · 9.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#import "ESATMUpdate.h"
@implementation ESATMUpdate
-(id)initWithString:(NSString *)update
{
self = [self init];
xmlDoc = [[NSXMLDocument alloc] initWithXMLString:update
options:0
error:&errorString];
esaStatus = [[NSDictionary alloc] initWithObjectsAndKeys:
@"Normal",[NSNumber numberWithInt:Normal],
@"Red Threshold Exceeded", [NSNumber numberWithInt:RedThresholdExceeded],
@"Yellow Threshold Exceeded", [NSNumber numberWithInt:YellowThresholdExceeded],
@"No Disks", [NSNumber numberWithInt:NoDisks],
@"Bad Disk", [NSNumber numberWithInt:BadDisk],
@"Too Many Missing Disks", [NSNumber numberWithInt:TooManyMissingDisks],
@"No Redundancy", [NSNumber numberWithInt:NoRedundancy],
@"No Magic Hotspare", [NSNumber numberWithInt:NoMagicHotspare],
@"Relayout In Progress", [NSNumber numberWithInt:RelayoutInProgress],
@"Format In Progress", [NSNumber numberWithInt:FormatInProgress],
@"Mismatched Disks", [NSNumber numberWithInt:MismatchedDisks],
@"Unknown Version", [NSNumber numberWithInt:UnknownVersion],
@"New Firmware Installed", [NSNumber numberWithInt:NewFirmwareInstalled],
@"New Lun Available After Reboot", [NSNumber numberWithInt:NewLunAvailableAfterReboot],
@"Unknown Status", [NSNumber numberWithInt:UnknownStatus],
nil];
//ledStatus = [NSMapTable mapTableWithKeyOptions:NSMapTableObjectPointerPersonality valueOptions:NSMapTableStrongMemory];
ledStatus= [[NSDictionary alloc] initWithObjectsAndKeys:
@"Off", [NSNumber numberWithInt:LEDOff],
@"Red", [NSNumber numberWithInt:LEDRedOn],
@"Yellow", [NSNumber numberWithInt:LEDYellowOn],
@"Green", [NSNumber numberWithInt:LEDGreenOn],
@"Flashing Yellow-Green", [NSNumber numberWithInt:LEDFlashYellowGreen],
@"Flashing Red-Green", [NSNumber numberWithInt:LEDFlashRedGreen],
@"Flashing Red", [NSNumber numberWithInt:LEDFlashRed],
@"Flashing Red-Yellow", [NSNumber numberWithInt:LEDFlashRedYellow],
@"Empty", [NSNumber numberWithInt:LEDSlotEmpty],
nil];
/*
[ledStatus setObject:(void *)LEDOff forKey:@"Off"];
[ledStatus setObject:(void *)LEDRedOn forKey:@"Red"];
[ledStatus setObject:(void *)LEDYellowOn forKey:@"Yellow"];
[ledStatus setObject:(void *)LEDGreenOn forKey:@"Green"];
[ledStatus setObject:(void *)LEDFlashYellowGreen forKey:@"Flashing Yellow-Green"];
[ledStatus setObject:(void *)LEDFlashRedGreen forKey:@"Flashing Red-Green"];
[ledStatus setObject:(void *)LEDFlashRed forKey:@"Flashing Red"];
[ledStatus setObject:(void *)LEDFlashRedYellow forKey:@"Flashing Red-Yellow"];
[ledStatus setObject:(void *)LEDSlotEmpty forKey:@"Empty"];
*/
return self;
}
-(NSString *)getESAID { return [[[[xmlDoc rootElement] nodesForXPath:@"/ESATMUpdate[1]/mESAID[1]" error:&errorString] objectAtIndex:0] stringValue];}
-(NSString *)getSerial { return [[[[xmlDoc rootElement] nodesForXPath:@"/ESATMUpdate[1]/mSerial[1]" error:&errorString] objectAtIndex:0] stringValue];}
-(NSString *)getName { return [[[[xmlDoc rootElement] nodesForXPath:@"/ESATMUpdate[1]/mName[1]" error:&errorString] objectAtIndex:0] stringValue];}
-(NSString *)getVersion { return [[[[xmlDoc rootElement] nodesForXPath:@"/ESATMUpdate[1]/mVersion[1]" error:&errorString] objectAtIndex:0] stringValue];}
-(NSString *)getReleaseDate { return [[[[xmlDoc rootElement] nodesForXPath:@"/ESATMUpdate[1]/mReleaseDate[1]" error:&errorString] objectAtIndex:0] stringValue];}
-(NSString *)getArch { return [[[[xmlDoc rootElement] nodesForXPath:@"/ESATMUpdate[1]/mArch[1]" error:&errorString] objectAtIndex:0] stringValue];}
-(int)getFirmwareFeatures { return [[[[[xmlDoc rootElement] nodesForXPath:@"/ESATMUpdate[1]/mFirmwareFeatures[1]" error:&errorString] objectAtIndex:0] stringValue] intValue];}
-(int)getStatus { return [[[[[xmlDoc rootElement] nodesForXPath:@"/ESATMUpdate[1]/mStatus[1]" error:&errorString] objectAtIndex:0] stringValue] intValue];}
-(NSArray *)getStatusAsArray {
int status = [self getStatus];
NSMutableArray *a = [NSMutableArray arrayWithCapacity:2];
if (status == 0)
{
[a addObject:[esaStatus objectForKey:[NSNumber numberWithInt:0]]];
}
enum ESAStatus t;
t=1;
while (t < 0x8000) {
if ((status & t) == t)
[a addObject:[esaStatus objectForKey:[NSNumber numberWithInt:t]]];
t *=2;
}
return a;
}
-(NSString *)getStatusAsString {
return [[self getStatusAsArray] componentsJoinedByString:@", "];
}
-(int)getRelayoutCount { return [[[[[xmlDoc rootElement] nodesForXPath:@"/ESATMUpdate[1]/mRelayoutCount[1]" error:&errorString] objectAtIndex:0] stringValue] intValue]; }
-(long long)getTotalCapacityProtected{ return [[[[[xmlDoc rootElement] nodesForXPath:@"/ESATMUpdate[1]/mTotalCapacityProtected[1]" error:&errorString] objectAtIndex:0] stringValue] longLongValue];}
-(long long)getUsedCapacityProtected { return [[[[[xmlDoc rootElement] nodesForXPath:@"/ESATMUpdate[1]/mUsedCapacityProtected[1]" error:&errorString] objectAtIndex:0] stringValue] longLongValue];}
-(long long)getFreeCapacityProtected { return [[[[[xmlDoc rootElement] nodesForXPath:@"/ESATMUpdate[1]/mFreeCapacityProtected[1]" error:&errorString] objectAtIndex:0] stringValue] longLongValue];}
-(long long)getUsedCapacityOS { return [[[[[xmlDoc rootElement] nodesForXPath:@"/ESATMUpdate[1]/mUsedCapacityOS[1]" error:&errorString] objectAtIndex:0] stringValue] longLongValue];}
-(int)getYellowThreshold { return [[[[[xmlDoc rootElement] nodesForXPath:@"/ESATMUpdate[1]/mYellowThreshold[1]" error:&errorString] objectAtIndex:0] stringValue] intValue];}
-(int)getRedThreshold { return [[[[[xmlDoc rootElement] nodesForXPath:@"/ESATMUpdate[1]/mTotalCapacityProtected[1]" error:&errorString] objectAtIndex:0] stringValue] intValue];}
-(int)getUseUnprotectedCapacity { return [[[[[xmlDoc rootElement] nodesForXPath:@"/ESATMUpdate[1]/mUseUnprotectedCapacity[1]" error:&errorString] objectAtIndex:0] stringValue] intValue];}
-(NSString *)getDroboName { return [[[[xmlDoc rootElement] nodesForXPath:@"/ESATMUpdate[1]/mDroboName[1]" error:&errorString] objectAtIndex:0] stringValue];}
-(int)getSlotCountExp { return [[[[[xmlDoc rootElement] nodesForXPath:@"/ESATMUpdate[1]/mSlotCountExp[1]" error:&errorString] objectAtIndex:0] stringValue] intValue];}
-(int)getStatusAtSlot:(int)slot {
return [[[[[xmlDoc rootElement] nodesForXPath:[NSString stringWithFormat:@"/ESATMUpdate[1]/mSlotsExp[1]/n%d[1]/mStatus[1]",slot] error:&errorString] objectAtIndex:0] stringValue] longLongValue];
}
-(NSString *)getStatusAtSlotAsString:(int)slot {
return [ledStatus objectForKey:[NSNumber numberWithInt:[self getStatusAtSlot:slot]]];
}
-(long long)getPhysicalCapacityAtSlot:(int)slot {
return [[[[[xmlDoc rootElement] nodesForXPath:[NSString stringWithFormat:@"/ESATMUpdate[1]/mSlotsExp[1]/n%d[1]/mPhysicalCapacity[1]",slot] error:&errorString] objectAtIndex:0] stringValue] longLongValue];
}
-(int)getLUNCount { return [[[[[xmlDoc rootElement] nodesForXPath:@"/ESATMUpdate[1]/mLUNCount[1]" error:&errorString] objectAtIndex:0] stringValue] intValue];}
-(int)getMaxLUNs { return [[[[[xmlDoc rootElement] nodesForXPath:@"/ESATMUpdate[1]/mMaxLUNs[1]" error:&errorString] objectAtIndex:0] stringValue] intValue];}
-(long long)getMaximumLUNSizeAtLUN:(int)lun {
return [[[[[xmlDoc rootElement]
nodesForXPath:[NSString
stringWithFormat:@"/ESATMUpdate[1]/mLUNUpdates[1]/n%d[1]/mMaximumLUNSize[1]",lun]
error:&errorString]
objectAtIndex:0]
stringValue]
longLongValue];
}
-(long long)getUsedCapacityOSAtLUN:(int)lun {
return [[[[[xmlDoc rootElement]
nodesForXPath:[NSString
stringWithFormat:@"/ESATMUpdate[1]/mLUNUpdates[1]/n%d[1]/mUsedCapacityOS[1]",lun]
error:&errorString]
objectAtIndex:0]
stringValue]
longLongValue];
}
-(int)getPartitionCountAtLUN:(int)lun {
return [[[[[xmlDoc rootElement]
nodesForXPath:[NSString
stringWithFormat:@"/ESATMUpdate[1]/mLUNUpdates[1]/n%d[1]/mPartitionCount[1]",lun]
error:&errorString]
objectAtIndex:0]
stringValue]
intValue];
}
-(int)getPartitionTypeAtLUN:(int)lun {
return [[[[[xmlDoc rootElement]
nodesForXPath:[NSString
stringWithFormat:@"/ESATMUpdate[1]/mLUNUpdates[1]/n%d[1]/mPartitionType[1]",lun]
error:&errorString]
objectAtIndex:0]
stringValue]
intValue];
}
-(int)getPartitionFormatAtLUN:(int)lun {
return [[[[[xmlDoc rootElement]
nodesForXPath:[NSString
stringWithFormat:@"/ESATMUpdate[1]/mLUNUpdates[1]/n%d[1]/mPartitionFormat[1]",lun]
error:&errorString]
objectAtIndex:0]
stringValue]
intValue];
}
-(int)getSledStatus { return [[[[[xmlDoc rootElement] nodesForXPath:@"/ESATMUpdate[1]/mSledStatus[1]" error:&errorString] objectAtIndex:0] stringValue] intValue];}
-(int)getDiskPackStatus { return [[[[[xmlDoc rootElement] nodesForXPath:@"/ESATMUpdate[1]/mDiskPackStatus[1]" error:&errorString] objectAtIndex:0] stringValue] intValue];}
-(void)xml
{
NSLog(@"%@",[[[NSString alloc] initWithData:[xmlDoc XMLData] encoding:NSASCIIStringEncoding ] autorelease]);
}
-(void)xpath
{
NSXMLNode *aNode = [xmlDoc rootElement];
while ((aNode = [aNode nextNode])) {
NSLog(@"Name: %@=%@",[aNode XPath],[aNode objectValue]);
}
}
@end