wwndesc  1.0-76
NetAppDescription.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  * NetAppDescription (ie NetApp-123456-iGrp1-0a) breaks out the serial, IO Group, and port information from the WWPN
13  */
15 {
16  /** @copydoc WWNDesc#WWNDesc(String) */
17  public NetAppDescription(String wwn)
18  {
19  super(wwn);
20  }
21  /** @copydoc WWNDesc#WWNDesc(boolean,String) */
22  public NetAppDescription(boolean brief, String wwn)
23  {
24  super(brief,wwn);
25  }
26 
27  /**
28  * If this class matches or describes the given WWN, returns a new instance of this class loaded with the given WWN.
29  *
30  * @return new instance of this class, or null if the given wwn does not match this class
31  * @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
32  * @param brief is used to ask for a shorter description: a more concise nickname or alias
33  * @param wwn the WWN (WWPN or WWNN, but typically WWPN) to match
34  */
35  public static WWNDesc getDesc(/* ignored */ boolean strong, boolean brief, String wwn)
36  {
37  return getDesc(strong, brief, wwn, DevRole.max()-1);
38  }
39  /**
40  * @copydoc #getDesc(boolean, boolean, String)
41  * @param role Role (Initiator/Switch/Target) to check for
42  */
43  public static WWNDesc getDesc (boolean strong, boolean brief, String wwn, int role)
44  {
45  if (!isA(role))
46  return null;
47  else if (wwn.matches("500a098.*"))
48  return new NetAppDescription(brief, wwn);
49  else
50  return null;
51  }
52 
53  /**
54  * 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
55  *
56  * @see getDesc(boolean,boolean,String)
57  *
58  * @return generated alias or nickname for the WWN
59  */
60  public String toString()
61  {
62  String res = super.toString();
63  if (null == res) res = "";
64 
65  /* for example start with 500a:0983:0000:4060 on http://pic.dhe.ibm.com/infocenter/storwize/ic/index.jsp?topic=%2Fcom.ibm.storwize.v7000.641.doc%2Fsvc_netapplocwwpn_327ams.html */
66  /* http://exchangeengine.wordpress.com/2011/07/25/how-to-find-out-wwpn-for-netapp-storage/ */ /* admin is ssh://naroot@host */
67  /* http://www.datadisk.co.uk/html_docs/netapp/netapp_cs.htm */
68  /* https://communities.netapp.com/thread/31347
69  *
70  * "lun show -v" shows a NetApp "Serial#: 20pa3?DGVO5f"
71  * "igroup show" shows 3 interfaces:
72  * 50:0a:09:81:98:3d:73:3b (virtual?)
73  * 50:0a:09:82:98:3d:73:3b (virtual?)
74  * 50:0a:09:80:88:3d:73:3b (physical?)
75  * "fcp config" shows 1 WWNN, 2 WWPN:
76  * 0a: ONLINE <ADAPTER UP> Loop No Fabric
77  * host address 0000ef
78  * portname 50:0a:09:81:98:3d:73:3b nodename 50:0a:09:80:88:3d:73:3b
79  * mediatype auto speed auto
80  *
81  * 0b: LINK NOT CONNECTED <ADAPTER UP>
82  * host address 000000
83  * portname 50:0a:09:82:98:3d:73:3b nodename 50:0a:09:80:88:3d:73:3b
84  * mediatype auto speed auto
85  *
86  * It would seem that:
87  * 5 is of course the type, 00a098 is of course the OUI
88  * 08 is the primary WWNN; 19, 29 are virtual interfaces that are expressed as WWPN (on Controller 2?) (18,28 on controller 1?)
89  * 8:3d:73:3b or some subset is a serial
90  *
91  * It may be possible that other igroups have additional controllers -- for example, 98.18.8, 98.28.8, 98.38.8, 98.39.8, 98.48.8, 98.49.8
92  *
93  * This is still only one controller's igroups; there is a separate redundant controller that may own disks. Maybe more controllers. Adapter 0c/0d on controller #2?
94  *
95  * http://exchangeengine.wordpress.com/2011/07/25/how-to-find-out-wwpn-for-netapp-storage/ argues: 0b has a ..98.29.8 of WWNN's 98.08.8
96  *
97  * http://www.ebay.com/itm/like/290900844309?lpid=82 implies (FAS2020 controller, WWN=5-00a098-0-00027540) that the -0- is significant, but seems to support that the 00a098-0 is the WWNN, >0 is a WWPN
98  */
99 
100  BigInteger serDirPort = wwn.subtract(wwn.shiftRight(36).shiftLeft(36));
101 
102  /* our example now has 300004060 */
103  BigInteger serPort[] = serDirPort.divideAndRemainder(new BigInteger("1000000",16)); /* serPort[0] is 300, serPort[1] is 004060 */
104 
105  /*
106  * 08 -> WWNN
107  * 18 -> WWPN C0-0a ?
108  * 28 -> WWPN C0-0b ?
109  * 19 -> WWPN C1-0a
110  * 29 -> WWPN C1-0b
111  */
112 
113  int controller = (serPort[0].intValue() / 0x010) % 8;
114  int offset = (serPort[0].intValue() / 0x100) % 8;
115  char SP = 'a';
116  if (0 == offset) SP = 'N';
117  else SP += (offset-1);
118 
119  if (brief)
120  return res + String.format("NetApp-%04x-SP%d%c",serPort[1].intValue() % 0x10000,controller,SP);
121  else
122  return res + String.format("NetApp-%06x-iGrp%d-0%c",serPort[1].intValue(),controller,SP);
123  }
124 }
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...
static boolean isA(int role)
convenience function to use bit-masks to check for membership in this role
Definition: WWNDesc.java:158
NetAppDescription(boolean brief, String wwn)
create an instance with the given WWN.
DevRole role
role of the device: Target, Switch, Initiator
Definition: WWNDesc.java:24
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...
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
NetAppDescription(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
String toString()
return a description or alias for this WWN; if brief is set to true during the call to getDesc()...
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
NetAppDescription (ie NetApp-123456-iGrp1-0a) breaks out the serial, IO Group, and port information f...
BigInteger wwn
the WWN that the instance tried to describe
Definition: WWNDesc.java:21