wwndesc  1.0-76
EMCVPLEXDescription.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  * EMCVPLEXDescription (ie VPlex-07a3b-A0-FC00) breaks out the serial and FE/BE port from the WWPN. @sa EMCClariionDescription @sa EMCSymmetrixDescription @sa EMCVMAXDescription
12  */
14 {
15  /** @copydoc WWNDesc#WWNDesc(String) */
16  public EMCVPLEXDescription(String wwn)
17  {
18  super(wwn);
19  }
20  /** @copydoc WWNDesc#WWNDesc(boolean,String) */
21  public EMCVPLEXDescription(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("50001442.*"))
47  return new EMCVPLEXDescription(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 50001442607a3b00 on https://community.emc.com/thread/146058 */
65  BigInteger serDirPort = wwn.subtract(wwn.shiftRight(32).shiftLeft(32));
66  res += "VPlex-";
67 
68  /* our example now has 607a3b00 */
69  /* get the next digit ("num"): even is A, odd is B. four of the serial: 4 bits: {reserved/0} {A}{B} {reserved/0} */
70  BigInteger numSeedIOPort[] = serDirPort.divideAndRemainder(new BigInteger("10000000",16)); /* numSeedIOPort[0] = 6, numSeedIOPort[1] = 07a3b00 */
71 
72  //numSeedIOPort[0] = numSeedIOPort[0].shiftRight(7).shiftLeft(7); /* numSeedIOPort[0] = 0 --> A Director, numSeedIOPort[1] = 07a3b00 */
73  char director='A';
74  director += (numSeedIOPort[0].intValue() % 2);
75 
76  BigInteger seedIOPort[] = numSeedIOPort[1].divideAndRemainder(new BigInteger("100",16)); /* seedIOPort[0] = 07a3b, seedIOPort[1] = 00 */
77 
78  /* Assume we're all VS2 architecture @todo fix the assumpiton that VS1 VPLEX no longer exist */
79  String front = "un";
80  switch (seedIOPort[1].intValue() / 16)
81  {
82  case 0:
83  front = "FE";
84  break;
85  case 1:
86  front = "BE";
87  break;
88  case 2:
89  front = "WA";
90  break;
91  case 3:
92  front = "LO";
93  break;
94  /* default: stick with an X, dunno what to do with that value */
95  }
96 
97  /* want a result such as VPLEX02_E1B_BE13 */
98  /* can get a brief result such as VPlex-07a3b-EB-BE13 */
99  if (brief)
100  return res + String.format("%05x-E%c-%s%d%d",seedIOPort[0].intValue(),director,front,seedIOPort[1].intValue() / 16, seedIOPort[1].intValue() % 16);
101  /* can get a result such as VPlex-07a3b-A0-FC00 */
102  else
103  return res + String.format("%05x-%c%d-FC0%d",seedIOPort[0].intValue(),director,seedIOPort[1].intValue() / 16, seedIOPort[1].intValue() % 16);
104  }
105 }
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...
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
EMCVPLEXDescription(String wwn)
create an instance with brief set to false.
boolean brief
whether a more brief output should be offered in toString() (ie the difference between "VMax-HK192601...
Definition: WWNDesc.java:22
EMCVPLEXDescription (ie VPlex-07a3b-A0-FC00) breaks out the serial and FE/BE port from the WWPN...
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
WWNDesc is the basic generic class from which each vendor-specific pattern is built upon; similar to ...
Definition: WWNDesc.java:19
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...
EMCVPLEXDescription(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
String toString()
return a description or alias for this WWN; if brief is set to true during the call to getDesc()...
BigInteger wwn
the WWN that the instance tried to describe
Definition: WWNDesc.java:21