wwndesc  1.0-76
EMCVMAXDescription.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  * EMCVMAXDescription (ie VMax-HK192601234-12gB or VMax-1234-12gB) breaks out the country of manufacturer, serial and FA port from the WWPN. @sa EMCClariionDescription @sa EMCSymmetrixDescription @sa EMCVPLEXDescription
12  */
14 {
15  /** @copydoc WWNDesc#WWNDesc(String) */
16  public EMCVMAXDescription(String wwn)
17  {
18  super(wwn);
19  }
20  /** @copydoc WWNDesc#WWNDesc(boolean,String) */
21  public EMCVMAXDescription(boolean brief, String wwn)
22  {
23  super(brief,wwn);
24  }
25 
26  /**
27  * If this class matches or describes the given WWN, returns a new instance of this class loaded with the given WWN.
28  *
29  * @return new instance of this class, or null if the given wwn does not match this class
30  * @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
31  * @param brief is used to ask for a shorter description: a more concise nickname or alias
32  * @param wwn the WWN (WWPN or WWNN, but typically WWPN) to match
33  */
34  public static WWNDesc getDesc(/* ignored */ boolean strong, boolean brief, String wwn)
35  {
36  return getDesc(strong, brief, wwn, DevRole.max()-1);
37  }
38  /**
39  * @copydoc #getDesc(boolean, boolean, String)
40  * @param role Role (Initiator/Switch/Target) to check for
41  */
42  public static WWNDesc getDesc (boolean strong, boolean brief, String wwn, int role)
43  {
44  if (!isA(role))
45  return null;
46  else if (wwn.matches("5000097.*"))
47  return new EMCVMAXDescription(brief, wwn);
48  else
49  return null;
50  }
51 
52  /**
53  * 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
54  *
55  * @see getDesc(boolean,boolean,String)
56  *
57  * @return generated alias or nickname for the WWN
58  */
59  public String toString()
60  {
61  String res = super.toString();
62  if (null == res) res = "";
63 
64  /* for example start with 50000972081349AD on https://community.emc.com/thread/118881 */
65  BigInteger serDirPort = wwn.subtract(wwn.shiftRight(36).shiftLeft(36));
66  res += "VMax-";
67 
68  /* our example now has 2081349AD */
69  /* get the first four of the serial: 4 bits: {reserved/0} {A}{B} {reserved/0} */
70  BigInteger countDirPort[] = serDirPort.divideAndRemainder(new BigInteger("200000000",16)); /* countDirPort[0] = 2, countDirPort[1] = 081349AD */
71  BigInteger modelDirPort[] = countDirPort[1].divideAndRemainder(new BigInteger("8000000",16)); /* modelDirPort[0] = 1, modelDirPort[1] = 01349AD */
72  if (!brief)
73  {
74  switch (countDirPort[0].intValue())
75  {
76  case 1: /* 0-01-0 == USA/HK19 seen on 20k VMax? */ /* 0-01-1 == USA/40k VMax? */
77  res += "HK19";
78  break;
79  case 2: /* 0-10-0 == Ireland/CK29 */
80  res += "CK29";
81  break;
82  default:/* unknown */
83  res += "Unkn";
84  }
85 
86  /* our example now has 081349AD - get the 4-bit model code */
87  //BigInteger modelDirPort[] = countDirPort[1].divideAndRemainder(new BigInteger("8000000",16)); /* modelDirPort[0] = 1, modelDirPort[1] = 01349AD */
88 //System.out.println("modelDirPort[0] is "+modelDirPort[0] + " --> "+modelDirPort[0].intValue());
89  switch (modelDirPort[0].intValue())
90  {
91  case 0: /* 000000: 40k V-Max */
92  res += "46";
93  break;
94  case 1: /* 000001: 20k V-Max? */
95  case (1+32): /* 100001: Unknown */
96  res += "26";
97  break;
98  case 24: /* 011000: V-Max SE */
99  res += "49";
100  break;
101  /* Previously, bit #32 was reserved set to 0. This is no longer the case */
102  case 32: /* 100000: V-Max 40k 4-engine (TMO) */
103  res += "57";
104  break;
105  default:/* unknown */
106  res += "UN";
107  }
108  }
109 
110  /* our example now has 081349AD - get the 5-digit serial number ending */
111  BigInteger serialDirPort[] = modelDirPort[1].divideAndRemainder(new BigInteger("400",16)); /* serialDirPort[0] = 004d2, serialDirPort[1] = 1AD */
112 
113  /* our example now has 1AD - get the 4-bit Processor code */
114  BigInteger procDirPort[] = serialDirPort[1].divideAndRemainder(new BigInteger("40",16)); /* procDirPort[0] = 6, procDirPort[1] = 2D */
115 
116  /* our example now has 2D - get the 4-bit Director code */
117  BigInteger dirDirPort[] = procDirPort[1].divideAndRemainder(new BigInteger("4",16)); /* dirDirPort[0] = C, dirDirPort[1] = %01 */
118  return res + String.format("%0"+(brief?4:5)+"d-%02d%c%c",serialDirPort[0].intValue(),dirDirPort[0].intValue()+1,procDirPort[0].intValue()+'a',dirDirPort[1].intValue()+'A');
119  }
120 }
EMCVMAXDescription(boolean brief, String wwn)
create an instance with the given WWN.
EMCVMAXDescription(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
DevRole role
role of the device: Target, Switch, Initiator
Definition: WWNDesc.java:24
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...
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
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
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...
WWNDesc is the basic generic class from which each vendor-specific pattern is built upon; similar to ...
Definition: WWNDesc.java:19
EMCVMAXDescription (ie VMax-HK192601234-12gB or VMax-1234-12gB) breaks out the country of manufacture...
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
String toString()
return a description or alias for this WWN; if brief is set to true during the call to getDesc()...