diff --git a/power/models/create_data_volume.go b/power/models/create_data_volume.go index ab5c4051..52d2a500 100644 --- a/power/models/create_data_volume.go +++ b/power/models/create_data_volume.go @@ -46,6 +46,9 @@ type CreateDataVolume struct { // Indicates if the volume should be replication enabled or not ReplicationEnabled *bool `json:"replicationEnabled,omitempty"` + // List of replication sites for volume replication + ReplicationSite []string `json:"replicationSite,omitempty"` + // Indicates if the volume is shareable between VMs Shareable *bool `json:"shareable,omitempty"` diff --git a/power/models/multi_volumes_create.go b/power/models/multi_volumes_create.go index 7b1a701f..28ce2b24 100644 --- a/power/models/multi_volumes_create.go +++ b/power/models/multi_volumes_create.go @@ -49,6 +49,9 @@ type MultiVolumesCreate struct { // Indicates if the volume should be replication enabled or not ReplicationEnabled *bool `json:"replicationEnabled,omitempty"` + // List of replication sites for volume replication + ReplicationSite []string `json:"replicationSite,omitempty"` + // Indicates if the volume is shareable between VMs Shareable *bool `json:"shareable,omitempty"` diff --git a/power/models/site.go b/power/models/site.go index e6523f50..2a9caa29 100644 --- a/power/models/site.go +++ b/power/models/site.go @@ -7,7 +7,9 @@ package models import ( "context" + "strconv" + "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) @@ -17,6 +19,9 @@ import ( // swagger:model Site type Site struct { + // replication pool map + ReplicationPoolMap []*StoragePoolMap `json:"ReplicationPoolMap,omitempty"` + // true if location is active , otherwise it is false IsActive bool `json:"isActive,omitempty"` @@ -26,11 +31,80 @@ type Site struct { // Validate validates this site func (m *Site) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateReplicationPoolMap(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Site) validateReplicationPoolMap(formats strfmt.Registry) error { + if swag.IsZero(m.ReplicationPoolMap) { // not required + return nil + } + + for i := 0; i < len(m.ReplicationPoolMap); i++ { + if swag.IsZero(m.ReplicationPoolMap[i]) { // not required + continue + } + + if m.ReplicationPoolMap[i] != nil { + if err := m.ReplicationPoolMap[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ReplicationPoolMap" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ReplicationPoolMap" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + return nil } -// ContextValidate validates this site based on context it is used +// ContextValidate validate this site based on the context it is used func (m *Site) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateReplicationPoolMap(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Site) contextValidateReplicationPoolMap(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.ReplicationPoolMap); i++ { + + if m.ReplicationPoolMap[i] != nil { + + if swag.IsZero(m.ReplicationPoolMap[i]) { // not required + return nil + } + + if err := m.ReplicationPoolMap[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ReplicationPoolMap" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ReplicationPoolMap" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + return nil } diff --git a/power/models/storage_pool_map.go b/power/models/storage_pool_map.go new file mode 100644 index 00000000..d42b5209 --- /dev/null +++ b/power/models/storage_pool_map.go @@ -0,0 +1,53 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// StoragePoolMap storage pool map +// +// swagger:model StoragePoolMap +type StoragePoolMap struct { + + // remote pool + RemotePool string `json:"remotePool,omitempty"` + + // volume pool + VolumePool string `json:"volumePool,omitempty"` +} + +// Validate validates this storage pool map +func (m *StoragePoolMap) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this storage pool map based on context it is used +func (m *StoragePoolMap) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *StoragePoolMap) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *StoragePoolMap) UnmarshalBinary(b []byte) error { + var res StoragePoolMap + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +}