wwndesc  1.0-76
IBM500507630Description.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  * IBM500507630 covers the following types:
12  * <ul>
13  * <li>1750 DS6000 500507630zFExxxx 500507630zyyxxxx</li>
14  * <li>2105 ESS or Shark 5005076300c0xxxx 5005076300yyxxxx</li>
15  * <li>2107 DS8000 500507630zFFxxxx 500507630zyyyxxx</li>
16  * </ul>
17  *
18  * @see http://aussiestorageblog.files.wordpress.com/2013/01/ibm-storage-systems-wwpn-determination-version-6-6.pdf
19  * @see http://www-03.ibm.com/support/techdocs/atsmastr.nsf/WebIndex/TD105450
20  * @see http://linuxvm.org/present/SHARE100/S9333NFa.pdf seems to imply that 50050763004029a0 is actually a tape ID within a IBM 3590(E) tape library
21  */
23 {
24  /** @copydoc WWNDesc#WWNDesc(String) */
26  {
27  super(wwn);
28  }
29  /** @copydoc WWNDesc#WWNDesc(boolean,String) */
30  public IBM500507630Description(boolean brief, String wwn)
31  {
32  super(brief, wwn);
33  }
34 
35  /**
36  * If this class matches or describes the given WWN, returns a new instance of this class loaded with the given WWN.
37  *
38  * @return new instance of this class, or null if the given wwn does not match this class
39  * @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
40  * @param brief is ignored: this class has only one representation of the WWN description or alias
41  * @param wwn the WWN (WWPN or WWNN, but typically WWPN) to match
42  */
43  public static WWNDesc getDesc(/* ignored */ boolean strong, /* ignored */ boolean brief, String wwn)
44  {
45  return getDesc(strong, brief, wwn, DevRole.max()-1);
46  }
47  /**
48  * @copydoc #getDesc(boolean, boolean, String)
49  * @param role Role (Initiator/Switch/Target) to check for
50  */
51  public static WWNDesc getDesc (boolean strong, boolean brief, String wwn, int role)
52  {
53  if (!isA(role))
54  return null;
55  else if (wwn.matches("500507630.*"))
56  return new IBM500507630Description(brief, wwn);
57  else
58  return null;
59  }
60 
61  /**
62  * return a description or alias for this WWN
63  *
64  * @return generated alias or nickname for the WWN
65  */
66  public String toString()
67  {
68  String res = super.toString();
69  if (null == res) res = "";
70 
71  /* convert 2P:0N:0020C2:MMMMMM into RamSan-MMMMMM-FC-NP */
72  /* for example start with 21:08:0020c2:078332 and produce RamSan-G8332-FC-2B */
73  BigInteger nodePortOUISer[] = wwn.divideAndRemainder(new BigInteger("1000000",16));
74  /* nodePortOUISer[0]=21080020c2 ; nodePortOUISer[1]=078332 */
75 
76  BigInteger nodePortOUI[] = nodePortOUISer[0].divideAndRemainder(new BigInteger("1000000",16));
77  /* nodePortOUI[0]=2108 ; nodePortOUI[1]=0020c2 */
78  BigInteger nodePort[] = nodePortOUI[0].divideAndRemainder(new BigInteger("100",16));
79  /* nodePort[0]=21 ; nodePort[1]=08 */
80  BigInteger serial[] = nodePortOUISer[1].divideAndRemainder(new BigInteger("10000",16));
81  /* serial[0]=07 ; serial[1]=8332 */
82 
83  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');
84  }
85 }
String toString()
return a description or alias for this WWN
IBM500507630Description(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
IBM500507630Description(boolean brief, String wwn)
create an instance with the given WWN.
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...
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...
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
WWNDesc is the basic generic class from which each vendor-specific pattern is built upon; similar to ...
Definition: WWNDesc.java:19
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
IBM500507630 covers the following types: