wwndesc  1.0-76
OraclePillarDescription.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  * Descriptor for (Oracle) Pillar Data Systems' Service Lifecycle Management devices
12  */
14 {
15  /** @copydoc WWNDesc#WWNDesc(String) */
17  {
18  super(wwn);
19  }
20 
21  /**
22  * If this class matches or describes the given WWN, returns a new instance of this class loaded with the given WWN.
23  *
24  * @return new instance of this class, or null if the given wwn does not match this class
25  * @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
26  * @param brief is ignored: this class has only one representation of the WWN description or alias
27  * @param wwn the WWN (WWPN or WWNN, but typically WWPN) to match
28  */
29  public static WWNDesc getDesc(/* ignored */ boolean strong, /* ignored */ boolean brief, String wwn)
30  {
31  return getDesc(strong, brief, wwn, DevRole.max()-1);
32  }
33  /**
34  * @copydoc #getDesc(boolean, boolean, String)
35  * @param role Role (Initiator/Switch/Target) to check for
36  */
37  public static WWNDesc getDesc (boolean strong, boolean brief, String wwn, int role)
38  {
39  if (!isA(role))
40  return null;
41  else if (wwn.matches("2[12][0-9a-fA-F][0-9a-fA-F]000b08.*"))
42  return new OraclePillarDescription(wwn);
43  else
44  return null;
45  }
46 
47  /**
48  * return a description or alias for this WWN
49  *
50  * @return generated alias or nickname for the WWN
51  */
52  public String toString()
53  {
54  String res = super.toString();
55  if (null == res) res = "";
56 
57  /* convert 2C00:000b08:SSSSSP into Axiom-SSSSS-cCpP */
58  /* for example start with 2100:000b08:123450 and produce Axiom-12345-c0p0 */
59  BigInteger serDirPort[] = wwn.divideAndRemainder(new BigInteger("1000000",16));
60  /* serDirPort[0]=2100:000b08 ; serDirPort[1]=123450 */
61 
62  BigInteger twoContZeroZero[] = serDirPort[0].divideAndRemainder(new BigInteger("100000000",16));
63  /* twoContZeroZero[0]=21; twoContZeroZero[1]=00:000b08 */
64  BigInteger twoCont[] = twoContZeroZero[0].divideAndRemainder(new BigInteger("10",16));
65  /* twoCont[0]=2 ; twoCont[1]=1*/
66 
67  BigInteger serialPort[] = serDirPort[1].divideAndRemainder(new BigInteger("10",16));
68  /* serialPort[0]=12345 ; serialPort[1]=0 */
69 
70  return res + String.format("Axiom-%05X-c%sp%X",serialPort[0].intValue(), twoCont[1].intValue()-1, serialPort[1].intValue());
71  }
72 }
OraclePillarDescription(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
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
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...
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
String toString()
return a description or alias for this WWN
simple pass-thru class to define internal value for a Target in an idempotent way ...
Definition: WWNDesc.java:139
Descriptor for (Oracle) Pillar Data Systems' Service Lifecycle Management devices.
BigInteger wwn
the WWN that the instance tried to describe
Definition: WWNDesc.java:21