forked from rook/rook
enable file and object store smoke test and fix naming conventions
This commit is contained in:
@@ -251,3 +251,47 @@ func (k8sh *K8sHelper) IsThirdPartyResourcePresent(tprname string) bool {
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (k8sh *K8sHelper) GetPodDetails(podNamePattern string, namespace string) (string, error) {
|
||||
cmdArgs := []string{"get", "pods", "-l", "app=" + podNamePattern, "-o", "wide", "--no-headers=true"}
|
||||
if namespace != "" {
|
||||
cmdArgs = append(cmdArgs, []string{"-n", namespace}...)
|
||||
}
|
||||
sout, serr, status := ExecuteCmd("kubectl", cmdArgs)
|
||||
if status != 0 || strings.Contains(sout, "No resources found") {
|
||||
return serr, fmt.Errorf("Cannot find pod in with name like %s in namespace : %s", podNamePattern, namespace)
|
||||
}
|
||||
return sout, nil
|
||||
}
|
||||
|
||||
func (k8sh *K8sHelper) GetPodHostId(podNamePattern string, namespace string) (string, error) {
|
||||
data, err := k8sh.GetPodDetails(podNamePattern, namespace)
|
||||
if err != nil {
|
||||
return data, err
|
||||
}
|
||||
|
||||
// Handle case when no data is returned
|
||||
lines := strings.Split(data, "\n")
|
||||
|
||||
//extract name of the pod
|
||||
lineRawdata := strings.Split(lines[0], " ")
|
||||
var r []string
|
||||
for _, str := range lineRawdata {
|
||||
if str != "" {
|
||||
r = append(r, strings.TrimSpace(str))
|
||||
}
|
||||
}
|
||||
|
||||
//get host Ip of the pod
|
||||
cmdArgs := []string{"get", "pods", r[0], "-o", "jsonpath='{.status.hostIP}'"}
|
||||
if namespace != "" {
|
||||
cmdArgs = append(cmdArgs, []string{"-n", namespace}...)
|
||||
}
|
||||
sout, serr, status := ExecuteCmd("kubectl", cmdArgs)
|
||||
if status == 0 {
|
||||
hostIp := strings.Replace(sout, "'", "", -1)
|
||||
return strings.TrimSpace(hostIp), nil
|
||||
} else {
|
||||
return serr, fmt.Errorf("Error Getting Monitor IP")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
@@ -221,26 +220,3 @@ func (rh *RookHelper) ParserObjectBucketListData(rawdata string) map[string]Obje
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func (rh *RookHelper) GetRgwServiceNodePort(rawdata string) (string, error) {
|
||||
lines := strings.Split(rawdata, "\n")
|
||||
if len(lines) <= 1 {
|
||||
return "NOT FOUND", fmt.Errorf("Port not found")
|
||||
}
|
||||
lines = lines[1 : len(lines)-1]
|
||||
if len(lines) == 1 {
|
||||
bktsrawdata := strings.Split(lines[0], " ")
|
||||
var r []string
|
||||
for _, str := range bktsrawdata {
|
||||
if str != "" {
|
||||
r = append(r, strings.TrimSpace(str))
|
||||
}
|
||||
}
|
||||
ports := strings.Split(r[3], ":")
|
||||
port := strings.Replace(ports[1], "/TCP", "", -1)
|
||||
return port, nil
|
||||
|
||||
} else {
|
||||
return "NOT FOUND", fmt.Errorf("Port not found")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,29 +2,38 @@ package utils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/aws/aws-sdk-go/service/s3"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type S3Helper struct {
|
||||
s3client *s3.S3
|
||||
}
|
||||
|
||||
// create a s3 client for specfied endpoint and creds
|
||||
func CreateNewS3Helper(endpoint string, keyId string, keySecret string) *S3Helper {
|
||||
|
||||
creds := credentials.NewStaticCredentials(keyId, keySecret, "")
|
||||
_, err := creds.Get()
|
||||
if err != nil {
|
||||
fmt.Printf("bad credentials: %s", err)
|
||||
}
|
||||
cfg := aws.NewConfig().WithEndpoint(endpoint).WithRegion("us-west-1").WithCredentials(creds).WithDisableSSL(true)
|
||||
|
||||
svc := s3.New(session.New(), cfg)
|
||||
// create aws s3 config, must use 'other-v2-signature' region for ceph object store
|
||||
awsConfig := aws.NewConfig().
|
||||
WithRegion("other-v2-signature").
|
||||
WithCredentials(creds).
|
||||
WithEndpoint(endpoint).
|
||||
WithS3ForcePathStyle(true).
|
||||
WithDisableSSL(true)
|
||||
|
||||
return &S3Helper{svc}
|
||||
//create new session
|
||||
ses := session.New()
|
||||
|
||||
//create new s3 client connection
|
||||
c := s3.New(ses, awsConfig)
|
||||
|
||||
return &S3Helper{c}
|
||||
}
|
||||
|
||||
func (h *S3Helper) CreateBucket(name string) (bool, error) {
|
||||
|
||||
Reference in New Issue
Block a user