wwndesc  1.0-76
HDSVSPDescription.java
Go to the documentation of this file.
1 /* smallfoot.org is owned by allan.clark */
2 package org.smallfoot.wwn;
3 
4 import java.math.BigInteger;
5 
6 /**
7  * @file
8  */
9 
10 /**
11  * HDSVSPDescription (ie USPV-10098-CL2A) breaks out the model type, serial, and FA port from the WWPN
12  */
13 
15 {
16  /** @copydoc WWNDesc#WWNDesc(String) */
17  public HDSVSPDescription(String wwn)
18  {
19  super(wwn);
20  }
21  /** @copydoc WWNDesc#WWNDesc(boolean,String) */
22  public HDSVSPDescription(boolean brief, String wwn)
23  {
24  super(brief, wwn);
25  }
26 
27  /**
28  * If this class matches or describes the given WWN, returns a new instance of this class loaded with the given WWN.
29  *
30  * @return new instance of this class, or null if the given wwn does not match this class
31  * @param strong is ignored: this class is a strong representation, not a weak one based on empirical matching, hence can always be used with confidence
32  * @param brief is used to ask for a shorter description: a more concise nickname or alias
33  * @param wwn the WWN (WWPN or WWNN, but typically WWPN) to match
34  */
35  public static WWNDesc getDesc(/* ignored */ boolean strong, boolean brief, String wwn)
36  {
37  return getDesc(strong, brief, wwn, DevRole.max()-1);
38  }
39  /**
40  * @copydoc #getDesc(boolean, boolean, String)
41  * @param role Role (Initiator/Switch/Target) to check for
42  */
43  public static WWNDesc getDesc (boolean strong, boolean brief, String wwn, int role)
44  {
45  if (!isA(role))
46  return null;
47  else if (wwn.startsWith("50060e8010"))
48  return new HDSModularDescription(brief, wwn);
49  else if (wwn.startsWith("50060e8"))
50  return new HDSVSPDescription(brief, wwn);
51  else
52  return null;
53  }
54 
55  /**
56  * return a description or alias for this WWN; if brief is set to true during the call to getDesc(), then a shorter description or alias will be returned
57  *
58  * @see getDesc(boolean,boolean,String)
59  *
60  * @return generated alias or nickname for the WWN
61  */
62  public String toString()
63  {
64  String res = super.toString();
65  if (null == res) res = "";
66  if (!brief) res += "HDS-";
67 
68  /**
69  * @todo 50060e8:
70  * 005: USP-V: http://www.hitachi-storage.com/content/how-decode-usp-v-wwn
71  * 00/5: USP-V: brionetka.com/linux/?p=38 breaks it up as NOOOOOOF FFSS SSCP (N=5, OOOOOO = OUI, FF = Family {01=7700/Lightning, 02=9900/Thunder}, SSSS=Serial, C = Cluster, P=Port (0-F=A-Q skipping "I") note article confuses NAA marker as "50"
72  * need to check against http://p2v.it/tools/wwndec/index.php?input=50060E8010277210
73  * need to check http://p2v.it/tools/wwndec/index.php?input=50060e8016624800
74  *
75  * NOTE that https://tuf.hds.com/wiki/pub/Main/Lunstat/lsu0011.pdf agrees with this class logic
76  * - 50060E80034E3901 gives 9970 with serial 20025
77  */
78  /* for example start with 50060e8005123442 on http://www.hitachi-storage.com/content/how-decode-usp-v-wwn */
79  BigInteger serDirPort = wwn.remainder(new BigInteger("1000000000",16));
80 
81  /* our example now has 005123442 - get the 3-nibble model code */
82  BigInteger modelDirPort[];
83  modelDirPort = serDirPort.divideAndRemainder(new BigInteger("1000000",16)); /* modelDirPort[0] = 005, modelDirPort[1] = 123442 */
84 
85  switch (modelDirPort[0].intValue())
86  {
87  case 0x01: /* 001: 7700E */
88  res += "7700E-";
89  break;
90  case 0x02: /* 002: 9900 */
91  res += "9900-";
92  break;
93  case 0x03: /* 003: 9900V : HDS-9970 / HDS-9980 AKA HP-XP128 or HP-XP1024 */
94  res += "9900V-";
95  break;
96  case 0x04: /* 004, 014: USP */
97  case 0x14:
98  res += "USP-";
99  break;
100  case 5: /* 005: regular USP-V */
101  case 0x15:
102  res += "USPV-";
103  break;
104  case 6: /* 006: seen and confirmed VSP at Associated Proj-00666 */
105  case 0x16:
106  /* unknown but seen at AdCenter: 50060e8015345800 is serial 78936 port CL1A */
107  /* 016: unknown but seen at ChampionSG Proj-712 */
108  res += "VSP-";
109  break;
110  case 0x10: /* 010: DF700/DF800/SA/DF850 */
111  res += "HUSV-";
112  break;
113  case 0x13: /* Jan reinmuth: HUS VM */
114  res += "HUSV-";
115  break;
116  default: /* unknown */
117  res += String.format("HDSUnkn%03x-",modelDirPort[0].intValue());
118  }
119 
120  /* our example now has 123442 - get the 4-digit serial number */
121  BigInteger serialPort[] = modelDirPort[1].divideAndRemainder(new BigInteger("100",16)); /* serialPort[0] = 1234, serialPort[1] = 42 */
122  serialPort[0] = serialPort[0].add(modelDirPort[0].divide(new BigInteger("10",16)).multiply(new BigInteger("10000",16)));
123  BigInteger clusterPort[] = serialPort[1].divideAndRemainder(new BigInteger("10",16)); /* clusterPort[0] = 4, clusterPort[1] = 2 */
124  char port = 'A';
125  port += clusterPort[1].intValue();
126  if (port > 'H') port ++;
127  return res + String.format("%05d-CL%x%c",serialPort[0].intValue(),clusterPort[0].intValue()+1, port);
128  }
129 }
HDSVSPDescription(String wwn)
create an instance with brief set to false.
static boolean isA(int role)
convenience function to use bit-masks to check for membership in this role
Definition: WWNDesc.java:158
HDSModularDescription (ie HDS-D850-31787-CTL0-PortD) breaks out the model type, serial, and FA port from the WWPN.
DevRole role
role of the device: Target, Switch, Initiator
Definition: WWNDesc.java:24
HDSVSPDescription (ie USPV-10098-CL2A) breaks out the model type, serial, and FA port from the WWPN...
boolean brief
whether a more brief output should be offered in toString() (ie the difference between "VMax-HK192601...
Definition: WWNDesc.java:22
static int max
global singleton to keep track of the max DevRole.value so far
Definition: DevRole.java:21
static WWNDesc getDesc(boolean strong, boolean brief, String wwn, int role)
If this class matches or describes the given WWN, returns a new instance of this class loaded with th...
This class seeks to provide simple bitfield type-checking of a device in a fabric so that I can use t...
Definition: DevRole.java:18
String toString()
return a description or alias for this WWN; if brief is set to true during the call to getDesc()...
static WWNDesc getDesc(boolean strong, boolean brief, String wwn)
If this class matches or describes the given WWN, returns a new instance of this class loaded with th...
WWNDesc is the basic generic class from which each vendor-specific pattern is built upon; similar to ...
Definition: WWNDesc.java:19
HDSVSPDescription(boolean brief, String wwn)
create an instance with the given WWN.
simple pass-thru class to define internal value for a Target in an idempotent way ...
Definition: WWNDesc.java:139
BigInteger wwn
the WWN that the instance tried to describe
Definition: WWNDesc.java:21