001/*
002 * To change this template, choose Tools | Templates
003 * and open the template in the editor.
004 */
005package org.anarres.qemu.exec.host.disk;
006
007import java.net.InetAddress;
008
009/**
010 *
011 * @author shevek
012 */
013public class IScsiDisk extends AbstractDisk {
014// "iscsi://<target-ip>[:<port>]/<target-iqn>/<lun>"
015
016    private final InetAddress address;
017    private final int port;
018    private final String iqn;
019    private final int lun;
020    private final String user;
021    private final String password;
022
023    public IScsiDisk(InetAddress address, int port, String iqn, int lun, String user, String password) {
024        this.address = address;
025        this.port = port;
026        this.iqn = iqn;
027        this.lun = lun;
028        this.user = user;
029        this.password = password;
030    }
031
032    public IScsiDisk(InetAddress address, int port, String iqn, int lun) {
033        this(address, port, iqn, lun, null, null);
034    }
035
036    public IScsiDisk(InetAddress address, String iqn, int lun) {
037        this(address, -1, iqn, lun);
038    }
039
040    @Override
041    public String toString() {
042        StringBuilder buf = new StringBuilder("iscsi://");
043        buf.append(address.getHostAddress());
044        if (port != -1)
045            buf.append(':').append(port);
046        buf.append('/').append(iqn);
047        buf.append('/').append(lun);
048        return buf.toString();
049    }
050}