2.3. Managing Target Groups

This section explains how to create and manage groups of iSCSI targets.

2.3.1. Creating Target Groups

Before you create any target groups, assign the network with the iSCSI traffic type to a network interface on each node that you will add to a target group.

To create a target group, you will need a configuration file with a list of nodes to add to the group as well as target WWNs and portals. For example:

[
  {
    "NodeId": "01baeabee73e4a0d",
    "WWN": "iqn.2013-10.com.vstorage:test1",
    "Portals": [
      {
        "Addr": "192.168.10.11",
        "Port": 3025
      }
    ]
  },
  {
    "NodeId": "0d90158e9d2444e1",
    "WWN": "iqn.2013-10.com.vstorage:test2",
    "Portals": [
      {
        "Addr": "192.168.10.12",
        "Port": 3025
      }
    ]
  },
  {
    "NodeId": "a9eca47661a64031",
    "WWN": "iqn.2013-10.com.vstorage:test3",
    "Portals": [
      {
        "Addr": "192.168.10.13",
        "Port": 3025
      }
    ]
  }
]

In this configuration file:

  • NodeId is a node identifier that you can obtain from /etc/vstorage/host_id on a node.
  • WWN is a target world wide name:
    • an IQN if iSCSI protocol is used, e.g., iqn.2013-10.com.vstorage:test1 (you can only customize the last part after the colon), or
    • a WWPN in NAA format if Fibre Channel protocol is used, e.g., naa.21000024ff586d3b (you can obtain the port number from /sys/class/fc_host/host6/port_name).
  • Portals is one or more target portals, IP address and port combinations that the target will be accessible at. The IP address Addr is one that belongs to a public network interface on the node that handles the iSCSI traffic type. The port Port is optional and defaults to 3260 if omitted.

Once you have the configuration file, e.g., tg1.json, you can create the target group with the vstorage-target tg-create command. For example, to create an iSCSI target group, run:

# vstorage-target tg-create -name tg1 -targets tg1.json -type ISCSI
{
  "Id": "3d8364f5-b830-4211-85af-3a19d30ebac4"
}

When you run the command, targets are created on nodes specified in the configuration file and joined to the target group, target portals are created on specified network interfaces and ports.

2.3.2. Starting and Stopping Target Groups

When you create a target group, its targets are initially stopped. You can start them with the vstorage-target tg-start command. For example:

# vstorage-target tg-start -id 3d8364f5-b830-4211-85af-3a19d30ebac4

This command starts all targets in the group with the ID 3d8364f5-b830-4211-85af-3a19d30ebac4.

All targets in a group can either be running or stopped. So if you add targets to a group of running targets, the new targets will be started automatically.

To stop a target group, use the vstorage-target tg-stop command. For example:

# vstorage-target tg-stop -id 3d8364f5-b830-4211-85af-3a19d30ebac4

2.3.3. Listing Target Groups

You can list target groups with the vstorage-target tg-list command that displays basic information about groups. For example:

# vstorage-target tg-list
[
  {
    "Id": "3d8364f5-b830-4211-85af-3a19d30ebac4",
    "Name": "tg1",
    "Type": "ISCSI",
    "Running": true,
    "ACL": false,
    "ChapAuth": false,
    "CHAP": {},
    "Mode": 0
  },
  {
    "Id": "78c3b51e-fd9a-485b-91ce-bc0a8171c89d",
    "Name": "tg2",
    "Type": "ISCSI",
    "Running": false,
    "ACL": false,
    "ChapAuth": false,
    "CHAP": {},
    "Mode": 0
  }
]

To print complete information about all target groups, use vstorage-target tg-list -all.

2.3.4. Printing Details of Target Groups

To print the details of a specific group, use the vstorage-target tg-status command. For example:

# vstorage-target tg-status -id faeacacd-eba6-416c-9a7f-b5ba9e372e16

This command prints the complete details of the target group with the ID faeacacd-eba6-416c-9a7f-b5ba9e372e16. One parameter to pay attention to is NodeState. It indicates whether a node is in sync with the target group, i.e. aware of its current configuration. The following states can be shown:

  • synced, node is in sync with the target group,
  • syncing, node is syncing with the target group,
  • failed, node failed to sync with the target group (see the Error parameter for details),
  • offline, node is offline,
  • disabled, node is disabled and its target is offline.

2.3.5. Deleting Target Groups

To delete a target group, use the vstorage-target tg-delete command. For example:

# vstorage-target tg-delete -id 3d8364f5-b830-4211-85af-3a19d30ebac4

This command deletes the target group with the ID 3d8364f5-b830-4211-85af-3a19d30ebac4.