wwndesc  1.0-76
HP3ParDescription.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  * HP3ParDescription (ie 3Par-1234:0:0:1) breaks out the serial, chassis, node, and port information from the WWPN
12  */
14 {
15  /** @copydoc WWNDesc#WWNDesc(String) */
16  public HP3ParDescription(String wwn)
17  {
18  super(wwn);
19  }
20  /** @copydoc WWNDesc#WWNDesc(boolean,String) */
21  public HP3ParDescription(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-9a-f][0-9a-f]0002ac.*")) /* 50002AC000020C3A */
47  return new HP3ParDescription(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 2N:SP:00:20:AC:MM:MM:MM to 3Par-Serial:N:S:P */
63  /* ie 20:12:00:02:AC:00:0C:3A is serial number 1303130 */
64  BigInteger serDirPort[] = wwn.divideAndRemainder(new BigInteger("1000000",16));
65  /* serDirPort[0]=20120002ac ; serDirPort[1]=000c3a */
66 
67  BigInteger portChassisNode[] = serDirPort[0].divideAndRemainder(new BigInteger("1000000",16));
68  /* portChassisNode[0]=2012 ; portChassisNode[1]=0002ac */
69  BigInteger chassisNode[] = portChassisNode[0].divideAndRemainder(new BigInteger("100",16));
70  /* chassisNode[0]=20 ; chassisNode[1]=12 */
71 
72  return res + String.format("3Par-%04d:%x:%x:%x",serDirPort[1].intValue(), chassisNode[0].intValue() % 16, chassisNode[1].intValue() / 16, chassisNode[1].intValue() % 16);
73  }
74 }
75 
HP3ParDescription (ie 3Par-1234:0:0:1) breaks out the serial, chassis, node, and port information fro...
HP3ParDescription(String wwn)
create an instance with brief set to false.
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...
HP3ParDescription(boolean brief, String wwn)
create an instance with the given WWN.
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)
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
String toString()
return a description or alias for this WWN
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