From dc40b0141b17716d53e0bcf525442286788c4a3e Mon Sep 17 00:00:00 2001 From: Xing Yang Date: Thu, 7 Feb 2019 10:22:11 -0500 Subject: [PATCH] Revert "Update OpenSDS dependency to v0.5.0" --- Gopkg.lock | 7 +- Gopkg.toml | 2 +- .../github.com/opensds/opensds/client/auth.go | 17 +--- .../opensds/opensds/client/client.go | 21 +---- .../github.com/opensds/opensds/client/fake.go | 7 +- .../opensds/opensds/client/receiver.go | 41 +-------- .../contrib/connector/fc/fibreChannel.go | 3 +- .../opensds/pkg/db/drivers/etcd/etcd.go | 30 +++---- .../opensds/opensds/pkg/model/volume.go | 6 +- .../opensds/pkg/utils/constants/constants.go | 6 -- .../opensds/opensds/pkg/utils/logs/logs.go | 2 +- .../opensds/opensds/pkg/utils/pwd/aes.go | 84 ------------------- .../opensds/opensds/pkg/utils/pwd/pwd.go | 29 ------- 13 files changed, 40 insertions(+), 215 deletions(-) delete mode 100644 vendor/github.com/opensds/opensds/pkg/utils/pwd/aes.go delete mode 100644 vendor/github.com/opensds/opensds/pkg/utils/pwd/pwd.go diff --git a/Gopkg.lock b/Gopkg.lock index 7726245aa..955b64963 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -276,7 +276,7 @@ version = "1.0.1" [[projects]] - digest = "1:034ec214e5110c413112b180a05090545a35392ad4a79cd5f61a011632872186" + digest = "1:7483830cd7cdd811f26cc081942c96a959bb28e3653a1dd1ccb7b82fc1b65dbe" name = "github.com/opensds/opensds" packages = [ "client", @@ -292,13 +292,12 @@ "pkg/utils", "pkg/utils/constants", "pkg/utils/logs", - "pkg/utils/pwd", "pkg/utils/urls", "testutils/collection", ] pruneopts = "UT" - revision = "76481a4c6f9b17d8055606ad60b4170cd0962c91" - version = "v0.5.0" + revision = "f52f384985b60a49697be2d628f12ed45baf24a6" + version = "v0.4.0" [[projects]] digest = "1:e5d0bd87abc2781d14e274807a470acd180f0499f8bf5bb18606e9ec22ad9de9" diff --git a/Gopkg.toml b/Gopkg.toml index ef8b6c9d9..c017d916a 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -43,7 +43,7 @@ [[constraint]] name = "github.com/opensds/opensds" - version = "0.5.0" + version = "0.4.0" [[constraint]] name = "github.com/pmorie/go-open-service-broker-client" diff --git a/vendor/github.com/opensds/opensds/client/auth.go b/vendor/github.com/opensds/opensds/client/auth.go index 50b85904e..fedd10682 100644 --- a/vendor/github.com/opensds/opensds/client/auth.go +++ b/vendor/github.com/opensds/opensds/client/auth.go @@ -18,7 +18,6 @@ import ( "os" "github.com/opensds/opensds/pkg/utils/constants" - "github.com/opensds/opensds/pkg/utils/pwd" ) const ( @@ -33,9 +32,9 @@ const ( OsTenantName = "OS_TENANT_NAME" OsProjectName = "OS_PROJECT_NAME" OsUserDomainId = "OS_USER_DOMAIN_ID" - OsPasswordTool = "OS_PASSWORD_DECRYPT_TOOL" - Keystone = "keystone" - Noauth = "noauth" + + Keystone = "keystone" + Noauth = "noauth" ) type AuthOptions interface { @@ -79,21 +78,13 @@ func LoadKeystoneAuthOptionsFromEnv() *KeystoneAuthOptions { opt := NewKeystoneAuthOptions() opt.IdentityEndpoint = os.Getenv(OsAuthUrl) opt.Username = os.Getenv(OsUsername) - // Decrypte the password - // Get the cipher text of the password - pwdCiphertext := os.Getenv(OsPassword) - // Instantiate an encryption tool - pwdTool := pwd.NewPwdTool(os.Getenv(OsPasswordTool)) - // Decrypt the password and obtain the password. - opt.Password, _ = pwdTool.Decrypter(pwdCiphertext) - + opt.Password = os.Getenv(OsPassword) opt.TenantName = os.Getenv(OsTenantName) projectName := os.Getenv(OsProjectName) opt.DomainID = os.Getenv(OsUserDomainId) if opt.TenantName == "" { opt.TenantName = projectName } - return opt } diff --git a/vendor/github.com/opensds/opensds/client/client.go b/vendor/github.com/opensds/opensds/client/client.go index f750b9749..5eb495929 100755 --- a/vendor/github.com/opensds/opensds/client/client.go +++ b/vendor/github.com/opensds/opensds/client/client.go @@ -16,8 +16,7 @@ package client import ( "errors" - "fmt" - "net/url" + "log" "strings" "github.com/opensds/opensds/pkg/utils/constants" @@ -27,10 +26,6 @@ const ( OpensdsEndpoint = "OPENSDS_ENDPOINT" ) -var ( - cacert string -) - // Client is a struct for exposing some operations of opensds resources. type Client struct { *ProfileMgr @@ -46,7 +41,6 @@ type Client struct { // Config is a struct that defines some options for calling the Client. type Config struct { Endpoint string - CACert string AuthOptions AuthOptions } @@ -55,16 +49,7 @@ func NewClient(c *Config) *Client { // If endpoint field not specified,use the default value localhost. if c.Endpoint == "" { c.Endpoint = constants.DefaultOpensdsEndpoint - fmt.Printf("Warnning: OpenSDS Endpoint is not specified using the default value(%s)\n", c.Endpoint) - } - - u, _ := url.Parse(c.Endpoint) - if u.Scheme == "https" { - if c.CACert == "" { - fmt.Println("If https is enabled, CA cert file should be provided.") - return nil - } - cacert = c.CACert + log.Printf("Warnning: OpenSDS Endpoint is not specified using the default value(%s)", c.Endpoint) } var r Receiver @@ -74,7 +59,7 @@ func NewClient(c *Config) *Client { case *KeystoneAuthOptions: r = NewKeystoneReciver(c.AuthOptions.(*KeystoneAuthOptions)) default: - fmt.Println("Warning: Not support auth options, use default.") + log.Printf("Warnning: Not support auth options, use default") r = NewReceiver() c.AuthOptions = NewNoauthOptions(constants.DefaultTenantId) } diff --git a/vendor/github.com/opensds/opensds/client/fake.go b/vendor/github.com/opensds/opensds/client/fake.go index eb6390a73..9e4dd483a 100644 --- a/vendor/github.com/opensds/opensds/client/fake.go +++ b/vendor/github.com/opensds/opensds/client/fake.go @@ -312,8 +312,9 @@ func (*fakeReplicationReceiver) Recv( case "POST": if out != nil { return json.Unmarshal([]byte(ByteReplication), out) + } else { + return nil } - return nil case "PUT": return json.Unmarshal([]byte(ByteReplication), out) case "GET": @@ -327,8 +328,10 @@ func (*fakeReplicationReceiver) Recv( } case "DELETE": return nil + default: + return errors.New("inputed method format not supported") } - return errors.New("input method format not supported") + return nil } func NewFakeVersionReceiver() Receiver { diff --git a/vendor/github.com/opensds/opensds/client/receiver.go b/vendor/github.com/opensds/opensds/client/receiver.go index c7693e299..2829a9358 100755 --- a/vendor/github.com/opensds/opensds/client/receiver.go +++ b/vendor/github.com/opensds/opensds/client/receiver.go @@ -15,14 +15,11 @@ package client import ( - "crypto/tls" - "crypto/x509" "encoding/json" "fmt" "io/ioutil" "log" "net/http" - "net/url" "strings" "time" @@ -70,44 +67,12 @@ func NewReceiver() Receiver { return &receiver{} } -func customVerify(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error { - roots := x509.NewCertPool() - caStr, err := ioutil.ReadFile(constants.OpensdsCaCertFile) - if err != nil { - msg := fmt.Sprintf("Read certfile failed,error:%v ", err) - log.Println(msg) - return err - } - - roots.AppendCertsFromPEM(caStr) - - for _, rawCert := range rawCerts { - cert, _ := x509.ParseCertificate(rawCert) - opts := x509.VerifyOptions{ - Roots: roots, - } - _, err := cert.Verify(opts) - if err != nil { - return err - } - } - - return nil -} - -func request(urlStr string, method string, headers HeaderOption, input interface{}, output interface{}) error { - req := httplib.NewBeegoRequest(urlStr, strings.ToUpper(method)) - - u, _ := url.Parse(urlStr) - if u.Scheme == "https" && cacert != "" { - log.Println("Https mode.") - req.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true, VerifyPeerCertificate: customVerify}) - } - +func request(url string, method string, headers HeaderOption, input interface{}, output interface{}) error { + req := httplib.NewBeegoRequest(url, strings.ToUpper(method)) // Set the request timeout a little bit longer upload snapshot to cloud temporarily. req.SetTimeout(time.Minute*6, time.Minute*6) // init body - log.Printf("%s %s\n", strings.ToUpper(method), urlStr) + log.Printf("%s %s\n", strings.ToUpper(method), url) if input != nil { body, err := json.MarshalIndent(input, "", " ") if err != nil { diff --git a/vendor/github.com/opensds/opensds/contrib/connector/fc/fibreChannel.go b/vendor/github.com/opensds/opensds/contrib/connector/fc/fibreChannel.go index 6bcdf565e..ecc0c272b 100644 --- a/vendor/github.com/opensds/opensds/contrib/connector/fc/fibreChannel.go +++ b/vendor/github.com/opensds/opensds/contrib/connector/fc/fibreChannel.go @@ -89,8 +89,9 @@ func (f *fibreChannel) volPathDiscovery(volPaths []string, tries int, tgtWWN []s if f.helper.pathExists(path) { deviceName := f.helper.getContentfromSymboliclink(path) return path, deviceName + } else { + f.helper.rescanHosts(tgtWWN, hbas) } - f.helper.rescanHosts(tgtWWN, hbas) } time.Sleep(2 * time.Second) diff --git a/vendor/github.com/opensds/opensds/pkg/db/drivers/etcd/etcd.go b/vendor/github.com/opensds/opensds/pkg/db/drivers/etcd/etcd.go index f228278e7..3143ce06a 100755 --- a/vendor/github.com/opensds/opensds/pkg/db/drivers/etcd/etcd.go +++ b/vendor/github.com/opensds/opensds/pkg/db/drivers/etcd/etcd.go @@ -284,7 +284,7 @@ func (c *Client) ListDocks(ctx *c.Context) ([]*model.DockSpec, error) { return dcks, nil } -var dockSortKey string +var dock_sortKey string type DockSlice []*model.DockSpec @@ -293,7 +293,7 @@ func (dock DockSlice) Len() int { return len(dock) } func (dock DockSlice) Swap(i, j int) { dock[i], dock[j] = dock[j], dock[i] } func (dock DockSlice) Less(i, j int) bool { - switch dockSortKey { + switch dock_sortKey { case "ID": return dock[i].Id < dock[j].Id @@ -362,7 +362,7 @@ func (c *Client) SelectDocks(m map[string][]string, docks []*model.DockSpec) []* } func (c *Client) SortDocks(dcks []*model.DockSpec, p *Parameter) []*model.DockSpec { - dockSortKey = p.sortKey + dock_sortKey = p.sortKey if strings.EqualFold(p.sortDir, "asc") { sort.Sort(DockSlice(dcks)) } else { @@ -455,7 +455,7 @@ func (c *Client) CreatePool(ctx *c.Context, pol *model.StoragePoolSpec) (*model. return pol, nil } -var poolSortKey string +var pool_sortKey string type StoragePoolSlice []*model.StoragePoolSpec @@ -464,7 +464,7 @@ func (pool StoragePoolSlice) Len() int { return len(pool) } func (pool StoragePoolSlice) Swap(i, j int) { pool[i], pool[j] = pool[j], pool[i] } func (pool StoragePoolSlice) Less(i, j int) bool { - switch poolSortKey { + switch pool_sortKey { case "ID": return pool[i].Id < pool[j].Id @@ -538,7 +538,7 @@ func (c *Client) SelectPools(m map[string][]string, pools []*model.StoragePoolSp func (c *Client) SortPools(pools []*model.StoragePoolSpec, p *Parameter) []*model.StoragePoolSpec { - poolSortKey = p.sortKey + pool_sortKey = p.sortKey if strings.EqualFold(p.sortDir, "asc") { sort.Sort(StoragePoolSlice(pools)) @@ -765,7 +765,7 @@ func (c *Client) ListProfiles(ctx *c.Context) ([]*model.ProfileSpec, error) { return prfs, nil } -var profileSortKey string +var profile_sortKey string type ProfileSlice []*model.ProfileSpec @@ -774,7 +774,7 @@ func (profile ProfileSlice) Len() int { return len(profile) } func (profile ProfileSlice) Swap(i, j int) { profile[i], profile[j] = profile[j], profile[i] } func (profile ProfileSlice) Less(i, j int) bool { - switch profileSortKey { + switch profile_sortKey { case "ID": return profile[i].Id < profile[j].Id @@ -805,7 +805,7 @@ func (c *Client) FindProfileValue(k string, p *model.ProfileSpec) string { } func (c *Client) SortProfiles(profiles []*model.ProfileSpec, p *Parameter) []*model.ProfileSpec { - profileSortKey = p.sortKey + profile_sortKey = p.sortKey if strings.EqualFold(p.sortDir, "asc") { sort.Sort(ProfileSlice(profiles)) @@ -1378,7 +1378,7 @@ func (c *Client) ListVolumeAttachments(ctx *c.Context, volumeId string) ([]*mode } -var volumeAttachmentSortKey string +var volumeAttachment_sortKey string type VolumeAttachmentSlice []*model.VolumeAttachmentSpec @@ -1390,7 +1390,7 @@ func (volumeAttachment VolumeAttachmentSlice) Swap(i, j int) { } func (volumeAttachment VolumeAttachmentSlice) Less(i, j int) bool { - switch volumeAttachmentSortKey { + switch volumeAttachment_sortKey { case "ID": return volumeAttachment[i].Id < volumeAttachment[j].Id case "VOLUMEID": @@ -1455,7 +1455,7 @@ func (c *Client) SelectVolumeAttachments(m map[string][]string, attachments []*m } func (c *Client) SortVolumeAttachments(attachments []*model.VolumeAttachmentSpec, p *Parameter) []*model.VolumeAttachmentSpec { - volumeAttachmentSortKey = p.sortKey + volumeAttachment_sortKey = p.sortKey if strings.EqualFold(p.sortDir, "asc") { sort.Sort(VolumeAttachmentSlice(attachments)) @@ -1663,7 +1663,7 @@ func (c *Client) ListVolumeSnapshots(ctx *c.Context) ([]*model.VolumeSnapshotSpe return vss, nil } -var volumeSnapshotSortKey string +var volumeSnapshot_sortKey string type VolumeSnapshotSlice []*model.VolumeSnapshotSpec @@ -1675,7 +1675,7 @@ func (volumeSnapshot VolumeSnapshotSlice) Swap(i, j int) { } func (volumeSnapshot VolumeSnapshotSlice) Less(i, j int) bool { - switch volumeSnapshotSortKey { + switch volumeSnapshot_sortKey { case "ID": return volumeSnapshot[i].Id < volumeSnapshot[j].Id case "VOLUMEID": @@ -1747,7 +1747,7 @@ func (c *Client) SelectSnapshots(m map[string][]string, snapshots []*model.Volum } func (c *Client) SortSnapshots(snapshots []*model.VolumeSnapshotSpec, p *Parameter) []*model.VolumeSnapshotSpec { - volumeSnapshotSortKey = p.sortKey + volumeSnapshot_sortKey = p.sortKey if strings.EqualFold(p.sortDir, "asc") { sort.Sort(VolumeSnapshotSlice(snapshots)) diff --git a/vendor/github.com/opensds/opensds/pkg/model/volume.go b/vendor/github.com/opensds/opensds/pkg/model/volume.go index f87c34314..ee9c48890 100755 --- a/vendor/github.com/opensds/opensds/pkg/model/volume.go +++ b/vendor/github.com/opensds/opensds/pkg/model/volume.go @@ -69,10 +69,10 @@ type VolumeSpec struct { Metadata map[string]string `json:"metadata,omitempty"` // The uuid of the snapshot which the volume is created - SnapshotId string `json:"snapshotId,omitempty"` + SnapshotId string `json:"snapshotId, omitempty"` // Download Snapshot From Cloud - SnapshotFromCloud bool `json:"snapshotFromCloud,omitempty"` + SnapshotFromCloud bool `json:"snapshotFromCloud, omitempty"` // The uuid of the replication which the volume belongs to. ReplicationId string `json:"replicationId,omitempty"` @@ -115,7 +115,7 @@ type VolumeAttachmentSpec struct { // See details in `ConnectionInfo` ConnectionInfo `json:"connectionInfo,omitempty"` - // The protocol + // The protocl AccessProtocol string `json:"accessProtocol,omitempty"` } diff --git a/vendor/github.com/opensds/opensds/pkg/utils/constants/constants.go b/vendor/github.com/opensds/opensds/pkg/utils/constants/constants.go index 8e5e3850a..dc398947a 100644 --- a/vendor/github.com/opensds/opensds/pkg/utils/constants/constants.go +++ b/vendor/github.com/opensds/opensds/pkg/utils/constants/constants.go @@ -30,10 +30,4 @@ const ( // OpenSDS current api version APIVersion = "v1beta" - - // BeegoServerTimeOut ... - BeegoServerTimeOut = 60 - - // OpensdsCaCertFile ... - OpensdsCaCertFile = "/opt/opensds-security/ca/ca-cert.pem" ) diff --git a/vendor/github.com/opensds/opensds/pkg/utils/logs/logs.go b/vendor/github.com/opensds/opensds/pkg/utils/logs/logs.go index ec97ac044..25e6c384b 100755 --- a/vendor/github.com/opensds/opensds/pkg/utils/logs/logs.go +++ b/vendor/github.com/opensds/opensds/pkg/utils/logs/logs.go @@ -31,7 +31,7 @@ const DefaultLogDir = "/var/log/opensds" // flushDaemon periodically flushes the log file buffers. func flushDaemon(period time.Duration) { - for range time.NewTicker(period).C { + for _ = range time.NewTicker(period).C { glog.Flush() } } diff --git a/vendor/github.com/opensds/opensds/pkg/utils/pwd/aes.go b/vendor/github.com/opensds/opensds/pkg/utils/pwd/aes.go deleted file mode 100644 index e5ef47c54..000000000 --- a/vendor/github.com/opensds/opensds/pkg/utils/pwd/aes.go +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) 2019 Huawei Technologies Co., Ltd. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package pwd - -import ( - "crypto/aes" - "crypto/cipher" - "crypto/rand" - "encoding/hex" - "errors" - "io" -) - -type AES struct{} - -var ( - key = []byte("8RcY34!7dce3,cdcaeb*faeC3cd9fQfe") -) - -func (*AES) Encrypter(password string) (string, error) { - if len(key) != 32 { - return "", errors.New("The length of the key must be 32.") - } - - plaintext := []byte(password) - - block, err := aes.NewCipher(key) - if err != nil { - return "", err - } - - // The IV needs to be unique, but not secure. Therefore it's common to - // include it at the beginning of the ciphertext. - ciphertext := make([]byte, aes.BlockSize+len(plaintext)) - iv := ciphertext[:aes.BlockSize] - if _, err := io.ReadFull(rand.Reader, iv); err != nil { - return "", err - } - - stream := cipher.NewCFBEncrypter(block, iv) - stream.XORKeyStream(ciphertext[aes.BlockSize:], plaintext) - - return hex.EncodeToString(ciphertext), nil -} - -func (*AES) Decrypter(code string) (string, error) { - ciphertext, err := hex.DecodeString(code) - if err != nil { - return "", err - } - - block, err := aes.NewCipher(key) - if err != nil { - return "", err - } - - // The IV needs to be unique, but not secure. Therefore it's common to - // include it at the beginning of the ciphertext. - if len(ciphertext) < aes.BlockSize { - return "", errors.New("Ciphertext too short") - } - - iv := ciphertext[:aes.BlockSize] - ciphertext = ciphertext[aes.BlockSize:] - - stream := cipher.NewCFBDecrypter(block, iv) - - // XORKeyStream can work in-place if the two arguments are the same. - stream.XORKeyStream(ciphertext, ciphertext) - - return string(ciphertext), nil -} diff --git a/vendor/github.com/opensds/opensds/pkg/utils/pwd/pwd.go b/vendor/github.com/opensds/opensds/pkg/utils/pwd/pwd.go deleted file mode 100644 index 4b1a5e866..000000000 --- a/vendor/github.com/opensds/opensds/pkg/utils/pwd/pwd.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2019 Huawei Technologies Co., Ltd. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package pwd - -type PwdTool interface { - Encrypter(password string) (string, error) - Decrypter(code string) (string, error) -} - -func NewPwdTool(tool string) PwdTool { - switch tool { - case "aes": - return &AES{} - default: - return &AES{} - } -}