Giter Club home page Giter Club logo

goock's Introduction

Goock

Go Report Card CircleCI Codecov

Goock is a Golang library/client for discovering and managing block device. it dramatically eases the efforts needed when connecting/disconnecting to storage backend.

Table of Content

Overview

Goock aims at providing a easy-to-use library/client for block device discovering and management. user no longer needs the use of multiple linux tools like open-iscsi, multipath-tools, sysfsutils and sg3-utils). Instead,
goock will leverage the power of many *nux device management tools, and provides simple and straightforward API/CLI for developers and administrators.

This project is inspired by OpenStack project os-brick

Features

  • Discovery of devices for iSCSI transport protocol.
  • Discovery of devices for FibreChanel transport protocol.
  • Removal of devices from a host
  • Multipath support

Installation

Note: if you want build binary from source, please firstly setup Go environment.

  • Get the binary of goock, you have 2 ways to do this:

    • Download the binary of goock from goock releases

    • Either:

      • download the source and it's dependencies from github
      go get -d -v -t github.com/peter-wangxu/goock
      
      • Build the binary
      go build

      a binary file named goock will be in place for use.

  • Install tools

This step installs couple of tools that goock relies on.

On Debian/Ubuntu

sudo apt-get install open-iscsi multipath-tools sysfsutils sg3-utils

On RHEL/CentOS

yum install iscsi-initiator-utils device-mapper-multipath sysfsutils sg3_utils

Development requirements

Goock can be built or developed on both Linux or Windows platform.

  • Linux/Windows
  • Go 1.7 or later

Usage

As a library

Goock is a library for connecting/disconnecting block devices for any Golang based software. the example usage below:

Connect to a storage device

package main

import (
        "github.com/peter-wangxu/goock/connector"
)

iscsi := connector.New()

conn := connector.ConnectionProperty{}
conn.TargetPortals = []string{"192.168.1.30"}
conn.TargetIqns = []string{"iqn.xxxxxxxxxxxxxx"}
conn.TargetPortals = []int{10}

deviceInfo, _ : = iscsi.ConnectVolume(conn)

Disconnect a device from storage system

package main

import (
        "github.com/peter-wangxu/goock/connector"
)

iscsi := connector.New()

conn := connector.ConnectionProperty{}
conn.TargetPortals = []string{"192.168.1.30"}
conn.TargetIqns = []string{"iqn.xxxxxxxxxxxxxx"}
conn.TargetPortals = []int{10}

deviceInfo, _ : = iscsi.DisconnectVolume(conn)

Extend a already connected device

Sometimes, the device needs be extended on the storage system, while host was not aware of size change immediately, in this case, a host side rescan is needed.

package main

import (
        "github.com/peter-wangxu/goock/connector"
)

iscsi := connector.New()

conn := connector.ConnectionProperty{}
conn.TargetPortals = []string{"192.168.1.30"}
conn.TargetIqns = []string{"iqn.xxxxxxxxxxxxxx"}
conn.TargetPortals = []int{10}

deviceInfo, _ : = iscsi.ExtendVolume(conn)

As a client tool

Goock is also client tool, which can be used from shell. When the host is connecting with backend storage(such as enterprise array, DellEMC Unity, HPE 3Par etc.), goock can be helpful to connect with the storage device and inspect its information.

NOTE: make sure you have permission to operate the block device.

Example usage below:

Show the goock version

goock -v

Get host information

goock info

the output likes below:

Volume Information:
iSCSI Qualified Name(IQN)      :
iqn.1993-08.org.debian:01:b974ee37fea
Host Bus Adapter               :
[20000090fa534cd0:10000090fa534cd0 20000090fa534cd1:10000090fa534cd1]
Connected Fibre Channel Target :
[5006016089200925:5006016d09200925 50060160b6e00e5a:5006016036e00e5a 5006016089200925:5006016509200925 50060160b6e00e5a:5006016136e00e5a]
Connected iSCSI sessions       :
192.168.1.99 192.168.1.100

Connect to a LUN on specific target

# Connect and rescan storage device whose iSCSI target ip is <target IP>, the desired
# Device LUN ID is [LUN ID]
goock connect <TARGET> <LUN ID>

The <TARGET> here and below commands example denotes the IP address or WWN of remote storage device.

The <LUN ID> is allocated by the storage array, usually a integer less than 255.

Connect and rescan all LUNs from a target

Not support yet.

goock connect <TARGET>

Disconnect a LUN from storage system

goock disconnect <Target> <LUN ID>

Extend a connected device

goock extend <Target> <LUN ID>

or

Not support yet.

goock extend /dev/sdx

Get help for each command

goock help connect

Testing

Unit test

cd goock
go test -v ./...

Manual test

  • first build a binary from source
cd goock
go build
  • run goock command by specifying some parameters
goock connect <TARGET> <LUN ID>

Contributions

Simply fork this repo and send PR for your code change(also tests to cover your change), remember to give a title and description of your PR.

License

Apache License Version 2.0

FAQ

goock's People

Contributors

lianwaiyuchanchan avatar murray-liang avatar peter-wangxu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

goock's Issues

No able to work with iscsi target

$ sudo ./goock -d connect 172.17.0.2 1
DEBU[0000] Trying to validate the target IP : 172.17.0.2, LUN ID: [1]
DEBU[0000] Executing command: [iscsiadm -m discovery -t sendtargets -I default -p 172.17.0.2 --op new]
DEBU[0000] Command Result cmd=[iscsiadm -m discovery -t sendtargets -I default -p 172.17.0.2 --op new] duration=0.0028s exit_code=21 output="iscsiadm: No portals found
"
DEBU[0000] Discover result discovered= target=[172.17.0.2]
DEBU[0000] Executing command: [iscsiadm -m session]
DEBU[0000] Command Result cmd=[iscsiadm -m session] duration=0.0020s exit_code=21 output="iscsiadm: No active sessions.
"
DEBU[0000] Executing command: [iscsiadm -m session --rescan]
DEBU[0000] Command Result cmd=[iscsiadm -m session --rescan] duration=0.0023s exit_code=21 output="iscsiadm: No session found.
"
ERRO[0002] Unable to find any existing path within [] error="No path found"
Volume Information:
Multipath:
Single Paths:

Multipath ID:
WWN:

Add multipath parser

the example output is below:

36006016074e03a002176255815692cc7 dm-9 DGC,VRAID
size=4.0G features='2 queue_if_no_path retain_attached_hw_handler' hwhandler='1 alua' wp=rw
|-+- policy='round-robin 0' prio=50 status=active
| `- 9:0:0:17   sdt  65:48  active ready running
`-+- policy='round-robin 0' prio=10 status=enabled
  `- 9:0:2:17   sdax 67:16  active ready running
36006016074e03a00e98b07ef80df4e3a dm-3 DGC,VRAID
size=3.0G features='2 queue_if_no_path retain_attached_hw_handler' hwhandler='1 alua' wp=rw
|-+- policy='round-robin 0' prio=50 status=active
| `- 9:0:2:11   sdar 66:176 active ready running
`-+- policy='round-robin 0' prio=10 status=enabled
  `- 9:0:0:11   sdn  8:208  active ready running

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.