forked from hpe-storage/common-host-libs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iscsi_linux.go
76 lines (65 loc) · 2.51 KB
/
iscsi_linux.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// (c) Copyright 2019 Hewlett Packard Enterprise Development LP
package iscsi
import (
"github.com/hpe-storage/common-host-libs/chapi2/cerrors"
"github.com/hpe-storage/common-host-libs/chapi2/model"
log "github.com/hpe-storage/common-host-libs/logger"
"github.com/hpe-storage/common-host-libs/util"
)
const (
initiatorPath = "/etc/iscsi/initiatorname.iscsi"
initiatorNamePattern = "^InitiatorName=(?P<iscsiinit>.*)$"
)
func getIscsiInitiators() (init *model.Initiator, err error) {
log.Trace(">>>>> getIscsiInitiators")
defer log.Trace("<<<<< getIscsiInitiators")
exists, _, err := util.FileExists(initiatorPath)
if !exists {
return nil, cerrors.NewChapiErrorf(cerrors.NotFound, errorMessageIscsiPathNotFound, initiatorPath)
return nil, nil
}
initiators, err := util.FileGetStringsWithPattern(initiatorPath, initiatorNamePattern)
if err != nil {
log.Errorf("failed to get iqn from %s error %s", initiatorPath, err.Error())
return nil, err
}
if len(initiators) == 0 {
log.Errorf("empty iqn found from %s", initiatorPath)
return nil, cerrors.NewChapiError(cerrors.NotFound, errorMessageEmptyIqnFound)
}
log.Tracef("got iscsi initiator name as %s", initiators[0])
init = &model.Initiator{AccessProtocol: model.AccessProtocolIscsi, Init: initiators}
return init, err
}
// getTargetScope enumerates the target scope for the given iSCSI target. An empty string is
// returned if we were unable to determine the target scope.
func getTargetScope(targetName string) (targetScope string, err error) {
// TODO
return "", nil
}
// rescanIscsiTarget rescans host ports for iSCSI devices
func rescanIscsiTarget(lunID string) error {
// TODO
return nil
}
// getTargetPortals enumerates the target portals for the given iSCSI target
func (plugin *IscsiPlugin) getTargetPortals(targetName string, ipv4Only bool) ([]*model.TargetPortal, error) {
// TODO
return nil, nil
}
// loginTarget is called to connect to the given iSCSI target. The parent LoginTarget() routine
// has already validated that target iqn and blockDev.IscsiAccessInfo are provided.
func (plugin *IscsiPlugin) loginTarget(blockDev model.BlockDeviceAccessInfo) (err error) {
// TODO
return nil
}
// logoutTarget is called to disconnect the given iSCSI target from this host.
func (plugin *IscsiPlugin) logoutTarget(targetName string) (err error) {
// TODO
return nil
}
// isTargetLoggedIn checks to see if the given iSCSI target is already logged in.
func (plugin *IscsiPlugin) isTargetLoggedIn(targetName string) (bool, error) {
// TODO
return false, nil
}