Documentation ¶
Index ¶
- Variables
- func CIDRToIPv4Range(cidr string) (string, string, error)
- func CIDRToLongRange(cidr string) (uint32, uint32, error)
- func FromPBHostDefinitionToPBGatewayDefinition(in pb.HostDefinition) pb.GatewayDefinition
- func FromPBHostSizing(src pb.HostSizing) resources.SizingRequirements
- func GetConnection(host string, port int) *grpc.ClientConn
- func GetContext(storeUUID bool) (context.Context, error)
- func GetReference(in *pb.Reference) string
- func GetTimeoutContext(timeout time.Duration) (context.Context, context.CancelFunc, error)
- func GetUUID() string
- func Hash(reader io.Reader) string
- func IPv4ToLong(ip string) uint32
- func IsCIDRRoutable(cidr string) (bool, error)
- func JobCancelUUID(uuid string)
- func JobDeregister(ctx context.Context)
- func JobDeregisterUUID(uuid string)
- func JobList() map[string]string
- func JobRegister(ctx context.Context, cancelFunc func(), command string) error
- func LongToIPv4(value uint32) string
- func ToHostStatus(in *resources.Host) *pb.HostStatus
- func ToPBBucketList(in []string) *pb.BucketList
- func ToPBBucketMountPoint(in *resources.Bucket) *pb.BucketMountingPoint
- func ToPBFileList(fileNames []string, uploadDates []string, fileSizes []int64, ...) *pb.FileList
- func ToPBGatewayDefinition(in *resources.HostDefinition) *pb.GatewayDefinition
- func ToPBHost(in *resources.Host) *pb.Host
- func ToPBHostDefinition(in *resources.HostDefinition) *pb.HostDefinition
- func ToPBHostSizing(src resources.SizingRequirements) pb.HostSizing
- func ToPBHostTemplate(in *resources.HostTemplate) *pb.HostTemplate
- func ToPBImage(in *resources.Image) *pb.Image
- func ToPBNetwork(in *resources.Network) *pb.Network
- func ToPBShare(hostName string, share *propsv1.HostShare) *pb.ShareDefinition
- func ToPBShareMount(shareName string, hostName string, mount *propsv1.HostRemoteMount) *pb.ShareMountDefinition
- func ToPBShareMountList(hostName string, share *propsv1.HostShare, ...) *pb.ShareMountList
- func ToPBSshConfig(from *system.SSHConfig) *pb.SshConfig
- func ToPBVirtualIP(src resources.VIP) pb.VirtualIp
- func ToPBVolume(in *resources.Volume) *pb.Volume
- func ToPBVolumeAttachment(in *resources.VolumeAttachment) *pb.VolumeAttachment
- func ToPBVolumeInfo(volume *resources.Volume, mounts map[string]*propsv1.HostLocalMount) *pb.VolumeInfo
- func ToSystemSSHConfig(from *pb.SshConfig) *system.SSHConfig
- type BucketGenerator
- type ChunkGroup
- func (cg *ChunkGroup) ComputeShardCheckSum(shardNum int, reader io.Reader) (string, error)
- func (cg *ChunkGroup) Encrypt() ([]byte, *KeyInfo, error)
- func (cg *ChunkGroup) GenerateNonce(shardNum int, nonceSize int) ([]byte, error)
- func (cg *ChunkGroup) GetBatchSizeInfo() (int, int, int)
- func (cg *ChunkGroup) GetBucketNames() []string
- func (cg *ChunkGroup) GetCheckSum(shardNum int) string
- func (cg *ChunkGroup) GetEncryptedChunkSize() int
- func (cg *ChunkGroup) GetFileInfos() (string, string, int64)
- func (cg *ChunkGroup) GetGCM() (cipher.AEAD, error)
- func (cg *ChunkGroup) GetNbBatchs() int
- func (cg *ChunkGroup) GetNbShards() (int, int)
- func (cg *ChunkGroup) GetNonce(shardNum int) []byte
- func (cg *ChunkGroup) GetPaddingSize() int
- func (cg *ChunkGroup) GetShardNum(batchNum int, iterationNum int) int
- func (cg *ChunkGroup) GetStorageInfo(shardNum int) (string, string)
- func (cg *ChunkGroup) InitShards(chunkSize int, maxBatchSize int, ratioNumerator int, ratioDenominator int, ...) (dataShards int, parityShards int, err error)
- func (cg *ChunkGroup) IsReconstructible(missingBuckets []string) bool
- func (cg *ChunkGroup) ToString() string
- type KeyInfo
- type Shard
Constants ¶
This section is empty.
Variables ¶
var ( // BaseFolder is the path of the base folder containing safescale data BaseFolder = "/opt/safescale" // VarFolder ... VarFolder = BaseFolder + "/var" // LogFolder ... LogFolder = VarFolder + "/log" // TempFolder ... TempFolder = VarFolder + "/tmp" )
var ( // Debug if set to true, work in debug mode Debug = false // Verbose if set to true, increase verbosity Verbose = false )
Functions ¶
func CIDRToIPv4Range ¶
CIDRToIPv4Range converts CIDR to IPv4 range
func CIDRToLongRange ¶
CIDRToLongRange converts CIDR to IPv4 range
func FromPBHostDefinitionToPBGatewayDefinition ¶
func FromPBHostDefinitionToPBGatewayDefinition(in pb.HostDefinition) pb.GatewayDefinition
FromPBHostDefinitionToPBGatewayDefinition converts a pb.HostDefinition to pb.GatewayDefinition
func FromPBHostSizing ¶
func FromPBHostSizing(src pb.HostSizing) resources.SizingRequirements
FromPBHostSizing converts a protobuf HostSizing message to resources.SizingRequirements
func GetConnection ¶
func GetConnection(host string, port int) *grpc.ClientConn
GetConnection returns a connection to GRPC server
func GetReference ¶
GetReference return a reference from the name or id given in the pb.Reference
func GetTimeoutContext ¶
GetTimeoutContext return a context for grpc commands
func IsCIDRRoutable ¶
IsCIDRRoutable tells if the network is routable
func JobRegister ¶
JobRegister ...
func ToPBBucketList ¶
func ToPBBucketList(in []string) *pb.BucketList
ToPBBucketList convert a list of string into a *ContainerLsit
func ToPBBucketMountPoint ¶
func ToPBBucketMountPoint(in *resources.Bucket) *pb.BucketMountingPoint
ToPBBucketMountPoint convert a Bucket into a BucketMountingPoint
func ToPBFileList ¶
func ToPBFileList(fileNames []string, uploadDates []string, fileSizes []int64, fileBuckets [][]string) *pb.FileList
ToPBFileList convert a list of file names from api to protocolbuffer FileList format
func ToPBGatewayDefinition ¶
func ToPBGatewayDefinition(in *resources.HostDefinition) *pb.GatewayDefinition
ToPBGatewayDefinition converts a resources.HostDefinition tp .GatewayDefinition
func ToPBHostDefinition ¶
func ToPBHostDefinition(in *resources.HostDefinition) *pb.HostDefinition
ToPBHostDefinition ...
func ToPBHostSizing ¶
func ToPBHostSizing(src resources.SizingRequirements) pb.HostSizing
ToPBHostSizing converts a protobuf HostSizing message to resources.SizingRequirements
func ToPBHostTemplate ¶
func ToPBHostTemplate(in *resources.HostTemplate) *pb.HostTemplate
ToPBHostTemplate convert an template from api to protocolbuffer format
func ToPBNetwork ¶
ToPBNetwork convert a network from api to protocolbuffer format
func ToPBShare ¶
func ToPBShare(hostName string, share *propsv1.HostShare) *pb.ShareDefinition
ToPBShare convert a share from model to protocolbuffer format
func ToPBShareMount ¶
func ToPBShareMount(shareName string, hostName string, mount *propsv1.HostRemoteMount) *pb.ShareMountDefinition
ToPBShareMount convert share mount on host to protocolbuffer format
func ToPBShareMountList ¶
func ToPBShareMountList(hostName string, share *propsv1.HostShare, mounts map[string]*propsv1.HostRemoteMount) *pb.ShareMountList
ToPBShareMountList converts share mounts to protocol buffer
func ToPBSshConfig ¶
ToPBSshConfig converts a system.SSHConfig into a SshConfig
func ToPBVirtualIP ¶
ToPBVirtualIP converts a resources.VIP to a pb.VirtualIp
func ToPBVolume ¶
ToPBVolume converts an api.Volume to a *Volume
func ToPBVolumeAttachment ¶
func ToPBVolumeAttachment(in *resources.VolumeAttachment) *pb.VolumeAttachment
ToPBVolumeAttachment converts an api.Volume to a *Volume
func ToPBVolumeInfo ¶
func ToPBVolumeInfo(volume *resources.Volume, mounts map[string]*propsv1.HostLocalMount) *pb.VolumeInfo
ToPBVolumeInfo converts an api.Volume to a *VolumeInfo
Types ¶
type BucketGenerator ¶
type BucketGenerator struct {
// contains filtered or unexported fields
}
BucketGenerator ...
func NewBucketGenerator ¶
func NewBucketGenerator(buckets []objectstorage.Bucket) *BucketGenerator
NewBucketGenerator return a bucketGenerator returning the buckets given as parameters
func (*BucketGenerator) Next ¶
func (bg *BucketGenerator) Next() objectstorage.Bucket
Next return the bucket currently pointed by the iterator and then iterate
type ChunkGroup ¶
type ChunkGroup struct { FileName string `json:"filename,omitempty"` FileSize int64 `json:"filsize,omitempty"` Date string `json:"date,omitempty"` AesPassword string `json:"aespassword,omitempty"` Shards []*Shard `json:"shards,omitempty"` NbDataShards int `json:"nbdatashards,omitempty"` NbParityShards int `json:"nbparityshards,omitempty"` ChunkSize int `json:"chunksize,omitempty"` NbDataShardsPerBatch int `json:"nbdatachunkperbatch,omitempty"` NbParityShardsPerBatch int `json:"nbparitychunkperbatch,omitempty"` PaddingSize int `json:"paddingsize,omitempty"` BucketNames []string `json:"bucketnames,omitempty"` }
ChunkGroup ...
func DecryptChunkGroup ¶
func DecryptChunkGroup(encrypted []byte, ki *KeyInfo) (*ChunkGroup, error)
DecryptChunkGroup use the keyInfo to decrypt the encryptedChunkGroup, then deserialize it from json, return a chunkGroup
func NewChunkGroup ¶
func NewChunkGroup(fileName string, fileSize int64, bucketNames []string) (*ChunkGroup, error)
NewChunkGroup return a chunk group initialized with a new random aesPassword, buckets, and file infos
func (*ChunkGroup) ComputeShardCheckSum ¶
ComputeShardCheckSum compute the check sum of a given shard, with a reader of the shard datas, return the checksum
func (*ChunkGroup) Encrypt ¶
func (cg *ChunkGroup) Encrypt() ([]byte, *KeyInfo, error)
Encrypt serialize the chunkGroup to JSON then generate a KeyInfo and use it to encrypt the chunkGroup, return the encrypted chunkGroup and the keyInfo
func (*ChunkGroup) GenerateNonce ¶
func (cg *ChunkGroup) GenerateNonce(shardNum int, nonceSize int) ([]byte, error)
GenerateNonce generate a nonce for a given shard, return the nonce
func (*ChunkGroup) GetBatchSizeInfo ¶
func (cg *ChunkGroup) GetBatchSizeInfo() (int, int, int)
GetBatchSizeInfo return the chunkSize, the number of data shards and parity shards per batch
func (*ChunkGroup) GetBucketNames ¶
func (cg *ChunkGroup) GetBucketNames() []string
GetBucketNames return the list of bucket names
func (*ChunkGroup) GetCheckSum ¶
func (cg *ChunkGroup) GetCheckSum(shardNum int) string
GetCheckSum return the checkSum of a given shard
func (*ChunkGroup) GetEncryptedChunkSize ¶
func (cg *ChunkGroup) GetEncryptedChunkSize() int
GetEncryptedChunkSize return the size of an encrypted chunk
func (*ChunkGroup) GetFileInfos ¶
func (cg *ChunkGroup) GetFileInfos() (string, string, int64)
GetFileInfos return the file name, upload date and size
func (*ChunkGroup) GetGCM ¶
func (cg *ChunkGroup) GetGCM() (cipher.AEAD, error)
GetGCM return a gcm initialized with the cg.AesPassword
func (*ChunkGroup) GetNbBatchs ¶
func (cg *ChunkGroup) GetNbBatchs() int
GetNbBatchs return the number of batchs neededs to process all the shards according to the number of shards per batch
func (*ChunkGroup) GetNbShards ¶
func (cg *ChunkGroup) GetNbShards() (int, int)
GetNbShards return the number of data shards and parity shards
func (*ChunkGroup) GetNonce ¶
func (cg *ChunkGroup) GetNonce(shardNum int) []byte
GetNonce return the nonce of a given shard
func (*ChunkGroup) GetPaddingSize ¶
func (cg *ChunkGroup) GetPaddingSize() int
GetPaddingSize return the padding size of the last data shard
func (*ChunkGroup) GetShardNum ¶
func (cg *ChunkGroup) GetShardNum(batchNum int, iterationNum int) int
GetShardNum return the number of the shard in the shard arrays according to the number of the batch and the position of the shard in the batch
func (*ChunkGroup) GetStorageInfo ¶
func (cg *ChunkGroup) GetStorageInfo(shardNum int) (string, string)
GetStorageInfo return the storageInfos of a given shard (fileName, bucketName)
func (*ChunkGroup) InitShards ¶
func (cg *ChunkGroup) InitShards(chunkSize int, maxBatchSize int, ratioNumerator int, ratioDenominator int, bucketGenerator *BucketGenerator) (dataShards int, parityShards int, err error)
InitShards initialize the shard array and return the number of data shards and parity shards
func (*ChunkGroup) IsReconstructible ¶
func (cg *ChunkGroup) IsReconstructible(missingBuckets []string) bool
IsReconstructible return true if the file can be reconstructed even with the given buckets unavailable, false otherwise
func (*ChunkGroup) ToString ¶
func (cg *ChunkGroup) ToString() string
ToString return a string representation on a chunckGroup ready to be displayed
type KeyInfo ¶
type KeyInfo struct { AesPassword string `json:"aespassword,omitempty"` Nonce []byte `json:"nonce,omitempty"` }
KeyInfo ...
func DecryptKeyInfo ¶
DecryptKeyInfo use the private RSA Key to decrypt the encryptedKeyInfo, then deserialize it from json, return a KeyInfo
func NewKeyInfo ¶
NewKeyInfo retrurn a keyInfo struct with a random AES password generated
func (*KeyInfo) Encrypt ¶
Encrypt serialize iKeyInfot to JSON, then use the private RSA Key to encrypt it, return an encrypted KeyInfo
type Shard ¶
type Shard struct { //The name the shard have in the object storage Name string `json:"name,omitempty"` //The name of the bucket where the shard is stored BucketName string `json:"bucketName,omitempty"` //The shard checkSum (after encryption) CheckSum string `json:"checkSum,omitempty"` //The Nonce used to encrypt the shard Nonce []byte `json:"nonce,omitempty"` }
Shard ...
func NewShard ¶
func NewShard(bucket objectstorage.Bucket) (*Shard, error)
NewShard return a new Shard
func (*Shard) GenerateNonce ¶
GenerateNonce generate, set and return a nonce of the required size
func (*Shard) GetStorageInfo ¶
GetStorageInfo return the name and bucket name of the shard
func (*Shard) SetCheckSum ¶
SetCheckSum will hash the file in the reader and store the result as a string