package com.onaro.sanscreen.client.view.task.template.addhost.generator.host;
import com.onaro.sanscreen.task.interfaces.data.template.AddHostTaskTemplateInstance;
import com.onaro.sanscreen.task.interfaces.data.template.AddHostTemplate;
import com.onaro.sanscreen.task.interfaces.data.inventory.ZoneMemberType;
/**
* Describes an adapter, its ports and configurations (zoning and LUN-masking).
*/
public class Adapter {
private int index;
private AddHostTaskTemplateInstance instance;
private Port ports[];
/**
* If not null, LUN masking is applied to the adapter. Its ileagal that both the adapter
* and its ports will have non-null masking.
*/
private VolumeMapMask masking;
/**
* If not null, zoning is applied to the adapter. Its ileagal that both the adapter
* and its ports will have non-null zoning.
*/
private AdapterZoning zoning;
public Adapter(AddHostTaskTemplateInstance instance, int index) {
this.index = index;
this.instance = instance;
AddHostTemplate template = instance.getAddHostTemplate();
if (template.isMaskByAdapter()) {
masking = new VolumeMapMask(instance, index);
}
if (template.isAddZone() && !template.isSameZoneName() &&
ZoneMemberType.NODE_WWN.equals(template.getHostZoneMemberType())) {
zoning = new AdapterZoning(instance, index);
}
ports = new Port[instance.getPortsPerAdapter(index)];
for (int portIndex = 0; portIndex < ports.length; ++portIndex) {
ports[portIndex] = new Port(instance, index, portIndex);
}
}
public String getWwn() {
return instance.getAdapterWwn(index);
}
public void setWwn(String wwn) {
instance.setAdapterWwn(index,wwn);
}
public VolumeMapMask getMasking() {
return masking;
}
public AdapterZoning getZoning() {
return zoning;
}
public int getPortsCount() {
return ports.length;
}
public Port getPort(int index) {
return ports[index];
}
}