wwndesc  1.0-76
IBM3700Description.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  * IBM3700Description (ie RamSan-G8332-FC-2B) breaks out the serial and port information from the Texas Memory Systems hardware initially called RamSan
12  */
14 {
15  /** @copydoc WWNDesc#WWNDesc(String) */
16  public IBM3700Description(String wwn)
17  {
18  super(wwn);
19  }
20  /** @copydoc WWNDesc#WWNDesc(boolean,String) */
21  public IBM3700Description(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 ignored: this class has only one representation of the WWN description or alias
32  * @param wwn the WWN (WWPN or WWNN, but typically WWPN) to match
33  */
34  public static WWNDesc getDesc(/* ignored */ boolean strong, /* ignored */ 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("2[0-9a-f]0[0-9a-f]0020c2.*"))
47  return new IBM3700Description(brief, wwn);
48  else
49  return null;
50  }
51 
52  /**
53  * return a description or alias for this WWN
54  *
55  * @return generated alias or nickname for the WWN
56  */
57  public String toString()
58  {
59  String res = super.toString();
60  if (null == res) res = "";
61 
62  /* convert 2P:0N:0020C2:MMMMMM into RamSan-MMMMMM-FC-NP */
63  /* for example start with 21:08:0020c2:078332 and produce RamSan-G8332-FC-2B */
64  BigInteger nodePortOUISer[] = wwn.divideAndRemainder(new BigInteger("1000000",16));
65  /* nodePortOUISer[0]=21080020c2 ; nodePortOUISer[1]=078332 */
66 
67  BigInteger nodePortOUI[] = nodePortOUISer[0].divideAndRemainder(new BigInteger("1000000",16));
68  /* nodePortOUI[0]=2108 ; nodePortOUI[1]=0020c2 */
69  BigInteger nodePort[] = nodePortOUI[0].divideAndRemainder(new BigInteger("100",16));
70  /* nodePort[0]=21 ; nodePort[1]=08 */
71  BigInteger serial[] = nodePortOUISer[1].divideAndRemainder(new BigInteger("10000",16));
72  /* serial[0]=07 ; serial[1]=8332 */
73 
74  return res + String.format("RamSan-%c%04X-FC-%x%c",serial[0].intValue()-1+'A', serial[1].intValue(), nodePort[1].intValue()/4, nodePort[0].intValue() % 16 +'A');
75  }
76 }
String toString()
return a description or alias for this WWN
IBM3700Description(String wwn)
create an instance with brief set to false.
IBM3700Description (ie RamSan-G8332-FC-2B) breaks out the serial and port information from the Texas ...
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
IBM3700Description(boolean brief, String wwn)
create an instance with the given WWN.
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...
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