in src/terraform/providers/terraform-provider-avere/averevfxt.go [1061:1135]
func (a *AvereVfxt) UploadFlatFiles() error {
if !a.IsUsingFlatFiles() {
return nil
}
log.Printf("[INFO] [uploading flat files")
defer log.Printf("[INFO] uploading flat files]")
// cleanup any existing flat files, this avoids failed copy or generation because of incorrect permissions
if _, err := a.ShellCommand(a.getCleanFlatFileCommand()); err != nil {
return fmt.Errorf("Error cleaning up flat files: %v", err)
}
if a.CifsRidMappingBaseInteger > 0 {
log.Printf("[INFO] step 1 - upload rid generator")
ridGeneratorFileB64z, err := GetRidGeneratorB64z()
if err != nil {
return fmt.Errorf("Error create rid generator b64z file: %s", ridGeneratorFileB64z)
}
if _, err := a.ShellCommand(a.getPutRidGeneratorCommand(ridGeneratorFileB64z)); err != nil {
return fmt.Errorf("Error uploading rid generator file: %v", err)
}
log.Printf("[INFO] step 2 - copy rid generator to Avere and execute")
scpCmd := a.getRidGeneratorScpCommand()
if _, err := a.ShellCommand(scpCmd); err != nil {
return fmt.Errorf("Error running scp command for rid generator: %v", err)
}
log.Printf("[INFO] step 2.1 - Execute rid generator")
ridGeneratorCmd := a.getExecuteRidGeneratorCommand()
if _, err := a.ShellCommand(ridGeneratorCmd); err != nil {
return fmt.Errorf("Error running rid generator execution: %v", err)
}
} else {
log.Printf("[INFO] step 1 - put flat files on controller")
if _, err := a.ShellCommand(a.getPutPasswdFileCommand()); err != nil {
return fmt.Errorf("Error uploading passwd file: %v", err)
}
if _, err := a.ShellCommand(a.getPutGroupFileCommand()); err != nil {
return fmt.Errorf("Error uploading group file: %v", err)
}
log.Printf("[INFO] step 2 - copy to Avere webserver")
scpCmd := a.getFlatFileScpCommand()
if _, err := a.ShellCommand(scpCmd); err != nil {
return fmt.Errorf("Error running scp command: %v", err)
}
}
mountWritableCmd := a.getMakeVFXTWritableCommand()
if _, err := a.ShellCommand(mountWritableCmd); err != nil {
return fmt.Errorf("Error running mount writable command: %v", err)
}
mountReadonlyCmd := a.getMakeVFXTReadonlyCommand()
// always mount readable
defer func() {
if _, err := a.ShellCommand(mountReadonlyCmd); err != nil {
log.Printf("[ERROR] Error running mount readable command: %v", err)
}
}()
copyUserCmd := a.getCopyPasswdFileCommand()
if _, err := a.ShellCommand(copyUserCmd); err != nil {
return fmt.Errorf("Error running copy group command: %v", err)
}
copyGroupCmd := a.getCopyGroupFileCommand()
if _, err := a.ShellCommand(copyGroupCmd); err != nil {
return fmt.Errorf("Error running copy group command: %v", err)
}
log.Printf("[INFO] step 3 - cleanup")
// done in the defer command
return nil
}