Skip to content

Commit c4f22d9

Browse files
authored
Merge pull request #3 from Seagate/feat/saswwn
feat: SAS attach using WWN, multipath, GUIDEBOOK.md
2 parents cb93f2d + 1d457cb commit c4f22d9

File tree

8 files changed

+581
-189
lines changed

8 files changed

+581
-189
lines changed

GUIDEBOOK.md

Lines changed: 414 additions & 0 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ install:
2525
go install ./sas/
2626

2727
run: build
28-
_output/example
28+
_output/example -h
2929

3030
test:
3131
go test -v ./sas/

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
# CSI lib-sas
1+
# csi-lib-sas
22

3-
A go package that can be imported to help CSI plugins with connecting to
4-
SAS devices. Simply import it and get access to the necessary functions.
3+
A go package that can be imported to help CSI plugins connect to SAS devices. Simply import it and get access to the necessary functions.
54

65
## Goals
76

@@ -10,9 +9,15 @@ Provide a basic, lightweight library for CSI Plugin Authors to leverage some of
109
We intentionally avoid pulling in additional dependencies, and we intend to be stateless and as such are not using receivers. Currently the focus is strictly based on a CSI context.
1110

1211
## Design Philosophy
13-
The idea is to keep this as lightweight and generic as possible. We intentionally avoid the use of any third party
14-
libraries or packages in this project. We don't have a vendor directory, because we attempt to rely only on the std
15-
golang libs. This may prove to not be ideal, and may be changed over time, but initially it's a worthwhile goal.
12+
13+
The idea is to keep this as lightweight and generic as possible. We intentionally avoid the use of any third party libraries or packages in this project. We don't have a vendor directory, because we attempt to rely only on the std golang libs.
14+
15+
This library leverages structured and contextual logging. Logging verbosity can be increased using the standard -v=# syntax.
16+
17+
## SAS Library Backgroud
18+
19+
- An [example program](example/main.go) is provided for library usage:
20+
- A [SAS Guidebook](GUIDEBOOK.md) details SAS specific system information and example program usage.
1621

1722
## Community, discussion, contribution, and support
1823

SECURITY.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# SAS Security Policy
2+
3+
We take the security of the csi-lib-sas project seriously. If you find any security vulnerabilities in any of the source code managed via our [GitHub Organization](https://github.com/Seagate) repositories, please report it to us as described below.
4+
5+
## Reporting Security Issues
6+
7+
:warning: **Please do not publicly report any security vulnerabilities via GitHub issues.**
8+
9+
If you have concerns or questions, please email us at [opensource@seagate.com](mailto:opensource@seagate.com).
10+
11+
To report an actual vulnerability, please use the "[Seagate Responsible Vulnerability Disclosure Policy](https://www.seagate.com/legal-privacy/responsible-vulnerability-disclosure-policy/)"
12+
13+
14+
### Reporting Format
15+
16+
To make your reporting meaningful and help us understand the nature and scope of the issue, please include as much information as possible.
17+
18+
### Preferred Languages
19+
20+
We prefer all communications to be in English.

SECURITY_CONTACTS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
# DO NOT REPORT SECURITY VULNERABILITIES DIRECTLY TO THESE NAMES, FOLLOW THE
1111
# INSTRUCTIONS AT https://kubernetes.io/security/
1212

13-
childsb
14-
saad-ali
13+
jskazinski
14+

example/main.go

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,65 @@ package main
1818
import (
1919
"context"
2020
"flag"
21-
"strings"
21+
"fmt"
2222

2323
"github.com/Seagate/csi-lib-sas/sas"
2424
"k8s.io/klog/v2"
2525
)
2626

27+
// Define usage and some common examples
28+
const (
29+
usage = `====================================================================================================
30+
example - Run the SAS Library Example Program
31+
32+
Examples:
33+
./example -wwn 600c0ff000546067369fe36201000000
34+
./example -wwn 600c0ff000546067369fe36201000000 -v=4
35+
./example -wwn 600c0ff000546067369fe36201000000 -v=4 -detach
36+
37+
Low level library commands require sudo or root privilege. You must provide a wwn to be succeed.
38+
39+
Options:
40+
`
41+
)
42+
2743
func main() {
2844
// Enable contextual logging
2945
ctx := context.Background()
3046
klog.InitFlags(nil)
3147
klog.EnableContextualLogging(true)
3248
logger := klog.FromContext(ctx)
3349

34-
wwns := flag.String("wwns", "", "Specify a comma separated list of WWNs")
35-
lun := flag.String("lun", "1", "Specify a LUN, defaults to 1")
36-
flag.Parse()
50+
wwn := flag.String("wwn", "", "Specify a WWN")
51+
detach := flag.Bool("detach", false, "automatically detach after a successful attach")
3752

38-
lcwwns := strings.ToLower(*wwns)
39-
logger.Info("[] sas test example", "lun", *lun, "wwns", lcwwns)
53+
flag.Usage = func() {
54+
fmt.Fprintf(flag.CommandLine.Output(), usage)
55+
flag.PrintDefaults()
56+
}
4057

41-
c := sas.Connector{}
58+
flag.Parse()
59+
60+
logger.Info("[] sas test example", "wwn", *wwn, "detach", *detach)
4261

4362
// Use command line arguments for test settings
44-
c.TargetWWNs = strings.Split(lcwwns, ",")
45-
c.Lun = *lun
63+
c := sas.Connector{
64+
TargetWWN: *wwn,
65+
}
4666

47-
dp, err := sas.Attach(ctx, c, &sas.OSioHandler{})
67+
dp, err := sas.Attach(ctx, &c, &sas.OSioHandler{})
4868

4969
if err != nil {
5070
logger.Error(err, "SAS Attach failure")
5171
} else {
52-
logger.Info("SAS Attach success", "devicePath", dp)
53-
sas.Detach(ctx, dp, &sas.OSioHandler{})
72+
logger.Info("SAS Attach success", "device", dp, "connector", c)
73+
if *detach {
74+
err = sas.Detach(ctx, dp, &sas.OSioHandler{})
75+
if err == nil {
76+
logger.Error(err, "SAS Detach success")
77+
} else {
78+
logger.Error(err, "SAS Detach failure")
79+
}
80+
}
5481
}
5582
}

0 commit comments

Comments
 (0)