wwndesc  1.0-76
SymbiosDescription.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 //import java.util.*;
6 
7 /**
8  * @file
9  */
10 
11 /**
12  * SymbiosDescription (ie DS3400-123456:A:FC1) breaks out the UUID, Controller, and FC port for a DS3400 storage array
13  * ref: IBM Storage Systems WWPN Determination
14  */
16 {
17  /** @copydoc WWNDesc#WWNDesc(String) */
18  public SymbiosDescription(String wwn)
19  {
20  super(wwn);
21  }
22  /** @copydoc WWNDesc#WWNDesc(boolean,String) */
23  public SymbiosDescription(boolean brief, String wwn)
24  {
25  super(brief,wwn);
26  }
27 
28  /**
29  * If this class matches or describes the given WWN, returns a new instance of this class loaded with the given WWN.
30  *
31  * @return new instance of this class, or null if the given wwn does not match this class
32  * @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
33  * @param brief is used to ask for a shorter description: a more concise nickname or alias
34  * @param wwn the WWN (WWPN or WWNN, but typically WWPN) to match
35  */
36  public static WWNDesc getDesc(/* ignored */ boolean strong, boolean brief, String wwn)
37  {
38  return getDesc(strong, brief, wwn, DevRole.max()-1);
39  }
40  /**
41  * @copydoc #getDesc(boolean, boolean, String)
42  * @param role Role (Initiator/Switch/Target) to check for
43  */
44  public static WWNDesc getDesc (boolean strong, boolean brief, String wwn, int role)
45  {
46  if (!isA(role))
47  return null;
48  else if (wwn.matches("20[1-4][4-7]00a0b8[0-9a-f]{6}"))
49  return new SymbiosDescription(brief, wwn);
50  else
51  return null;
52  }
53 
54  /**
55  * return a description or alias for this WWN; if brief is set to true during the call to getDesc(), then a shorter description or alias will be returned
56  *
57  * @see getDesc(boolean,boolean,String)
58  *
59  * @return generated alias or nickname for the WWN
60  */
61  public String toString()
62  {
63  String res = super.toString();
64  if (null == res) res = "";
65 
66  /* for example start with 2024:00a0b8:123456 */
67 
68  BigInteger serDirPort[] = wwn.divideAndRemainder(new BigInteger("1000000",16)); /* serDirPort[0] is 2024:00a0b8, serDirPort[1] is 123456 */
69 
70  BigInteger dirPort[] = serDirPort[0].divideAndRemainder(new BigInteger("1000000",16)); /* dirPort[0] is 2024, dirPort[1] is 00a0b8 */
71 
72  /*
73  * 08 -> WWNN
74  * 18 -> WWPN C0-0a ?
75  * 28 -> WWPN C0-0b ?
76  * 19 -> WWPN C1-0a
77  * 29 -> WWPN C1-0b
78  */
79 
80  int port = (dirPort[0].intValue() / 0x010) % 2;
81  int controller = (dirPort[0].intValue() % 2);
82 
83  char SP = 'A';
84  SP += controller;
85 
86  if (brief)
87  return res + String.format("DS3400-%06x:%c:%d",serDirPort[1].intValue(),SP,port+1);
88  else
89  return res + String.format("DS3400-%06x-ctrl%c-FC%d",serDirPort[1].intValue(),SP,port+1);
90  }
91 }
String toString()
return a description or alias for this WWN; if brief is set to true during the call to getDesc()...
static boolean isA(int role)
convenience function to use bit-masks to check for membership in this role
Definition: WWNDesc.java:158
DevRole role
role of the device: Target, Switch, Initiator
Definition: WWNDesc.java:24
SymbiosDescription (ie DS3400-123456:A:FC1) breaks out the UUID, Controller, and FC port for a DS3400...
boolean brief
whether a more brief output should be offered in toString() (ie the difference between "VMax-HK192601...
Definition: WWNDesc.java:22
SymbiosDescription(boolean brief, String wwn)
create an instance with the given WWN.
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, int role)
If this class matches or describes the given WWN, returns a new instance of this class loaded with th...
SymbiosDescription(String wwn)
create an instance with brief set to false.
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