wwndesc  1.0-76
HPDotHillDescription.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  * HPDotHillDescription (ie P2000-123456-B1) breaks out a unique code and the port information from the WWPN of a Dot Hill Systems Modular Smart Array P2000 which HP resells.
12  *
13  * These descriptors are fairly weak: I'm somewhat sure of the serial, but only two matches for the port-number logic.
14  */
16 {
17  /** @copydoc WWNDesc#WWNDesc(String) */
18  public HPDotHillDescription(String wwn)
19  {
20  super(wwn);
21  }
22 
23  /**
24  * If this class matches or describes the given WWN, returns a new instance of this class loaded with the given WWN.
25  *
26  * @return new instance of this class, or null if the given wwn does not match this class
27  * @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
28  * @param brief is ignored: this class has only one representation of the WWN description or alias
29  * @param wwn the WWN (WWPN or WWNN, but typically WWPN) to match
30  */
31  public static WWNDesc getDesc(/* ignored */ boolean strong, /* ignored */ boolean brief, String wwn)
32  {
33  return getDesc(strong, brief, wwn, DevRole.max()-1);
34  }
35  /**
36  * @copydoc #getDesc(boolean, boolean, String)
37  * @param role Role (Initiator/Switch/Target) to check for
38  */
39  public static WWNDesc getDesc (boolean strong, boolean brief, String wwn, int role)
40  {
41  if (!isA(role))
42  return null;
43  else if (wwn.matches("2[0-9a-f][0-9a-f][0-9a-f]00c0ff.*"))
44  return new HPDotHillDescription(wwn);
45  else
46  return null;
47  }
48 
49  /**
50  * return a description or alias for this WWN
51  *
52  * @return generated alias or nickname for the WWN
53  */
54  public String toString()
55  {
56  String res = super.toString();
57  if (null == res) res = "";
58 
59  /* convert 2170:00c0ff:012345 into P2000-012345-A2 */
60  BigInteger serDirPort[] = wwn.divideAndRemainder(new BigInteger("1000000",16));
61  /* serDirPort[0]=217000c0ff ; serDirPort[1]=012345 */
62 
63  BigInteger portChassisNode[] = serDirPort[0].divideAndRemainder(new BigInteger("100000000",16));
64  /* portChassisNode[0]=21 ; portChassisNode[1]=7000c0ff */
65  BigInteger chassisNode[] = portChassisNode[0].divideAndRemainder(new BigInteger("10",16));
66  /* chassisNode[0]=2 ; chassisNode[1]=1 */
67 
68  return res + String.format("P2000-%06x-%c%c",serDirPort[1].intValue(), 'A'+(chassisNode[1].intValue()/4), '1'+(chassisNode[1].intValue()%4));
69  }
70 }
String toString()
return a description or alias for this WWN
static boolean isA(int role)
convenience function to use bit-masks to check for membership in this role
Definition: WWNDesc.java:158
HPDotHillDescription(String wwn)
create an instance with brief set to false.
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
HPDotHillDescription (ie P2000-123456-B1) breaks out a unique code and the port information from the ...
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...
simple pass-thru class to define internal value for a Target in an idempotent way ...
Definition: WWNDesc.java:139
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...
BigInteger wwn
the WWN that the instance tried to describe
Definition: WWNDesc.java:21