...

Source file src/github.com/LINBIT/golinstor/client/physicalstorage.go

Documentation: github.com/LINBIT/golinstor/client

     1  // Copyright (C) LINBIT HA-Solutions GmbH
     2  // All Rights Reserved.
     3  // Author: Roland Kammerer <roland.kammerer@linbit.com>
     4  //
     5  // Licensed under the Apache License, Version 2.0 (the "License"); you may
     6  // not use this file except in compliance with the License. You may obtain
     7  // a copy of the License at
     8  //
     9  // http://www.apache.org/licenses/LICENSE-2.0
    10  //
    11  // Unless required by applicable law or agreed to in writing, software
    12  // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    13  // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
    14  // License for the specific language governing permissions and limitations
    15  // under the License.
    16  
    17  package client
    18  
    19  import "context"
    20  
    21  // copy & paste from generated code
    22  
    23  // PhysicalStorageStoragePoolCreate is used for create physical-storage
    24  type PhysicalStorageStoragePoolCreate struct {
    25  	// Name of the linstor storage pool
    26  	Name string `json:"name,omitempty"`
    27  	// A string to string property map.
    28  	Props map[string]string `json:"props,omitempty"`
    29  	// Name of the shared space
    30  	SharedSpace string `json:"shared_space,omitempty"`
    31  	// true if a shared storage pool uses linstor-external locking, like cLVM
    32  	ExternalLocking bool `json:"external_locking,omitempty"`
    33  }
    34  
    35  // PhysicalStorageCreate is a configuration struct used to represent pysical storage on a given node.
    36  // If with_storage_pool is set a linstor storage pool will also be created using this device pool
    37  type PhysicalStorageCreate struct {
    38  	ProviderKind ProviderKind `json:"provider_kind"`
    39  	DevicePaths  []string     `json:"device_paths"`
    40  	// RAID level to use for pool.
    41  	RaidLevel         string                           `json:"raid_level,omitempty"`
    42  	PoolName          string                           `json:"pool_name,omitempty"`
    43  	VdoEnable         bool                             `json:"vdo_enable,omitempty"`
    44  	VdoSlabSizeKib    int64                            `json:"vdo_slab_size_kib,omitempty"`
    45  	VdoLogicalSizeKib int64                            `json:"vdo_logical_size_kib,omitempty"`
    46  	WithStoragePool   PhysicalStorageStoragePoolCreate `json:"with_storage_pool,omitempty"`
    47  }
    48  
    49  type PhysicalStorageNode struct {
    50  	PhysicalStorageDevice
    51  	Size       int64 `json:"size,omitempty"`
    52  	Rotational bool  `json:"rotational,omitempty"`
    53  }
    54  
    55  // PhysicalStorageDevice represents a physical storage device on a a node.
    56  type PhysicalStorageDevice struct {
    57  	Device string `json:"device,omitempty"`
    58  	Model  string `json:"model,omitempty"`
    59  	Serial string `json:"serial,omitempty"`
    60  	Wwn    string `json:"wwn,omitempty"`
    61  }
    62  
    63  // PhysicalStorageViewItem is a view on a physical storage on multiple nodes.
    64  type PhysicalStorageViewItem struct {
    65  	Size       int64                              `json:"size,omitempty"`
    66  	Rotational bool                               `json:"rotational,omitempty"`
    67  	Nodes      map[string][]PhysicalStorageDevice `json:"nodes,omitempty"`
    68  }
    69  
    70  // GetPhysicalStorageView gets a grouped list of physical storage that can be turned into a LINSTOR storage-pool
    71  func (n *NodeService) GetPhysicalStorageView(ctx context.Context, opts ...*ListOpts) ([]PhysicalStorageViewItem, error) {
    72  	var ps []PhysicalStorageViewItem
    73  	_, err := n.client.doGET(ctx, "/v1/physical-storage/", &ps, opts...)
    74  	return ps, err
    75  }
    76  
    77  func (n *NodeService) GetPhysicalStorage(ctx context.Context, nodeName string) ([]PhysicalStorageNode, error) {
    78  	var ps []PhysicalStorageNode
    79  	_, err := n.client.doGET(ctx, "/v1/physical-storage/"+nodeName, &ps)
    80  	return ps, err
    81  }
    82  
    83  // CreateDevicePool creates an LVM, LVM-thin or ZFS pool, optional VDO under it on a given node.
    84  func (n *NodeService) CreateDevicePool(ctx context.Context, nodeName string, psc PhysicalStorageCreate) error {
    85  	_, err := n.client.doPOST(ctx, "/v1/physical-storage/"+nodeName, psc)
    86  	return err
    87  }
    88  

View as plain text