Debian Codegraph @

client/physicalstorage.go

raw
1 // Copyright (C) LINBIT HA-Solutions GmbH
2 // All Rights Reserved.
3 // Author: Roland Kammerer <[email protected]>
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 PvCreateArguments []string `json:"pv_create_arguments,omitempty"`
48 VgCreateArguments []string `json:"vg_create_arguments,omitempty"`
49 LvCreateArguments []string `json:"lv_create_arguments,omitempty"`
50 ZpoolCreateArguments []string `json:"zpool_create_arguments,omitempty"`
51 }
52
53 type PhysicalStorageNode struct {
54 PhysicalStorageDevice
55 Size int64 `json:"size,omitempty"`
56 Rotational bool `json:"rotational,omitempty"`
57 }
58
59 // PhysicalStorageDevice represents a physical storage device on a a node.
60 type PhysicalStorageDevice struct {
61 Device string `json:"device,omitempty"`
62 Model string `json:"model,omitempty"`
63 Serial string `json:"serial,omitempty"`
64 Wwn string `json:"wwn,omitempty"`
65 }
66
67 // PhysicalStorageViewItem is a view on a physical storage on multiple nodes.
68 type PhysicalStorageViewItem struct {
69 Size int64 `json:"size,omitempty"`
70 Rotational bool `json:"rotational,omitempty"`
71 Nodes map[string][]PhysicalStorageDevice `json:"nodes,omitempty"`
72 }
73
74 // GetPhysicalStorageView gets a grouped list of physical storage that can be turned into a LINSTOR storage-pool
75 func (n *NodeService) GetPhysicalStorageView(ctx context.Context, opts ...*ListOpts) ([]PhysicalStorageViewItem, error) {
76 var ps []PhysicalStorageViewItem
77 _, err := n.client.doGET(ctx, "/v1/physical-storage/", &ps, opts...)
78 return ps, err
79 }
80
81 func (n *NodeService) GetPhysicalStorage(ctx context.Context, nodeName string) ([]PhysicalStorageNode, error) {
82 var ps []PhysicalStorageNode
83 _, err := n.client.doGET(ctx, "/v1/physical-storage/"+nodeName, &ps)
84 return ps, err
85 }
86
87 // CreateDevicePool creates an LVM, LVM-thin or ZFS pool, optional VDO under it on a given node.
88 func (n *NodeService) CreateDevicePool(ctx context.Context, nodeName string, psc PhysicalStorageCreate) error {
89 _, err := n.client.doPOST(ctx, "/v1/physical-storage/"+nodeName, psc)
90 return err
91 }