...

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

Documentation: github.com/LINBIT/golinstor/client

     1  package client
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  )
     7  
     8  // copy & paste from generated code
     9  
    10  // ExosConnectionMap struct for ExosConnectionMap
    11  type ExosConnectionMap struct {
    12  	NodeName      string   `json:"node_name,omitempty"`
    13  	EnclosureName string   `json:"enclosure_name,omitempty"`
    14  	Connections   []string `json:"connections,omitempty"`
    15  }
    16  
    17  // ExosDefaults Default settings for EXOS enclosures
    18  type ExosDefaults struct {
    19  	Username    string `json:"username,omitempty"`
    20  	UsernameEnv string `json:"username_env,omitempty"`
    21  	Password    string `json:"password,omitempty"`
    22  	PasswordEnv string `json:"password_env,omitempty"`
    23  }
    24  
    25  // ExosDefaultsModifyAllOf struct for ExosDefaultsModifyAllOf
    26  type ExosDefaultsModifyAllOf struct {
    27  	// A list of keys to unset. The keys have to exist in ExosDefaults
    28  	UnsetKeys []string `json:"unset_keys,omitempty"`
    29  }
    30  
    31  // ExosDefaultsModify struct for ExosDefaultsModify
    32  type ExosDefaultsModify struct {
    33  	Username    string `json:"username,omitempty"`
    34  	UsernameEnv string `json:"username_env,omitempty"`
    35  	Password    string `json:"password,omitempty"`
    36  	PasswordEnv string `json:"password_env,omitempty"`
    37  	// A list of keys to unset. The keys have to exist in ExosDefaults
    38  	UnsetKeys []string `json:"unset_keys,omitempty"`
    39  }
    40  
    41  // ExosEnclosureEvent EXOS event
    42  type ExosEnclosureEvent struct {
    43  	Severity              string `json:"severity,omitempty"`
    44  	EventId               string `json:"event_id,omitempty"`
    45  	Controller            string `json:"controller,omitempty"`
    46  	TimeStamp             string `json:"time_stamp,omitempty"`
    47  	TimeStampNumeric      int64  `json:"time_stamp_numeric,omitempty"`
    48  	Message               string `json:"message,omitempty"`
    49  	AdditionalInformation string `json:"additional_information,omitempty"`
    50  	RecommendedAction     string `json:"recommended_action,omitempty"`
    51  }
    52  
    53  // ExosEnclosure EXOS enclosure
    54  type ExosEnclosure struct {
    55  	Name        string `json:"name,omitempty"`
    56  	CtrlAIp     string `json:"ctrl_a_ip,omitempty"`
    57  	CtrlBIp     string `json:"ctrl_b_ip,omitempty"`
    58  	Username    string `json:"username,omitempty"`
    59  	UsernameEnv string `json:"username_env,omitempty"`
    60  	Password    string `json:"password,omitempty"`
    61  	PasswordEnv string `json:"password_env,omitempty"`
    62  }
    63  
    64  // ExosEnclosureHealth EXOS enclosure name, controller IPs and health status
    65  type ExosEnclosureHealth struct {
    66  	Name         string `json:"name,omitempty"`
    67  	CtrlAIp      string `json:"ctrl_a_ip,omitempty"`
    68  	CtrlBIp      string `json:"ctrl_b_ip,omitempty"`
    69  	Health       string `json:"health,omitempty"`
    70  	HealthReason string `json:"health_reason,omitempty"`
    71  }
    72  
    73  // custom code
    74  
    75  type VendorProvider interface {
    76  	// GetExosDefaults lists default settings for all EXOS enclosures
    77  	GetExosDefaults(ctx context.Context) (ExosDefaults, error)
    78  	// ModifyExosDefaults sets or modifies default username / password for EXOS enclosures
    79  	ModifyExosDefaults(ctx context.Context, defaults ExosDefaultsModify) error
    80  	// GetExosEnclosures lists EXOS enclosures including controller IP and health status
    81  	GetExosEnclosures(ctx context.Context, noCache bool) ([]ExosEnclosure, error)
    82  	// CreateExosEnclosure creates a new enclosure unless it already exists
    83  	CreateExosEnclosure(ctx context.Context, enclosure ExosEnclosure) error
    84  	// ModifyExosEnclosure modifies an existing enclosure
    85  	ModifyExosEnclosure(ctx context.Context, name string, enclosure ExosEnclosure) error
    86  	// DeleteExosEnclosure deletes an existing enclosure
    87  	DeleteExosEnclosure(ctx context.Context, name string) error
    88  	// GetExosEvents lists the most current "count" events
    89  	GetExosEvents(ctx context.Context, name string, count int32) ([]ExosEnclosureEvent, error)
    90  	// GetExosConnectionMap lists the connection-mesh of EXOS Ports to LINSTOR Nodes
    91  	GetExosConnectionMap(ctx context.Context) (ExosConnectionMap, error)
    92  }
    93  
    94  type VendorService struct {
    95  	client *Client
    96  }
    97  
    98  // GetExosDefaults lists default settings for all EXOS enclosures
    99  func (s *VendorService) GetExosDefaults(ctx context.Context) (ExosDefaults, error) {
   100  	var defaults ExosDefaults
   101  	_, err := s.client.doGET(ctx, "/v1/vendor/seagate/exos/defaults", &defaults)
   102  	return defaults, err
   103  }
   104  
   105  // ModifyExosDefaults sets or modifies default username / password for EXOS enclosures
   106  func (s *VendorService) ModifyExosDefaults(ctx context.Context, defaults ExosDefaultsModify) error {
   107  	_, err := s.client.doPUT(ctx, "/v1/vendor/seagate/exos/defaults", defaults)
   108  	return err
   109  }
   110  
   111  // GetExosEnclosures lists EXOS enclosures including controller IP and health status
   112  func (s *VendorService) GetExosEnclosures(ctx context.Context, noCache bool) ([]ExosEnclosure, error) {
   113  	var enclosures []ExosEnclosure
   114  	_, err := s.client.doGET(ctx, fmt.Sprintf("/v1/vendor/seagate/exos/enclosures?nocache=%t", noCache), &enclosures)
   115  	return enclosures, err
   116  }
   117  
   118  // CreateExosEnclosure creates a new enclosure unless it already exists
   119  func (s *VendorService) CreateExosEnclosure(ctx context.Context, enclosure ExosEnclosure) error {
   120  	_, err := s.client.doPOST(ctx, "/v1/vendor/seagate/exos/enclosures", enclosure)
   121  	return err
   122  }
   123  
   124  // ModifyExosEnclosure modifies an existing enclosure
   125  func (s *VendorService) ModifyExosEnclosure(ctx context.Context, name string, enclosure ExosEnclosure) error {
   126  	_, err := s.client.doPUT(ctx, "/v1/vendor/seagate/exos/enclosures/"+name, enclosure)
   127  	return err
   128  }
   129  
   130  // DeleteExosEnclosure deletes an existing enclosure
   131  func (s *VendorService) DeleteExosEnclosure(ctx context.Context, name string) error {
   132  	_, err := s.client.doDELETE(ctx, "/v1/vendor/seagate/exos/enclosures/"+name, nil)
   133  	return err
   134  }
   135  
   136  // GetExosEvents lists the most current "count" events
   137  func (s *VendorService) GetExosEvents(ctx context.Context, name string, count int32) ([]ExosEnclosureEvent, error) {
   138  	var events []ExosEnclosureEvent
   139  	_, err := s.client.doGET(ctx, "/v1/vendor/seagate/exos/enclosures/"+name+"/events", &events)
   140  	return events, err
   141  }
   142  
   143  // GetExosConnectionMap lists the connection-mesh of EXOS Ports to LINSTOR Nodes
   144  func (s *VendorService) GetExosConnectionMap(ctx context.Context) (ExosConnectionMap, error) {
   145  	var connMap ExosConnectionMap
   146  	_, err := s.client.doGET(ctx, "/v1/vendor/seagate/exos/map", &connMap)
   147  	return connMap, err
   148  }
   149  

View as plain text