You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
1.9 KiB
77 lines
1.9 KiB
10 years ago
|
/*
|
||
|
* Minimalist Object Storage, (C) 2015 Minio, Inc.
|
||
|
*
|
||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
* you may not use this file except in compliance with the License.
|
||
|
* You may obtain a copy of the License at
|
||
|
*
|
||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||
|
*
|
||
|
* Unless required by applicable law or agreed to in writing, software
|
||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
* See the License for the specific language governing permissions and
|
||
|
* limitations under the License.
|
||
|
*/
|
||
|
|
||
|
package donut
|
||
|
|
||
10 years ago
|
import (
|
||
10 years ago
|
"github.com/minio/minio/pkg/donut/disk"
|
||
10 years ago
|
"github.com/minio/minio/pkg/iodine"
|
||
|
)
|
||
10 years ago
|
|
||
10 years ago
|
// node struct internal
|
||
10 years ago
|
type node struct {
|
||
|
hostname string
|
||
10 years ago
|
disks map[int]disk.Disk
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
// newNode - instantiates a new node
|
||
|
func newNode(hostname string) (node, error) {
|
||
10 years ago
|
if hostname == "" {
|
||
10 years ago
|
return node{}, iodine.New(InvalidArgument{}, nil)
|
||
10 years ago
|
}
|
||
10 years ago
|
disks := make(map[int]disk.Disk)
|
||
10 years ago
|
n := node{
|
||
|
hostname: hostname,
|
||
|
disks: disks,
|
||
|
}
|
||
|
return n, nil
|
||
|
}
|
||
|
|
||
10 years ago
|
// GetHostname - return hostname
|
||
|
func (n node) GetHostname() string {
|
||
10 years ago
|
return n.hostname
|
||
|
}
|
||
|
|
||
10 years ago
|
// ListDisks - return number of disks
|
||
10 years ago
|
func (n node) ListDisks() (map[int]disk.Disk, error) {
|
||
10 years ago
|
return n.disks, nil
|
||
|
}
|
||
|
|
||
10 years ago
|
// AttachDisk - attach a disk
|
||
10 years ago
|
func (n node) AttachDisk(disk disk.Disk, diskOrder int) error {
|
||
|
if diskOrder < 0 {
|
||
10 years ago
|
return iodine.New(InvalidArgument{}, nil)
|
||
10 years ago
|
}
|
||
10 years ago
|
n.disks[diskOrder] = disk
|
||
10 years ago
|
return nil
|
||
|
}
|
||
|
|
||
10 years ago
|
// DetachDisk - detach a disk
|
||
10 years ago
|
func (n node) DetachDisk(diskOrder int) error {
|
||
|
delete(n.disks, diskOrder)
|
||
10 years ago
|
return nil
|
||
|
}
|
||
|
|
||
10 years ago
|
// SaveConfig - save node configuration
|
||
10 years ago
|
func (n node) SaveConfig() error {
|
||
10 years ago
|
return iodine.New(NotImplemented{Function: "SaveConfig"}, nil)
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
// LoadConfig - load node configuration from saved configs
|
||
10 years ago
|
func (n node) LoadConfig() error {
|
||
10 years ago
|
return iodine.New(NotImplemented{Function: "LoadConfig"}, nil)
|
||
10 years ago
|
}
|