wwndesc  1.0-76
EMCClariionDescription.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  * EMCClariionDescription (ie CL-01234567-SPB1) describes the serial and CL of a Clariion; EMC doesn't seem to include any additional data in the WWPN. @sa EMCSymmetrixDescription @sa EMCVMAXDescription @sa EMCVPLEXDescription
12  *
13  * 00:60:48 Symmetrix DMX
14  * 00:00:97 Symmetrix VMAX
15  * 00:60:16 CLariion/VNX
16  */
18 {
19  /** @copydoc WWNDesc#WWNDesc(String) */
20  public EMCClariionDescription(String wwn)
21  {
22  super(wwn);
23  }
24 
25  /**
26  * If this class matches or describes the given WWN, returns a new instance of this class loaded with the given WWN.
27  *
28  * @return new instance of this class, or null if the given wwn does not match this class
29  * @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
30  * @param brief is ignored: this class has only one representation of the WWN description or alias
31  * @param wwn the WWN (WWPN or WWNN, but typically WWPN) to match
32  */
33  public static WWNDesc getDesc(/* ignored */ boolean strong, /* ignored */ boolean brief, String wwn)
34  {
35  return getDesc(strong, brief, wwn, DevRole.max()-1);
36  }
37  /**
38  * @copydoc #getDesc(boolean, boolean, String)
39  * @param role Role (Initiator/Switch/Target) to check for
40  */
41  public static WWNDesc getDesc (boolean strong, boolean brief, String wwn, int role)
42  {
43  if (!isA(role))
44  return null;
45  else if (wwn.matches("5006016.*"))
46  return new EMCClariionDescription(wwn);
47  else
48  return null;
49  }
50 
51  /**
52  * return a description or alias for this WWN
53  *
54  * @return generated alias or nickname for the WWN
55  */
56  public String toString()
57  {
58  String res = super.toString();
59  if (null == res) res = "";
60 
61  /* for example start with 5006016A12345678 on http://blog.fosketts.net/toolbox/emc-symmetrix-wwn-calculator/ */
62  /* http://goingvirtual.wordpress.com/2011/09/09/how-i-zone-vnx-storage-arrays/ */
63  /* http://www.thesangeek.com/2011/02/09/sangeek-clariion-cx4-wwn-interpretations/ */
64  /* http://clariionblogs.blogspot.com/2007/11/storage-processor-ports-wwns.html */
65  /* http://architecting.it/2013/09/06/what-emc-should-have-done-with-vnx/ */
66 
67  BigInteger serDirPort = wwn.subtract(wwn.shiftRight(36).shiftLeft(36));
68 
69  /* our example now has A12345678 */
70  BigInteger serPort[] = serDirPort.divideAndRemainder(new BigInteger("100000000",16));
71 
72  Character SP;
73  switch (serPort[0].intValue() / 8)
74  {
75  case 0:
76  SP='A';
77  break;
78  case 1:
79  SP='B';
80  break;
81  default:
82  SP='X';
83  }
84  return res + String.format("CL-%08x-SP%c%d",serPort[1].intValue(),SP,serPort[0].intValue() % 8);
85  }
86 }
static boolean isA(int role)
convenience function to use bit-masks to check for membership in this role
Definition: WWNDesc.java:158
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...
DevRole role
role of the device: Target, Switch, Initiator
Definition: WWNDesc.java:24
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
EMCClariionDescription (ie CL-01234567-SPB1) describes the serial and CL of a Clariion; EMC doesn't s...
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
WWNDesc is the basic generic class from which each vendor-specific pattern is built upon; similar to ...
Definition: WWNDesc.java:19
EMCClariionDescription(String wwn)
create an instance with brief set to false.
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)
If this class matches or describes the given WWN, returns a new instance of this class loaded with th...