wwndesc  1.0-76
EMCSymmetrixDescription.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  * EMCSymmetrixDescription (ie Symm-187900328-03dB or Symm-0328-03dB) breaks out the serial and FA port from the WWPN. @sa EMCSymmetrixDescription @sa EMCVMAXDescription @sa EMCVPLEXDescription
12  */
14 {
15  /** @copydoc WWNDesc#WWNDesc(String) */
17  {
18  super(wwn);
19  }
20  /** @copydoc WWNDesc#WWNDesc(boolean,String) */
21  public EMCSymmetrixDescription(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("5006048.*"))
47  return new EMCSymmetrixDescription(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 5006048ACCC86A32 on http://www.emcstorageinfo.com/2007/08/how-to-decode-symmetrix-world-wide.html */
65  BigInteger serDirPort = wwn.subtract(wwn.shiftRight(36).shiftLeft(36));
66 
67  /* our example now has ACCC86A32 */
68  BigInteger sDirPort[] = serDirPort.divideAndRemainder(new BigInteger("40",16));
69  BigInteger xDirPort[] = sDirPort[0].divideAndRemainder(new BigInteger("20000000",16));
70 
71  if (brief)
72  res += String.format("Symm-%04d",xDirPort[1].mod(new BigInteger("10000",10)));
73  else
74  res += "Symm-"+xDirPort[1];
75 
76  BigInteger DirPort[] = sDirPort[1].divideAndRemainder(new BigInteger("10",16));
77  res += String.format("-%02d",DirPort[1].intValue()+1);
78 
79  switch (4*xDirPort[0].intValue()+DirPort[0].intValue())
80  {
81  case 0:
82  res += "aA";
83  break;
84  case 1:
85  res += "bA";
86  break;
87  case 2:
88  res += "aB";
89  break;
90  case 3:
91  res += "bB";
92  break;
93  case 4:
94  res += "cA";
95  break;
96  case 5:
97  res += "dA";
98  break;
99  case 6:
100  res += "cB";
101  break;
102  case 7:
103  res += "dB";
104  break;
105  }
106 
107  return res;
108  }
109 }
String toString()
return a description or alias for this WWN; if brief is set to true during the call to getDesc()...
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
EMCSymmetrixDescription(boolean brief, String wwn)
create an instance with the given WWN.
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
EMCSymmetrixDescription (ie Symm-187900328-03dB or Symm-0328-03dB) breaks out the serial and FA port ...
WWNDesc is the basic generic class from which each vendor-specific pattern is built upon; similar to ...
Definition: WWNDesc.java:19
EMCSymmetrixDescription(String wwn)
create an instance with brief set to false.
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...
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
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...