wwndesc  1.0-76
HPVirtualServerDescription.java
1 /* smallfoot.org is owned by allan.clark */
2 package org.smallfoot.wwn;
3 
4 import java.math.BigInteger;
5 
6 /**
7  * HPVirtualServerDescription (ie HP-123456:010) breaks out the uniqueness number
8  * and port index from the WWPN. This one is fairly weak in that HP clearly
9  * indicates the 00110a OUI is the unwashed-masses of roll-your-own-WWPN, and users
10  * do indeed roll random values. This class is intended more to provide guidance
11  * to the uniqueness of a 2nnn00110axxxxxx device wherein for consistent xxxxxx
12  * values, nnn does change.
13  *
14  * http://h20628.www2.hp.com/km-ext/kmcsdirect/emr_na-c03169041-2.pdf
15  * http://h20000.www2.hp.com/bc/docs/support/SupportManual/c03314921/c03314921.pdf.
16 
17  * http://h20000.www2.hp.com/bc/docs/support/SupportManual/c02494590/c02494590.pdf.
18  * 50:01:43:80:02:A3:00:00 - 50:01:43:80:02:A4:FF:FF VCEM
19  * 50:06:0B:00:00:C2:62:00 - 50:06:0B:00:00:C3:61:FF HP Pre-defined (64 blocks of 1024 IDs: ie C2:62:00 - C2:65:FF
20  *
21  * http://www.filibeto.org/unix/hp-ux/lib/os/vpar/6.0/vpars-6.0-npiv-4AA3-8665ENW.pdf
22  * The range that HP has reserved for NPIV is 0x50014c2000000000 to 0x50014c27ffffffff for Port WWNs and 0x50014c2800000000 to 0x50014c2fffffffff for Node WWNs.
23  * ...
24  * When manually configuring vHBAs, vWWNs may safely be picked from the range 0x100000110a0300 - 0x100000110a030fff
25  *
26  * http://h20000.www2.hp.com/bc/docs/support/SupportManual/c03967142/c03967142.pdf
27  * 10:00:38:9d:30:60:00:00 - 10:00:38:9d:30:6f:ff:ff used in examples of API
28  *
29  * 50060b00 range used in http://www.filibeto.org/unix/hp-ux/lib/os/vpar/6.0/vpars-6.0-npiv-4AA3-8665ENW.pdf as a config example. Customers tend to follow examples.
30  *
31  * 00:60:B0 Integrity and HP9000
32  * 00:11:0a Compaq Proliant (500110a in servers)
33  * 00:01:FE EVA from DEC
34  * 00:17:A4 MSL Tape
35  */
37 {
38  /** @copydoc WWNDesc#WWNDesc(String) */
40  {
41  super(wwn);
42  }
43 
44  /**
45  * If this class matches or describes the given WWN, returns a new instance of this class loaded with the given WWN.
46  *
47  * @return new instance of this class, or null if the given wwn does not match this class
48  * @param strong used to restrict matching to strong-matches only. This is a weak-confidence description, so will return null for strong-only matching
49  * @param brief is used to ask for a shorter description: a more concise nickname or alias
50  * @param wwn the WWN (WWPN or WWNN, but typically WWPN) to match
51  */
52  public static WWNDesc getDesc(boolean strong, boolean brief, String wwn)
53  {
54  return getDesc(strong, brief, wwn, DevRole.max()-1);
55  }
56  /**
57  * @copydoc #getDesc(boolean, boolean, String)
58  * @param role Role (Initiator/Switch/Target) to check for
59  */
60  public static WWNDesc getDesc (boolean strong, boolean brief, String wwn, int role)
61  {
62 //System.out.println("checking wwn "+wwn+" in role "+role+" strong: "+strong+" brief: "+brief+" isA: "+isA(role));
63  if (!isA(role))
64  return null;
65  else if (strong)
66  return null;
67  else if (wwn.matches("2[0-9a-f]{3}00110a[0-9a-f]{6}"))
68  return new HPVirtualServerDescription(brief, wwn);
69  else
70  return null;
71  }
72 
73  /** @copydoc WWNDesc#WWNDesc(boolean,String) */
74  public HPVirtualServerDescription(boolean brief, String wwn)
75  {
76  super(brief, wwn);
77  }
78  /**
79  * 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
80  *
81  * @see getDesc(boolean,boolean,String)
82  *
83  * @return generated alias or nickname for the WWN
84  */
85  public String toString()
86  {
87  String res = super.toString();
88  if (null == res) res = "";
89 
90  /* for example start with 20:13:00:11:0a:12:34:56 or 2:013:00110a:123456 broken apart */
91 
92  BigInteger portOuiSer[] = wwn.divideAndRemainder(new BigInteger("1000000",16));
93 
94  /* our example now has portOuiSer = { [2:013:00110a],[123456] } */
95  BigInteger portOui[] = portOuiSer[0].divideAndRemainder(new BigInteger("1000000",16));
96 
97  /* our example now has portOui = { [2:013], [00110a] } */
98 
99  return res + String.format("HPVC-%06x:%03x",portOuiSer[1].intValue(),portOui[0].intValue() % (1 << 12) );
100  }
101 
102  /**
103  * describe the WWPN's unique port label/index
104  *
105  * @return the unique name for the port WWPN
106  */
107  public String descPort()
108  {
109  BigInteger serPort[] = wwn.divideAndRemainder(new BigInteger("1000000000000",16));
110  return String.format("%03x",serPort[0].intValue() % (1 << 12));
111  }
112 }
HPVirtualServerDescription (ie HP-123456:010) breaks out the uniqueness number and port index from 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...
HPVirtualServerDescription(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:106
String toString()
return a description or alias for this WWN; if brief is set to true during the call to getDesc()...
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 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...
HPVirtualServerDescription(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
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 descPort()
describe the WWPN's unique port label/index
simple pass-thru class to define internal value for a Initiator in an idempotent way ...
Definition: WWNDesc.java:87
BigInteger wwn
the WWN that the instance tried to describe
Definition: WWNDesc.java:21