From 654b1b4f1d943426e70acf525020433f3c8506af Mon Sep 17 00:00:00 2001 From: olgashtivelman <33713489+olgashtivelman@users.noreply.github.com> Date: Thu, 13 Dec 2018 10:26:29 +0200 Subject: [PATCH 01/36] Modify volume size unit from gb to gib (#286) Currently, the pvc unit is gib in yaml file, but ubiquity sent to scb with unit gb. That caused the volume size is not correct. As confirmed with SCB developer, SCB support both unit gib and gb. I just modify the unit from gb to gib in this patch. --- local/scbe/scbe_rest_client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/local/scbe/scbe_rest_client.go b/local/scbe/scbe_rest_client.go index 492d0eab..93722a79 100644 --- a/local/scbe/scbe_rest_client.go +++ b/local/scbe/scbe_rest_client.go @@ -53,7 +53,7 @@ const ( UrlScbeResourceVolume = "volumes" UrlScbeResourceMapping = "mappings" UrlScbeResourceHost = "hosts" - DefaultSizeUnit = "gb" + DefaultSizeUnit = "gib" LunNumberNoMapping = -1 ) From f455cba3012eaccdede371c16198c4fb578fa540 Mon Sep 17 00:00:00 2001 From: Deepak Ghuge Date: Thu, 13 Dec 2018 13:57:18 +0530 Subject: [PATCH 02/36] UB-1757 Fix for error: concurrent map writes #285 Fix for "concurrent map writes" error causing Ubiquity restart --- database/migrate.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/database/migrate.go b/database/migrate.go index 6e62e78c..fccbcf08 100644 --- a/database/migrate.go +++ b/database/migrate.go @@ -18,33 +18,35 @@ package database import ( "fmt" + "sync" "github.com/IBM/ubiquity/utils/logs" ) -var migrations = make(map[string]interface{}) +var migrations = new(sync.Map) func RegisterMigration(obj interface{}) { defer logs.GetLogger().Trace(logs.DEBUG)() - - migrations[fmt.Sprintf("%v", obj)] = obj + migrations.Store(fmt.Sprintf("%v", obj), obj) } func UnregisterAllMigrations() { defer logs.GetLogger().Trace(logs.DEBUG)() - - migrations = make(map[string]interface{}) + migrations = new(sync.Map) } func doMigrations(connection Connection) error { defer logs.GetLogger().Trace(logs.DEBUG)() logger := logs.GetLogger() - for k, v := range migrations { + + migrations.Range(func(k, v interface{}) bool { logger.Info("migrating", logs.Args{{"migration", k}}) if err := connection.GetDb().AutoMigrate(v).Error; err != nil { logger.ErrorRet(err, "failed") } - delete(migrations, k) - } + migrations.Delete(k) + return true + }) + return nil } From 123decbffdb9577b69d3e36b0c7036d3896930ee Mon Sep 17 00:00:00 2001 From: Deepak Ghuge Date: Thu, 13 Dec 2018 13:57:45 +0530 Subject: [PATCH 03/36] UB-1760 : Added Tuning for max_connection (#284) Changing postgresql max_connection to 1000 from current default 100. --- scripts/ubiquity-postgresql/Dockerfile | 3 ++- .../docker-entrypoint-initdb.d/init-db-tuning.sh | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 scripts/ubiquity-postgresql/docker-entrypoint-initdb.d/init-db-tuning.sh diff --git a/scripts/ubiquity-postgresql/Dockerfile b/scripts/ubiquity-postgresql/Dockerfile index 45e156e6..43fa3ddc 100644 --- a/scripts/ubiquity-postgresql/Dockerfile +++ b/scripts/ubiquity-postgresql/Dockerfile @@ -3,7 +3,8 @@ FROM postgres:9.6 ENV UBIQUITY_DB_CERT_PRIVATE="/var/lib/postgresql/ssl/private/ubiquity-db.key" \ UBIQUITY_DB_CERT_PUBLIC="/var/lib/postgresql/ssl/private/ubiquity-db.crt" \ UBIQUITY_DB_PROVIDED_CERT_PRIVATE="/var/lib/postgresql/ssl/provided/ubiquity-db.key" \ - UBIQUITY_DB_PROVIDED_CERT_PUBLIC="/var/lib/postgresql/ssl/provided/ubiquity-db.crt" + UBIQUITY_DB_PROVIDED_CERT_PUBLIC="/var/lib/postgresql/ssl/provided/ubiquity-db.crt"\ + UBIQUITY_DB_MAX_CONNECTION="1000" RUN PGSSL_PRIVATE="`dirname $UBIQUITY_DB_CERT_PRIVATE`" && mkdir -p "$PGSSL_PRIVATE" && chown -R postgres:postgres "$PGSSL_PRIVATE" && chmod 777 "$PGSSL_PRIVATE" RUN PGSSL_PUBLIC="`dirname $UBIQUITY_DB_CERT_PUBLIC`" && mkdir -p "$PGSSL_PUBLIC" && chown -R postgres:postgres "$PGSSL_PUBLIC" && chmod 777 "$PGSSL_PUBLIC" diff --git a/scripts/ubiquity-postgresql/docker-entrypoint-initdb.d/init-db-tuning.sh b/scripts/ubiquity-postgresql/docker-entrypoint-initdb.d/init-db-tuning.sh new file mode 100644 index 00000000..4ab9ad17 --- /dev/null +++ b/scripts/ubiquity-postgresql/docker-entrypoint-initdb.d/init-db-tuning.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -e + +if [ ! -z "$UBIQUITY_DB_MAX_CONNECTION" ] +then + echo "Updating max_connection to $UBIQUITY_DB_MAX_CONNECTION" + sed -i "s/max_connections = 100/max_connections = ${UBIQUITY_DB_MAX_CONNECTION}/g" /var/lib/postgresql/data/postgresql.conf +fi From f422ef212a95a4579e69637967735be3bcf7dab5 Mon Sep 17 00:00:00 2001 From: Deepak Ghuge Date: Thu, 13 Dec 2018 13:58:19 +0530 Subject: [PATCH 04/36] UB-1761 - Changed order of defer function to avoid iterating and updating map at same time. (#282) Fixing error concurrent map iteration and map write error --- utils/locker.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/locker.go b/utils/locker.go index 25638331..02113db0 100644 --- a/utils/locker.go +++ b/utils/locker.go @@ -104,8 +104,8 @@ func (l *locker) updateStats(name string) { defer l.logger.Trace(logs.DEBUG, logs.Args{{"lockName", name}})() l.statsLock.Lock() - defer l.cleanup() defer l.statsLock.Unlock() + defer l.cleanup() if stat, exists := l.stats[name]; exists { stat = time.Now() l.stats[name] = stat From b0aefe10b7c074dd7eda25a6fafef6422ce5308f Mon Sep 17 00:00:00 2001 From: Lihi Zitzer Date: Wed, 26 Dec 2018 09:16:33 +0200 Subject: [PATCH 05/36] UB-211: add build script --- scripts/build_images.sh | 81 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100755 scripts/build_images.sh diff --git a/scripts/build_images.sh b/scripts/build_images.sh new file mode 100755 index 00000000..a53a0559 --- /dev/null +++ b/scripts/build_images.sh @@ -0,0 +1,81 @@ +set -x +export PATH=$PATH:/usr/local/go/bin:$WORKSPACE/work/bin + +pwd +ls +PWDO=`pwd` +export GOPATH=`pwd`/work +rm -rf work/src/github.com/IBM/ubiquity || : +mkdir -p work/src/github.com/IBM/ubiquity +mv * work/src/github.com/IBM/ubiquity || : +cd work/src/github.com/IBM/ubiquity +pwd +ls + + +echo "------- Docker image build and push - Start" + +branch=`echo $GIT_BRANCH| sed 's|/|.|g'` #not sure if docker accept / in the version +specific_tag="${IMAGE_VERSION}_b${BUILD_NUMBER}_${branch}" + +if [ "$GIT_BRANCH" = "dev" -o "$GIT_BRANCH" = "origin/dev" -o "$GIT_BRANCH" = "master" -o "$to_tag_latest_also_none_dev_branches" = "true" ]; then + tag_latest="true" + echo "will tag latest \ version in addition to the branch tag $GIT_BRANCH" +else + tag_latest="false" + echo "NO latest \ version tag for you $GIT_BRANCH" +fi + +echo "build ubiquity image" +echo "====================" +ubiquity_registry="${DOCKER_REGISTRY}/${UBIQUITY_IMAGE}" +ubiquity_tag_specific="${ubiquity_registry}:${specific_tag}" +ubiquity_tag_latest=${ubiquity_registry}:latest +ubiquity_tag_version=${ubiquity_registry}:${IMAGE_VERSION} +[ "$tag_latest" = "true" ] && taglatestflag="-t ${ubiquity_tag_latest} -t ${ubiquity_tag_version}" || taglatestflag="" +# Build and tags togather +docker build -t ${ubiquity_tag_specific} ${taglatestflag} -f Dockerfile . + +# push the tags +docker push ${ubiquity_tag_specific} +[ "$tag_latest" = "true" ] && docker push ${ubiquity_tag_latest} || : +[ "$tag_latest" = "true" ] && docker push ${ubiquity_tag_version} || : + +echo "build ubiquity-db image" +echo "=======================" +ubiquity_db_registry="${DOCKER_REGISTRY}/${UBIQUITY_DB_IMAGE}" +ubiquity_db_tag_specific="${ubiquity_db_registry}:${specific_tag}" +ubiquity_db_tag_latest=${ubiquity_db_registry}:latest +ubiquity_db_tag_version=${ubiquity_db_registry}:${IMAGE_VERSION} + +[ "$tag_latest" = "true" ] && taglatestflag="-t ${ubiquity_db_tag_latest} -t ${ubiquity_db_tag_version}" || taglatestflag="" +cp LICENSE ./scripts/ubiquity-postgresql +cd ./scripts/ubiquity-postgresql +# Build and tags togather +docker build -t ${ubiquity_db_tag_specific} ${taglatestflag} -f Dockerfile . + +# push the tags +docker push ${ubiquity_db_tag_specific} +[ "$tag_latest" = "true" ] && docker push ${ubiquity_db_tag_latest} || : +[ "$tag_latest" = "true" ] && docker push ${ubiquity_db_tag_version} || : + +cd - + +echo "------- Docker image build and push - Done" + + + +cd $PWDO + + +echo "=============================" +echo "ubiquity server IMAGE name : " +echo " specific tag : ${ubiquity_tag_specific}" +[ "$tag_latest" = "true" ] && echo " latest \ version tag : ${ubiquity_tag_latest} ${ubiquity_tag_version}" || echo "no latest tag" +echo "=============================" +echo "ubiquity-db IMAGE name : " +echo " specific tag : ${ubiquity_db_tag_specific}" +[ "$tag_latest" = "true" ] && echo " latest \ version tag : ${ubiquity_db_tag_latest} ${ubiquity_db_tag_version}" || echo "no latest tag" + +echo ${ubiquity_tag_specific} > ubiquity_tags +echo ${ubiquity_db_tag_specific} >> ubiquity_tags From 82aa37c695a9217f4e9836237f4e67ce5bab72db Mon Sep 17 00:00:00 2001 From: Lihi Zitzer Date: Wed, 26 Dec 2018 10:07:52 +0200 Subject: [PATCH 06/36] UB-211: move ci build script to ci folder --- scripts/{ => ci}/build_images.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/{ => ci}/build_images.sh (100%) diff --git a/scripts/build_images.sh b/scripts/ci/build_images.sh similarity index 100% rename from scripts/build_images.sh rename to scripts/ci/build_images.sh From bf9a572a09294818716306cad200c0f8cd252108 Mon Sep 17 00:00:00 2001 From: Ran Harel Date: Sun, 6 Jan 2019 17:11:00 +0200 Subject: [PATCH 07/36] UB-1802 - build script will exit on error --- scripts/ci/build_images.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/ci/build_images.sh b/scripts/ci/build_images.sh index a53a0559..628df8b4 100755 --- a/scripts/ci/build_images.sh +++ b/scripts/ci/build_images.sh @@ -1,4 +1,5 @@ set -x +set -e export PATH=$PATH:/usr/local/go/bin:$WORKSPACE/work/bin pwd From 5d52b33ace870567fa58097bcdc6f6035f44eded Mon Sep 17 00:00:00 2001 From: 27149chen <7991675+27149chen@users.noreply.github.com> Date: Sun, 10 Feb 2019 17:24:07 +0200 Subject: [PATCH 08/36] UB-1622 provisioner long time for start in the installation phase (#291) * set timeout && retry when activate failed Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> * update timeout interval to 30 Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> * increase activation timeout to 5 seconds Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> --- remote/client.go | 21 ++++++++++++++++++--- remote/client_init.go | 12 ++++++++---- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/remote/client.go b/remote/client.go index 88e80faf..6f81a776 100644 --- a/remote/client.go +++ b/remote/client.go @@ -21,11 +21,13 @@ package remote import ( + "net/http" + "reflect" + "time" + "github.com/IBM/ubiquity/resources" "github.com/IBM/ubiquity/utils" "github.com/IBM/ubiquity/utils/logs" - "net/http" - "reflect" ) type remoteClient struct { @@ -46,7 +48,20 @@ func (s *remoteClient) Activate(activateRequest resources.ActivateRequest) error // call remote activate activateURL := utils.FormatURL(s.storageApiURL, "activate") activateRequest.CredentialInfo = s.config.CredentialInfo - response, err := utils.HttpExecute(s.httpClient, "POST", activateURL, activateRequest, activateRequest.Context) + + clientWithShortTimeout := new(http.Client) + *clientWithShortTimeout = *s.httpClient + clientWithShortTimeout.Timeout = time.Second * 5 + + var err error + var response *http.Response + // retry 15 times in case the ubiquity server is not ready yet + for i := 15; i > 0; i-- { + response, err = utils.HttpExecute(clientWithShortTimeout, "POST", activateURL, activateRequest, activateRequest.Context) + if err == nil { + break + } + } if err != nil { return s.logger.ErrorRet(err, "utils.HttpExecute failed") } diff --git a/remote/client_init.go b/remote/client_init.go index a0a94bcd..e4991cb4 100644 --- a/remote/client_init.go +++ b/remote/client_init.go @@ -20,14 +20,16 @@ import ( "crypto/tls" "crypto/x509" "fmt" - "github.com/IBM/ubiquity/resources" - "github.com/IBM/ubiquity/utils" - "github.com/IBM/ubiquity/utils/logs" "io/ioutil" "log" "net/http" "os" "strings" + "time" + + "github.com/IBM/ubiquity/resources" + "github.com/IBM/ubiquity/utils" + "github.com/IBM/ubiquity/utils/logs" ) const KeyUseSsl = "UBIQUITY_PLUGIN_USE_SSL" @@ -66,7 +68,9 @@ func (s *remoteClient) initialize() error { protocol := s.getProtocol() s.storageApiURL = fmt.Sprintf(storageAPIURL, protocol, s.config.UbiquityServer.Address, s.config.UbiquityServer.Port) - s.httpClient = &http.Client{} + s.httpClient = &http.Client{ + Timeout: time.Second * 30, + } verifyFileCA := os.Getenv(KeyVerifyCA) sslMode := strings.ToLower(os.Getenv(resources.KeySslMode)) if sslMode == "" { From e84470e4694afd24f7d711fda4fcec0e0ab29c7a Mon Sep 17 00:00:00 2001 From: olgasht Date: Mon, 18 Feb 2019 10:17:06 +0200 Subject: [PATCH 09/36] UB-1857: chagne cluster id to be an integer instead of string --- local/scbe/resources.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/local/scbe/resources.go b/local/scbe/resources.go index 52e127c1..a132664b 100644 --- a/local/scbe/resources.go +++ b/local/scbe/resources.go @@ -226,7 +226,7 @@ type ScbeResponseHost struct { Array string `json:"array"` HostId string `json:"host_id"` Name string `json:"name"` - StorageCluster string `json:"storage_cluster"` + StorageCluster int `json:"storage_cluster"` PhysicalHost int `json:"physical_host"` } From 7da11d14ab81fadb2eb0eaa80834b750d46a8d93 Mon Sep 17 00:00:00 2001 From: 27149chen <7991675+27149chen@users.noreply.github.com> Date: Sat, 23 Feb 2019 21:57:00 +0800 Subject: [PATCH 10/36] UB-1835 new rescan and delete method Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> --- fakes/fake_ScbeDataModel.go | 223 ++- fakes/fake_SpectrumDataModel.go | 477 ++--- fakes/fake_block_device_mounter_utils.go | 344 ++-- fakes/fake_block_device_utils.go | 1106 ++++++----- fakes/fake_executor.go | 1609 ++++++++++------- fakes/fake_initiator.go | 184 ++ fakes/fake_mounter.go | 206 ++- fakes/fake_mounter_factory.go | 42 +- fakes/fake_scbe_rest_client.go | 607 ++++--- fakes/fake_simple_rest_client.go | 349 ++-- fakes/fake_spectrum.go | 1352 +++++++------- fakes/fake_storage_client.go | 544 +++--- local/scbe/datamodel_wrapper.go | 2 - local/scbe/scbe_rest_client.go | 2 +- local/scbe/simple_rest_client.go | 9 +- .../block_device_mounter_utils.go | 55 +- .../block_device_utils_mounter_test.go | 39 +- .../block_device_mounter_utils/resources.go | 7 +- .../block_device_utils/block_device_utils.go | 10 +- .../block_device_utils_test.go | 46 +- remote/mounter/block_device_utils/mpath.go | 20 +- remote/mounter/block_device_utils/rescan.go | 79 +- .../mounter/block_device_utils/resources.go | 10 +- .../initiator/connectors/fibre_channel.go | 115 ++ remote/mounter/initiator/linuxfc.go | 204 +++ remote/mounter/initiator/linuxscsi.go | 30 + remote/mounter/initiator/resources.go | 21 + remote/mounter/mounter_factory.go | 5 +- remote/mounter/scbe.go | 61 +- remote/mounter/scbe_test.go | 28 +- resources/resources.go | 5 + utils/error.go | 10 +- 32 files changed, 4598 insertions(+), 3203 deletions(-) create mode 100644 fakes/fake_initiator.go create mode 100644 remote/mounter/initiator/connectors/fibre_channel.go create mode 100644 remote/mounter/initiator/linuxfc.go create mode 100644 remote/mounter/initiator/linuxscsi.go create mode 100644 remote/mounter/initiator/resources.go diff --git a/fakes/fake_ScbeDataModel.go b/fakes/fake_ScbeDataModel.go index 8f695867..1a56bae8 100644 --- a/fakes/fake_ScbeDataModel.go +++ b/fakes/fake_ScbeDataModel.go @@ -8,10 +8,10 @@ import ( ) type FakeScbeDataModel struct { - DeleteVolumeStub func(name string) error + DeleteVolumeStub func(string) error deleteVolumeMutex sync.RWMutex deleteVolumeArgsForCall []struct { - name string + arg1 string } deleteVolumeReturns struct { result1 error @@ -19,23 +19,10 @@ type FakeScbeDataModel struct { deleteVolumeReturnsOnCall map[int]struct { result1 error } - InsertVolumeStub func(volumeName string, wwn string, fstype string) error - insertVolumeMutex sync.RWMutex - insertVolumeArgsForCall []struct { - volumeName string - wwn string - fstype string - } - insertVolumeReturns struct { - result1 error - } - insertVolumeReturnsOnCall map[int]struct { - result1 error - } - GetVolumeStub func(name string) (scbe.ScbeVolume, bool, error) + GetVolumeStub func(string) (scbe.ScbeVolume, bool, error) getVolumeMutex sync.RWMutex getVolumeArgsForCall []struct { - name string + arg1 string } getVolumeReturns struct { result1 scbe.ScbeVolume @@ -47,10 +34,24 @@ type FakeScbeDataModel struct { result2 bool result3 error } + InsertVolumeStub func(string, string, string) error + insertVolumeMutex sync.RWMutex + insertVolumeArgsForCall []struct { + arg1 string + arg2 string + arg3 string + } + insertVolumeReturns struct { + result1 error + } + insertVolumeReturnsOnCall map[int]struct { + result1 error + } ListVolumesStub func() ([]scbe.ScbeVolume, error) listVolumesMutex sync.RWMutex - listVolumesArgsForCall []struct{} - listVolumesReturns struct { + listVolumesArgsForCall []struct { + } + listVolumesReturns struct { result1 []scbe.ScbeVolume result2 error } @@ -62,21 +63,22 @@ type FakeScbeDataModel struct { invocationsMutex sync.RWMutex } -func (fake *FakeScbeDataModel) DeleteVolume(name string) error { +func (fake *FakeScbeDataModel) DeleteVolume(arg1 string) error { fake.deleteVolumeMutex.Lock() ret, specificReturn := fake.deleteVolumeReturnsOnCall[len(fake.deleteVolumeArgsForCall)] fake.deleteVolumeArgsForCall = append(fake.deleteVolumeArgsForCall, struct { - name string - }{name}) - fake.recordInvocation("DeleteVolume", []interface{}{name}) + arg1 string + }{arg1}) + fake.recordInvocation("DeleteVolume", []interface{}{arg1}) fake.deleteVolumeMutex.Unlock() if fake.DeleteVolumeStub != nil { - return fake.DeleteVolumeStub(name) + return fake.DeleteVolumeStub(arg1) } if specificReturn { return ret.result1 } - return fake.deleteVolumeReturns.result1 + fakeReturns := fake.deleteVolumeReturns + return fakeReturns.result1 } func (fake *FakeScbeDataModel) DeleteVolumeCallCount() int { @@ -85,13 +87,22 @@ func (fake *FakeScbeDataModel) DeleteVolumeCallCount() int { return len(fake.deleteVolumeArgsForCall) } +func (fake *FakeScbeDataModel) DeleteVolumeCalls(stub func(string) error) { + fake.deleteVolumeMutex.Lock() + defer fake.deleteVolumeMutex.Unlock() + fake.DeleteVolumeStub = stub +} + func (fake *FakeScbeDataModel) DeleteVolumeArgsForCall(i int) string { fake.deleteVolumeMutex.RLock() defer fake.deleteVolumeMutex.RUnlock() - return fake.deleteVolumeArgsForCall[i].name + argsForCall := fake.deleteVolumeArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeScbeDataModel) DeleteVolumeReturns(result1 error) { + fake.deleteVolumeMutex.Lock() + defer fake.deleteVolumeMutex.Unlock() fake.DeleteVolumeStub = nil fake.deleteVolumeReturns = struct { result1 error @@ -99,6 +110,8 @@ func (fake *FakeScbeDataModel) DeleteVolumeReturns(result1 error) { } func (fake *FakeScbeDataModel) DeleteVolumeReturnsOnCall(i int, result1 error) { + fake.deleteVolumeMutex.Lock() + defer fake.deleteVolumeMutex.Unlock() fake.DeleteVolumeStub = nil if fake.deleteVolumeReturnsOnCall == nil { fake.deleteVolumeReturnsOnCall = make(map[int]struct { @@ -110,71 +123,22 @@ func (fake *FakeScbeDataModel) DeleteVolumeReturnsOnCall(i int, result1 error) { }{result1} } -func (fake *FakeScbeDataModel) InsertVolume(volumeName string, wwn string, fstype string) error { - fake.insertVolumeMutex.Lock() - ret, specificReturn := fake.insertVolumeReturnsOnCall[len(fake.insertVolumeArgsForCall)] - fake.insertVolumeArgsForCall = append(fake.insertVolumeArgsForCall, struct { - volumeName string - wwn string - fstype string - }{volumeName, wwn, fstype}) - fake.recordInvocation("InsertVolume", []interface{}{volumeName, wwn, fstype}) - fake.insertVolumeMutex.Unlock() - if fake.InsertVolumeStub != nil { - return fake.InsertVolumeStub(volumeName, wwn, fstype) - } - if specificReturn { - return ret.result1 - } - return fake.insertVolumeReturns.result1 -} - -func (fake *FakeScbeDataModel) InsertVolumeCallCount() int { - fake.insertVolumeMutex.RLock() - defer fake.insertVolumeMutex.RUnlock() - return len(fake.insertVolumeArgsForCall) -} - -func (fake *FakeScbeDataModel) InsertVolumeArgsForCall(i int) (string, string, string) { - fake.insertVolumeMutex.RLock() - defer fake.insertVolumeMutex.RUnlock() - return fake.insertVolumeArgsForCall[i].volumeName, fake.insertVolumeArgsForCall[i].wwn, fake.insertVolumeArgsForCall[i].fstype -} - -func (fake *FakeScbeDataModel) InsertVolumeReturns(result1 error) { - fake.InsertVolumeStub = nil - fake.insertVolumeReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeScbeDataModel) InsertVolumeReturnsOnCall(i int, result1 error) { - fake.InsertVolumeStub = nil - if fake.insertVolumeReturnsOnCall == nil { - fake.insertVolumeReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.insertVolumeReturnsOnCall[i] = struct { - result1 error - }{result1} -} - -func (fake *FakeScbeDataModel) GetVolume(name string) (scbe.ScbeVolume, bool, error) { +func (fake *FakeScbeDataModel) GetVolume(arg1 string) (scbe.ScbeVolume, bool, error) { fake.getVolumeMutex.Lock() ret, specificReturn := fake.getVolumeReturnsOnCall[len(fake.getVolumeArgsForCall)] fake.getVolumeArgsForCall = append(fake.getVolumeArgsForCall, struct { - name string - }{name}) - fake.recordInvocation("GetVolume", []interface{}{name}) + arg1 string + }{arg1}) + fake.recordInvocation("GetVolume", []interface{}{arg1}) fake.getVolumeMutex.Unlock() if fake.GetVolumeStub != nil { - return fake.GetVolumeStub(name) + return fake.GetVolumeStub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - return fake.getVolumeReturns.result1, fake.getVolumeReturns.result2, fake.getVolumeReturns.result3 + fakeReturns := fake.getVolumeReturns + return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } func (fake *FakeScbeDataModel) GetVolumeCallCount() int { @@ -183,13 +147,22 @@ func (fake *FakeScbeDataModel) GetVolumeCallCount() int { return len(fake.getVolumeArgsForCall) } +func (fake *FakeScbeDataModel) GetVolumeCalls(stub func(string) (scbe.ScbeVolume, bool, error)) { + fake.getVolumeMutex.Lock() + defer fake.getVolumeMutex.Unlock() + fake.GetVolumeStub = stub +} + func (fake *FakeScbeDataModel) GetVolumeArgsForCall(i int) string { fake.getVolumeMutex.RLock() defer fake.getVolumeMutex.RUnlock() - return fake.getVolumeArgsForCall[i].name + argsForCall := fake.getVolumeArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeScbeDataModel) GetVolumeReturns(result1 scbe.ScbeVolume, result2 bool, result3 error) { + fake.getVolumeMutex.Lock() + defer fake.getVolumeMutex.Unlock() fake.GetVolumeStub = nil fake.getVolumeReturns = struct { result1 scbe.ScbeVolume @@ -199,6 +172,8 @@ func (fake *FakeScbeDataModel) GetVolumeReturns(result1 scbe.ScbeVolume, result2 } func (fake *FakeScbeDataModel) GetVolumeReturnsOnCall(i int, result1 scbe.ScbeVolume, result2 bool, result3 error) { + fake.getVolumeMutex.Lock() + defer fake.getVolumeMutex.Unlock() fake.GetVolumeStub = nil if fake.getVolumeReturnsOnCall == nil { fake.getVolumeReturnsOnCall = make(map[int]struct { @@ -214,10 +189,73 @@ func (fake *FakeScbeDataModel) GetVolumeReturnsOnCall(i int, result1 scbe.ScbeVo }{result1, result2, result3} } +func (fake *FakeScbeDataModel) InsertVolume(arg1 string, arg2 string, arg3 string) error { + fake.insertVolumeMutex.Lock() + ret, specificReturn := fake.insertVolumeReturnsOnCall[len(fake.insertVolumeArgsForCall)] + fake.insertVolumeArgsForCall = append(fake.insertVolumeArgsForCall, struct { + arg1 string + arg2 string + arg3 string + }{arg1, arg2, arg3}) + fake.recordInvocation("InsertVolume", []interface{}{arg1, arg2, arg3}) + fake.insertVolumeMutex.Unlock() + if fake.InsertVolumeStub != nil { + return fake.InsertVolumeStub(arg1, arg2, arg3) + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.insertVolumeReturns + return fakeReturns.result1 +} + +func (fake *FakeScbeDataModel) InsertVolumeCallCount() int { + fake.insertVolumeMutex.RLock() + defer fake.insertVolumeMutex.RUnlock() + return len(fake.insertVolumeArgsForCall) +} + +func (fake *FakeScbeDataModel) InsertVolumeCalls(stub func(string, string, string) error) { + fake.insertVolumeMutex.Lock() + defer fake.insertVolumeMutex.Unlock() + fake.InsertVolumeStub = stub +} + +func (fake *FakeScbeDataModel) InsertVolumeArgsForCall(i int) (string, string, string) { + fake.insertVolumeMutex.RLock() + defer fake.insertVolumeMutex.RUnlock() + argsForCall := fake.insertVolumeArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 +} + +func (fake *FakeScbeDataModel) InsertVolumeReturns(result1 error) { + fake.insertVolumeMutex.Lock() + defer fake.insertVolumeMutex.Unlock() + fake.InsertVolumeStub = nil + fake.insertVolumeReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeScbeDataModel) InsertVolumeReturnsOnCall(i int, result1 error) { + fake.insertVolumeMutex.Lock() + defer fake.insertVolumeMutex.Unlock() + fake.InsertVolumeStub = nil + if fake.insertVolumeReturnsOnCall == nil { + fake.insertVolumeReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.insertVolumeReturnsOnCall[i] = struct { + result1 error + }{result1} +} + func (fake *FakeScbeDataModel) ListVolumes() ([]scbe.ScbeVolume, error) { fake.listVolumesMutex.Lock() ret, specificReturn := fake.listVolumesReturnsOnCall[len(fake.listVolumesArgsForCall)] - fake.listVolumesArgsForCall = append(fake.listVolumesArgsForCall, struct{}{}) + fake.listVolumesArgsForCall = append(fake.listVolumesArgsForCall, struct { + }{}) fake.recordInvocation("ListVolumes", []interface{}{}) fake.listVolumesMutex.Unlock() if fake.ListVolumesStub != nil { @@ -226,7 +264,8 @@ func (fake *FakeScbeDataModel) ListVolumes() ([]scbe.ScbeVolume, error) { if specificReturn { return ret.result1, ret.result2 } - return fake.listVolumesReturns.result1, fake.listVolumesReturns.result2 + fakeReturns := fake.listVolumesReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeScbeDataModel) ListVolumesCallCount() int { @@ -235,7 +274,15 @@ func (fake *FakeScbeDataModel) ListVolumesCallCount() int { return len(fake.listVolumesArgsForCall) } +func (fake *FakeScbeDataModel) ListVolumesCalls(stub func() ([]scbe.ScbeVolume, error)) { + fake.listVolumesMutex.Lock() + defer fake.listVolumesMutex.Unlock() + fake.ListVolumesStub = stub +} + func (fake *FakeScbeDataModel) ListVolumesReturns(result1 []scbe.ScbeVolume, result2 error) { + fake.listVolumesMutex.Lock() + defer fake.listVolumesMutex.Unlock() fake.ListVolumesStub = nil fake.listVolumesReturns = struct { result1 []scbe.ScbeVolume @@ -244,6 +291,8 @@ func (fake *FakeScbeDataModel) ListVolumesReturns(result1 []scbe.ScbeVolume, res } func (fake *FakeScbeDataModel) ListVolumesReturnsOnCall(i int, result1 []scbe.ScbeVolume, result2 error) { + fake.listVolumesMutex.Lock() + defer fake.listVolumesMutex.Unlock() fake.ListVolumesStub = nil if fake.listVolumesReturnsOnCall == nil { fake.listVolumesReturnsOnCall = make(map[int]struct { @@ -262,10 +311,10 @@ func (fake *FakeScbeDataModel) Invocations() map[string][][]interface{} { defer fake.invocationsMutex.RUnlock() fake.deleteVolumeMutex.RLock() defer fake.deleteVolumeMutex.RUnlock() - fake.insertVolumeMutex.RLock() - defer fake.insertVolumeMutex.RUnlock() fake.getVolumeMutex.RLock() defer fake.getVolumeMutex.RUnlock() + fake.insertVolumeMutex.RLock() + defer fake.insertVolumeMutex.RUnlock() fake.listVolumesMutex.RLock() defer fake.listVolumesMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} diff --git a/fakes/fake_SpectrumDataModel.go b/fakes/fake_SpectrumDataModel.go index 9eff3fbe..a9547b36 100644 --- a/fakes/fake_SpectrumDataModel.go +++ b/fakes/fake_SpectrumDataModel.go @@ -1,19 +1,3 @@ -/** - * Copyright 2017 IBM Corp. - * - * 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. - */ - // Code generated by counterfeiter. DO NOT EDIT. package fakes @@ -27,17 +11,18 @@ import ( type FakeSpectrumDataModel struct { CreateVolumeTableStub func() error createVolumeTableMutex sync.RWMutex - createVolumeTableArgsForCall []struct{} - createVolumeTableReturns struct { + createVolumeTableArgsForCall []struct { + } + createVolumeTableReturns struct { result1 error } createVolumeTableReturnsOnCall map[int]struct { result1 error } - DeleteVolumeStub func(name string) error + DeleteVolumeStub func(string) error deleteVolumeMutex sync.RWMutex deleteVolumeArgsForCall []struct { - name string + arg1 string } deleteVolumeReturns struct { result1 error @@ -45,46 +30,30 @@ type FakeSpectrumDataModel struct { deleteVolumeReturnsOnCall map[int]struct { result1 error } - InsertFilesetVolumeStub func(fileset, volumeName string, filesystem string, isPreexisting bool, opts map[string]interface{}) error - insertFilesetVolumeMutex sync.RWMutex - insertFilesetVolumeArgsForCall []struct { - fileset string - volumeName string - filesystem string - isPreexisting bool - opts map[string]interface{} - } - insertFilesetVolumeReturns struct { - result1 error - } - insertFilesetVolumeReturnsOnCall map[int]struct { - result1 error + GetVolumeStub func(string) (spectrumscale.SpectrumScaleVolume, bool, error) + getVolumeMutex sync.RWMutex + getVolumeArgsForCall []struct { + arg1 string } - InsertLightweightVolumeStub func(fileset, directory, volumeName string, filesystem string, isPreexisting bool, opts map[string]interface{}) error - insertLightweightVolumeMutex sync.RWMutex - insertLightweightVolumeArgsForCall []struct { - fileset string - directory string - volumeName string - filesystem string - isPreexisting bool - opts map[string]interface{} - } - insertLightweightVolumeReturns struct { - result1 error + getVolumeReturns struct { + result1 spectrumscale.SpectrumScaleVolume + result2 bool + result3 error } - insertLightweightVolumeReturnsOnCall map[int]struct { - result1 error + getVolumeReturnsOnCall map[int]struct { + result1 spectrumscale.SpectrumScaleVolume + result2 bool + result3 error } - InsertFilesetQuotaVolumeStub func(fileset, quota, volumeName string, filesystem string, isPreexisting bool, opts map[string]interface{}) error + InsertFilesetQuotaVolumeStub func(string, string, string, string, bool, map[string]interface{}) error insertFilesetQuotaVolumeMutex sync.RWMutex insertFilesetQuotaVolumeArgsForCall []struct { - fileset string - quota string - volumeName string - filesystem string - isPreexisting bool - opts map[string]interface{} + arg1 string + arg2 string + arg3 string + arg4 string + arg5 bool + arg6 map[string]interface{} } insertFilesetQuotaVolumeReturns struct { result1 error @@ -92,25 +61,26 @@ type FakeSpectrumDataModel struct { insertFilesetQuotaVolumeReturnsOnCall map[int]struct { result1 error } - GetVolumeStub func(name string) (spectrumscale.SpectrumScaleVolume, bool, error) - getVolumeMutex sync.RWMutex - getVolumeArgsForCall []struct { - name string + InsertFilesetVolumeStub func(string, string, string, bool, map[string]interface{}) error + insertFilesetVolumeMutex sync.RWMutex + insertFilesetVolumeArgsForCall []struct { + arg1 string + arg2 string + arg3 string + arg4 bool + arg5 map[string]interface{} } - getVolumeReturns struct { - result1 spectrumscale.SpectrumScaleVolume - result2 bool - result3 error + insertFilesetVolumeReturns struct { + result1 error } - getVolumeReturnsOnCall map[int]struct { - result1 spectrumscale.SpectrumScaleVolume - result2 bool - result3 error + insertFilesetVolumeReturnsOnCall map[int]struct { + result1 error } ListVolumesStub func() ([]resources.Volume, error) listVolumesMutex sync.RWMutex - listVolumesArgsForCall []struct{} - listVolumesReturns struct { + listVolumesArgsForCall []struct { + } + listVolumesReturns struct { result1 []resources.Volume result2 error } @@ -118,11 +88,11 @@ type FakeSpectrumDataModel struct { result1 []resources.Volume result2 error } - UpdateVolumeMountpointStub func(name string, mountpoint string) error + UpdateVolumeMountpointStub func(string, string) error updateVolumeMountpointMutex sync.RWMutex updateVolumeMountpointArgsForCall []struct { - name string - mountpoint string + arg1 string + arg2 string } updateVolumeMountpointReturns struct { result1 error @@ -137,7 +107,8 @@ type FakeSpectrumDataModel struct { func (fake *FakeSpectrumDataModel) CreateVolumeTable() error { fake.createVolumeTableMutex.Lock() ret, specificReturn := fake.createVolumeTableReturnsOnCall[len(fake.createVolumeTableArgsForCall)] - fake.createVolumeTableArgsForCall = append(fake.createVolumeTableArgsForCall, struct{}{}) + fake.createVolumeTableArgsForCall = append(fake.createVolumeTableArgsForCall, struct { + }{}) fake.recordInvocation("CreateVolumeTable", []interface{}{}) fake.createVolumeTableMutex.Unlock() if fake.CreateVolumeTableStub != nil { @@ -146,7 +117,8 @@ func (fake *FakeSpectrumDataModel) CreateVolumeTable() error { if specificReturn { return ret.result1 } - return fake.createVolumeTableReturns.result1 + fakeReturns := fake.createVolumeTableReturns + return fakeReturns.result1 } func (fake *FakeSpectrumDataModel) CreateVolumeTableCallCount() int { @@ -155,7 +127,15 @@ func (fake *FakeSpectrumDataModel) CreateVolumeTableCallCount() int { return len(fake.createVolumeTableArgsForCall) } +func (fake *FakeSpectrumDataModel) CreateVolumeTableCalls(stub func() error) { + fake.createVolumeTableMutex.Lock() + defer fake.createVolumeTableMutex.Unlock() + fake.CreateVolumeTableStub = stub +} + func (fake *FakeSpectrumDataModel) CreateVolumeTableReturns(result1 error) { + fake.createVolumeTableMutex.Lock() + defer fake.createVolumeTableMutex.Unlock() fake.CreateVolumeTableStub = nil fake.createVolumeTableReturns = struct { result1 error @@ -163,6 +143,8 @@ func (fake *FakeSpectrumDataModel) CreateVolumeTableReturns(result1 error) { } func (fake *FakeSpectrumDataModel) CreateVolumeTableReturnsOnCall(i int, result1 error) { + fake.createVolumeTableMutex.Lock() + defer fake.createVolumeTableMutex.Unlock() fake.CreateVolumeTableStub = nil if fake.createVolumeTableReturnsOnCall == nil { fake.createVolumeTableReturnsOnCall = make(map[int]struct { @@ -174,21 +156,22 @@ func (fake *FakeSpectrumDataModel) CreateVolumeTableReturnsOnCall(i int, result1 }{result1} } -func (fake *FakeSpectrumDataModel) DeleteVolume(name string) error { +func (fake *FakeSpectrumDataModel) DeleteVolume(arg1 string) error { fake.deleteVolumeMutex.Lock() ret, specificReturn := fake.deleteVolumeReturnsOnCall[len(fake.deleteVolumeArgsForCall)] fake.deleteVolumeArgsForCall = append(fake.deleteVolumeArgsForCall, struct { - name string - }{name}) - fake.recordInvocation("DeleteVolume", []interface{}{name}) + arg1 string + }{arg1}) + fake.recordInvocation("DeleteVolume", []interface{}{arg1}) fake.deleteVolumeMutex.Unlock() if fake.DeleteVolumeStub != nil { - return fake.DeleteVolumeStub(name) + return fake.DeleteVolumeStub(arg1) } if specificReturn { return ret.result1 } - return fake.deleteVolumeReturns.result1 + fakeReturns := fake.deleteVolumeReturns + return fakeReturns.result1 } func (fake *FakeSpectrumDataModel) DeleteVolumeCallCount() int { @@ -197,13 +180,22 @@ func (fake *FakeSpectrumDataModel) DeleteVolumeCallCount() int { return len(fake.deleteVolumeArgsForCall) } +func (fake *FakeSpectrumDataModel) DeleteVolumeCalls(stub func(string) error) { + fake.deleteVolumeMutex.Lock() + defer fake.deleteVolumeMutex.Unlock() + fake.DeleteVolumeStub = stub +} + func (fake *FakeSpectrumDataModel) DeleteVolumeArgsForCall(i int) string { fake.deleteVolumeMutex.RLock() defer fake.deleteVolumeMutex.RUnlock() - return fake.deleteVolumeArgsForCall[i].name + argsForCall := fake.deleteVolumeArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeSpectrumDataModel) DeleteVolumeReturns(result1 error) { + fake.deleteVolumeMutex.Lock() + defer fake.deleteVolumeMutex.Unlock() fake.DeleteVolumeStub = nil fake.deleteVolumeReturns = struct { result1 error @@ -211,6 +203,8 @@ func (fake *FakeSpectrumDataModel) DeleteVolumeReturns(result1 error) { } func (fake *FakeSpectrumDataModel) DeleteVolumeReturnsOnCall(i int, result1 error) { + fake.deleteVolumeMutex.Lock() + defer fake.deleteVolumeMutex.Unlock() fake.DeleteVolumeStub = nil if fake.deleteVolumeReturnsOnCall == nil { fake.deleteVolumeReturnsOnCall = make(map[int]struct { @@ -222,131 +216,93 @@ func (fake *FakeSpectrumDataModel) DeleteVolumeReturnsOnCall(i int, result1 erro }{result1} } -func (fake *FakeSpectrumDataModel) InsertFilesetVolume(fileset string, volumeName string, filesystem string, isPreexisting bool, opts map[string]interface{}) error { - fake.insertFilesetVolumeMutex.Lock() - ret, specificReturn := fake.insertFilesetVolumeReturnsOnCall[len(fake.insertFilesetVolumeArgsForCall)] - fake.insertFilesetVolumeArgsForCall = append(fake.insertFilesetVolumeArgsForCall, struct { - fileset string - volumeName string - filesystem string - isPreexisting bool - opts map[string]interface{} - }{fileset, volumeName, filesystem, isPreexisting, opts}) - fake.recordInvocation("InsertFilesetVolume", []interface{}{fileset, volumeName, filesystem, isPreexisting, opts}) - fake.insertFilesetVolumeMutex.Unlock() - if fake.InsertFilesetVolumeStub != nil { - return fake.InsertFilesetVolumeStub(fileset, volumeName, filesystem, isPreexisting, opts) +func (fake *FakeSpectrumDataModel) GetVolume(arg1 string) (spectrumscale.SpectrumScaleVolume, bool, error) { + fake.getVolumeMutex.Lock() + ret, specificReturn := fake.getVolumeReturnsOnCall[len(fake.getVolumeArgsForCall)] + fake.getVolumeArgsForCall = append(fake.getVolumeArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("GetVolume", []interface{}{arg1}) + fake.getVolumeMutex.Unlock() + if fake.GetVolumeStub != nil { + return fake.GetVolumeStub(arg1) } if specificReturn { - return ret.result1 - } - return fake.insertFilesetVolumeReturns.result1 -} - -func (fake *FakeSpectrumDataModel) InsertFilesetVolumeCallCount() int { - fake.insertFilesetVolumeMutex.RLock() - defer fake.insertFilesetVolumeMutex.RUnlock() - return len(fake.insertFilesetVolumeArgsForCall) -} - -func (fake *FakeSpectrumDataModel) InsertFilesetVolumeArgsForCall(i int) (string, string, string, bool, map[string]interface{}) { - fake.insertFilesetVolumeMutex.RLock() - defer fake.insertFilesetVolumeMutex.RUnlock() - return fake.insertFilesetVolumeArgsForCall[i].fileset, fake.insertFilesetVolumeArgsForCall[i].volumeName, fake.insertFilesetVolumeArgsForCall[i].filesystem, fake.insertFilesetVolumeArgsForCall[i].isPreexisting, fake.insertFilesetVolumeArgsForCall[i].opts -} - -func (fake *FakeSpectrumDataModel) InsertFilesetVolumeReturns(result1 error) { - fake.InsertFilesetVolumeStub = nil - fake.insertFilesetVolumeReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeSpectrumDataModel) InsertFilesetVolumeReturnsOnCall(i int, result1 error) { - fake.InsertFilesetVolumeStub = nil - if fake.insertFilesetVolumeReturnsOnCall == nil { - fake.insertFilesetVolumeReturnsOnCall = make(map[int]struct { - result1 error - }) + return ret.result1, ret.result2, ret.result3 } - fake.insertFilesetVolumeReturnsOnCall[i] = struct { - result1 error - }{result1} + fakeReturns := fake.getVolumeReturns + return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } -func (fake *FakeSpectrumDataModel) InsertLightweightVolume(fileset string, directory string, volumeName string, filesystem string, isPreexisting bool, opts map[string]interface{}) error { - fake.insertLightweightVolumeMutex.Lock() - ret, specificReturn := fake.insertLightweightVolumeReturnsOnCall[len(fake.insertLightweightVolumeArgsForCall)] - fake.insertLightweightVolumeArgsForCall = append(fake.insertLightweightVolumeArgsForCall, struct { - fileset string - directory string - volumeName string - filesystem string - isPreexisting bool - opts map[string]interface{} - }{fileset, directory, volumeName, filesystem, isPreexisting, opts}) - fake.recordInvocation("InsertLightweightVolume", []interface{}{fileset, directory, volumeName, filesystem, isPreexisting, opts}) - fake.insertLightweightVolumeMutex.Unlock() - if fake.InsertLightweightVolumeStub != nil { - return fake.InsertLightweightVolumeStub(fileset, directory, volumeName, filesystem, isPreexisting, opts) - } - if specificReturn { - return ret.result1 - } - return fake.insertLightweightVolumeReturns.result1 +func (fake *FakeSpectrumDataModel) GetVolumeCallCount() int { + fake.getVolumeMutex.RLock() + defer fake.getVolumeMutex.RUnlock() + return len(fake.getVolumeArgsForCall) } -func (fake *FakeSpectrumDataModel) InsertLightweightVolumeCallCount() int { - fake.insertLightweightVolumeMutex.RLock() - defer fake.insertLightweightVolumeMutex.RUnlock() - return len(fake.insertLightweightVolumeArgsForCall) +func (fake *FakeSpectrumDataModel) GetVolumeCalls(stub func(string) (spectrumscale.SpectrumScaleVolume, bool, error)) { + fake.getVolumeMutex.Lock() + defer fake.getVolumeMutex.Unlock() + fake.GetVolumeStub = stub } -func (fake *FakeSpectrumDataModel) InsertLightweightVolumeArgsForCall(i int) (string, string, string, string, bool, map[string]interface{}) { - fake.insertLightweightVolumeMutex.RLock() - defer fake.insertLightweightVolumeMutex.RUnlock() - return fake.insertLightweightVolumeArgsForCall[i].fileset, fake.insertLightweightVolumeArgsForCall[i].directory, fake.insertLightweightVolumeArgsForCall[i].volumeName, fake.insertLightweightVolumeArgsForCall[i].filesystem, fake.insertLightweightVolumeArgsForCall[i].isPreexisting, fake.insertLightweightVolumeArgsForCall[i].opts +func (fake *FakeSpectrumDataModel) GetVolumeArgsForCall(i int) string { + fake.getVolumeMutex.RLock() + defer fake.getVolumeMutex.RUnlock() + argsForCall := fake.getVolumeArgsForCall[i] + return argsForCall.arg1 } -func (fake *FakeSpectrumDataModel) InsertLightweightVolumeReturns(result1 error) { - fake.InsertLightweightVolumeStub = nil - fake.insertLightweightVolumeReturns = struct { - result1 error - }{result1} +func (fake *FakeSpectrumDataModel) GetVolumeReturns(result1 spectrumscale.SpectrumScaleVolume, result2 bool, result3 error) { + fake.getVolumeMutex.Lock() + defer fake.getVolumeMutex.Unlock() + fake.GetVolumeStub = nil + fake.getVolumeReturns = struct { + result1 spectrumscale.SpectrumScaleVolume + result2 bool + result3 error + }{result1, result2, result3} } -func (fake *FakeSpectrumDataModel) InsertLightweightVolumeReturnsOnCall(i int, result1 error) { - fake.InsertLightweightVolumeStub = nil - if fake.insertLightweightVolumeReturnsOnCall == nil { - fake.insertLightweightVolumeReturnsOnCall = make(map[int]struct { - result1 error +func (fake *FakeSpectrumDataModel) GetVolumeReturnsOnCall(i int, result1 spectrumscale.SpectrumScaleVolume, result2 bool, result3 error) { + fake.getVolumeMutex.Lock() + defer fake.getVolumeMutex.Unlock() + fake.GetVolumeStub = nil + if fake.getVolumeReturnsOnCall == nil { + fake.getVolumeReturnsOnCall = make(map[int]struct { + result1 spectrumscale.SpectrumScaleVolume + result2 bool + result3 error }) } - fake.insertLightweightVolumeReturnsOnCall[i] = struct { - result1 error - }{result1} + fake.getVolumeReturnsOnCall[i] = struct { + result1 spectrumscale.SpectrumScaleVolume + result2 bool + result3 error + }{result1, result2, result3} } -func (fake *FakeSpectrumDataModel) InsertFilesetQuotaVolume(fileset string, quota string, volumeName string, filesystem string, isPreexisting bool, opts map[string]interface{}) error { +func (fake *FakeSpectrumDataModel) InsertFilesetQuotaVolume(arg1 string, arg2 string, arg3 string, arg4 string, arg5 bool, arg6 map[string]interface{}) error { fake.insertFilesetQuotaVolumeMutex.Lock() ret, specificReturn := fake.insertFilesetQuotaVolumeReturnsOnCall[len(fake.insertFilesetQuotaVolumeArgsForCall)] fake.insertFilesetQuotaVolumeArgsForCall = append(fake.insertFilesetQuotaVolumeArgsForCall, struct { - fileset string - quota string - volumeName string - filesystem string - isPreexisting bool - opts map[string]interface{} - }{fileset, quota, volumeName, filesystem, isPreexisting, opts}) - fake.recordInvocation("InsertFilesetQuotaVolume", []interface{}{fileset, quota, volumeName, filesystem, isPreexisting, opts}) + arg1 string + arg2 string + arg3 string + arg4 string + arg5 bool + arg6 map[string]interface{} + }{arg1, arg2, arg3, arg4, arg5, arg6}) + fake.recordInvocation("InsertFilesetQuotaVolume", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6}) fake.insertFilesetQuotaVolumeMutex.Unlock() if fake.InsertFilesetQuotaVolumeStub != nil { - return fake.InsertFilesetQuotaVolumeStub(fileset, quota, volumeName, filesystem, isPreexisting, opts) + return fake.InsertFilesetQuotaVolumeStub(arg1, arg2, arg3, arg4, arg5, arg6) } if specificReturn { return ret.result1 } - return fake.insertFilesetQuotaVolumeReturns.result1 + fakeReturns := fake.insertFilesetQuotaVolumeReturns + return fakeReturns.result1 } func (fake *FakeSpectrumDataModel) InsertFilesetQuotaVolumeCallCount() int { @@ -355,13 +311,22 @@ func (fake *FakeSpectrumDataModel) InsertFilesetQuotaVolumeCallCount() int { return len(fake.insertFilesetQuotaVolumeArgsForCall) } +func (fake *FakeSpectrumDataModel) InsertFilesetQuotaVolumeCalls(stub func(string, string, string, string, bool, map[string]interface{}) error) { + fake.insertFilesetQuotaVolumeMutex.Lock() + defer fake.insertFilesetQuotaVolumeMutex.Unlock() + fake.InsertFilesetQuotaVolumeStub = stub +} + func (fake *FakeSpectrumDataModel) InsertFilesetQuotaVolumeArgsForCall(i int) (string, string, string, string, bool, map[string]interface{}) { fake.insertFilesetQuotaVolumeMutex.RLock() defer fake.insertFilesetQuotaVolumeMutex.RUnlock() - return fake.insertFilesetQuotaVolumeArgsForCall[i].fileset, fake.insertFilesetQuotaVolumeArgsForCall[i].quota, fake.insertFilesetQuotaVolumeArgsForCall[i].volumeName, fake.insertFilesetQuotaVolumeArgsForCall[i].filesystem, fake.insertFilesetQuotaVolumeArgsForCall[i].isPreexisting, fake.insertFilesetQuotaVolumeArgsForCall[i].opts + argsForCall := fake.insertFilesetQuotaVolumeArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5, argsForCall.arg6 } func (fake *FakeSpectrumDataModel) InsertFilesetQuotaVolumeReturns(result1 error) { + fake.insertFilesetQuotaVolumeMutex.Lock() + defer fake.insertFilesetQuotaVolumeMutex.Unlock() fake.InsertFilesetQuotaVolumeStub = nil fake.insertFilesetQuotaVolumeReturns = struct { result1 error @@ -369,6 +334,8 @@ func (fake *FakeSpectrumDataModel) InsertFilesetQuotaVolumeReturns(result1 error } func (fake *FakeSpectrumDataModel) InsertFilesetQuotaVolumeReturnsOnCall(i int, result1 error) { + fake.insertFilesetQuotaVolumeMutex.Lock() + defer fake.insertFilesetQuotaVolumeMutex.Unlock() fake.InsertFilesetQuotaVolumeStub = nil if fake.insertFilesetQuotaVolumeReturnsOnCall == nil { fake.insertFilesetQuotaVolumeReturnsOnCall = make(map[int]struct { @@ -380,64 +347,75 @@ func (fake *FakeSpectrumDataModel) InsertFilesetQuotaVolumeReturnsOnCall(i int, }{result1} } -func (fake *FakeSpectrumDataModel) GetVolume(name string) (spectrumscale.SpectrumScaleVolume, bool, error) { - fake.getVolumeMutex.Lock() - ret, specificReturn := fake.getVolumeReturnsOnCall[len(fake.getVolumeArgsForCall)] - fake.getVolumeArgsForCall = append(fake.getVolumeArgsForCall, struct { - name string - }{name}) - fake.recordInvocation("GetVolume", []interface{}{name}) - fake.getVolumeMutex.Unlock() - if fake.GetVolumeStub != nil { - return fake.GetVolumeStub(name) +func (fake *FakeSpectrumDataModel) InsertFilesetVolume(arg1 string, arg2 string, arg3 string, arg4 bool, arg5 map[string]interface{}) error { + fake.insertFilesetVolumeMutex.Lock() + ret, specificReturn := fake.insertFilesetVolumeReturnsOnCall[len(fake.insertFilesetVolumeArgsForCall)] + fake.insertFilesetVolumeArgsForCall = append(fake.insertFilesetVolumeArgsForCall, struct { + arg1 string + arg2 string + arg3 string + arg4 bool + arg5 map[string]interface{} + }{arg1, arg2, arg3, arg4, arg5}) + fake.recordInvocation("InsertFilesetVolume", []interface{}{arg1, arg2, arg3, arg4, arg5}) + fake.insertFilesetVolumeMutex.Unlock() + if fake.InsertFilesetVolumeStub != nil { + return fake.InsertFilesetVolumeStub(arg1, arg2, arg3, arg4, arg5) } if specificReturn { - return ret.result1, ret.result2, ret.result3 + return ret.result1 } - return fake.getVolumeReturns.result1, fake.getVolumeReturns.result2, fake.getVolumeReturns.result3 + fakeReturns := fake.insertFilesetVolumeReturns + return fakeReturns.result1 } -func (fake *FakeSpectrumDataModel) GetVolumeCallCount() int { - fake.getVolumeMutex.RLock() - defer fake.getVolumeMutex.RUnlock() - return len(fake.getVolumeArgsForCall) +func (fake *FakeSpectrumDataModel) InsertFilesetVolumeCallCount() int { + fake.insertFilesetVolumeMutex.RLock() + defer fake.insertFilesetVolumeMutex.RUnlock() + return len(fake.insertFilesetVolumeArgsForCall) } -func (fake *FakeSpectrumDataModel) GetVolumeArgsForCall(i int) string { - fake.getVolumeMutex.RLock() - defer fake.getVolumeMutex.RUnlock() - return fake.getVolumeArgsForCall[i].name +func (fake *FakeSpectrumDataModel) InsertFilesetVolumeCalls(stub func(string, string, string, bool, map[string]interface{}) error) { + fake.insertFilesetVolumeMutex.Lock() + defer fake.insertFilesetVolumeMutex.Unlock() + fake.InsertFilesetVolumeStub = stub } -func (fake *FakeSpectrumDataModel) GetVolumeReturns(result1 spectrumscale.SpectrumScaleVolume, result2 bool, result3 error) { - fake.GetVolumeStub = nil - fake.getVolumeReturns = struct { - result1 spectrumscale.SpectrumScaleVolume - result2 bool - result3 error - }{result1, result2, result3} +func (fake *FakeSpectrumDataModel) InsertFilesetVolumeArgsForCall(i int) (string, string, string, bool, map[string]interface{}) { + fake.insertFilesetVolumeMutex.RLock() + defer fake.insertFilesetVolumeMutex.RUnlock() + argsForCall := fake.insertFilesetVolumeArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5 } -func (fake *FakeSpectrumDataModel) GetVolumeReturnsOnCall(i int, result1 spectrumscale.SpectrumScaleVolume, result2 bool, result3 error) { - fake.GetVolumeStub = nil - if fake.getVolumeReturnsOnCall == nil { - fake.getVolumeReturnsOnCall = make(map[int]struct { - result1 spectrumscale.SpectrumScaleVolume - result2 bool - result3 error +func (fake *FakeSpectrumDataModel) InsertFilesetVolumeReturns(result1 error) { + fake.insertFilesetVolumeMutex.Lock() + defer fake.insertFilesetVolumeMutex.Unlock() + fake.InsertFilesetVolumeStub = nil + fake.insertFilesetVolumeReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeSpectrumDataModel) InsertFilesetVolumeReturnsOnCall(i int, result1 error) { + fake.insertFilesetVolumeMutex.Lock() + defer fake.insertFilesetVolumeMutex.Unlock() + fake.InsertFilesetVolumeStub = nil + if fake.insertFilesetVolumeReturnsOnCall == nil { + fake.insertFilesetVolumeReturnsOnCall = make(map[int]struct { + result1 error }) } - fake.getVolumeReturnsOnCall[i] = struct { - result1 spectrumscale.SpectrumScaleVolume - result2 bool - result3 error - }{result1, result2, result3} + fake.insertFilesetVolumeReturnsOnCall[i] = struct { + result1 error + }{result1} } func (fake *FakeSpectrumDataModel) ListVolumes() ([]resources.Volume, error) { fake.listVolumesMutex.Lock() ret, specificReturn := fake.listVolumesReturnsOnCall[len(fake.listVolumesArgsForCall)] - fake.listVolumesArgsForCall = append(fake.listVolumesArgsForCall, struct{}{}) + fake.listVolumesArgsForCall = append(fake.listVolumesArgsForCall, struct { + }{}) fake.recordInvocation("ListVolumes", []interface{}{}) fake.listVolumesMutex.Unlock() if fake.ListVolumesStub != nil { @@ -446,7 +424,8 @@ func (fake *FakeSpectrumDataModel) ListVolumes() ([]resources.Volume, error) { if specificReturn { return ret.result1, ret.result2 } - return fake.listVolumesReturns.result1, fake.listVolumesReturns.result2 + fakeReturns := fake.listVolumesReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeSpectrumDataModel) ListVolumesCallCount() int { @@ -455,7 +434,15 @@ func (fake *FakeSpectrumDataModel) ListVolumesCallCount() int { return len(fake.listVolumesArgsForCall) } +func (fake *FakeSpectrumDataModel) ListVolumesCalls(stub func() ([]resources.Volume, error)) { + fake.listVolumesMutex.Lock() + defer fake.listVolumesMutex.Unlock() + fake.ListVolumesStub = stub +} + func (fake *FakeSpectrumDataModel) ListVolumesReturns(result1 []resources.Volume, result2 error) { + fake.listVolumesMutex.Lock() + defer fake.listVolumesMutex.Unlock() fake.ListVolumesStub = nil fake.listVolumesReturns = struct { result1 []resources.Volume @@ -464,6 +451,8 @@ func (fake *FakeSpectrumDataModel) ListVolumesReturns(result1 []resources.Volume } func (fake *FakeSpectrumDataModel) ListVolumesReturnsOnCall(i int, result1 []resources.Volume, result2 error) { + fake.listVolumesMutex.Lock() + defer fake.listVolumesMutex.Unlock() fake.ListVolumesStub = nil if fake.listVolumesReturnsOnCall == nil { fake.listVolumesReturnsOnCall = make(map[int]struct { @@ -477,22 +466,23 @@ func (fake *FakeSpectrumDataModel) ListVolumesReturnsOnCall(i int, result1 []res }{result1, result2} } -func (fake *FakeSpectrumDataModel) UpdateVolumeMountpoint(name string, mountpoint string) error { +func (fake *FakeSpectrumDataModel) UpdateVolumeMountpoint(arg1 string, arg2 string) error { fake.updateVolumeMountpointMutex.Lock() ret, specificReturn := fake.updateVolumeMountpointReturnsOnCall[len(fake.updateVolumeMountpointArgsForCall)] fake.updateVolumeMountpointArgsForCall = append(fake.updateVolumeMountpointArgsForCall, struct { - name string - mountpoint string - }{name, mountpoint}) - fake.recordInvocation("UpdateVolumeMountpoint", []interface{}{name, mountpoint}) + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("UpdateVolumeMountpoint", []interface{}{arg1, arg2}) fake.updateVolumeMountpointMutex.Unlock() if fake.UpdateVolumeMountpointStub != nil { - return fake.UpdateVolumeMountpointStub(name, mountpoint) + return fake.UpdateVolumeMountpointStub(arg1, arg2) } if specificReturn { return ret.result1 } - return fake.updateVolumeMountpointReturns.result1 + fakeReturns := fake.updateVolumeMountpointReturns + return fakeReturns.result1 } func (fake *FakeSpectrumDataModel) UpdateVolumeMountpointCallCount() int { @@ -501,13 +491,22 @@ func (fake *FakeSpectrumDataModel) UpdateVolumeMountpointCallCount() int { return len(fake.updateVolumeMountpointArgsForCall) } +func (fake *FakeSpectrumDataModel) UpdateVolumeMountpointCalls(stub func(string, string) error) { + fake.updateVolumeMountpointMutex.Lock() + defer fake.updateVolumeMountpointMutex.Unlock() + fake.UpdateVolumeMountpointStub = stub +} + func (fake *FakeSpectrumDataModel) UpdateVolumeMountpointArgsForCall(i int) (string, string) { fake.updateVolumeMountpointMutex.RLock() defer fake.updateVolumeMountpointMutex.RUnlock() - return fake.updateVolumeMountpointArgsForCall[i].name, fake.updateVolumeMountpointArgsForCall[i].mountpoint + argsForCall := fake.updateVolumeMountpointArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } func (fake *FakeSpectrumDataModel) UpdateVolumeMountpointReturns(result1 error) { + fake.updateVolumeMountpointMutex.Lock() + defer fake.updateVolumeMountpointMutex.Unlock() fake.UpdateVolumeMountpointStub = nil fake.updateVolumeMountpointReturns = struct { result1 error @@ -515,6 +514,8 @@ func (fake *FakeSpectrumDataModel) UpdateVolumeMountpointReturns(result1 error) } func (fake *FakeSpectrumDataModel) UpdateVolumeMountpointReturnsOnCall(i int, result1 error) { + fake.updateVolumeMountpointMutex.Lock() + defer fake.updateVolumeMountpointMutex.Unlock() fake.UpdateVolumeMountpointStub = nil if fake.updateVolumeMountpointReturnsOnCall == nil { fake.updateVolumeMountpointReturnsOnCall = make(map[int]struct { @@ -533,19 +534,21 @@ func (fake *FakeSpectrumDataModel) Invocations() map[string][][]interface{} { defer fake.createVolumeTableMutex.RUnlock() fake.deleteVolumeMutex.RLock() defer fake.deleteVolumeMutex.RUnlock() - fake.insertFilesetVolumeMutex.RLock() - defer fake.insertFilesetVolumeMutex.RUnlock() - fake.insertLightweightVolumeMutex.RLock() - defer fake.insertLightweightVolumeMutex.RUnlock() - fake.insertFilesetQuotaVolumeMutex.RLock() - defer fake.insertFilesetQuotaVolumeMutex.RUnlock() fake.getVolumeMutex.RLock() defer fake.getVolumeMutex.RUnlock() + fake.insertFilesetQuotaVolumeMutex.RLock() + defer fake.insertFilesetQuotaVolumeMutex.RUnlock() + fake.insertFilesetVolumeMutex.RLock() + defer fake.insertFilesetVolumeMutex.RUnlock() fake.listVolumesMutex.RLock() defer fake.listVolumesMutex.RUnlock() fake.updateVolumeMountpointMutex.RLock() defer fake.updateVolumeMountpointMutex.RUnlock() - return fake.invocations + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations } func (fake *FakeSpectrumDataModel) recordInvocation(key string, args []interface{}) { diff --git a/fakes/fake_block_device_mounter_utils.go b/fakes/fake_block_device_mounter_utils.go index abc68d0c..19c6f4a6 100644 --- a/fakes/fake_block_device_mounter_utils.go +++ b/fakes/fake_block_device_mounter_utils.go @@ -5,28 +5,41 @@ import ( "sync" "github.com/IBM/ubiquity/remote/mounter/block_device_mounter_utils" + "github.com/IBM/ubiquity/resources" ) type FakeBlockDeviceMounterUtils struct { - RescanAllStub func(wwn string, rescanForCleanUp bool, extraLunZeroScanning bool) error - rescanAllMutex sync.RWMutex - rescanAllArgsForCall []struct { - wwn string - rescanForCleanUp bool - extraLunZeroScanning bool + DisconnectAllStub func(*resources.VolumeMountProperties) error + disconnectAllMutex sync.RWMutex + disconnectAllArgsForCall []struct { + arg1 *resources.VolumeMountProperties } - rescanAllReturns struct { + disconnectAllReturns struct { result1 error } - rescanAllReturnsOnCall map[int]struct { + disconnectAllReturnsOnCall map[int]struct { result1 error } - MountDeviceFlowStub func(devicePath string, fsType string, mountPoint string) error + DiscoverStub func(string, bool) (string, error) + discoverMutex sync.RWMutex + discoverArgsForCall []struct { + arg1 string + arg2 bool + } + discoverReturns struct { + result1 string + result2 error + } + discoverReturnsOnCall map[int]struct { + result1 string + result2 error + } + MountDeviceFlowStub func(string, string, string) error mountDeviceFlowMutex sync.RWMutex mountDeviceFlowArgsForCall []struct { - devicePath string - fsType string - mountPoint string + arg1 string + arg2 string + arg3 string } mountDeviceFlowReturns struct { result1 error @@ -34,25 +47,22 @@ type FakeBlockDeviceMounterUtils struct { mountDeviceFlowReturnsOnCall map[int]struct { result1 error } - DiscoverStub func(volumeWwn string, deepDiscovery bool) (string, error) - discoverMutex sync.RWMutex - discoverArgsForCall []struct { - volumeWwn string - deepDiscovery bool + RescanAllStub func(*resources.VolumeMountProperties) error + rescanAllMutex sync.RWMutex + rescanAllArgsForCall []struct { + arg1 *resources.VolumeMountProperties } - discoverReturns struct { - result1 string - result2 error + rescanAllReturns struct { + result1 error } - discoverReturnsOnCall map[int]struct { - result1 string - result2 error + rescanAllReturnsOnCall map[int]struct { + result1 error } - UnmountDeviceFlowStub func(devicePath string, volumeWwn string) error + UnmountDeviceFlowStub func(string, string) error unmountDeviceFlowMutex sync.RWMutex unmountDeviceFlowArgsForCall []struct { - devicePath string - volumeWwn string + arg1 string + arg2 string } unmountDeviceFlowReturns struct { result1 error @@ -64,73 +74,148 @@ type FakeBlockDeviceMounterUtils struct { invocationsMutex sync.RWMutex } -func (fake *FakeBlockDeviceMounterUtils) RescanAll(wwn string, rescanForCleanUp bool, extraLunZeroScanning bool) error { - fake.rescanAllMutex.Lock() - ret, specificReturn := fake.rescanAllReturnsOnCall[len(fake.rescanAllArgsForCall)] - fake.rescanAllArgsForCall = append(fake.rescanAllArgsForCall, struct { - wwn string - rescanForCleanUp bool - extraLunZeroScanning bool - }{wwn, rescanForCleanUp, extraLunZeroScanning}) - fake.recordInvocation("RescanAll", []interface{}{wwn, rescanForCleanUp, extraLunZeroScanning}) - fake.rescanAllMutex.Unlock() - if fake.RescanAllStub != nil { - return fake.RescanAllStub(wwn, rescanForCleanUp, extraLunZeroScanning) +func (fake *FakeBlockDeviceMounterUtils) DisconnectAll(arg1 *resources.VolumeMountProperties) error { + fake.disconnectAllMutex.Lock() + ret, specificReturn := fake.disconnectAllReturnsOnCall[len(fake.disconnectAllArgsForCall)] + fake.disconnectAllArgsForCall = append(fake.disconnectAllArgsForCall, struct { + arg1 *resources.VolumeMountProperties + }{arg1}) + fake.recordInvocation("DisconnectAll", []interface{}{arg1}) + fake.disconnectAllMutex.Unlock() + if fake.DisconnectAllStub != nil { + return fake.DisconnectAllStub(arg1) } if specificReturn { return ret.result1 } - return fake.rescanAllReturns.result1 + fakeReturns := fake.disconnectAllReturns + return fakeReturns.result1 } -func (fake *FakeBlockDeviceMounterUtils) RescanAllCallCount() int { - fake.rescanAllMutex.RLock() - defer fake.rescanAllMutex.RUnlock() - return len(fake.rescanAllArgsForCall) +func (fake *FakeBlockDeviceMounterUtils) DisconnectAllCallCount() int { + fake.disconnectAllMutex.RLock() + defer fake.disconnectAllMutex.RUnlock() + return len(fake.disconnectAllArgsForCall) } -func (fake *FakeBlockDeviceMounterUtils) RescanAllArgsForCall(i int) (string, bool, bool) { - fake.rescanAllMutex.RLock() - defer fake.rescanAllMutex.RUnlock() - return fake.rescanAllArgsForCall[i].wwn, fake.rescanAllArgsForCall[i].rescanForCleanUp, fake.rescanAllArgsForCall[i].extraLunZeroScanning +func (fake *FakeBlockDeviceMounterUtils) DisconnectAllCalls(stub func(*resources.VolumeMountProperties) error) { + fake.disconnectAllMutex.Lock() + defer fake.disconnectAllMutex.Unlock() + fake.DisconnectAllStub = stub } -func (fake *FakeBlockDeviceMounterUtils) RescanAllReturns(result1 error) { - fake.RescanAllStub = nil - fake.rescanAllReturns = struct { +func (fake *FakeBlockDeviceMounterUtils) DisconnectAllArgsForCall(i int) *resources.VolumeMountProperties { + fake.disconnectAllMutex.RLock() + defer fake.disconnectAllMutex.RUnlock() + argsForCall := fake.disconnectAllArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeBlockDeviceMounterUtils) DisconnectAllReturns(result1 error) { + fake.disconnectAllMutex.Lock() + defer fake.disconnectAllMutex.Unlock() + fake.DisconnectAllStub = nil + fake.disconnectAllReturns = struct { result1 error }{result1} } -func (fake *FakeBlockDeviceMounterUtils) RescanAllReturnsOnCall(i int, result1 error) { - fake.RescanAllStub = nil - if fake.rescanAllReturnsOnCall == nil { - fake.rescanAllReturnsOnCall = make(map[int]struct { +func (fake *FakeBlockDeviceMounterUtils) DisconnectAllReturnsOnCall(i int, result1 error) { + fake.disconnectAllMutex.Lock() + defer fake.disconnectAllMutex.Unlock() + fake.DisconnectAllStub = nil + if fake.disconnectAllReturnsOnCall == nil { + fake.disconnectAllReturnsOnCall = make(map[int]struct { result1 error }) } - fake.rescanAllReturnsOnCall[i] = struct { + fake.disconnectAllReturnsOnCall[i] = struct { result1 error }{result1} } -func (fake *FakeBlockDeviceMounterUtils) MountDeviceFlow(devicePath string, fsType string, mountPoint string) error { +func (fake *FakeBlockDeviceMounterUtils) Discover(arg1 string, arg2 bool) (string, error) { + fake.discoverMutex.Lock() + ret, specificReturn := fake.discoverReturnsOnCall[len(fake.discoverArgsForCall)] + fake.discoverArgsForCall = append(fake.discoverArgsForCall, struct { + arg1 string + arg2 bool + }{arg1, arg2}) + fake.recordInvocation("Discover", []interface{}{arg1, arg2}) + fake.discoverMutex.Unlock() + if fake.DiscoverStub != nil { + return fake.DiscoverStub(arg1, arg2) + } + if specificReturn { + return ret.result1, ret.result2 + } + fakeReturns := fake.discoverReturns + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeBlockDeviceMounterUtils) DiscoverCallCount() int { + fake.discoverMutex.RLock() + defer fake.discoverMutex.RUnlock() + return len(fake.discoverArgsForCall) +} + +func (fake *FakeBlockDeviceMounterUtils) DiscoverCalls(stub func(string, bool) (string, error)) { + fake.discoverMutex.Lock() + defer fake.discoverMutex.Unlock() + fake.DiscoverStub = stub +} + +func (fake *FakeBlockDeviceMounterUtils) DiscoverArgsForCall(i int) (string, bool) { + fake.discoverMutex.RLock() + defer fake.discoverMutex.RUnlock() + argsForCall := fake.discoverArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeBlockDeviceMounterUtils) DiscoverReturns(result1 string, result2 error) { + fake.discoverMutex.Lock() + defer fake.discoverMutex.Unlock() + fake.DiscoverStub = nil + fake.discoverReturns = struct { + result1 string + result2 error + }{result1, result2} +} + +func (fake *FakeBlockDeviceMounterUtils) DiscoverReturnsOnCall(i int, result1 string, result2 error) { + fake.discoverMutex.Lock() + defer fake.discoverMutex.Unlock() + fake.DiscoverStub = nil + if fake.discoverReturnsOnCall == nil { + fake.discoverReturnsOnCall = make(map[int]struct { + result1 string + result2 error + }) + } + fake.discoverReturnsOnCall[i] = struct { + result1 string + result2 error + }{result1, result2} +} + +func (fake *FakeBlockDeviceMounterUtils) MountDeviceFlow(arg1 string, arg2 string, arg3 string) error { fake.mountDeviceFlowMutex.Lock() ret, specificReturn := fake.mountDeviceFlowReturnsOnCall[len(fake.mountDeviceFlowArgsForCall)] fake.mountDeviceFlowArgsForCall = append(fake.mountDeviceFlowArgsForCall, struct { - devicePath string - fsType string - mountPoint string - }{devicePath, fsType, mountPoint}) - fake.recordInvocation("MountDeviceFlow", []interface{}{devicePath, fsType, mountPoint}) + arg1 string + arg2 string + arg3 string + }{arg1, arg2, arg3}) + fake.recordInvocation("MountDeviceFlow", []interface{}{arg1, arg2, arg3}) fake.mountDeviceFlowMutex.Unlock() if fake.MountDeviceFlowStub != nil { - return fake.MountDeviceFlowStub(devicePath, fsType, mountPoint) + return fake.MountDeviceFlowStub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - return fake.mountDeviceFlowReturns.result1 + fakeReturns := fake.mountDeviceFlowReturns + return fakeReturns.result1 } func (fake *FakeBlockDeviceMounterUtils) MountDeviceFlowCallCount() int { @@ -139,13 +224,22 @@ func (fake *FakeBlockDeviceMounterUtils) MountDeviceFlowCallCount() int { return len(fake.mountDeviceFlowArgsForCall) } +func (fake *FakeBlockDeviceMounterUtils) MountDeviceFlowCalls(stub func(string, string, string) error) { + fake.mountDeviceFlowMutex.Lock() + defer fake.mountDeviceFlowMutex.Unlock() + fake.MountDeviceFlowStub = stub +} + func (fake *FakeBlockDeviceMounterUtils) MountDeviceFlowArgsForCall(i int) (string, string, string) { fake.mountDeviceFlowMutex.RLock() defer fake.mountDeviceFlowMutex.RUnlock() - return fake.mountDeviceFlowArgsForCall[i].devicePath, fake.mountDeviceFlowArgsForCall[i].fsType, fake.mountDeviceFlowArgsForCall[i].mountPoint + argsForCall := fake.mountDeviceFlowArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 } func (fake *FakeBlockDeviceMounterUtils) MountDeviceFlowReturns(result1 error) { + fake.mountDeviceFlowMutex.Lock() + defer fake.mountDeviceFlowMutex.Unlock() fake.MountDeviceFlowStub = nil fake.mountDeviceFlowReturns = struct { result1 error @@ -153,6 +247,8 @@ func (fake *FakeBlockDeviceMounterUtils) MountDeviceFlowReturns(result1 error) { } func (fake *FakeBlockDeviceMounterUtils) MountDeviceFlowReturnsOnCall(i int, result1 error) { + fake.mountDeviceFlowMutex.Lock() + defer fake.mountDeviceFlowMutex.Unlock() fake.MountDeviceFlowStub = nil if fake.mountDeviceFlowReturnsOnCall == nil { fake.mountDeviceFlowReturnsOnCall = make(map[int]struct { @@ -164,74 +260,83 @@ func (fake *FakeBlockDeviceMounterUtils) MountDeviceFlowReturnsOnCall(i int, res }{result1} } -func (fake *FakeBlockDeviceMounterUtils) Discover(volumeWwn string, deepDiscovery bool) (string, error) { - fake.discoverMutex.Lock() - ret, specificReturn := fake.discoverReturnsOnCall[len(fake.discoverArgsForCall)] - fake.discoverArgsForCall = append(fake.discoverArgsForCall, struct { - volumeWwn string - deepDiscovery bool - }{volumeWwn, deepDiscovery}) - fake.recordInvocation("Discover", []interface{}{volumeWwn, deepDiscovery}) - fake.discoverMutex.Unlock() - if fake.DiscoverStub != nil { - return fake.DiscoverStub(volumeWwn, deepDiscovery) +func (fake *FakeBlockDeviceMounterUtils) RescanAll(arg1 *resources.VolumeMountProperties) error { + fake.rescanAllMutex.Lock() + ret, specificReturn := fake.rescanAllReturnsOnCall[len(fake.rescanAllArgsForCall)] + fake.rescanAllArgsForCall = append(fake.rescanAllArgsForCall, struct { + arg1 *resources.VolumeMountProperties + }{arg1}) + fake.recordInvocation("RescanAll", []interface{}{arg1}) + fake.rescanAllMutex.Unlock() + if fake.RescanAllStub != nil { + return fake.RescanAllStub(arg1) } if specificReturn { - return ret.result1, ret.result2 + return ret.result1 } - return fake.discoverReturns.result1, fake.discoverReturns.result2 + fakeReturns := fake.rescanAllReturns + return fakeReturns.result1 } -func (fake *FakeBlockDeviceMounterUtils) DiscoverCallCount() int { - fake.discoverMutex.RLock() - defer fake.discoverMutex.RUnlock() - return len(fake.discoverArgsForCall) +func (fake *FakeBlockDeviceMounterUtils) RescanAllCallCount() int { + fake.rescanAllMutex.RLock() + defer fake.rescanAllMutex.RUnlock() + return len(fake.rescanAllArgsForCall) } -func (fake *FakeBlockDeviceMounterUtils) DiscoverArgsForCall(i int) (string, bool) { - fake.discoverMutex.RLock() - defer fake.discoverMutex.RUnlock() - return fake.discoverArgsForCall[i].volumeWwn, fake.discoverArgsForCall[i].deepDiscovery +func (fake *FakeBlockDeviceMounterUtils) RescanAllCalls(stub func(*resources.VolumeMountProperties) error) { + fake.rescanAllMutex.Lock() + defer fake.rescanAllMutex.Unlock() + fake.RescanAllStub = stub } -func (fake *FakeBlockDeviceMounterUtils) DiscoverReturns(result1 string, result2 error) { - fake.DiscoverStub = nil - fake.discoverReturns = struct { - result1 string - result2 error - }{result1, result2} +func (fake *FakeBlockDeviceMounterUtils) RescanAllArgsForCall(i int) *resources.VolumeMountProperties { + fake.rescanAllMutex.RLock() + defer fake.rescanAllMutex.RUnlock() + argsForCall := fake.rescanAllArgsForCall[i] + return argsForCall.arg1 } -func (fake *FakeBlockDeviceMounterUtils) DiscoverReturnsOnCall(i int, result1 string, result2 error) { - fake.DiscoverStub = nil - if fake.discoverReturnsOnCall == nil { - fake.discoverReturnsOnCall = make(map[int]struct { - result1 string - result2 error +func (fake *FakeBlockDeviceMounterUtils) RescanAllReturns(result1 error) { + fake.rescanAllMutex.Lock() + defer fake.rescanAllMutex.Unlock() + fake.RescanAllStub = nil + fake.rescanAllReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeBlockDeviceMounterUtils) RescanAllReturnsOnCall(i int, result1 error) { + fake.rescanAllMutex.Lock() + defer fake.rescanAllMutex.Unlock() + fake.RescanAllStub = nil + if fake.rescanAllReturnsOnCall == nil { + fake.rescanAllReturnsOnCall = make(map[int]struct { + result1 error }) } - fake.discoverReturnsOnCall[i] = struct { - result1 string - result2 error - }{result1, result2} + fake.rescanAllReturnsOnCall[i] = struct { + result1 error + }{result1} } -func (fake *FakeBlockDeviceMounterUtils) UnmountDeviceFlow(devicePath string, volumeWwn string) error { +func (fake *FakeBlockDeviceMounterUtils) UnmountDeviceFlow(arg1 string, arg2 string) error { fake.unmountDeviceFlowMutex.Lock() ret, specificReturn := fake.unmountDeviceFlowReturnsOnCall[len(fake.unmountDeviceFlowArgsForCall)] fake.unmountDeviceFlowArgsForCall = append(fake.unmountDeviceFlowArgsForCall, struct { - devicePath string - volumeWwn string - }{devicePath, volumeWwn}) - fake.recordInvocation("UnmountDeviceFlow", []interface{}{devicePath, volumeWwn}) + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("UnmountDeviceFlow", []interface{}{arg1, arg2}) fake.unmountDeviceFlowMutex.Unlock() if fake.UnmountDeviceFlowStub != nil { - return fake.UnmountDeviceFlowStub(devicePath, volumeWwn) + return fake.UnmountDeviceFlowStub(arg1, arg2) } if specificReturn { return ret.result1 } - return fake.unmountDeviceFlowReturns.result1 + fakeReturns := fake.unmountDeviceFlowReturns + return fakeReturns.result1 } func (fake *FakeBlockDeviceMounterUtils) UnmountDeviceFlowCallCount() int { @@ -240,13 +345,22 @@ func (fake *FakeBlockDeviceMounterUtils) UnmountDeviceFlowCallCount() int { return len(fake.unmountDeviceFlowArgsForCall) } +func (fake *FakeBlockDeviceMounterUtils) UnmountDeviceFlowCalls(stub func(string, string) error) { + fake.unmountDeviceFlowMutex.Lock() + defer fake.unmountDeviceFlowMutex.Unlock() + fake.UnmountDeviceFlowStub = stub +} + func (fake *FakeBlockDeviceMounterUtils) UnmountDeviceFlowArgsForCall(i int) (string, string) { fake.unmountDeviceFlowMutex.RLock() defer fake.unmountDeviceFlowMutex.RUnlock() - return fake.unmountDeviceFlowArgsForCall[i].devicePath, fake.unmountDeviceFlowArgsForCall[i].volumeWwn + argsForCall := fake.unmountDeviceFlowArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } func (fake *FakeBlockDeviceMounterUtils) UnmountDeviceFlowReturns(result1 error) { + fake.unmountDeviceFlowMutex.Lock() + defer fake.unmountDeviceFlowMutex.Unlock() fake.UnmountDeviceFlowStub = nil fake.unmountDeviceFlowReturns = struct { result1 error @@ -254,6 +368,8 @@ func (fake *FakeBlockDeviceMounterUtils) UnmountDeviceFlowReturns(result1 error) } func (fake *FakeBlockDeviceMounterUtils) UnmountDeviceFlowReturnsOnCall(i int, result1 error) { + fake.unmountDeviceFlowMutex.Lock() + defer fake.unmountDeviceFlowMutex.Unlock() fake.UnmountDeviceFlowStub = nil if fake.unmountDeviceFlowReturnsOnCall == nil { fake.unmountDeviceFlowReturnsOnCall = make(map[int]struct { @@ -268,12 +384,14 @@ func (fake *FakeBlockDeviceMounterUtils) UnmountDeviceFlowReturnsOnCall(i int, r func (fake *FakeBlockDeviceMounterUtils) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() - fake.rescanAllMutex.RLock() - defer fake.rescanAllMutex.RUnlock() - fake.mountDeviceFlowMutex.RLock() - defer fake.mountDeviceFlowMutex.RUnlock() + fake.disconnectAllMutex.RLock() + defer fake.disconnectAllMutex.RUnlock() fake.discoverMutex.RLock() defer fake.discoverMutex.RUnlock() + fake.mountDeviceFlowMutex.RLock() + defer fake.mountDeviceFlowMutex.RUnlock() + fake.rescanAllMutex.RLock() + defer fake.rescanAllMutex.RUnlock() fake.unmountDeviceFlowMutex.RLock() defer fake.unmountDeviceFlowMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} diff --git a/fakes/fake_block_device_utils.go b/fakes/fake_block_device_utils.go index 850d50e0..2d00c2da 100644 --- a/fakes/fake_block_device_utils.go +++ b/fakes/fake_block_device_utils.go @@ -5,43 +5,51 @@ import ( "sync" "github.com/IBM/ubiquity/remote/mounter/block_device_utils" + "github.com/IBM/ubiquity/resources" ) type FakeBlockDeviceUtils struct { - RescanStub func(protocol block_device_utils.Protocol) error - rescanMutex sync.RWMutex - rescanArgsForCall []struct { - protocol block_device_utils.Protocol + CheckFsStub func(string) (bool, error) + checkFsMutex sync.RWMutex + checkFsArgsForCall []struct { + arg1 string } - rescanReturns struct { - result1 error + checkFsReturns struct { + result1 bool + result2 error } - rescanReturnsOnCall map[int]struct { - result1 error + checkFsReturnsOnCall map[int]struct { + result1 bool + result2 error + } + CleanupStub func(string) error + cleanupMutex sync.RWMutex + cleanupArgsForCall []struct { + arg1 string } - RescanSCSILun0Stub func() error - rescanSCSILun0Mutex sync.RWMutex - rescanSCSILun0ArgsForCall []struct{} - rescanSCSILun0Returns struct { + cleanupReturns struct { result1 error } - rescanSCSILun0ReturnsOnCall map[int]struct { + cleanupReturnsOnCall map[int]struct { result1 error } - ReloadMultipathStub func() error - reloadMultipathMutex sync.RWMutex - reloadMultipathArgsForCall []struct{} - reloadMultipathReturns struct { + DisconnectStub func(block_device_utils.Protocol, *resources.VolumeMountProperties) error + disconnectMutex sync.RWMutex + disconnectArgsForCall []struct { + arg1 block_device_utils.Protocol + arg2 *resources.VolumeMountProperties + } + disconnectReturns struct { result1 error } - reloadMultipathReturnsOnCall map[int]struct { + disconnectReturnsOnCall map[int]struct { result1 error } - DiscoverStub func(volumeWwn string, deepDiscovery bool) (string, error) + DiscoverStub func(string, bool) (string, error) discoverMutex sync.RWMutex discoverArgsForCall []struct { - volumeWwn string - deepDiscovery bool + arg1 string + arg2 bool } discoverReturns struct { result1 string @@ -51,63 +59,69 @@ type FakeBlockDeviceUtils struct { result1 string result2 error } - GetWwnByScsiInqStub func(mpathOutput string, dev string) (string, error) - getWwnByScsiInqMutex sync.RWMutex - getWwnByScsiInqArgsForCall []struct { - mpathOutput string - dev string + DiscoverBySgInqStub func(string, string) (string, error) + discoverBySgInqMutex sync.RWMutex + discoverBySgInqArgsForCall []struct { + arg1 string + arg2 string } - getWwnByScsiInqReturns struct { + discoverBySgInqReturns struct { result1 string result2 error } - getWwnByScsiInqReturnsOnCall map[int]struct { + discoverBySgInqReturnsOnCall map[int]struct { result1 string result2 error } - DiscoverBySgInqStub func(mpathOutput string, volumeWwn string) (string, error) - discoverBySgInqMutex sync.RWMutex - discoverBySgInqArgsForCall []struct { - mpathOutput string - volumeWwn string + GetWwnByScsiInqStub func(string, string) (string, error) + getWwnByScsiInqMutex sync.RWMutex + getWwnByScsiInqArgsForCall []struct { + arg1 string + arg2 string } - discoverBySgInqReturns struct { + getWwnByScsiInqReturns struct { result1 string result2 error } - discoverBySgInqReturnsOnCall map[int]struct { + getWwnByScsiInqReturnsOnCall map[int]struct { result1 string result2 error } - CleanupStub func(mpath string) error - cleanupMutex sync.RWMutex - cleanupArgsForCall []struct { - mpath string + IsDeviceMountedStub func(string) (bool, []string, error) + isDeviceMountedMutex sync.RWMutex + isDeviceMountedArgsForCall []struct { + arg1 string } - cleanupReturns struct { - result1 error + isDeviceMountedReturns struct { + result1 bool + result2 []string + result3 error } - cleanupReturnsOnCall map[int]struct { - result1 error + isDeviceMountedReturnsOnCall map[int]struct { + result1 bool + result2 []string + result3 error } - CheckFsStub func(mpath string) (bool, error) - checkFsMutex sync.RWMutex - checkFsArgsForCall []struct { - mpath string + IsDirAMountPointStub func(string) (bool, []string, error) + isDirAMountPointMutex sync.RWMutex + isDirAMountPointArgsForCall []struct { + arg1 string } - checkFsReturns struct { + isDirAMountPointReturns struct { result1 bool - result2 error + result2 []string + result3 error } - checkFsReturnsOnCall map[int]struct { + isDirAMountPointReturnsOnCall map[int]struct { result1 bool - result2 error + result2 []string + result3 error } - MakeFsStub func(mpath string, fsType string) error + MakeFsStub func(string, string) error makeFsMutex sync.RWMutex makeFsArgsForCall []struct { - mpath string - fsType string + arg1 string + arg2 string } makeFsReturns struct { result1 error @@ -115,11 +129,11 @@ type FakeBlockDeviceUtils struct { makeFsReturnsOnCall map[int]struct { result1 error } - MountFsStub func(mpath string, mpoint string) error + MountFsStub func(string, string) error mountFsMutex sync.RWMutex mountFsArgsForCall []struct { - mpath string - mpoint string + arg1 string + arg2 string } mountFsReturns struct { result1 error @@ -127,52 +141,32 @@ type FakeBlockDeviceUtils struct { mountFsReturnsOnCall map[int]struct { result1 error } - UmountFsStub func(mpoint string, volumeWwn string) error - umountFsMutex sync.RWMutex - umountFsArgsForCall []struct { - mpoint string - volumeWwn string + ReloadMultipathStub func() error + reloadMultipathMutex sync.RWMutex + reloadMultipathArgsForCall []struct { } - umountFsReturns struct { + reloadMultipathReturns struct { result1 error } - umountFsReturnsOnCall map[int]struct { + reloadMultipathReturnsOnCall map[int]struct { result1 error } - IsDeviceMountedStub func(devPath string) (bool, []string, error) - isDeviceMountedMutex sync.RWMutex - isDeviceMountedArgsForCall []struct { - devPath string - } - isDeviceMountedReturns struct { - result1 bool - result2 []string - result3 error - } - isDeviceMountedReturnsOnCall map[int]struct { - result1 bool - result2 []string - result3 error - } - IsDirAMountPointStub func(dirPath string) (bool, []string, error) - isDirAMountPointMutex sync.RWMutex - isDirAMountPointArgsForCall []struct { - dirPath string + RescanStub func(block_device_utils.Protocol, *resources.VolumeMountProperties) error + rescanMutex sync.RWMutex + rescanArgsForCall []struct { + arg1 block_device_utils.Protocol + arg2 *resources.VolumeMountProperties } - isDirAMountPointReturns struct { - result1 bool - result2 []string - result3 error + rescanReturns struct { + result1 error } - isDirAMountPointReturnsOnCall map[int]struct { - result1 bool - result2 []string - result3 error + rescanReturnsOnCall map[int]struct { + result1 error } - SetDmsetupStub func(mpath string) error + SetDmsetupStub func(string) error setDmsetupMutex sync.RWMutex setDmsetupArgsForCall []struct { - mpath string + arg1 string } setDmsetupReturns struct { result1 error @@ -180,154 +174,223 @@ type FakeBlockDeviceUtils struct { setDmsetupReturnsOnCall map[int]struct { result1 error } + UmountFsStub func(string, string) error + umountFsMutex sync.RWMutex + umountFsArgsForCall []struct { + arg1 string + arg2 string + } + umountFsReturns struct { + result1 error + } + umountFsReturnsOnCall map[int]struct { + result1 error + } invocations map[string][][]interface{} invocationsMutex sync.RWMutex } -func (fake *FakeBlockDeviceUtils) Rescan(protocol block_device_utils.Protocol) error { - fake.rescanMutex.Lock() - ret, specificReturn := fake.rescanReturnsOnCall[len(fake.rescanArgsForCall)] - fake.rescanArgsForCall = append(fake.rescanArgsForCall, struct { - protocol block_device_utils.Protocol - }{protocol}) - fake.recordInvocation("Rescan", []interface{}{protocol}) - fake.rescanMutex.Unlock() - if fake.RescanStub != nil { - return fake.RescanStub(protocol) +func (fake *FakeBlockDeviceUtils) CheckFs(arg1 string) (bool, error) { + fake.checkFsMutex.Lock() + ret, specificReturn := fake.checkFsReturnsOnCall[len(fake.checkFsArgsForCall)] + fake.checkFsArgsForCall = append(fake.checkFsArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("CheckFs", []interface{}{arg1}) + fake.checkFsMutex.Unlock() + if fake.CheckFsStub != nil { + return fake.CheckFsStub(arg1) } if specificReturn { - return ret.result1 + return ret.result1, ret.result2 } - return fake.rescanReturns.result1 + fakeReturns := fake.checkFsReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeBlockDeviceUtils) RescanCallCount() int { - fake.rescanMutex.RLock() - defer fake.rescanMutex.RUnlock() - return len(fake.rescanArgsForCall) +func (fake *FakeBlockDeviceUtils) CheckFsCallCount() int { + fake.checkFsMutex.RLock() + defer fake.checkFsMutex.RUnlock() + return len(fake.checkFsArgsForCall) } -func (fake *FakeBlockDeviceUtils) RescanArgsForCall(i int) block_device_utils.Protocol { - fake.rescanMutex.RLock() - defer fake.rescanMutex.RUnlock() - return fake.rescanArgsForCall[i].protocol +func (fake *FakeBlockDeviceUtils) CheckFsCalls(stub func(string) (bool, error)) { + fake.checkFsMutex.Lock() + defer fake.checkFsMutex.Unlock() + fake.CheckFsStub = stub } -func (fake *FakeBlockDeviceUtils) RescanReturns(result1 error) { - fake.RescanStub = nil - fake.rescanReturns = struct { - result1 error - }{result1} +func (fake *FakeBlockDeviceUtils) CheckFsArgsForCall(i int) string { + fake.checkFsMutex.RLock() + defer fake.checkFsMutex.RUnlock() + argsForCall := fake.checkFsArgsForCall[i] + return argsForCall.arg1 } -func (fake *FakeBlockDeviceUtils) RescanReturnsOnCall(i int, result1 error) { - fake.RescanStub = nil - if fake.rescanReturnsOnCall == nil { - fake.rescanReturnsOnCall = make(map[int]struct { - result1 error +func (fake *FakeBlockDeviceUtils) CheckFsReturns(result1 bool, result2 error) { + fake.checkFsMutex.Lock() + defer fake.checkFsMutex.Unlock() + fake.CheckFsStub = nil + fake.checkFsReturns = struct { + result1 bool + result2 error + }{result1, result2} +} + +func (fake *FakeBlockDeviceUtils) CheckFsReturnsOnCall(i int, result1 bool, result2 error) { + fake.checkFsMutex.Lock() + defer fake.checkFsMutex.Unlock() + fake.CheckFsStub = nil + if fake.checkFsReturnsOnCall == nil { + fake.checkFsReturnsOnCall = make(map[int]struct { + result1 bool + result2 error }) } - fake.rescanReturnsOnCall[i] = struct { - result1 error - }{result1} + fake.checkFsReturnsOnCall[i] = struct { + result1 bool + result2 error + }{result1, result2} } -func (fake *FakeBlockDeviceUtils) RescanSCSILun0() error { - fake.rescanSCSILun0Mutex.Lock() - ret, specificReturn := fake.rescanSCSILun0ReturnsOnCall[len(fake.rescanSCSILun0ArgsForCall)] - fake.rescanSCSILun0ArgsForCall = append(fake.rescanSCSILun0ArgsForCall, struct{}{}) - fake.recordInvocation("RescanSCSILun0", []interface{}{}) - fake.rescanSCSILun0Mutex.Unlock() - if fake.RescanSCSILun0Stub != nil { - return fake.RescanSCSILun0Stub() +func (fake *FakeBlockDeviceUtils) Cleanup(arg1 string) error { + fake.cleanupMutex.Lock() + ret, specificReturn := fake.cleanupReturnsOnCall[len(fake.cleanupArgsForCall)] + fake.cleanupArgsForCall = append(fake.cleanupArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("Cleanup", []interface{}{arg1}) + fake.cleanupMutex.Unlock() + if fake.CleanupStub != nil { + return fake.CleanupStub(arg1) } if specificReturn { return ret.result1 } - return fake.rescanSCSILun0Returns.result1 + fakeReturns := fake.cleanupReturns + return fakeReturns.result1 +} + +func (fake *FakeBlockDeviceUtils) CleanupCallCount() int { + fake.cleanupMutex.RLock() + defer fake.cleanupMutex.RUnlock() + return len(fake.cleanupArgsForCall) } -func (fake *FakeBlockDeviceUtils) RescanSCSILun0CallCount() int { - fake.rescanSCSILun0Mutex.RLock() - defer fake.rescanSCSILun0Mutex.RUnlock() - return len(fake.rescanSCSILun0ArgsForCall) +func (fake *FakeBlockDeviceUtils) CleanupCalls(stub func(string) error) { + fake.cleanupMutex.Lock() + defer fake.cleanupMutex.Unlock() + fake.CleanupStub = stub +} + +func (fake *FakeBlockDeviceUtils) CleanupArgsForCall(i int) string { + fake.cleanupMutex.RLock() + defer fake.cleanupMutex.RUnlock() + argsForCall := fake.cleanupArgsForCall[i] + return argsForCall.arg1 } -func (fake *FakeBlockDeviceUtils) RescanSCSILun0Returns(result1 error) { - fake.RescanSCSILun0Stub = nil - fake.rescanSCSILun0Returns = struct { +func (fake *FakeBlockDeviceUtils) CleanupReturns(result1 error) { + fake.cleanupMutex.Lock() + defer fake.cleanupMutex.Unlock() + fake.CleanupStub = nil + fake.cleanupReturns = struct { result1 error }{result1} } -func (fake *FakeBlockDeviceUtils) RescanSCSILun0ReturnsOnCall(i int, result1 error) { - fake.RescanSCSILun0Stub = nil - if fake.rescanSCSILun0ReturnsOnCall == nil { - fake.rescanSCSILun0ReturnsOnCall = make(map[int]struct { +func (fake *FakeBlockDeviceUtils) CleanupReturnsOnCall(i int, result1 error) { + fake.cleanupMutex.Lock() + defer fake.cleanupMutex.Unlock() + fake.CleanupStub = nil + if fake.cleanupReturnsOnCall == nil { + fake.cleanupReturnsOnCall = make(map[int]struct { result1 error }) } - fake.rescanSCSILun0ReturnsOnCall[i] = struct { + fake.cleanupReturnsOnCall[i] = struct { result1 error }{result1} } -func (fake *FakeBlockDeviceUtils) ReloadMultipath() error { - fake.reloadMultipathMutex.Lock() - ret, specificReturn := fake.reloadMultipathReturnsOnCall[len(fake.reloadMultipathArgsForCall)] - fake.reloadMultipathArgsForCall = append(fake.reloadMultipathArgsForCall, struct{}{}) - fake.recordInvocation("ReloadMultipath", []interface{}{}) - fake.reloadMultipathMutex.Unlock() - if fake.ReloadMultipathStub != nil { - return fake.ReloadMultipathStub() +func (fake *FakeBlockDeviceUtils) Disconnect(arg1 block_device_utils.Protocol, arg2 *resources.VolumeMountProperties) error { + fake.disconnectMutex.Lock() + ret, specificReturn := fake.disconnectReturnsOnCall[len(fake.disconnectArgsForCall)] + fake.disconnectArgsForCall = append(fake.disconnectArgsForCall, struct { + arg1 block_device_utils.Protocol + arg2 *resources.VolumeMountProperties + }{arg1, arg2}) + fake.recordInvocation("Disconnect", []interface{}{arg1, arg2}) + fake.disconnectMutex.Unlock() + if fake.DisconnectStub != nil { + return fake.DisconnectStub(arg1, arg2) } if specificReturn { return ret.result1 } - return fake.reloadMultipathReturns.result1 + fakeReturns := fake.disconnectReturns + return fakeReturns.result1 } -func (fake *FakeBlockDeviceUtils) ReloadMultipathCallCount() int { - fake.reloadMultipathMutex.RLock() - defer fake.reloadMultipathMutex.RUnlock() - return len(fake.reloadMultipathArgsForCall) +func (fake *FakeBlockDeviceUtils) DisconnectCallCount() int { + fake.disconnectMutex.RLock() + defer fake.disconnectMutex.RUnlock() + return len(fake.disconnectArgsForCall) } -func (fake *FakeBlockDeviceUtils) ReloadMultipathReturns(result1 error) { - fake.ReloadMultipathStub = nil - fake.reloadMultipathReturns = struct { +func (fake *FakeBlockDeviceUtils) DisconnectCalls(stub func(block_device_utils.Protocol, *resources.VolumeMountProperties) error) { + fake.disconnectMutex.Lock() + defer fake.disconnectMutex.Unlock() + fake.DisconnectStub = stub +} + +func (fake *FakeBlockDeviceUtils) DisconnectArgsForCall(i int) (block_device_utils.Protocol, *resources.VolumeMountProperties) { + fake.disconnectMutex.RLock() + defer fake.disconnectMutex.RUnlock() + argsForCall := fake.disconnectArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeBlockDeviceUtils) DisconnectReturns(result1 error) { + fake.disconnectMutex.Lock() + defer fake.disconnectMutex.Unlock() + fake.DisconnectStub = nil + fake.disconnectReturns = struct { result1 error }{result1} } -func (fake *FakeBlockDeviceUtils) ReloadMultipathReturnsOnCall(i int, result1 error) { - fake.ReloadMultipathStub = nil - if fake.reloadMultipathReturnsOnCall == nil { - fake.reloadMultipathReturnsOnCall = make(map[int]struct { +func (fake *FakeBlockDeviceUtils) DisconnectReturnsOnCall(i int, result1 error) { + fake.disconnectMutex.Lock() + defer fake.disconnectMutex.Unlock() + fake.DisconnectStub = nil + if fake.disconnectReturnsOnCall == nil { + fake.disconnectReturnsOnCall = make(map[int]struct { result1 error }) } - fake.reloadMultipathReturnsOnCall[i] = struct { + fake.disconnectReturnsOnCall[i] = struct { result1 error }{result1} } -func (fake *FakeBlockDeviceUtils) Discover(volumeWwn string, deepDiscovery bool) (string, error) { +func (fake *FakeBlockDeviceUtils) Discover(arg1 string, arg2 bool) (string, error) { fake.discoverMutex.Lock() ret, specificReturn := fake.discoverReturnsOnCall[len(fake.discoverArgsForCall)] fake.discoverArgsForCall = append(fake.discoverArgsForCall, struct { - volumeWwn string - deepDiscovery bool - }{volumeWwn, deepDiscovery}) - fake.recordInvocation("Discover", []interface{}{volumeWwn, deepDiscovery}) + arg1 string + arg2 bool + }{arg1, arg2}) + fake.recordInvocation("Discover", []interface{}{arg1, arg2}) fake.discoverMutex.Unlock() if fake.DiscoverStub != nil { - return fake.DiscoverStub(volumeWwn, deepDiscovery) + return fake.DiscoverStub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - return fake.discoverReturns.result1, fake.discoverReturns.result2 + fakeReturns := fake.discoverReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeBlockDeviceUtils) DiscoverCallCount() int { @@ -336,13 +399,22 @@ func (fake *FakeBlockDeviceUtils) DiscoverCallCount() int { return len(fake.discoverArgsForCall) } +func (fake *FakeBlockDeviceUtils) DiscoverCalls(stub func(string, bool) (string, error)) { + fake.discoverMutex.Lock() + defer fake.discoverMutex.Unlock() + fake.DiscoverStub = stub +} + func (fake *FakeBlockDeviceUtils) DiscoverArgsForCall(i int) (string, bool) { fake.discoverMutex.RLock() defer fake.discoverMutex.RUnlock() - return fake.discoverArgsForCall[i].volumeWwn, fake.discoverArgsForCall[i].deepDiscovery + argsForCall := fake.discoverArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } func (fake *FakeBlockDeviceUtils) DiscoverReturns(result1 string, result2 error) { + fake.discoverMutex.Lock() + defer fake.discoverMutex.Unlock() fake.DiscoverStub = nil fake.discoverReturns = struct { result1 string @@ -351,6 +423,8 @@ func (fake *FakeBlockDeviceUtils) DiscoverReturns(result1 string, result2 error) } func (fake *FakeBlockDeviceUtils) DiscoverReturnsOnCall(i int, result1 string, result2 error) { + fake.discoverMutex.Lock() + defer fake.discoverMutex.Unlock() fake.DiscoverStub = nil if fake.discoverReturnsOnCall == nil { fake.discoverReturnsOnCall = make(map[int]struct { @@ -364,225 +438,283 @@ func (fake *FakeBlockDeviceUtils) DiscoverReturnsOnCall(i int, result1 string, r }{result1, result2} } -func (fake *FakeBlockDeviceUtils) GetWwnByScsiInq(mpathOutput string, dev string) (string, error) { - fake.getWwnByScsiInqMutex.Lock() - ret, specificReturn := fake.getWwnByScsiInqReturnsOnCall[len(fake.getWwnByScsiInqArgsForCall)] - fake.getWwnByScsiInqArgsForCall = append(fake.getWwnByScsiInqArgsForCall, struct { - mpathOutput string - dev string - }{mpathOutput, dev}) - fake.recordInvocation("GetWwnByScsiInq", []interface{}{mpathOutput, dev}) - fake.getWwnByScsiInqMutex.Unlock() - if fake.GetWwnByScsiInqStub != nil { - return fake.GetWwnByScsiInqStub(mpathOutput, dev) +func (fake *FakeBlockDeviceUtils) DiscoverBySgInq(arg1 string, arg2 string) (string, error) { + fake.discoverBySgInqMutex.Lock() + ret, specificReturn := fake.discoverBySgInqReturnsOnCall[len(fake.discoverBySgInqArgsForCall)] + fake.discoverBySgInqArgsForCall = append(fake.discoverBySgInqArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("DiscoverBySgInq", []interface{}{arg1, arg2}) + fake.discoverBySgInqMutex.Unlock() + if fake.DiscoverBySgInqStub != nil { + return fake.DiscoverBySgInqStub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - return fake.getWwnByScsiInqReturns.result1, fake.getWwnByScsiInqReturns.result2 + fakeReturns := fake.discoverBySgInqReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeBlockDeviceUtils) GetWwnByScsiInqCallCount() int { - fake.getWwnByScsiInqMutex.RLock() - defer fake.getWwnByScsiInqMutex.RUnlock() - return len(fake.getWwnByScsiInqArgsForCall) +func (fake *FakeBlockDeviceUtils) DiscoverBySgInqCallCount() int { + fake.discoverBySgInqMutex.RLock() + defer fake.discoverBySgInqMutex.RUnlock() + return len(fake.discoverBySgInqArgsForCall) } -func (fake *FakeBlockDeviceUtils) GetWwnByScsiInqArgsForCall(i int) (string, string) { - fake.getWwnByScsiInqMutex.RLock() - defer fake.getWwnByScsiInqMutex.RUnlock() - return fake.getWwnByScsiInqArgsForCall[i].mpathOutput, fake.getWwnByScsiInqArgsForCall[i].dev +func (fake *FakeBlockDeviceUtils) DiscoverBySgInqCalls(stub func(string, string) (string, error)) { + fake.discoverBySgInqMutex.Lock() + defer fake.discoverBySgInqMutex.Unlock() + fake.DiscoverBySgInqStub = stub } -func (fake *FakeBlockDeviceUtils) GetWwnByScsiInqReturns(result1 string, result2 error) { - fake.GetWwnByScsiInqStub = nil - fake.getWwnByScsiInqReturns = struct { - result1 string - result2 error - }{result1, result2} +func (fake *FakeBlockDeviceUtils) DiscoverBySgInqArgsForCall(i int) (string, string) { + fake.discoverBySgInqMutex.RLock() + defer fake.discoverBySgInqMutex.RUnlock() + argsForCall := fake.discoverBySgInqArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } -func (fake *FakeBlockDeviceUtils) GetWwnByScsiInqReturnsOnCall(i int, result1 string, result2 error) { - fake.GetWwnByScsiInqStub = nil - if fake.getWwnByScsiInqReturnsOnCall == nil { - fake.getWwnByScsiInqReturnsOnCall = make(map[int]struct { +func (fake *FakeBlockDeviceUtils) DiscoverBySgInqReturns(result1 string, result2 error) { + fake.discoverBySgInqMutex.Lock() + defer fake.discoverBySgInqMutex.Unlock() + fake.DiscoverBySgInqStub = nil + fake.discoverBySgInqReturns = struct { + result1 string + result2 error + }{result1, result2} +} + +func (fake *FakeBlockDeviceUtils) DiscoverBySgInqReturnsOnCall(i int, result1 string, result2 error) { + fake.discoverBySgInqMutex.Lock() + defer fake.discoverBySgInqMutex.Unlock() + fake.DiscoverBySgInqStub = nil + if fake.discoverBySgInqReturnsOnCall == nil { + fake.discoverBySgInqReturnsOnCall = make(map[int]struct { result1 string result2 error }) } - fake.getWwnByScsiInqReturnsOnCall[i] = struct { + fake.discoverBySgInqReturnsOnCall[i] = struct { result1 string result2 error }{result1, result2} } -func (fake *FakeBlockDeviceUtils) DiscoverBySgInq(mpathOutput string, volumeWwn string) (string, error) { - fake.discoverBySgInqMutex.Lock() - ret, specificReturn := fake.discoverBySgInqReturnsOnCall[len(fake.discoverBySgInqArgsForCall)] - fake.discoverBySgInqArgsForCall = append(fake.discoverBySgInqArgsForCall, struct { - mpathOutput string - volumeWwn string - }{mpathOutput, volumeWwn}) - fake.recordInvocation("DiscoverBySgInq", []interface{}{mpathOutput, volumeWwn}) - fake.discoverBySgInqMutex.Unlock() - if fake.DiscoverBySgInqStub != nil { - return fake.DiscoverBySgInqStub(mpathOutput, volumeWwn) +func (fake *FakeBlockDeviceUtils) GetWwnByScsiInq(arg1 string, arg2 string) (string, error) { + fake.getWwnByScsiInqMutex.Lock() + ret, specificReturn := fake.getWwnByScsiInqReturnsOnCall[len(fake.getWwnByScsiInqArgsForCall)] + fake.getWwnByScsiInqArgsForCall = append(fake.getWwnByScsiInqArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("GetWwnByScsiInq", []interface{}{arg1, arg2}) + fake.getWwnByScsiInqMutex.Unlock() + if fake.GetWwnByScsiInqStub != nil { + return fake.GetWwnByScsiInqStub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - return fake.discoverBySgInqReturns.result1, fake.discoverBySgInqReturns.result2 + fakeReturns := fake.getWwnByScsiInqReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeBlockDeviceUtils) DiscoverBySgInqCallCount() int { - fake.discoverBySgInqMutex.RLock() - defer fake.discoverBySgInqMutex.RUnlock() - return len(fake.discoverBySgInqArgsForCall) +func (fake *FakeBlockDeviceUtils) GetWwnByScsiInqCallCount() int { + fake.getWwnByScsiInqMutex.RLock() + defer fake.getWwnByScsiInqMutex.RUnlock() + return len(fake.getWwnByScsiInqArgsForCall) } -func (fake *FakeBlockDeviceUtils) DiscoverBySgInqArgsForCall(i int) (string, string) { - fake.discoverBySgInqMutex.RLock() - defer fake.discoverBySgInqMutex.RUnlock() - return fake.discoverBySgInqArgsForCall[i].mpathOutput, fake.discoverBySgInqArgsForCall[i].volumeWwn +func (fake *FakeBlockDeviceUtils) GetWwnByScsiInqCalls(stub func(string, string) (string, error)) { + fake.getWwnByScsiInqMutex.Lock() + defer fake.getWwnByScsiInqMutex.Unlock() + fake.GetWwnByScsiInqStub = stub } -func (fake *FakeBlockDeviceUtils) DiscoverBySgInqReturns(result1 string, result2 error) { - fake.DiscoverBySgInqStub = nil - fake.discoverBySgInqReturns = struct { +func (fake *FakeBlockDeviceUtils) GetWwnByScsiInqArgsForCall(i int) (string, string) { + fake.getWwnByScsiInqMutex.RLock() + defer fake.getWwnByScsiInqMutex.RUnlock() + argsForCall := fake.getWwnByScsiInqArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeBlockDeviceUtils) GetWwnByScsiInqReturns(result1 string, result2 error) { + fake.getWwnByScsiInqMutex.Lock() + defer fake.getWwnByScsiInqMutex.Unlock() + fake.GetWwnByScsiInqStub = nil + fake.getWwnByScsiInqReturns = struct { result1 string result2 error }{result1, result2} } -func (fake *FakeBlockDeviceUtils) DiscoverBySgInqReturnsOnCall(i int, result1 string, result2 error) { - fake.DiscoverBySgInqStub = nil - if fake.discoverBySgInqReturnsOnCall == nil { - fake.discoverBySgInqReturnsOnCall = make(map[int]struct { +func (fake *FakeBlockDeviceUtils) GetWwnByScsiInqReturnsOnCall(i int, result1 string, result2 error) { + fake.getWwnByScsiInqMutex.Lock() + defer fake.getWwnByScsiInqMutex.Unlock() + fake.GetWwnByScsiInqStub = nil + if fake.getWwnByScsiInqReturnsOnCall == nil { + fake.getWwnByScsiInqReturnsOnCall = make(map[int]struct { result1 string result2 error }) } - fake.discoverBySgInqReturnsOnCall[i] = struct { + fake.getWwnByScsiInqReturnsOnCall[i] = struct { result1 string result2 error }{result1, result2} } -func (fake *FakeBlockDeviceUtils) Cleanup(mpath string) error { - fake.cleanupMutex.Lock() - ret, specificReturn := fake.cleanupReturnsOnCall[len(fake.cleanupArgsForCall)] - fake.cleanupArgsForCall = append(fake.cleanupArgsForCall, struct { - mpath string - }{mpath}) - fake.recordInvocation("Cleanup", []interface{}{mpath}) - fake.cleanupMutex.Unlock() - if fake.CleanupStub != nil { - return fake.CleanupStub(mpath) +func (fake *FakeBlockDeviceUtils) IsDeviceMounted(arg1 string) (bool, []string, error) { + fake.isDeviceMountedMutex.Lock() + ret, specificReturn := fake.isDeviceMountedReturnsOnCall[len(fake.isDeviceMountedArgsForCall)] + fake.isDeviceMountedArgsForCall = append(fake.isDeviceMountedArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("IsDeviceMounted", []interface{}{arg1}) + fake.isDeviceMountedMutex.Unlock() + if fake.IsDeviceMountedStub != nil { + return fake.IsDeviceMountedStub(arg1) } if specificReturn { - return ret.result1 + return ret.result1, ret.result2, ret.result3 } - return fake.cleanupReturns.result1 + fakeReturns := fake.isDeviceMountedReturns + return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } -func (fake *FakeBlockDeviceUtils) CleanupCallCount() int { - fake.cleanupMutex.RLock() - defer fake.cleanupMutex.RUnlock() - return len(fake.cleanupArgsForCall) +func (fake *FakeBlockDeviceUtils) IsDeviceMountedCallCount() int { + fake.isDeviceMountedMutex.RLock() + defer fake.isDeviceMountedMutex.RUnlock() + return len(fake.isDeviceMountedArgsForCall) } -func (fake *FakeBlockDeviceUtils) CleanupArgsForCall(i int) string { - fake.cleanupMutex.RLock() - defer fake.cleanupMutex.RUnlock() - return fake.cleanupArgsForCall[i].mpath +func (fake *FakeBlockDeviceUtils) IsDeviceMountedCalls(stub func(string) (bool, []string, error)) { + fake.isDeviceMountedMutex.Lock() + defer fake.isDeviceMountedMutex.Unlock() + fake.IsDeviceMountedStub = stub } -func (fake *FakeBlockDeviceUtils) CleanupReturns(result1 error) { - fake.CleanupStub = nil - fake.cleanupReturns = struct { - result1 error - }{result1} +func (fake *FakeBlockDeviceUtils) IsDeviceMountedArgsForCall(i int) string { + fake.isDeviceMountedMutex.RLock() + defer fake.isDeviceMountedMutex.RUnlock() + argsForCall := fake.isDeviceMountedArgsForCall[i] + return argsForCall.arg1 } -func (fake *FakeBlockDeviceUtils) CleanupReturnsOnCall(i int, result1 error) { - fake.CleanupStub = nil - if fake.cleanupReturnsOnCall == nil { - fake.cleanupReturnsOnCall = make(map[int]struct { - result1 error +func (fake *FakeBlockDeviceUtils) IsDeviceMountedReturns(result1 bool, result2 []string, result3 error) { + fake.isDeviceMountedMutex.Lock() + defer fake.isDeviceMountedMutex.Unlock() + fake.IsDeviceMountedStub = nil + fake.isDeviceMountedReturns = struct { + result1 bool + result2 []string + result3 error + }{result1, result2, result3} +} + +func (fake *FakeBlockDeviceUtils) IsDeviceMountedReturnsOnCall(i int, result1 bool, result2 []string, result3 error) { + fake.isDeviceMountedMutex.Lock() + defer fake.isDeviceMountedMutex.Unlock() + fake.IsDeviceMountedStub = nil + if fake.isDeviceMountedReturnsOnCall == nil { + fake.isDeviceMountedReturnsOnCall = make(map[int]struct { + result1 bool + result2 []string + result3 error }) } - fake.cleanupReturnsOnCall[i] = struct { - result1 error - }{result1} + fake.isDeviceMountedReturnsOnCall[i] = struct { + result1 bool + result2 []string + result3 error + }{result1, result2, result3} } -func (fake *FakeBlockDeviceUtils) CheckFs(mpath string) (bool, error) { - fake.checkFsMutex.Lock() - ret, specificReturn := fake.checkFsReturnsOnCall[len(fake.checkFsArgsForCall)] - fake.checkFsArgsForCall = append(fake.checkFsArgsForCall, struct { - mpath string - }{mpath}) - fake.recordInvocation("CheckFs", []interface{}{mpath}) - fake.checkFsMutex.Unlock() - if fake.CheckFsStub != nil { - return fake.CheckFsStub(mpath) +func (fake *FakeBlockDeviceUtils) IsDirAMountPoint(arg1 string) (bool, []string, error) { + fake.isDirAMountPointMutex.Lock() + ret, specificReturn := fake.isDirAMountPointReturnsOnCall[len(fake.isDirAMountPointArgsForCall)] + fake.isDirAMountPointArgsForCall = append(fake.isDirAMountPointArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("IsDirAMountPoint", []interface{}{arg1}) + fake.isDirAMountPointMutex.Unlock() + if fake.IsDirAMountPointStub != nil { + return fake.IsDirAMountPointStub(arg1) } if specificReturn { - return ret.result1, ret.result2 + return ret.result1, ret.result2, ret.result3 } - return fake.checkFsReturns.result1, fake.checkFsReturns.result2 + fakeReturns := fake.isDirAMountPointReturns + return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } -func (fake *FakeBlockDeviceUtils) CheckFsCallCount() int { - fake.checkFsMutex.RLock() - defer fake.checkFsMutex.RUnlock() - return len(fake.checkFsArgsForCall) +func (fake *FakeBlockDeviceUtils) IsDirAMountPointCallCount() int { + fake.isDirAMountPointMutex.RLock() + defer fake.isDirAMountPointMutex.RUnlock() + return len(fake.isDirAMountPointArgsForCall) } -func (fake *FakeBlockDeviceUtils) CheckFsArgsForCall(i int) string { - fake.checkFsMutex.RLock() - defer fake.checkFsMutex.RUnlock() - return fake.checkFsArgsForCall[i].mpath +func (fake *FakeBlockDeviceUtils) IsDirAMountPointCalls(stub func(string) (bool, []string, error)) { + fake.isDirAMountPointMutex.Lock() + defer fake.isDirAMountPointMutex.Unlock() + fake.IsDirAMountPointStub = stub } -func (fake *FakeBlockDeviceUtils) CheckFsReturns(result1 bool, result2 error) { - fake.CheckFsStub = nil - fake.checkFsReturns = struct { +func (fake *FakeBlockDeviceUtils) IsDirAMountPointArgsForCall(i int) string { + fake.isDirAMountPointMutex.RLock() + defer fake.isDirAMountPointMutex.RUnlock() + argsForCall := fake.isDirAMountPointArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeBlockDeviceUtils) IsDirAMountPointReturns(result1 bool, result2 []string, result3 error) { + fake.isDirAMountPointMutex.Lock() + defer fake.isDirAMountPointMutex.Unlock() + fake.IsDirAMountPointStub = nil + fake.isDirAMountPointReturns = struct { result1 bool - result2 error - }{result1, result2} + result2 []string + result3 error + }{result1, result2, result3} } -func (fake *FakeBlockDeviceUtils) CheckFsReturnsOnCall(i int, result1 bool, result2 error) { - fake.CheckFsStub = nil - if fake.checkFsReturnsOnCall == nil { - fake.checkFsReturnsOnCall = make(map[int]struct { +func (fake *FakeBlockDeviceUtils) IsDirAMountPointReturnsOnCall(i int, result1 bool, result2 []string, result3 error) { + fake.isDirAMountPointMutex.Lock() + defer fake.isDirAMountPointMutex.Unlock() + fake.IsDirAMountPointStub = nil + if fake.isDirAMountPointReturnsOnCall == nil { + fake.isDirAMountPointReturnsOnCall = make(map[int]struct { result1 bool - result2 error + result2 []string + result3 error }) } - fake.checkFsReturnsOnCall[i] = struct { + fake.isDirAMountPointReturnsOnCall[i] = struct { result1 bool - result2 error - }{result1, result2} + result2 []string + result3 error + }{result1, result2, result3} } -func (fake *FakeBlockDeviceUtils) MakeFs(mpath string, fsType string) error { +func (fake *FakeBlockDeviceUtils) MakeFs(arg1 string, arg2 string) error { fake.makeFsMutex.Lock() ret, specificReturn := fake.makeFsReturnsOnCall[len(fake.makeFsArgsForCall)] fake.makeFsArgsForCall = append(fake.makeFsArgsForCall, struct { - mpath string - fsType string - }{mpath, fsType}) - fake.recordInvocation("MakeFs", []interface{}{mpath, fsType}) + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("MakeFs", []interface{}{arg1, arg2}) fake.makeFsMutex.Unlock() if fake.MakeFsStub != nil { - return fake.MakeFsStub(mpath, fsType) + return fake.MakeFsStub(arg1, arg2) } if specificReturn { return ret.result1 } - return fake.makeFsReturns.result1 + fakeReturns := fake.makeFsReturns + return fakeReturns.result1 } func (fake *FakeBlockDeviceUtils) MakeFsCallCount() int { @@ -591,13 +723,22 @@ func (fake *FakeBlockDeviceUtils) MakeFsCallCount() int { return len(fake.makeFsArgsForCall) } +func (fake *FakeBlockDeviceUtils) MakeFsCalls(stub func(string, string) error) { + fake.makeFsMutex.Lock() + defer fake.makeFsMutex.Unlock() + fake.MakeFsStub = stub +} + func (fake *FakeBlockDeviceUtils) MakeFsArgsForCall(i int) (string, string) { fake.makeFsMutex.RLock() defer fake.makeFsMutex.RUnlock() - return fake.makeFsArgsForCall[i].mpath, fake.makeFsArgsForCall[i].fsType + argsForCall := fake.makeFsArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } func (fake *FakeBlockDeviceUtils) MakeFsReturns(result1 error) { + fake.makeFsMutex.Lock() + defer fake.makeFsMutex.Unlock() fake.MakeFsStub = nil fake.makeFsReturns = struct { result1 error @@ -605,6 +746,8 @@ func (fake *FakeBlockDeviceUtils) MakeFsReturns(result1 error) { } func (fake *FakeBlockDeviceUtils) MakeFsReturnsOnCall(i int, result1 error) { + fake.makeFsMutex.Lock() + defer fake.makeFsMutex.Unlock() fake.MakeFsStub = nil if fake.makeFsReturnsOnCall == nil { fake.makeFsReturnsOnCall = make(map[int]struct { @@ -616,22 +759,23 @@ func (fake *FakeBlockDeviceUtils) MakeFsReturnsOnCall(i int, result1 error) { }{result1} } -func (fake *FakeBlockDeviceUtils) MountFs(mpath string, mpoint string) error { +func (fake *FakeBlockDeviceUtils) MountFs(arg1 string, arg2 string) error { fake.mountFsMutex.Lock() ret, specificReturn := fake.mountFsReturnsOnCall[len(fake.mountFsArgsForCall)] fake.mountFsArgsForCall = append(fake.mountFsArgsForCall, struct { - mpath string - mpoint string - }{mpath, mpoint}) - fake.recordInvocation("MountFs", []interface{}{mpath, mpoint}) + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("MountFs", []interface{}{arg1, arg2}) fake.mountFsMutex.Unlock() if fake.MountFsStub != nil { - return fake.MountFsStub(mpath, mpoint) + return fake.MountFsStub(arg1, arg2) } if specificReturn { return ret.result1 } - return fake.mountFsReturns.result1 + fakeReturns := fake.mountFsReturns + return fakeReturns.result1 } func (fake *FakeBlockDeviceUtils) MountFsCallCount() int { @@ -640,13 +784,22 @@ func (fake *FakeBlockDeviceUtils) MountFsCallCount() int { return len(fake.mountFsArgsForCall) } +func (fake *FakeBlockDeviceUtils) MountFsCalls(stub func(string, string) error) { + fake.mountFsMutex.Lock() + defer fake.mountFsMutex.Unlock() + fake.MountFsStub = stub +} + func (fake *FakeBlockDeviceUtils) MountFsArgsForCall(i int) (string, string) { fake.mountFsMutex.RLock() defer fake.mountFsMutex.RUnlock() - return fake.mountFsArgsForCall[i].mpath, fake.mountFsArgsForCall[i].mpoint + argsForCall := fake.mountFsArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } func (fake *FakeBlockDeviceUtils) MountFsReturns(result1 error) { + fake.mountFsMutex.Lock() + defer fake.mountFsMutex.Unlock() fake.MountFsStub = nil fake.mountFsReturns = struct { result1 error @@ -654,6 +807,8 @@ func (fake *FakeBlockDeviceUtils) MountFsReturns(result1 error) { } func (fake *FakeBlockDeviceUtils) MountFsReturnsOnCall(i int, result1 error) { + fake.mountFsMutex.Lock() + defer fake.mountFsMutex.Unlock() fake.MountFsStub = nil if fake.mountFsReturnsOnCall == nil { fake.mountFsReturnsOnCall = make(map[int]struct { @@ -665,178 +820,135 @@ func (fake *FakeBlockDeviceUtils) MountFsReturnsOnCall(i int, result1 error) { }{result1} } -func (fake *FakeBlockDeviceUtils) UmountFs(mpoint string, volumeWwn string) error { - fake.umountFsMutex.Lock() - ret, specificReturn := fake.umountFsReturnsOnCall[len(fake.umountFsArgsForCall)] - fake.umountFsArgsForCall = append(fake.umountFsArgsForCall, struct { - mpoint string - volumeWwn string - }{mpoint, volumeWwn}) - fake.recordInvocation("UmountFs", []interface{}{mpoint, volumeWwn}) - fake.umountFsMutex.Unlock() - if fake.UmountFsStub != nil { - return fake.UmountFsStub(mpoint, volumeWwn) +func (fake *FakeBlockDeviceUtils) ReloadMultipath() error { + fake.reloadMultipathMutex.Lock() + ret, specificReturn := fake.reloadMultipathReturnsOnCall[len(fake.reloadMultipathArgsForCall)] + fake.reloadMultipathArgsForCall = append(fake.reloadMultipathArgsForCall, struct { + }{}) + fake.recordInvocation("ReloadMultipath", []interface{}{}) + fake.reloadMultipathMutex.Unlock() + if fake.ReloadMultipathStub != nil { + return fake.ReloadMultipathStub() } if specificReturn { return ret.result1 } - return fake.umountFsReturns.result1 + fakeReturns := fake.reloadMultipathReturns + return fakeReturns.result1 } -func (fake *FakeBlockDeviceUtils) UmountFsCallCount() int { - fake.umountFsMutex.RLock() - defer fake.umountFsMutex.RUnlock() - return len(fake.umountFsArgsForCall) +func (fake *FakeBlockDeviceUtils) ReloadMultipathCallCount() int { + fake.reloadMultipathMutex.RLock() + defer fake.reloadMultipathMutex.RUnlock() + return len(fake.reloadMultipathArgsForCall) } -func (fake *FakeBlockDeviceUtils) UmountFsArgsForCall(i int) (string, string) { - fake.umountFsMutex.RLock() - defer fake.umountFsMutex.RUnlock() - return fake.umountFsArgsForCall[i].mpoint, fake.umountFsArgsForCall[i].volumeWwn +func (fake *FakeBlockDeviceUtils) ReloadMultipathCalls(stub func() error) { + fake.reloadMultipathMutex.Lock() + defer fake.reloadMultipathMutex.Unlock() + fake.ReloadMultipathStub = stub } -func (fake *FakeBlockDeviceUtils) UmountFsReturns(result1 error) { - fake.UmountFsStub = nil - fake.umountFsReturns = struct { +func (fake *FakeBlockDeviceUtils) ReloadMultipathReturns(result1 error) { + fake.reloadMultipathMutex.Lock() + defer fake.reloadMultipathMutex.Unlock() + fake.ReloadMultipathStub = nil + fake.reloadMultipathReturns = struct { result1 error }{result1} } -func (fake *FakeBlockDeviceUtils) UmountFsReturnsOnCall(i int, result1 error) { - fake.UmountFsStub = nil - if fake.umountFsReturnsOnCall == nil { - fake.umountFsReturnsOnCall = make(map[int]struct { +func (fake *FakeBlockDeviceUtils) ReloadMultipathReturnsOnCall(i int, result1 error) { + fake.reloadMultipathMutex.Lock() + defer fake.reloadMultipathMutex.Unlock() + fake.ReloadMultipathStub = nil + if fake.reloadMultipathReturnsOnCall == nil { + fake.reloadMultipathReturnsOnCall = make(map[int]struct { result1 error }) } - fake.umountFsReturnsOnCall[i] = struct { + fake.reloadMultipathReturnsOnCall[i] = struct { result1 error }{result1} } -func (fake *FakeBlockDeviceUtils) IsDeviceMounted(devPath string) (bool, []string, error) { - fake.isDeviceMountedMutex.Lock() - ret, specificReturn := fake.isDeviceMountedReturnsOnCall[len(fake.isDeviceMountedArgsForCall)] - fake.isDeviceMountedArgsForCall = append(fake.isDeviceMountedArgsForCall, struct { - devPath string - }{devPath}) - fake.recordInvocation("IsDeviceMounted", []interface{}{devPath}) - fake.isDeviceMountedMutex.Unlock() - if fake.IsDeviceMountedStub != nil { - return fake.IsDeviceMountedStub(devPath) +func (fake *FakeBlockDeviceUtils) Rescan(arg1 block_device_utils.Protocol, arg2 *resources.VolumeMountProperties) error { + fake.rescanMutex.Lock() + ret, specificReturn := fake.rescanReturnsOnCall[len(fake.rescanArgsForCall)] + fake.rescanArgsForCall = append(fake.rescanArgsForCall, struct { + arg1 block_device_utils.Protocol + arg2 *resources.VolumeMountProperties + }{arg1, arg2}) + fake.recordInvocation("Rescan", []interface{}{arg1, arg2}) + fake.rescanMutex.Unlock() + if fake.RescanStub != nil { + return fake.RescanStub(arg1, arg2) } if specificReturn { - return ret.result1, ret.result2, ret.result3 - } - return fake.isDeviceMountedReturns.result1, fake.isDeviceMountedReturns.result2, fake.isDeviceMountedReturns.result3 -} - -func (fake *FakeBlockDeviceUtils) IsDeviceMountedCallCount() int { - fake.isDeviceMountedMutex.RLock() - defer fake.isDeviceMountedMutex.RUnlock() - return len(fake.isDeviceMountedArgsForCall) -} - -func (fake *FakeBlockDeviceUtils) IsDeviceMountedArgsForCall(i int) string { - fake.isDeviceMountedMutex.RLock() - defer fake.isDeviceMountedMutex.RUnlock() - return fake.isDeviceMountedArgsForCall[i].devPath -} - -func (fake *FakeBlockDeviceUtils) IsDeviceMountedReturns(result1 bool, result2 []string, result3 error) { - fake.IsDeviceMountedStub = nil - fake.isDeviceMountedReturns = struct { - result1 bool - result2 []string - result3 error - }{result1, result2, result3} -} - -func (fake *FakeBlockDeviceUtils) IsDeviceMountedReturnsOnCall(i int, result1 bool, result2 []string, result3 error) { - fake.IsDeviceMountedStub = nil - if fake.isDeviceMountedReturnsOnCall == nil { - fake.isDeviceMountedReturnsOnCall = make(map[int]struct { - result1 bool - result2 []string - result3 error - }) + return ret.result1 } - fake.isDeviceMountedReturnsOnCall[i] = struct { - result1 bool - result2 []string - result3 error - }{result1, result2, result3} + fakeReturns := fake.rescanReturns + return fakeReturns.result1 } -func (fake *FakeBlockDeviceUtils) IsDirAMountPoint(dirPath string) (bool, []string, error) { - fake.isDirAMountPointMutex.Lock() - ret, specificReturn := fake.isDirAMountPointReturnsOnCall[len(fake.isDirAMountPointArgsForCall)] - fake.isDirAMountPointArgsForCall = append(fake.isDirAMountPointArgsForCall, struct { - dirPath string - }{dirPath}) - fake.recordInvocation("IsDirAMountPoint", []interface{}{dirPath}) - fake.isDirAMountPointMutex.Unlock() - if fake.IsDirAMountPointStub != nil { - return fake.IsDirAMountPointStub(dirPath) - } - if specificReturn { - return ret.result1, ret.result2, ret.result3 - } - return fake.isDirAMountPointReturns.result1, fake.isDirAMountPointReturns.result2, fake.isDirAMountPointReturns.result3 +func (fake *FakeBlockDeviceUtils) RescanCallCount() int { + fake.rescanMutex.RLock() + defer fake.rescanMutex.RUnlock() + return len(fake.rescanArgsForCall) } -func (fake *FakeBlockDeviceUtils) IsDirAMountPointCallCount() int { - fake.isDirAMountPointMutex.RLock() - defer fake.isDirAMountPointMutex.RUnlock() - return len(fake.isDirAMountPointArgsForCall) +func (fake *FakeBlockDeviceUtils) RescanCalls(stub func(block_device_utils.Protocol, *resources.VolumeMountProperties) error) { + fake.rescanMutex.Lock() + defer fake.rescanMutex.Unlock() + fake.RescanStub = stub } -func (fake *FakeBlockDeviceUtils) IsDirAMountPointArgsForCall(i int) string { - fake.isDirAMountPointMutex.RLock() - defer fake.isDirAMountPointMutex.RUnlock() - return fake.isDirAMountPointArgsForCall[i].dirPath +func (fake *FakeBlockDeviceUtils) RescanArgsForCall(i int) (block_device_utils.Protocol, *resources.VolumeMountProperties) { + fake.rescanMutex.RLock() + defer fake.rescanMutex.RUnlock() + argsForCall := fake.rescanArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } -func (fake *FakeBlockDeviceUtils) IsDirAMountPointReturns(result1 bool, result2 []string, result3 error) { - fake.IsDirAMountPointStub = nil - fake.isDirAMountPointReturns = struct { - result1 bool - result2 []string - result3 error - }{result1, result2, result3} +func (fake *FakeBlockDeviceUtils) RescanReturns(result1 error) { + fake.rescanMutex.Lock() + defer fake.rescanMutex.Unlock() + fake.RescanStub = nil + fake.rescanReturns = struct { + result1 error + }{result1} } -func (fake *FakeBlockDeviceUtils) IsDirAMountPointReturnsOnCall(i int, result1 bool, result2 []string, result3 error) { - fake.IsDirAMountPointStub = nil - if fake.isDirAMountPointReturnsOnCall == nil { - fake.isDirAMountPointReturnsOnCall = make(map[int]struct { - result1 bool - result2 []string - result3 error +func (fake *FakeBlockDeviceUtils) RescanReturnsOnCall(i int, result1 error) { + fake.rescanMutex.Lock() + defer fake.rescanMutex.Unlock() + fake.RescanStub = nil + if fake.rescanReturnsOnCall == nil { + fake.rescanReturnsOnCall = make(map[int]struct { + result1 error }) } - fake.isDirAMountPointReturnsOnCall[i] = struct { - result1 bool - result2 []string - result3 error - }{result1, result2, result3} + fake.rescanReturnsOnCall[i] = struct { + result1 error + }{result1} } -func (fake *FakeBlockDeviceUtils) SetDmsetup(mpath string) error { +func (fake *FakeBlockDeviceUtils) SetDmsetup(arg1 string) error { fake.setDmsetupMutex.Lock() ret, specificReturn := fake.setDmsetupReturnsOnCall[len(fake.setDmsetupArgsForCall)] fake.setDmsetupArgsForCall = append(fake.setDmsetupArgsForCall, struct { - mpath string - }{mpath}) - fake.recordInvocation("SetDmsetup", []interface{}{mpath}) + arg1 string + }{arg1}) + fake.recordInvocation("SetDmsetup", []interface{}{arg1}) fake.setDmsetupMutex.Unlock() if fake.SetDmsetupStub != nil { - return fake.SetDmsetupStub(mpath) + return fake.SetDmsetupStub(arg1) } if specificReturn { return ret.result1 } - return fake.setDmsetupReturns.result1 + fakeReturns := fake.setDmsetupReturns + return fakeReturns.result1 } func (fake *FakeBlockDeviceUtils) SetDmsetupCallCount() int { @@ -845,13 +957,22 @@ func (fake *FakeBlockDeviceUtils) SetDmsetupCallCount() int { return len(fake.setDmsetupArgsForCall) } +func (fake *FakeBlockDeviceUtils) SetDmsetupCalls(stub func(string) error) { + fake.setDmsetupMutex.Lock() + defer fake.setDmsetupMutex.Unlock() + fake.SetDmsetupStub = stub +} + func (fake *FakeBlockDeviceUtils) SetDmsetupArgsForCall(i int) string { fake.setDmsetupMutex.RLock() defer fake.setDmsetupMutex.RUnlock() - return fake.setDmsetupArgsForCall[i].mpath + argsForCall := fake.setDmsetupArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeBlockDeviceUtils) SetDmsetupReturns(result1 error) { + fake.setDmsetupMutex.Lock() + defer fake.setDmsetupMutex.Unlock() fake.SetDmsetupStub = nil fake.setDmsetupReturns = struct { result1 error @@ -859,6 +980,8 @@ func (fake *FakeBlockDeviceUtils) SetDmsetupReturns(result1 error) { } func (fake *FakeBlockDeviceUtils) SetDmsetupReturnsOnCall(i int, result1 error) { + fake.setDmsetupMutex.Lock() + defer fake.setDmsetupMutex.Unlock() fake.SetDmsetupStub = nil if fake.setDmsetupReturnsOnCall == nil { fake.setDmsetupReturnsOnCall = make(map[int]struct { @@ -870,37 +993,98 @@ func (fake *FakeBlockDeviceUtils) SetDmsetupReturnsOnCall(i int, result1 error) }{result1} } +func (fake *FakeBlockDeviceUtils) UmountFs(arg1 string, arg2 string) error { + fake.umountFsMutex.Lock() + ret, specificReturn := fake.umountFsReturnsOnCall[len(fake.umountFsArgsForCall)] + fake.umountFsArgsForCall = append(fake.umountFsArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("UmountFs", []interface{}{arg1, arg2}) + fake.umountFsMutex.Unlock() + if fake.UmountFsStub != nil { + return fake.UmountFsStub(arg1, arg2) + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.umountFsReturns + return fakeReturns.result1 +} + +func (fake *FakeBlockDeviceUtils) UmountFsCallCount() int { + fake.umountFsMutex.RLock() + defer fake.umountFsMutex.RUnlock() + return len(fake.umountFsArgsForCall) +} + +func (fake *FakeBlockDeviceUtils) UmountFsCalls(stub func(string, string) error) { + fake.umountFsMutex.Lock() + defer fake.umountFsMutex.Unlock() + fake.UmountFsStub = stub +} + +func (fake *FakeBlockDeviceUtils) UmountFsArgsForCall(i int) (string, string) { + fake.umountFsMutex.RLock() + defer fake.umountFsMutex.RUnlock() + argsForCall := fake.umountFsArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeBlockDeviceUtils) UmountFsReturns(result1 error) { + fake.umountFsMutex.Lock() + defer fake.umountFsMutex.Unlock() + fake.UmountFsStub = nil + fake.umountFsReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeBlockDeviceUtils) UmountFsReturnsOnCall(i int, result1 error) { + fake.umountFsMutex.Lock() + defer fake.umountFsMutex.Unlock() + fake.UmountFsStub = nil + if fake.umountFsReturnsOnCall == nil { + fake.umountFsReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.umountFsReturnsOnCall[i] = struct { + result1 error + }{result1} +} + func (fake *FakeBlockDeviceUtils) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() - fake.rescanMutex.RLock() - defer fake.rescanMutex.RUnlock() - fake.rescanSCSILun0Mutex.RLock() - defer fake.rescanSCSILun0Mutex.RUnlock() - fake.reloadMultipathMutex.RLock() - defer fake.reloadMultipathMutex.RUnlock() + fake.checkFsMutex.RLock() + defer fake.checkFsMutex.RUnlock() + fake.cleanupMutex.RLock() + defer fake.cleanupMutex.RUnlock() + fake.disconnectMutex.RLock() + defer fake.disconnectMutex.RUnlock() fake.discoverMutex.RLock() defer fake.discoverMutex.RUnlock() - fake.getWwnByScsiInqMutex.RLock() - defer fake.getWwnByScsiInqMutex.RUnlock() fake.discoverBySgInqMutex.RLock() defer fake.discoverBySgInqMutex.RUnlock() - fake.cleanupMutex.RLock() - defer fake.cleanupMutex.RUnlock() - fake.checkFsMutex.RLock() - defer fake.checkFsMutex.RUnlock() - fake.makeFsMutex.RLock() - defer fake.makeFsMutex.RUnlock() - fake.mountFsMutex.RLock() - defer fake.mountFsMutex.RUnlock() - fake.umountFsMutex.RLock() - defer fake.umountFsMutex.RUnlock() + fake.getWwnByScsiInqMutex.RLock() + defer fake.getWwnByScsiInqMutex.RUnlock() fake.isDeviceMountedMutex.RLock() defer fake.isDeviceMountedMutex.RUnlock() fake.isDirAMountPointMutex.RLock() defer fake.isDirAMountPointMutex.RUnlock() + fake.makeFsMutex.RLock() + defer fake.makeFsMutex.RUnlock() + fake.mountFsMutex.RLock() + defer fake.mountFsMutex.RUnlock() + fake.reloadMultipathMutex.RLock() + defer fake.reloadMultipathMutex.RUnlock() + fake.rescanMutex.RLock() + defer fake.rescanMutex.RUnlock() fake.setDmsetupMutex.RLock() defer fake.setDmsetupMutex.RUnlock() + fake.umountFsMutex.RLock() + defer fake.umountFsMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} for key, value := range fake.invocations { copiedInvocations[key] = value diff --git a/fakes/fake_executor.go b/fakes/fake_executor.go index a2da0012..931a575c 100644 --- a/fakes/fake_executor.go +++ b/fakes/fake_executor.go @@ -9,11 +9,24 @@ import ( ) type FakeExecutor struct { - ExecuteStub func(command string, args []string) ([]byte, error) + EvalSymlinksStub func(string) (string, error) + evalSymlinksMutex sync.RWMutex + evalSymlinksArgsForCall []struct { + arg1 string + } + evalSymlinksReturns struct { + result1 string + result2 error + } + evalSymlinksReturnsOnCall map[int]struct { + result1 string + result2 error + } + ExecuteStub func(string, []string) ([]byte, error) executeMutex sync.RWMutex executeArgsForCall []struct { - command string - args []string + arg1 string + arg2 []string } executeReturns struct { result1 []byte @@ -23,74 +36,79 @@ type FakeExecutor struct { result1 []byte result2 error } - StatStub func(string) (os.FileInfo, error) - statMutex sync.RWMutex - statArgsForCall []struct { - arg1 string + ExecuteWithTimeoutStub func(int, string, []string) ([]byte, error) + executeWithTimeoutMutex sync.RWMutex + executeWithTimeoutArgsForCall []struct { + arg1 int + arg2 string + arg3 []string } - statReturns struct { - result1 os.FileInfo + executeWithTimeoutReturns struct { + result1 []byte result2 error } - statReturnsOnCall map[int]struct { - result1 os.FileInfo + executeWithTimeoutReturnsOnCall map[int]struct { + result1 []byte result2 error } - MkdirStub func(string, os.FileMode) error - mkdirMutex sync.RWMutex - mkdirArgsForCall []struct { - arg1 string - arg2 os.FileMode + GetDeviceForFileStatStub func(os.FileInfo) uint64 + getDeviceForFileStatMutex sync.RWMutex + getDeviceForFileStatArgsForCall []struct { + arg1 os.FileInfo } - mkdirReturns struct { - result1 error + getDeviceForFileStatReturns struct { + result1 uint64 } - mkdirReturnsOnCall map[int]struct { - result1 error + getDeviceForFileStatReturnsOnCall map[int]struct { + result1 uint64 } - MkdirAllStub func(string, os.FileMode) error - mkdirAllMutex sync.RWMutex - mkdirAllArgsForCall []struct { + GetGlobFilesStub func(string) ([]string, error) + getGlobFilesMutex sync.RWMutex + getGlobFilesArgsForCall []struct { arg1 string - arg2 os.FileMode } - mkdirAllReturns struct { - result1 error + getGlobFilesReturns struct { + result1 []string + result2 error } - mkdirAllReturnsOnCall map[int]struct { - result1 error + getGlobFilesReturnsOnCall map[int]struct { + result1 []string + result2 error } - RemoveAllStub func(string) error - removeAllMutex sync.RWMutex - removeAllArgsForCall []struct { - arg1 string + HostnameStub func() (string, error) + hostnameMutex sync.RWMutex + hostnameArgsForCall []struct { } - removeAllReturns struct { - result1 error + hostnameReturns struct { + result1 string + result2 error } - removeAllReturnsOnCall map[int]struct { - result1 error + hostnameReturnsOnCall map[int]struct { + result1 string + result2 error } - RemoveStub func(string) error - removeMutex sync.RWMutex - removeArgsForCall []struct { - arg1 string + IsDirStub func(os.FileInfo) bool + isDirMutex sync.RWMutex + isDirArgsForCall []struct { + arg1 os.FileInfo } - removeReturns struct { - result1 error + isDirReturns struct { + result1 bool } - removeReturnsOnCall map[int]struct { - result1 error + isDirReturnsOnCall map[int]struct { + result1 bool } - HostnameStub func() (string, error) - hostnameMutex sync.RWMutex - hostnameArgsForCall []struct{} - hostnameReturns struct { - result1 string + IsDirEmptyStub func(string) (bool, error) + isDirEmptyMutex sync.RWMutex + isDirEmptyArgsForCall []struct { + arg1 string + } + isDirEmptyReturns struct { + result1 bool result2 error } - hostnameReturnsOnCall map[int]struct { - result1 string + isDirEmptyReturnsOnCall map[int]struct { + result1 bool result2 error } IsExecutableStub func(string) error @@ -115,38 +133,33 @@ type FakeExecutor struct { isNotExistReturnsOnCall map[int]struct { result1 bool } - EvalSymlinksStub func(path string) (string, error) - evalSymlinksMutex sync.RWMutex - evalSymlinksArgsForCall []struct { - path string + IsSameFileStub func(os.FileInfo, os.FileInfo) bool + isSameFileMutex sync.RWMutex + isSameFileArgsForCall []struct { + arg1 os.FileInfo + arg2 os.FileInfo } - evalSymlinksReturns struct { - result1 string - result2 error + isSameFileReturns struct { + result1 bool } - evalSymlinksReturnsOnCall map[int]struct { - result1 string - result2 error + isSameFileReturnsOnCall map[int]struct { + result1 bool } - ExecuteWithTimeoutStub func(mSeconds int, command string, args []string) ([]byte, error) - executeWithTimeoutMutex sync.RWMutex - executeWithTimeoutArgsForCall []struct { - mSeconds int - command string - args []string + IsSlinkStub func(os.FileInfo) bool + isSlinkMutex sync.RWMutex + isSlinkArgsForCall []struct { + arg1 os.FileInfo } - executeWithTimeoutReturns struct { - result1 []byte - result2 error + isSlinkReturns struct { + result1 bool } - executeWithTimeoutReturnsOnCall map[int]struct { - result1 []byte - result2 error + isSlinkReturnsOnCall map[int]struct { + result1 bool } - LstatStub func(path string) (os.FileInfo, error) + LstatStub func(string) (os.FileInfo, error) lstatMutex sync.RWMutex lstatArgsForCall []struct { - path string + arg1 string } lstatReturns struct { result1 os.FileInfo @@ -156,399 +169,411 @@ type FakeExecutor struct { result1 os.FileInfo result2 error } - IsDirStub func(fInfo os.FileInfo) bool - isDirMutex sync.RWMutex - isDirArgsForCall []struct { - fInfo os.FileInfo - } - isDirReturns struct { - result1 bool - } - isDirReturnsOnCall map[int]struct { - result1 bool - } - SymlinkStub func(target string, slink string) error - symlinkMutex sync.RWMutex - symlinkArgsForCall []struct { - target string - slink string + MkdirStub func(string, os.FileMode) error + mkdirMutex sync.RWMutex + mkdirArgsForCall []struct { + arg1 string + arg2 os.FileMode } - symlinkReturns struct { + mkdirReturns struct { result1 error } - symlinkReturnsOnCall map[int]struct { + mkdirReturnsOnCall map[int]struct { result1 error } - IsSlinkStub func(fInfo os.FileInfo) bool - isSlinkMutex sync.RWMutex - isSlinkArgsForCall []struct { - fInfo os.FileInfo + MkdirAllStub func(string, os.FileMode) error + mkdirAllMutex sync.RWMutex + mkdirAllArgsForCall []struct { + arg1 string + arg2 os.FileMode } - isSlinkReturns struct { - result1 bool + mkdirAllReturns struct { + result1 error } - isSlinkReturnsOnCall map[int]struct { - result1 bool + mkdirAllReturnsOnCall map[int]struct { + result1 error } - GetGlobFilesStub func(file_pattern string) (matches []string, err error) - getGlobFilesMutex sync.RWMutex - getGlobFilesArgsForCall []struct { - file_pattern string + RemoveStub func(string) error + removeMutex sync.RWMutex + removeArgsForCall []struct { + arg1 string } - getGlobFilesReturns struct { - result1 []string - result2 error + removeReturns struct { + result1 error } - getGlobFilesReturnsOnCall map[int]struct { - result1 []string - result2 error + removeReturnsOnCall map[int]struct { + result1 error } - IsSameFileStub func(file1 os.FileInfo, file2 os.FileInfo) bool - isSameFileMutex sync.RWMutex - isSameFileArgsForCall []struct { - file1 os.FileInfo - file2 os.FileInfo + RemoveAllStub func(string) error + removeAllMutex sync.RWMutex + removeAllArgsForCall []struct { + arg1 string } - isSameFileReturns struct { - result1 bool + removeAllReturns struct { + result1 error } - isSameFileReturnsOnCall map[int]struct { - result1 bool + removeAllReturnsOnCall map[int]struct { + result1 error } - IsDirEmptyStub func(dir string) (bool, error) - isDirEmptyMutex sync.RWMutex - isDirEmptyArgsForCall []struct { - dir string + StatStub func(string) (os.FileInfo, error) + statMutex sync.RWMutex + statArgsForCall []struct { + arg1 string } - isDirEmptyReturns struct { - result1 bool + statReturns struct { + result1 os.FileInfo result2 error } - isDirEmptyReturnsOnCall map[int]struct { - result1 bool + statReturnsOnCall map[int]struct { + result1 os.FileInfo result2 error } - GetDeviceForFileStatStub func(os.FileInfo) uint64 - getDeviceForFileStatMutex sync.RWMutex - getDeviceForFileStatArgsForCall []struct { - arg1 os.FileInfo + SymlinkStub func(string, string) error + symlinkMutex sync.RWMutex + symlinkArgsForCall []struct { + arg1 string + arg2 string } - getDeviceForFileStatReturns struct { - result1 uint64 + symlinkReturns struct { + result1 error } - getDeviceForFileStatReturnsOnCall map[int]struct { - result1 uint64 + symlinkReturnsOnCall map[int]struct { + result1 error } invocations map[string][][]interface{} invocationsMutex sync.RWMutex } -func (fake *FakeExecutor) Execute(command string, args []string) ([]byte, error) { - var argsCopy []string - if args != nil { - argsCopy = make([]string, len(args)) - copy(argsCopy, args) - } - fake.executeMutex.Lock() - ret, specificReturn := fake.executeReturnsOnCall[len(fake.executeArgsForCall)] - fake.executeArgsForCall = append(fake.executeArgsForCall, struct { - command string - args []string - }{command, argsCopy}) - fake.recordInvocation("Execute", []interface{}{command, argsCopy}) - fake.executeMutex.Unlock() - if fake.ExecuteStub != nil { - return fake.ExecuteStub(command, args) +func (fake *FakeExecutor) EvalSymlinks(arg1 string) (string, error) { + fake.evalSymlinksMutex.Lock() + ret, specificReturn := fake.evalSymlinksReturnsOnCall[len(fake.evalSymlinksArgsForCall)] + fake.evalSymlinksArgsForCall = append(fake.evalSymlinksArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("EvalSymlinks", []interface{}{arg1}) + fake.evalSymlinksMutex.Unlock() + if fake.EvalSymlinksStub != nil { + return fake.EvalSymlinksStub(arg1) } if specificReturn { return ret.result1, ret.result2 } - return fake.executeReturns.result1, fake.executeReturns.result2 + fakeReturns := fake.evalSymlinksReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeExecutor) ExecuteCallCount() int { - fake.executeMutex.RLock() - defer fake.executeMutex.RUnlock() - return len(fake.executeArgsForCall) +func (fake *FakeExecutor) EvalSymlinksCallCount() int { + fake.evalSymlinksMutex.RLock() + defer fake.evalSymlinksMutex.RUnlock() + return len(fake.evalSymlinksArgsForCall) } -func (fake *FakeExecutor) ExecuteArgsForCall(i int) (string, []string) { - fake.executeMutex.RLock() - defer fake.executeMutex.RUnlock() - return fake.executeArgsForCall[i].command, fake.executeArgsForCall[i].args +func (fake *FakeExecutor) EvalSymlinksCalls(stub func(string) (string, error)) { + fake.evalSymlinksMutex.Lock() + defer fake.evalSymlinksMutex.Unlock() + fake.EvalSymlinksStub = stub } -func (fake *FakeExecutor) ExecuteReturns(result1 []byte, result2 error) { - fake.ExecuteStub = nil - fake.executeReturns = struct { - result1 []byte +func (fake *FakeExecutor) EvalSymlinksArgsForCall(i int) string { + fake.evalSymlinksMutex.RLock() + defer fake.evalSymlinksMutex.RUnlock() + argsForCall := fake.evalSymlinksArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeExecutor) EvalSymlinksReturns(result1 string, result2 error) { + fake.evalSymlinksMutex.Lock() + defer fake.evalSymlinksMutex.Unlock() + fake.EvalSymlinksStub = nil + fake.evalSymlinksReturns = struct { + result1 string result2 error }{result1, result2} } -func (fake *FakeExecutor) ExecuteReturnsOnCall(i int, result1 []byte, result2 error) { - fake.ExecuteStub = nil - if fake.executeReturnsOnCall == nil { - fake.executeReturnsOnCall = make(map[int]struct { - result1 []byte +func (fake *FakeExecutor) EvalSymlinksReturnsOnCall(i int, result1 string, result2 error) { + fake.evalSymlinksMutex.Lock() + defer fake.evalSymlinksMutex.Unlock() + fake.EvalSymlinksStub = nil + if fake.evalSymlinksReturnsOnCall == nil { + fake.evalSymlinksReturnsOnCall = make(map[int]struct { + result1 string result2 error }) } - fake.executeReturnsOnCall[i] = struct { - result1 []byte + fake.evalSymlinksReturnsOnCall[i] = struct { + result1 string result2 error }{result1, result2} } -func (fake *FakeExecutor) Stat(arg1 string) (os.FileInfo, error) { - fake.statMutex.Lock() - ret, specificReturn := fake.statReturnsOnCall[len(fake.statArgsForCall)] - fake.statArgsForCall = append(fake.statArgsForCall, struct { +func (fake *FakeExecutor) Execute(arg1 string, arg2 []string) ([]byte, error) { + var arg2Copy []string + if arg2 != nil { + arg2Copy = make([]string, len(arg2)) + copy(arg2Copy, arg2) + } + fake.executeMutex.Lock() + ret, specificReturn := fake.executeReturnsOnCall[len(fake.executeArgsForCall)] + fake.executeArgsForCall = append(fake.executeArgsForCall, struct { arg1 string - }{arg1}) - fake.recordInvocation("Stat", []interface{}{arg1}) - fake.statMutex.Unlock() - if fake.StatStub != nil { - return fake.StatStub(arg1) + arg2 []string + }{arg1, arg2Copy}) + fake.recordInvocation("Execute", []interface{}{arg1, arg2Copy}) + fake.executeMutex.Unlock() + if fake.ExecuteStub != nil { + return fake.ExecuteStub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - return fake.statReturns.result1, fake.statReturns.result2 + fakeReturns := fake.executeReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeExecutor) StatCallCount() int { - fake.statMutex.RLock() - defer fake.statMutex.RUnlock() - return len(fake.statArgsForCall) +func (fake *FakeExecutor) ExecuteCallCount() int { + fake.executeMutex.RLock() + defer fake.executeMutex.RUnlock() + return len(fake.executeArgsForCall) } -func (fake *FakeExecutor) StatArgsForCall(i int) string { - fake.statMutex.RLock() - defer fake.statMutex.RUnlock() - return fake.statArgsForCall[i].arg1 +func (fake *FakeExecutor) ExecuteCalls(stub func(string, []string) ([]byte, error)) { + fake.executeMutex.Lock() + defer fake.executeMutex.Unlock() + fake.ExecuteStub = stub } -func (fake *FakeExecutor) StatReturns(result1 os.FileInfo, result2 error) { - fake.StatStub = nil - fake.statReturns = struct { - result1 os.FileInfo +func (fake *FakeExecutor) ExecuteArgsForCall(i int) (string, []string) { + fake.executeMutex.RLock() + defer fake.executeMutex.RUnlock() + argsForCall := fake.executeArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeExecutor) ExecuteReturns(result1 []byte, result2 error) { + fake.executeMutex.Lock() + defer fake.executeMutex.Unlock() + fake.ExecuteStub = nil + fake.executeReturns = struct { + result1 []byte result2 error }{result1, result2} } -func (fake *FakeExecutor) StatReturnsOnCall(i int, result1 os.FileInfo, result2 error) { - fake.StatStub = nil - if fake.statReturnsOnCall == nil { - fake.statReturnsOnCall = make(map[int]struct { - result1 os.FileInfo +func (fake *FakeExecutor) ExecuteReturnsOnCall(i int, result1 []byte, result2 error) { + fake.executeMutex.Lock() + defer fake.executeMutex.Unlock() + fake.ExecuteStub = nil + if fake.executeReturnsOnCall == nil { + fake.executeReturnsOnCall = make(map[int]struct { + result1 []byte result2 error }) } - fake.statReturnsOnCall[i] = struct { - result1 os.FileInfo + fake.executeReturnsOnCall[i] = struct { + result1 []byte result2 error }{result1, result2} } -func (fake *FakeExecutor) Mkdir(arg1 string, arg2 os.FileMode) error { - fake.mkdirMutex.Lock() - ret, specificReturn := fake.mkdirReturnsOnCall[len(fake.mkdirArgsForCall)] - fake.mkdirArgsForCall = append(fake.mkdirArgsForCall, struct { - arg1 string - arg2 os.FileMode - }{arg1, arg2}) - fake.recordInvocation("Mkdir", []interface{}{arg1, arg2}) - fake.mkdirMutex.Unlock() - if fake.MkdirStub != nil { - return fake.MkdirStub(arg1, arg2) +func (fake *FakeExecutor) ExecuteWithTimeout(arg1 int, arg2 string, arg3 []string) ([]byte, error) { + var arg3Copy []string + if arg3 != nil { + arg3Copy = make([]string, len(arg3)) + copy(arg3Copy, arg3) } - if specificReturn { - return ret.result1 + fake.executeWithTimeoutMutex.Lock() + ret, specificReturn := fake.executeWithTimeoutReturnsOnCall[len(fake.executeWithTimeoutArgsForCall)] + fake.executeWithTimeoutArgsForCall = append(fake.executeWithTimeoutArgsForCall, struct { + arg1 int + arg2 string + arg3 []string + }{arg1, arg2, arg3Copy}) + fake.recordInvocation("ExecuteWithTimeout", []interface{}{arg1, arg2, arg3Copy}) + fake.executeWithTimeoutMutex.Unlock() + if fake.ExecuteWithTimeoutStub != nil { + return fake.ExecuteWithTimeoutStub(arg1, arg2, arg3) } - return fake.mkdirReturns.result1 -} - -func (fake *FakeExecutor) MkdirCallCount() int { - fake.mkdirMutex.RLock() - defer fake.mkdirMutex.RUnlock() - return len(fake.mkdirArgsForCall) -} - -func (fake *FakeExecutor) MkdirArgsForCall(i int) (string, os.FileMode) { - fake.mkdirMutex.RLock() - defer fake.mkdirMutex.RUnlock() - return fake.mkdirArgsForCall[i].arg1, fake.mkdirArgsForCall[i].arg2 -} - -func (fake *FakeExecutor) MkdirReturns(result1 error) { - fake.MkdirStub = nil - fake.mkdirReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeExecutor) MkdirReturnsOnCall(i int, result1 error) { - fake.MkdirStub = nil - if fake.mkdirReturnsOnCall == nil { - fake.mkdirReturnsOnCall = make(map[int]struct { - result1 error - }) + if specificReturn { + return ret.result1, ret.result2 } - fake.mkdirReturnsOnCall[i] = struct { - result1 error - }{result1} + fakeReturns := fake.executeWithTimeoutReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeExecutor) MkdirAll(arg1 string, arg2 os.FileMode) error { - fake.mkdirAllMutex.Lock() - ret, specificReturn := fake.mkdirAllReturnsOnCall[len(fake.mkdirAllArgsForCall)] - fake.mkdirAllArgsForCall = append(fake.mkdirAllArgsForCall, struct { - arg1 string - arg2 os.FileMode - }{arg1, arg2}) - fake.recordInvocation("MkdirAll", []interface{}{arg1, arg2}) - fake.mkdirAllMutex.Unlock() - if fake.MkdirAllStub != nil { - return fake.MkdirAllStub(arg1, arg2) - } - if specificReturn { - return ret.result1 - } - return fake.mkdirAllReturns.result1 +func (fake *FakeExecutor) ExecuteWithTimeoutCallCount() int { + fake.executeWithTimeoutMutex.RLock() + defer fake.executeWithTimeoutMutex.RUnlock() + return len(fake.executeWithTimeoutArgsForCall) } -func (fake *FakeExecutor) MkdirAllCallCount() int { - fake.mkdirAllMutex.RLock() - defer fake.mkdirAllMutex.RUnlock() - return len(fake.mkdirAllArgsForCall) +func (fake *FakeExecutor) ExecuteWithTimeoutCalls(stub func(int, string, []string) ([]byte, error)) { + fake.executeWithTimeoutMutex.Lock() + defer fake.executeWithTimeoutMutex.Unlock() + fake.ExecuteWithTimeoutStub = stub } -func (fake *FakeExecutor) MkdirAllArgsForCall(i int) (string, os.FileMode) { - fake.mkdirAllMutex.RLock() - defer fake.mkdirAllMutex.RUnlock() - return fake.mkdirAllArgsForCall[i].arg1, fake.mkdirAllArgsForCall[i].arg2 +func (fake *FakeExecutor) ExecuteWithTimeoutArgsForCall(i int) (int, string, []string) { + fake.executeWithTimeoutMutex.RLock() + defer fake.executeWithTimeoutMutex.RUnlock() + argsForCall := fake.executeWithTimeoutArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 } -func (fake *FakeExecutor) MkdirAllReturns(result1 error) { - fake.MkdirAllStub = nil - fake.mkdirAllReturns = struct { - result1 error - }{result1} +func (fake *FakeExecutor) ExecuteWithTimeoutReturns(result1 []byte, result2 error) { + fake.executeWithTimeoutMutex.Lock() + defer fake.executeWithTimeoutMutex.Unlock() + fake.ExecuteWithTimeoutStub = nil + fake.executeWithTimeoutReturns = struct { + result1 []byte + result2 error + }{result1, result2} } -func (fake *FakeExecutor) MkdirAllReturnsOnCall(i int, result1 error) { - fake.MkdirAllStub = nil - if fake.mkdirAllReturnsOnCall == nil { - fake.mkdirAllReturnsOnCall = make(map[int]struct { - result1 error +func (fake *FakeExecutor) ExecuteWithTimeoutReturnsOnCall(i int, result1 []byte, result2 error) { + fake.executeWithTimeoutMutex.Lock() + defer fake.executeWithTimeoutMutex.Unlock() + fake.ExecuteWithTimeoutStub = nil + if fake.executeWithTimeoutReturnsOnCall == nil { + fake.executeWithTimeoutReturnsOnCall = make(map[int]struct { + result1 []byte + result2 error }) } - fake.mkdirAllReturnsOnCall[i] = struct { - result1 error - }{result1} + fake.executeWithTimeoutReturnsOnCall[i] = struct { + result1 []byte + result2 error + }{result1, result2} } -func (fake *FakeExecutor) RemoveAll(arg1 string) error { - fake.removeAllMutex.Lock() - ret, specificReturn := fake.removeAllReturnsOnCall[len(fake.removeAllArgsForCall)] - fake.removeAllArgsForCall = append(fake.removeAllArgsForCall, struct { - arg1 string +func (fake *FakeExecutor) GetDeviceForFileStat(arg1 os.FileInfo) uint64 { + fake.getDeviceForFileStatMutex.Lock() + ret, specificReturn := fake.getDeviceForFileStatReturnsOnCall[len(fake.getDeviceForFileStatArgsForCall)] + fake.getDeviceForFileStatArgsForCall = append(fake.getDeviceForFileStatArgsForCall, struct { + arg1 os.FileInfo }{arg1}) - fake.recordInvocation("RemoveAll", []interface{}{arg1}) - fake.removeAllMutex.Unlock() - if fake.RemoveAllStub != nil { - return fake.RemoveAllStub(arg1) + fake.recordInvocation("GetDeviceForFileStat", []interface{}{arg1}) + fake.getDeviceForFileStatMutex.Unlock() + if fake.GetDeviceForFileStatStub != nil { + return fake.GetDeviceForFileStatStub(arg1) } if specificReturn { return ret.result1 } - return fake.removeAllReturns.result1 + fakeReturns := fake.getDeviceForFileStatReturns + return fakeReturns.result1 } -func (fake *FakeExecutor) RemoveAllCallCount() int { - fake.removeAllMutex.RLock() - defer fake.removeAllMutex.RUnlock() - return len(fake.removeAllArgsForCall) +func (fake *FakeExecutor) GetDeviceForFileStatCallCount() int { + fake.getDeviceForFileStatMutex.RLock() + defer fake.getDeviceForFileStatMutex.RUnlock() + return len(fake.getDeviceForFileStatArgsForCall) } -func (fake *FakeExecutor) RemoveAllArgsForCall(i int) string { - fake.removeAllMutex.RLock() - defer fake.removeAllMutex.RUnlock() - return fake.removeAllArgsForCall[i].arg1 +func (fake *FakeExecutor) GetDeviceForFileStatCalls(stub func(os.FileInfo) uint64) { + fake.getDeviceForFileStatMutex.Lock() + defer fake.getDeviceForFileStatMutex.Unlock() + fake.GetDeviceForFileStatStub = stub } -func (fake *FakeExecutor) RemoveAllReturns(result1 error) { - fake.RemoveAllStub = nil - fake.removeAllReturns = struct { - result1 error +func (fake *FakeExecutor) GetDeviceForFileStatArgsForCall(i int) os.FileInfo { + fake.getDeviceForFileStatMutex.RLock() + defer fake.getDeviceForFileStatMutex.RUnlock() + argsForCall := fake.getDeviceForFileStatArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeExecutor) GetDeviceForFileStatReturns(result1 uint64) { + fake.getDeviceForFileStatMutex.Lock() + defer fake.getDeviceForFileStatMutex.Unlock() + fake.GetDeviceForFileStatStub = nil + fake.getDeviceForFileStatReturns = struct { + result1 uint64 }{result1} } -func (fake *FakeExecutor) RemoveAllReturnsOnCall(i int, result1 error) { - fake.RemoveAllStub = nil - if fake.removeAllReturnsOnCall == nil { - fake.removeAllReturnsOnCall = make(map[int]struct { - result1 error +func (fake *FakeExecutor) GetDeviceForFileStatReturnsOnCall(i int, result1 uint64) { + fake.getDeviceForFileStatMutex.Lock() + defer fake.getDeviceForFileStatMutex.Unlock() + fake.GetDeviceForFileStatStub = nil + if fake.getDeviceForFileStatReturnsOnCall == nil { + fake.getDeviceForFileStatReturnsOnCall = make(map[int]struct { + result1 uint64 }) } - fake.removeAllReturnsOnCall[i] = struct { - result1 error + fake.getDeviceForFileStatReturnsOnCall[i] = struct { + result1 uint64 }{result1} } -func (fake *FakeExecutor) Remove(arg1 string) error { - fake.removeMutex.Lock() - ret, specificReturn := fake.removeReturnsOnCall[len(fake.removeArgsForCall)] - fake.removeArgsForCall = append(fake.removeArgsForCall, struct { +func (fake *FakeExecutor) GetGlobFiles(arg1 string) ([]string, error) { + fake.getGlobFilesMutex.Lock() + ret, specificReturn := fake.getGlobFilesReturnsOnCall[len(fake.getGlobFilesArgsForCall)] + fake.getGlobFilesArgsForCall = append(fake.getGlobFilesArgsForCall, struct { arg1 string }{arg1}) - fake.recordInvocation("Remove", []interface{}{arg1}) - fake.removeMutex.Unlock() - if fake.RemoveStub != nil { - return fake.RemoveStub(arg1) + fake.recordInvocation("GetGlobFiles", []interface{}{arg1}) + fake.getGlobFilesMutex.Unlock() + if fake.GetGlobFilesStub != nil { + return fake.GetGlobFilesStub(arg1) } if specificReturn { - return ret.result1 + return ret.result1, ret.result2 } - return fake.removeReturns.result1 + fakeReturns := fake.getGlobFilesReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeExecutor) RemoveCallCount() int { - fake.removeMutex.RLock() - defer fake.removeMutex.RUnlock() - return len(fake.removeArgsForCall) +func (fake *FakeExecutor) GetGlobFilesCallCount() int { + fake.getGlobFilesMutex.RLock() + defer fake.getGlobFilesMutex.RUnlock() + return len(fake.getGlobFilesArgsForCall) } -func (fake *FakeExecutor) RemoveArgsForCall(i int) string { - fake.removeMutex.RLock() - defer fake.removeMutex.RUnlock() - return fake.removeArgsForCall[i].arg1 +func (fake *FakeExecutor) GetGlobFilesCalls(stub func(string) ([]string, error)) { + fake.getGlobFilesMutex.Lock() + defer fake.getGlobFilesMutex.Unlock() + fake.GetGlobFilesStub = stub } -func (fake *FakeExecutor) RemoveReturns(result1 error) { - fake.RemoveStub = nil - fake.removeReturns = struct { - result1 error - }{result1} +func (fake *FakeExecutor) GetGlobFilesArgsForCall(i int) string { + fake.getGlobFilesMutex.RLock() + defer fake.getGlobFilesMutex.RUnlock() + argsForCall := fake.getGlobFilesArgsForCall[i] + return argsForCall.arg1 } -func (fake *FakeExecutor) RemoveReturnsOnCall(i int, result1 error) { - fake.RemoveStub = nil - if fake.removeReturnsOnCall == nil { - fake.removeReturnsOnCall = make(map[int]struct { - result1 error +func (fake *FakeExecutor) GetGlobFilesReturns(result1 []string, result2 error) { + fake.getGlobFilesMutex.Lock() + defer fake.getGlobFilesMutex.Unlock() + fake.GetGlobFilesStub = nil + fake.getGlobFilesReturns = struct { + result1 []string + result2 error + }{result1, result2} +} + +func (fake *FakeExecutor) GetGlobFilesReturnsOnCall(i int, result1 []string, result2 error) { + fake.getGlobFilesMutex.Lock() + defer fake.getGlobFilesMutex.Unlock() + fake.GetGlobFilesStub = nil + if fake.getGlobFilesReturnsOnCall == nil { + fake.getGlobFilesReturnsOnCall = make(map[int]struct { + result1 []string + result2 error }) } - fake.removeReturnsOnCall[i] = struct { - result1 error - }{result1} + fake.getGlobFilesReturnsOnCall[i] = struct { + result1 []string + result2 error + }{result1, result2} } func (fake *FakeExecutor) Hostname() (string, error) { fake.hostnameMutex.Lock() ret, specificReturn := fake.hostnameReturnsOnCall[len(fake.hostnameArgsForCall)] - fake.hostnameArgsForCall = append(fake.hostnameArgsForCall, struct{}{}) + fake.hostnameArgsForCall = append(fake.hostnameArgsForCall, struct { + }{}) fake.recordInvocation("Hostname", []interface{}{}) fake.hostnameMutex.Unlock() if fake.HostnameStub != nil { @@ -557,7 +582,8 @@ func (fake *FakeExecutor) Hostname() (string, error) { if specificReturn { return ret.result1, ret.result2 } - return fake.hostnameReturns.result1, fake.hostnameReturns.result2 + fakeReturns := fake.hostnameReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeExecutor) HostnameCallCount() int { @@ -566,7 +592,15 @@ func (fake *FakeExecutor) HostnameCallCount() int { return len(fake.hostnameArgsForCall) } +func (fake *FakeExecutor) HostnameCalls(stub func() (string, error)) { + fake.hostnameMutex.Lock() + defer fake.hostnameMutex.Unlock() + fake.HostnameStub = stub +} + func (fake *FakeExecutor) HostnameReturns(result1 string, result2 error) { + fake.hostnameMutex.Lock() + defer fake.hostnameMutex.Unlock() fake.HostnameStub = nil fake.hostnameReturns = struct { result1 string @@ -575,6 +609,8 @@ func (fake *FakeExecutor) HostnameReturns(result1 string, result2 error) { } func (fake *FakeExecutor) HostnameReturnsOnCall(i int, result1 string, result2 error) { + fake.hostnameMutex.Lock() + defer fake.hostnameMutex.Unlock() fake.HostnameStub = nil if fake.hostnameReturnsOnCall == nil { fake.hostnameReturnsOnCall = make(map[int]struct { @@ -588,6 +624,129 @@ func (fake *FakeExecutor) HostnameReturnsOnCall(i int, result1 string, result2 e }{result1, result2} } +func (fake *FakeExecutor) IsDir(arg1 os.FileInfo) bool { + fake.isDirMutex.Lock() + ret, specificReturn := fake.isDirReturnsOnCall[len(fake.isDirArgsForCall)] + fake.isDirArgsForCall = append(fake.isDirArgsForCall, struct { + arg1 os.FileInfo + }{arg1}) + fake.recordInvocation("IsDir", []interface{}{arg1}) + fake.isDirMutex.Unlock() + if fake.IsDirStub != nil { + return fake.IsDirStub(arg1) + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.isDirReturns + return fakeReturns.result1 +} + +func (fake *FakeExecutor) IsDirCallCount() int { + fake.isDirMutex.RLock() + defer fake.isDirMutex.RUnlock() + return len(fake.isDirArgsForCall) +} + +func (fake *FakeExecutor) IsDirCalls(stub func(os.FileInfo) bool) { + fake.isDirMutex.Lock() + defer fake.isDirMutex.Unlock() + fake.IsDirStub = stub +} + +func (fake *FakeExecutor) IsDirArgsForCall(i int) os.FileInfo { + fake.isDirMutex.RLock() + defer fake.isDirMutex.RUnlock() + argsForCall := fake.isDirArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeExecutor) IsDirReturns(result1 bool) { + fake.isDirMutex.Lock() + defer fake.isDirMutex.Unlock() + fake.IsDirStub = nil + fake.isDirReturns = struct { + result1 bool + }{result1} +} + +func (fake *FakeExecutor) IsDirReturnsOnCall(i int, result1 bool) { + fake.isDirMutex.Lock() + defer fake.isDirMutex.Unlock() + fake.IsDirStub = nil + if fake.isDirReturnsOnCall == nil { + fake.isDirReturnsOnCall = make(map[int]struct { + result1 bool + }) + } + fake.isDirReturnsOnCall[i] = struct { + result1 bool + }{result1} +} + +func (fake *FakeExecutor) IsDirEmpty(arg1 string) (bool, error) { + fake.isDirEmptyMutex.Lock() + ret, specificReturn := fake.isDirEmptyReturnsOnCall[len(fake.isDirEmptyArgsForCall)] + fake.isDirEmptyArgsForCall = append(fake.isDirEmptyArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("IsDirEmpty", []interface{}{arg1}) + fake.isDirEmptyMutex.Unlock() + if fake.IsDirEmptyStub != nil { + return fake.IsDirEmptyStub(arg1) + } + if specificReturn { + return ret.result1, ret.result2 + } + fakeReturns := fake.isDirEmptyReturns + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeExecutor) IsDirEmptyCallCount() int { + fake.isDirEmptyMutex.RLock() + defer fake.isDirEmptyMutex.RUnlock() + return len(fake.isDirEmptyArgsForCall) +} + +func (fake *FakeExecutor) IsDirEmptyCalls(stub func(string) (bool, error)) { + fake.isDirEmptyMutex.Lock() + defer fake.isDirEmptyMutex.Unlock() + fake.IsDirEmptyStub = stub +} + +func (fake *FakeExecutor) IsDirEmptyArgsForCall(i int) string { + fake.isDirEmptyMutex.RLock() + defer fake.isDirEmptyMutex.RUnlock() + argsForCall := fake.isDirEmptyArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeExecutor) IsDirEmptyReturns(result1 bool, result2 error) { + fake.isDirEmptyMutex.Lock() + defer fake.isDirEmptyMutex.Unlock() + fake.IsDirEmptyStub = nil + fake.isDirEmptyReturns = struct { + result1 bool + result2 error + }{result1, result2} +} + +func (fake *FakeExecutor) IsDirEmptyReturnsOnCall(i int, result1 bool, result2 error) { + fake.isDirEmptyMutex.Lock() + defer fake.isDirEmptyMutex.Unlock() + fake.IsDirEmptyStub = nil + if fake.isDirEmptyReturnsOnCall == nil { + fake.isDirEmptyReturnsOnCall = make(map[int]struct { + result1 bool + result2 error + }) + } + fake.isDirEmptyReturnsOnCall[i] = struct { + result1 bool + result2 error + }{result1, result2} +} + func (fake *FakeExecutor) IsExecutable(arg1 string) error { fake.isExecutableMutex.Lock() ret, specificReturn := fake.isExecutableReturnsOnCall[len(fake.isExecutableArgsForCall)] @@ -602,7 +761,8 @@ func (fake *FakeExecutor) IsExecutable(arg1 string) error { if specificReturn { return ret.result1 } - return fake.isExecutableReturns.result1 + fakeReturns := fake.isExecutableReturns + return fakeReturns.result1 } func (fake *FakeExecutor) IsExecutableCallCount() int { @@ -611,13 +771,22 @@ func (fake *FakeExecutor) IsExecutableCallCount() int { return len(fake.isExecutableArgsForCall) } +func (fake *FakeExecutor) IsExecutableCalls(stub func(string) error) { + fake.isExecutableMutex.Lock() + defer fake.isExecutableMutex.Unlock() + fake.IsExecutableStub = stub +} + func (fake *FakeExecutor) IsExecutableArgsForCall(i int) string { fake.isExecutableMutex.RLock() defer fake.isExecutableMutex.RUnlock() - return fake.isExecutableArgsForCall[i].arg1 + argsForCall := fake.isExecutableArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeExecutor) IsExecutableReturns(result1 error) { + fake.isExecutableMutex.Lock() + defer fake.isExecutableMutex.Unlock() fake.IsExecutableStub = nil fake.isExecutableReturns = struct { result1 error @@ -625,6 +794,8 @@ func (fake *FakeExecutor) IsExecutableReturns(result1 error) { } func (fake *FakeExecutor) IsExecutableReturnsOnCall(i int, result1 error) { + fake.isExecutableMutex.Lock() + defer fake.isExecutableMutex.Unlock() fake.IsExecutableStub = nil if fake.isExecutableReturnsOnCall == nil { fake.isExecutableReturnsOnCall = make(map[int]struct { @@ -650,7 +821,8 @@ func (fake *FakeExecutor) IsNotExist(arg1 error) bool { if specificReturn { return ret.result1 } - return fake.isNotExistReturns.result1 + fakeReturns := fake.isNotExistReturns + return fakeReturns.result1 } func (fake *FakeExecutor) IsNotExistCallCount() int { @@ -659,13 +831,22 @@ func (fake *FakeExecutor) IsNotExistCallCount() int { return len(fake.isNotExistArgsForCall) } +func (fake *FakeExecutor) IsNotExistCalls(stub func(error) bool) { + fake.isNotExistMutex.Lock() + defer fake.isNotExistMutex.Unlock() + fake.IsNotExistStub = stub +} + func (fake *FakeExecutor) IsNotExistArgsForCall(i int) error { fake.isNotExistMutex.RLock() defer fake.isNotExistMutex.RUnlock() - return fake.isNotExistArgsForCall[i].arg1 + argsForCall := fake.isNotExistArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeExecutor) IsNotExistReturns(result1 bool) { + fake.isNotExistMutex.Lock() + defer fake.isNotExistMutex.Unlock() fake.IsNotExistStub = nil fake.isNotExistReturns = struct { result1 bool @@ -673,6 +854,8 @@ func (fake *FakeExecutor) IsNotExistReturns(result1 bool) { } func (fake *FakeExecutor) IsNotExistReturnsOnCall(i int, result1 bool) { + fake.isNotExistMutex.Lock() + defer fake.isNotExistMutex.Unlock() fake.IsNotExistStub = nil if fake.isNotExistReturnsOnCall == nil { fake.isNotExistReturnsOnCall = make(map[int]struct { @@ -684,130 +867,143 @@ func (fake *FakeExecutor) IsNotExistReturnsOnCall(i int, result1 bool) { }{result1} } -func (fake *FakeExecutor) EvalSymlinks(path string) (string, error) { - fake.evalSymlinksMutex.Lock() - ret, specificReturn := fake.evalSymlinksReturnsOnCall[len(fake.evalSymlinksArgsForCall)] - fake.evalSymlinksArgsForCall = append(fake.evalSymlinksArgsForCall, struct { - path string - }{path}) - fake.recordInvocation("EvalSymlinks", []interface{}{path}) - fake.evalSymlinksMutex.Unlock() - if fake.EvalSymlinksStub != nil { - return fake.EvalSymlinksStub(path) +func (fake *FakeExecutor) IsSameFile(arg1 os.FileInfo, arg2 os.FileInfo) bool { + fake.isSameFileMutex.Lock() + ret, specificReturn := fake.isSameFileReturnsOnCall[len(fake.isSameFileArgsForCall)] + fake.isSameFileArgsForCall = append(fake.isSameFileArgsForCall, struct { + arg1 os.FileInfo + arg2 os.FileInfo + }{arg1, arg2}) + fake.recordInvocation("IsSameFile", []interface{}{arg1, arg2}) + fake.isSameFileMutex.Unlock() + if fake.IsSameFileStub != nil { + return fake.IsSameFileStub(arg1, arg2) } if specificReturn { - return ret.result1, ret.result2 + return ret.result1 } - return fake.evalSymlinksReturns.result1, fake.evalSymlinksReturns.result2 + fakeReturns := fake.isSameFileReturns + return fakeReturns.result1 } -func (fake *FakeExecutor) EvalSymlinksCallCount() int { - fake.evalSymlinksMutex.RLock() - defer fake.evalSymlinksMutex.RUnlock() - return len(fake.evalSymlinksArgsForCall) +func (fake *FakeExecutor) IsSameFileCallCount() int { + fake.isSameFileMutex.RLock() + defer fake.isSameFileMutex.RUnlock() + return len(fake.isSameFileArgsForCall) } -func (fake *FakeExecutor) EvalSymlinksArgsForCall(i int) string { - fake.evalSymlinksMutex.RLock() - defer fake.evalSymlinksMutex.RUnlock() - return fake.evalSymlinksArgsForCall[i].path +func (fake *FakeExecutor) IsSameFileCalls(stub func(os.FileInfo, os.FileInfo) bool) { + fake.isSameFileMutex.Lock() + defer fake.isSameFileMutex.Unlock() + fake.IsSameFileStub = stub } -func (fake *FakeExecutor) EvalSymlinksReturns(result1 string, result2 error) { - fake.EvalSymlinksStub = nil - fake.evalSymlinksReturns = struct { - result1 string - result2 error - }{result1, result2} +func (fake *FakeExecutor) IsSameFileArgsForCall(i int) (os.FileInfo, os.FileInfo) { + fake.isSameFileMutex.RLock() + defer fake.isSameFileMutex.RUnlock() + argsForCall := fake.isSameFileArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } -func (fake *FakeExecutor) EvalSymlinksReturnsOnCall(i int, result1 string, result2 error) { - fake.EvalSymlinksStub = nil - if fake.evalSymlinksReturnsOnCall == nil { - fake.evalSymlinksReturnsOnCall = make(map[int]struct { - result1 string - result2 error +func (fake *FakeExecutor) IsSameFileReturns(result1 bool) { + fake.isSameFileMutex.Lock() + defer fake.isSameFileMutex.Unlock() + fake.IsSameFileStub = nil + fake.isSameFileReturns = struct { + result1 bool + }{result1} +} + +func (fake *FakeExecutor) IsSameFileReturnsOnCall(i int, result1 bool) { + fake.isSameFileMutex.Lock() + defer fake.isSameFileMutex.Unlock() + fake.IsSameFileStub = nil + if fake.isSameFileReturnsOnCall == nil { + fake.isSameFileReturnsOnCall = make(map[int]struct { + result1 bool }) } - fake.evalSymlinksReturnsOnCall[i] = struct { - result1 string - result2 error - }{result1, result2} + fake.isSameFileReturnsOnCall[i] = struct { + result1 bool + }{result1} } -func (fake *FakeExecutor) ExecuteWithTimeout(mSeconds int, command string, args []string) ([]byte, error) { - var argsCopy []string - if args != nil { - argsCopy = make([]string, len(args)) - copy(argsCopy, args) - } - fake.executeWithTimeoutMutex.Lock() - ret, specificReturn := fake.executeWithTimeoutReturnsOnCall[len(fake.executeWithTimeoutArgsForCall)] - fake.executeWithTimeoutArgsForCall = append(fake.executeWithTimeoutArgsForCall, struct { - mSeconds int - command string - args []string - }{mSeconds, command, argsCopy}) - fake.recordInvocation("ExecuteWithTimeout", []interface{}{mSeconds, command, argsCopy}) - fake.executeWithTimeoutMutex.Unlock() - if fake.ExecuteWithTimeoutStub != nil { - return fake.ExecuteWithTimeoutStub(mSeconds, command, args) +func (fake *FakeExecutor) IsSlink(arg1 os.FileInfo) bool { + fake.isSlinkMutex.Lock() + ret, specificReturn := fake.isSlinkReturnsOnCall[len(fake.isSlinkArgsForCall)] + fake.isSlinkArgsForCall = append(fake.isSlinkArgsForCall, struct { + arg1 os.FileInfo + }{arg1}) + fake.recordInvocation("IsSlink", []interface{}{arg1}) + fake.isSlinkMutex.Unlock() + if fake.IsSlinkStub != nil { + return fake.IsSlinkStub(arg1) } if specificReturn { - return ret.result1, ret.result2 + return ret.result1 } - return fake.executeWithTimeoutReturns.result1, fake.executeWithTimeoutReturns.result2 + fakeReturns := fake.isSlinkReturns + return fakeReturns.result1 } -func (fake *FakeExecutor) ExecuteWithTimeoutCallCount() int { - fake.executeWithTimeoutMutex.RLock() - defer fake.executeWithTimeoutMutex.RUnlock() - return len(fake.executeWithTimeoutArgsForCall) +func (fake *FakeExecutor) IsSlinkCallCount() int { + fake.isSlinkMutex.RLock() + defer fake.isSlinkMutex.RUnlock() + return len(fake.isSlinkArgsForCall) } -func (fake *FakeExecutor) ExecuteWithTimeoutArgsForCall(i int) (int, string, []string) { - fake.executeWithTimeoutMutex.RLock() - defer fake.executeWithTimeoutMutex.RUnlock() - return fake.executeWithTimeoutArgsForCall[i].mSeconds, fake.executeWithTimeoutArgsForCall[i].command, fake.executeWithTimeoutArgsForCall[i].args +func (fake *FakeExecutor) IsSlinkCalls(stub func(os.FileInfo) bool) { + fake.isSlinkMutex.Lock() + defer fake.isSlinkMutex.Unlock() + fake.IsSlinkStub = stub } -func (fake *FakeExecutor) ExecuteWithTimeoutReturns(result1 []byte, result2 error) { - fake.ExecuteWithTimeoutStub = nil - fake.executeWithTimeoutReturns = struct { - result1 []byte - result2 error - }{result1, result2} +func (fake *FakeExecutor) IsSlinkArgsForCall(i int) os.FileInfo { + fake.isSlinkMutex.RLock() + defer fake.isSlinkMutex.RUnlock() + argsForCall := fake.isSlinkArgsForCall[i] + return argsForCall.arg1 } -func (fake *FakeExecutor) ExecuteWithTimeoutReturnsOnCall(i int, result1 []byte, result2 error) { - fake.ExecuteWithTimeoutStub = nil - if fake.executeWithTimeoutReturnsOnCall == nil { - fake.executeWithTimeoutReturnsOnCall = make(map[int]struct { - result1 []byte - result2 error +func (fake *FakeExecutor) IsSlinkReturns(result1 bool) { + fake.isSlinkMutex.Lock() + defer fake.isSlinkMutex.Unlock() + fake.IsSlinkStub = nil + fake.isSlinkReturns = struct { + result1 bool + }{result1} +} + +func (fake *FakeExecutor) IsSlinkReturnsOnCall(i int, result1 bool) { + fake.isSlinkMutex.Lock() + defer fake.isSlinkMutex.Unlock() + fake.IsSlinkStub = nil + if fake.isSlinkReturnsOnCall == nil { + fake.isSlinkReturnsOnCall = make(map[int]struct { + result1 bool }) } - fake.executeWithTimeoutReturnsOnCall[i] = struct { - result1 []byte - result2 error - }{result1, result2} + fake.isSlinkReturnsOnCall[i] = struct { + result1 bool + }{result1} } -func (fake *FakeExecutor) Lstat(path string) (os.FileInfo, error) { +func (fake *FakeExecutor) Lstat(arg1 string) (os.FileInfo, error) { fake.lstatMutex.Lock() ret, specificReturn := fake.lstatReturnsOnCall[len(fake.lstatArgsForCall)] fake.lstatArgsForCall = append(fake.lstatArgsForCall, struct { - path string - }{path}) - fake.recordInvocation("Lstat", []interface{}{path}) + arg1 string + }{arg1}) + fake.recordInvocation("Lstat", []interface{}{arg1}) fake.lstatMutex.Unlock() if fake.LstatStub != nil { - return fake.LstatStub(path) + return fake.LstatStub(arg1) } if specificReturn { return ret.result1, ret.result2 } - return fake.lstatReturns.result1, fake.lstatReturns.result2 + fakeReturns := fake.lstatReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeExecutor) LstatCallCount() int { @@ -816,13 +1012,22 @@ func (fake *FakeExecutor) LstatCallCount() int { return len(fake.lstatArgsForCall) } +func (fake *FakeExecutor) LstatCalls(stub func(string) (os.FileInfo, error)) { + fake.lstatMutex.Lock() + defer fake.lstatMutex.Unlock() + fake.LstatStub = stub +} + func (fake *FakeExecutor) LstatArgsForCall(i int) string { fake.lstatMutex.RLock() defer fake.lstatMutex.RUnlock() - return fake.lstatArgsForCall[i].path + argsForCall := fake.lstatArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeExecutor) LstatReturns(result1 os.FileInfo, result2 error) { + fake.lstatMutex.Lock() + defer fake.lstatMutex.Unlock() fake.LstatStub = nil fake.lstatReturns = struct { result1 os.FileInfo @@ -831,6 +1036,8 @@ func (fake *FakeExecutor) LstatReturns(result1 os.FileInfo, result2 error) { } func (fake *FakeExecutor) LstatReturnsOnCall(i int, result1 os.FileInfo, result2 error) { + fake.lstatMutex.Lock() + defer fake.lstatMutex.Unlock() fake.LstatStub = nil if fake.lstatReturnsOnCall == nil { fake.lstatReturnsOnCall = make(map[int]struct { @@ -844,391 +1051,413 @@ func (fake *FakeExecutor) LstatReturnsOnCall(i int, result1 os.FileInfo, result2 }{result1, result2} } -func (fake *FakeExecutor) IsDir(fInfo os.FileInfo) bool { - fake.isDirMutex.Lock() - ret, specificReturn := fake.isDirReturnsOnCall[len(fake.isDirArgsForCall)] - fake.isDirArgsForCall = append(fake.isDirArgsForCall, struct { - fInfo os.FileInfo - }{fInfo}) - fake.recordInvocation("IsDir", []interface{}{fInfo}) - fake.isDirMutex.Unlock() - if fake.IsDirStub != nil { - return fake.IsDirStub(fInfo) +func (fake *FakeExecutor) Mkdir(arg1 string, arg2 os.FileMode) error { + fake.mkdirMutex.Lock() + ret, specificReturn := fake.mkdirReturnsOnCall[len(fake.mkdirArgsForCall)] + fake.mkdirArgsForCall = append(fake.mkdirArgsForCall, struct { + arg1 string + arg2 os.FileMode + }{arg1, arg2}) + fake.recordInvocation("Mkdir", []interface{}{arg1, arg2}) + fake.mkdirMutex.Unlock() + if fake.MkdirStub != nil { + return fake.MkdirStub(arg1, arg2) } if specificReturn { return ret.result1 } - return fake.isDirReturns.result1 + fakeReturns := fake.mkdirReturns + return fakeReturns.result1 } -func (fake *FakeExecutor) IsDirCallCount() int { - fake.isDirMutex.RLock() - defer fake.isDirMutex.RUnlock() - return len(fake.isDirArgsForCall) +func (fake *FakeExecutor) MkdirCallCount() int { + fake.mkdirMutex.RLock() + defer fake.mkdirMutex.RUnlock() + return len(fake.mkdirArgsForCall) } -func (fake *FakeExecutor) IsDirArgsForCall(i int) os.FileInfo { - fake.isDirMutex.RLock() - defer fake.isDirMutex.RUnlock() - return fake.isDirArgsForCall[i].fInfo +func (fake *FakeExecutor) MkdirCalls(stub func(string, os.FileMode) error) { + fake.mkdirMutex.Lock() + defer fake.mkdirMutex.Unlock() + fake.MkdirStub = stub } -func (fake *FakeExecutor) IsDirReturns(result1 bool) { - fake.IsDirStub = nil - fake.isDirReturns = struct { - result1 bool +func (fake *FakeExecutor) MkdirArgsForCall(i int) (string, os.FileMode) { + fake.mkdirMutex.RLock() + defer fake.mkdirMutex.RUnlock() + argsForCall := fake.mkdirArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeExecutor) MkdirReturns(result1 error) { + fake.mkdirMutex.Lock() + defer fake.mkdirMutex.Unlock() + fake.MkdirStub = nil + fake.mkdirReturns = struct { + result1 error }{result1} } -func (fake *FakeExecutor) IsDirReturnsOnCall(i int, result1 bool) { - fake.IsDirStub = nil - if fake.isDirReturnsOnCall == nil { - fake.isDirReturnsOnCall = make(map[int]struct { - result1 bool +func (fake *FakeExecutor) MkdirReturnsOnCall(i int, result1 error) { + fake.mkdirMutex.Lock() + defer fake.mkdirMutex.Unlock() + fake.MkdirStub = nil + if fake.mkdirReturnsOnCall == nil { + fake.mkdirReturnsOnCall = make(map[int]struct { + result1 error }) } - fake.isDirReturnsOnCall[i] = struct { - result1 bool + fake.mkdirReturnsOnCall[i] = struct { + result1 error }{result1} } -func (fake *FakeExecutor) Symlink(target string, slink string) error { - fake.symlinkMutex.Lock() - ret, specificReturn := fake.symlinkReturnsOnCall[len(fake.symlinkArgsForCall)] - fake.symlinkArgsForCall = append(fake.symlinkArgsForCall, struct { - target string - slink string - }{target, slink}) - fake.recordInvocation("Symlink", []interface{}{target, slink}) - fake.symlinkMutex.Unlock() - if fake.SymlinkStub != nil { - return fake.SymlinkStub(target, slink) +func (fake *FakeExecutor) MkdirAll(arg1 string, arg2 os.FileMode) error { + fake.mkdirAllMutex.Lock() + ret, specificReturn := fake.mkdirAllReturnsOnCall[len(fake.mkdirAllArgsForCall)] + fake.mkdirAllArgsForCall = append(fake.mkdirAllArgsForCall, struct { + arg1 string + arg2 os.FileMode + }{arg1, arg2}) + fake.recordInvocation("MkdirAll", []interface{}{arg1, arg2}) + fake.mkdirAllMutex.Unlock() + if fake.MkdirAllStub != nil { + return fake.MkdirAllStub(arg1, arg2) } if specificReturn { return ret.result1 } - return fake.symlinkReturns.result1 + fakeReturns := fake.mkdirAllReturns + return fakeReturns.result1 } -func (fake *FakeExecutor) SymlinkCallCount() int { - fake.symlinkMutex.RLock() - defer fake.symlinkMutex.RUnlock() - return len(fake.symlinkArgsForCall) +func (fake *FakeExecutor) MkdirAllCallCount() int { + fake.mkdirAllMutex.RLock() + defer fake.mkdirAllMutex.RUnlock() + return len(fake.mkdirAllArgsForCall) } -func (fake *FakeExecutor) SymlinkArgsForCall(i int) (string, string) { - fake.symlinkMutex.RLock() - defer fake.symlinkMutex.RUnlock() - return fake.symlinkArgsForCall[i].target, fake.symlinkArgsForCall[i].slink +func (fake *FakeExecutor) MkdirAllCalls(stub func(string, os.FileMode) error) { + fake.mkdirAllMutex.Lock() + defer fake.mkdirAllMutex.Unlock() + fake.MkdirAllStub = stub } -func (fake *FakeExecutor) SymlinkReturns(result1 error) { - fake.SymlinkStub = nil - fake.symlinkReturns = struct { +func (fake *FakeExecutor) MkdirAllArgsForCall(i int) (string, os.FileMode) { + fake.mkdirAllMutex.RLock() + defer fake.mkdirAllMutex.RUnlock() + argsForCall := fake.mkdirAllArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeExecutor) MkdirAllReturns(result1 error) { + fake.mkdirAllMutex.Lock() + defer fake.mkdirAllMutex.Unlock() + fake.MkdirAllStub = nil + fake.mkdirAllReturns = struct { result1 error }{result1} } -func (fake *FakeExecutor) SymlinkReturnsOnCall(i int, result1 error) { - fake.SymlinkStub = nil - if fake.symlinkReturnsOnCall == nil { - fake.symlinkReturnsOnCall = make(map[int]struct { +func (fake *FakeExecutor) MkdirAllReturnsOnCall(i int, result1 error) { + fake.mkdirAllMutex.Lock() + defer fake.mkdirAllMutex.Unlock() + fake.MkdirAllStub = nil + if fake.mkdirAllReturnsOnCall == nil { + fake.mkdirAllReturnsOnCall = make(map[int]struct { result1 error }) } - fake.symlinkReturnsOnCall[i] = struct { + fake.mkdirAllReturnsOnCall[i] = struct { result1 error }{result1} } -func (fake *FakeExecutor) IsSlink(fInfo os.FileInfo) bool { - fake.isSlinkMutex.Lock() - ret, specificReturn := fake.isSlinkReturnsOnCall[len(fake.isSlinkArgsForCall)] - fake.isSlinkArgsForCall = append(fake.isSlinkArgsForCall, struct { - fInfo os.FileInfo - }{fInfo}) - fake.recordInvocation("IsSlink", []interface{}{fInfo}) - fake.isSlinkMutex.Unlock() - if fake.IsSlinkStub != nil { - return fake.IsSlinkStub(fInfo) +func (fake *FakeExecutor) Remove(arg1 string) error { + fake.removeMutex.Lock() + ret, specificReturn := fake.removeReturnsOnCall[len(fake.removeArgsForCall)] + fake.removeArgsForCall = append(fake.removeArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("Remove", []interface{}{arg1}) + fake.removeMutex.Unlock() + if fake.RemoveStub != nil { + return fake.RemoveStub(arg1) } if specificReturn { return ret.result1 } - return fake.isSlinkReturns.result1 -} - -func (fake *FakeExecutor) IsSlinkCallCount() int { - fake.isSlinkMutex.RLock() - defer fake.isSlinkMutex.RUnlock() - return len(fake.isSlinkArgsForCall) -} - -func (fake *FakeExecutor) IsSlinkArgsForCall(i int) os.FileInfo { - fake.isSlinkMutex.RLock() - defer fake.isSlinkMutex.RUnlock() - return fake.isSlinkArgsForCall[i].fInfo -} - -func (fake *FakeExecutor) IsSlinkReturns(result1 bool) { - fake.IsSlinkStub = nil - fake.isSlinkReturns = struct { - result1 bool - }{result1} -} - -func (fake *FakeExecutor) IsSlinkReturnsOnCall(i int, result1 bool) { - fake.IsSlinkStub = nil - if fake.isSlinkReturnsOnCall == nil { - fake.isSlinkReturnsOnCall = make(map[int]struct { - result1 bool - }) - } - fake.isSlinkReturnsOnCall[i] = struct { - result1 bool - }{result1} + fakeReturns := fake.removeReturns + return fakeReturns.result1 } -func (fake *FakeExecutor) GetGlobFiles(file_pattern string) (matches []string, err error) { - fake.getGlobFilesMutex.Lock() - ret, specificReturn := fake.getGlobFilesReturnsOnCall[len(fake.getGlobFilesArgsForCall)] - fake.getGlobFilesArgsForCall = append(fake.getGlobFilesArgsForCall, struct { - file_pattern string - }{file_pattern}) - fake.recordInvocation("GetGlobFiles", []interface{}{file_pattern}) - fake.getGlobFilesMutex.Unlock() - if fake.GetGlobFilesStub != nil { - return fake.GetGlobFilesStub(file_pattern) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fake.getGlobFilesReturns.result1, fake.getGlobFilesReturns.result2 +func (fake *FakeExecutor) RemoveCallCount() int { + fake.removeMutex.RLock() + defer fake.removeMutex.RUnlock() + return len(fake.removeArgsForCall) } -func (fake *FakeExecutor) GetGlobFilesCallCount() int { - fake.getGlobFilesMutex.RLock() - defer fake.getGlobFilesMutex.RUnlock() - return len(fake.getGlobFilesArgsForCall) +func (fake *FakeExecutor) RemoveCalls(stub func(string) error) { + fake.removeMutex.Lock() + defer fake.removeMutex.Unlock() + fake.RemoveStub = stub } -func (fake *FakeExecutor) GetGlobFilesArgsForCall(i int) string { - fake.getGlobFilesMutex.RLock() - defer fake.getGlobFilesMutex.RUnlock() - return fake.getGlobFilesArgsForCall[i].file_pattern +func (fake *FakeExecutor) RemoveArgsForCall(i int) string { + fake.removeMutex.RLock() + defer fake.removeMutex.RUnlock() + argsForCall := fake.removeArgsForCall[i] + return argsForCall.arg1 } -func (fake *FakeExecutor) GetGlobFilesReturns(result1 []string, result2 error) { - fake.GetGlobFilesStub = nil - fake.getGlobFilesReturns = struct { - result1 []string - result2 error - }{result1, result2} +func (fake *FakeExecutor) RemoveReturns(result1 error) { + fake.removeMutex.Lock() + defer fake.removeMutex.Unlock() + fake.RemoveStub = nil + fake.removeReturns = struct { + result1 error + }{result1} } -func (fake *FakeExecutor) GetGlobFilesReturnsOnCall(i int, result1 []string, result2 error) { - fake.GetGlobFilesStub = nil - if fake.getGlobFilesReturnsOnCall == nil { - fake.getGlobFilesReturnsOnCall = make(map[int]struct { - result1 []string - result2 error +func (fake *FakeExecutor) RemoveReturnsOnCall(i int, result1 error) { + fake.removeMutex.Lock() + defer fake.removeMutex.Unlock() + fake.RemoveStub = nil + if fake.removeReturnsOnCall == nil { + fake.removeReturnsOnCall = make(map[int]struct { + result1 error }) } - fake.getGlobFilesReturnsOnCall[i] = struct { - result1 []string - result2 error - }{result1, result2} + fake.removeReturnsOnCall[i] = struct { + result1 error + }{result1} } -func (fake *FakeExecutor) IsSameFile(file1 os.FileInfo, file2 os.FileInfo) bool { - fake.isSameFileMutex.Lock() - ret, specificReturn := fake.isSameFileReturnsOnCall[len(fake.isSameFileArgsForCall)] - fake.isSameFileArgsForCall = append(fake.isSameFileArgsForCall, struct { - file1 os.FileInfo - file2 os.FileInfo - }{file1, file2}) - fake.recordInvocation("IsSameFile", []interface{}{file1, file2}) - fake.isSameFileMutex.Unlock() - if fake.IsSameFileStub != nil { - return fake.IsSameFileStub(file1, file2) +func (fake *FakeExecutor) RemoveAll(arg1 string) error { + fake.removeAllMutex.Lock() + ret, specificReturn := fake.removeAllReturnsOnCall[len(fake.removeAllArgsForCall)] + fake.removeAllArgsForCall = append(fake.removeAllArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("RemoveAll", []interface{}{arg1}) + fake.removeAllMutex.Unlock() + if fake.RemoveAllStub != nil { + return fake.RemoveAllStub(arg1) } if specificReturn { return ret.result1 } - return fake.isSameFileReturns.result1 + fakeReturns := fake.removeAllReturns + return fakeReturns.result1 } -func (fake *FakeExecutor) IsSameFileCallCount() int { - fake.isSameFileMutex.RLock() - defer fake.isSameFileMutex.RUnlock() - return len(fake.isSameFileArgsForCall) +func (fake *FakeExecutor) RemoveAllCallCount() int { + fake.removeAllMutex.RLock() + defer fake.removeAllMutex.RUnlock() + return len(fake.removeAllArgsForCall) } -func (fake *FakeExecutor) IsSameFileArgsForCall(i int) (os.FileInfo, os.FileInfo) { - fake.isSameFileMutex.RLock() - defer fake.isSameFileMutex.RUnlock() - return fake.isSameFileArgsForCall[i].file1, fake.isSameFileArgsForCall[i].file2 +func (fake *FakeExecutor) RemoveAllCalls(stub func(string) error) { + fake.removeAllMutex.Lock() + defer fake.removeAllMutex.Unlock() + fake.RemoveAllStub = stub } -func (fake *FakeExecutor) IsSameFileReturns(result1 bool) { - fake.IsSameFileStub = nil - fake.isSameFileReturns = struct { - result1 bool +func (fake *FakeExecutor) RemoveAllArgsForCall(i int) string { + fake.removeAllMutex.RLock() + defer fake.removeAllMutex.RUnlock() + argsForCall := fake.removeAllArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeExecutor) RemoveAllReturns(result1 error) { + fake.removeAllMutex.Lock() + defer fake.removeAllMutex.Unlock() + fake.RemoveAllStub = nil + fake.removeAllReturns = struct { + result1 error }{result1} } -func (fake *FakeExecutor) IsSameFileReturnsOnCall(i int, result1 bool) { - fake.IsSameFileStub = nil - if fake.isSameFileReturnsOnCall == nil { - fake.isSameFileReturnsOnCall = make(map[int]struct { - result1 bool +func (fake *FakeExecutor) RemoveAllReturnsOnCall(i int, result1 error) { + fake.removeAllMutex.Lock() + defer fake.removeAllMutex.Unlock() + fake.RemoveAllStub = nil + if fake.removeAllReturnsOnCall == nil { + fake.removeAllReturnsOnCall = make(map[int]struct { + result1 error }) } - fake.isSameFileReturnsOnCall[i] = struct { - result1 bool + fake.removeAllReturnsOnCall[i] = struct { + result1 error }{result1} } -func (fake *FakeExecutor) IsDirEmpty(dir string) (bool, error) { - fake.isDirEmptyMutex.Lock() - ret, specificReturn := fake.isDirEmptyReturnsOnCall[len(fake.isDirEmptyArgsForCall)] - fake.isDirEmptyArgsForCall = append(fake.isDirEmptyArgsForCall, struct { - dir string - }{dir}) - fake.recordInvocation("IsDirEmpty", []interface{}{dir}) - fake.isDirEmptyMutex.Unlock() - if fake.IsDirEmptyStub != nil { - return fake.IsDirEmptyStub(dir) +func (fake *FakeExecutor) Stat(arg1 string) (os.FileInfo, error) { + fake.statMutex.Lock() + ret, specificReturn := fake.statReturnsOnCall[len(fake.statArgsForCall)] + fake.statArgsForCall = append(fake.statArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("Stat", []interface{}{arg1}) + fake.statMutex.Unlock() + if fake.StatStub != nil { + return fake.StatStub(arg1) } if specificReturn { return ret.result1, ret.result2 } - return fake.isDirEmptyReturns.result1, fake.isDirEmptyReturns.result2 + fakeReturns := fake.statReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeExecutor) IsDirEmptyCallCount() int { - fake.isDirEmptyMutex.RLock() - defer fake.isDirEmptyMutex.RUnlock() - return len(fake.isDirEmptyArgsForCall) +func (fake *FakeExecutor) StatCallCount() int { + fake.statMutex.RLock() + defer fake.statMutex.RUnlock() + return len(fake.statArgsForCall) } -func (fake *FakeExecutor) IsDirEmptyArgsForCall(i int) string { - fake.isDirEmptyMutex.RLock() - defer fake.isDirEmptyMutex.RUnlock() - return fake.isDirEmptyArgsForCall[i].dir +func (fake *FakeExecutor) StatCalls(stub func(string) (os.FileInfo, error)) { + fake.statMutex.Lock() + defer fake.statMutex.Unlock() + fake.StatStub = stub } -func (fake *FakeExecutor) IsDirEmptyReturns(result1 bool, result2 error) { - fake.IsDirEmptyStub = nil - fake.isDirEmptyReturns = struct { - result1 bool +func (fake *FakeExecutor) StatArgsForCall(i int) string { + fake.statMutex.RLock() + defer fake.statMutex.RUnlock() + argsForCall := fake.statArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeExecutor) StatReturns(result1 os.FileInfo, result2 error) { + fake.statMutex.Lock() + defer fake.statMutex.Unlock() + fake.StatStub = nil + fake.statReturns = struct { + result1 os.FileInfo result2 error }{result1, result2} } -func (fake *FakeExecutor) IsDirEmptyReturnsOnCall(i int, result1 bool, result2 error) { - fake.IsDirEmptyStub = nil - if fake.isDirEmptyReturnsOnCall == nil { - fake.isDirEmptyReturnsOnCall = make(map[int]struct { - result1 bool +func (fake *FakeExecutor) StatReturnsOnCall(i int, result1 os.FileInfo, result2 error) { + fake.statMutex.Lock() + defer fake.statMutex.Unlock() + fake.StatStub = nil + if fake.statReturnsOnCall == nil { + fake.statReturnsOnCall = make(map[int]struct { + result1 os.FileInfo result2 error }) } - fake.isDirEmptyReturnsOnCall[i] = struct { - result1 bool + fake.statReturnsOnCall[i] = struct { + result1 os.FileInfo result2 error }{result1, result2} } -func (fake *FakeExecutor) GetDeviceForFileStat(arg1 os.FileInfo) uint64 { - fake.getDeviceForFileStatMutex.Lock() - ret, specificReturn := fake.getDeviceForFileStatReturnsOnCall[len(fake.getDeviceForFileStatArgsForCall)] - fake.getDeviceForFileStatArgsForCall = append(fake.getDeviceForFileStatArgsForCall, struct { - arg1 os.FileInfo - }{arg1}) - fake.recordInvocation("GetDeviceForFileStat", []interface{}{arg1}) - fake.getDeviceForFileStatMutex.Unlock() - if fake.GetDeviceForFileStatStub != nil { - return fake.GetDeviceForFileStatStub(arg1) +func (fake *FakeExecutor) Symlink(arg1 string, arg2 string) error { + fake.symlinkMutex.Lock() + ret, specificReturn := fake.symlinkReturnsOnCall[len(fake.symlinkArgsForCall)] + fake.symlinkArgsForCall = append(fake.symlinkArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("Symlink", []interface{}{arg1, arg2}) + fake.symlinkMutex.Unlock() + if fake.SymlinkStub != nil { + return fake.SymlinkStub(arg1, arg2) } if specificReturn { return ret.result1 } - return fake.getDeviceForFileStatReturns.result1 + fakeReturns := fake.symlinkReturns + return fakeReturns.result1 } -func (fake *FakeExecutor) GetDeviceForFileStatCallCount() int { - fake.getDeviceForFileStatMutex.RLock() - defer fake.getDeviceForFileStatMutex.RUnlock() - return len(fake.getDeviceForFileStatArgsForCall) +func (fake *FakeExecutor) SymlinkCallCount() int { + fake.symlinkMutex.RLock() + defer fake.symlinkMutex.RUnlock() + return len(fake.symlinkArgsForCall) } -func (fake *FakeExecutor) GetDeviceForFileStatArgsForCall(i int) os.FileInfo { - fake.getDeviceForFileStatMutex.RLock() - defer fake.getDeviceForFileStatMutex.RUnlock() - return fake.getDeviceForFileStatArgsForCall[i].arg1 +func (fake *FakeExecutor) SymlinkCalls(stub func(string, string) error) { + fake.symlinkMutex.Lock() + defer fake.symlinkMutex.Unlock() + fake.SymlinkStub = stub } -func (fake *FakeExecutor) GetDeviceForFileStatReturns(result1 uint64) { - fake.GetDeviceForFileStatStub = nil - fake.getDeviceForFileStatReturns = struct { - result1 uint64 +func (fake *FakeExecutor) SymlinkArgsForCall(i int) (string, string) { + fake.symlinkMutex.RLock() + defer fake.symlinkMutex.RUnlock() + argsForCall := fake.symlinkArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeExecutor) SymlinkReturns(result1 error) { + fake.symlinkMutex.Lock() + defer fake.symlinkMutex.Unlock() + fake.SymlinkStub = nil + fake.symlinkReturns = struct { + result1 error }{result1} } -func (fake *FakeExecutor) GetDeviceForFileStatReturnsOnCall(i int, result1 uint64) { - fake.GetDeviceForFileStatStub = nil - if fake.getDeviceForFileStatReturnsOnCall == nil { - fake.getDeviceForFileStatReturnsOnCall = make(map[int]struct { - result1 uint64 +func (fake *FakeExecutor) SymlinkReturnsOnCall(i int, result1 error) { + fake.symlinkMutex.Lock() + defer fake.symlinkMutex.Unlock() + fake.SymlinkStub = nil + if fake.symlinkReturnsOnCall == nil { + fake.symlinkReturnsOnCall = make(map[int]struct { + result1 error }) } - fake.getDeviceForFileStatReturnsOnCall[i] = struct { - result1 uint64 + fake.symlinkReturnsOnCall[i] = struct { + result1 error }{result1} } func (fake *FakeExecutor) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() + fake.evalSymlinksMutex.RLock() + defer fake.evalSymlinksMutex.RUnlock() fake.executeMutex.RLock() defer fake.executeMutex.RUnlock() - fake.statMutex.RLock() - defer fake.statMutex.RUnlock() - fake.mkdirMutex.RLock() - defer fake.mkdirMutex.RUnlock() - fake.mkdirAllMutex.RLock() - defer fake.mkdirAllMutex.RUnlock() - fake.removeAllMutex.RLock() - defer fake.removeAllMutex.RUnlock() - fake.removeMutex.RLock() - defer fake.removeMutex.RUnlock() + fake.executeWithTimeoutMutex.RLock() + defer fake.executeWithTimeoutMutex.RUnlock() + fake.getDeviceForFileStatMutex.RLock() + defer fake.getDeviceForFileStatMutex.RUnlock() + fake.getGlobFilesMutex.RLock() + defer fake.getGlobFilesMutex.RUnlock() fake.hostnameMutex.RLock() defer fake.hostnameMutex.RUnlock() + fake.isDirMutex.RLock() + defer fake.isDirMutex.RUnlock() + fake.isDirEmptyMutex.RLock() + defer fake.isDirEmptyMutex.RUnlock() fake.isExecutableMutex.RLock() defer fake.isExecutableMutex.RUnlock() fake.isNotExistMutex.RLock() defer fake.isNotExistMutex.RUnlock() - fake.evalSymlinksMutex.RLock() - defer fake.evalSymlinksMutex.RUnlock() - fake.executeWithTimeoutMutex.RLock() - defer fake.executeWithTimeoutMutex.RUnlock() + fake.isSameFileMutex.RLock() + defer fake.isSameFileMutex.RUnlock() + fake.isSlinkMutex.RLock() + defer fake.isSlinkMutex.RUnlock() fake.lstatMutex.RLock() defer fake.lstatMutex.RUnlock() - fake.isDirMutex.RLock() - defer fake.isDirMutex.RUnlock() + fake.mkdirMutex.RLock() + defer fake.mkdirMutex.RUnlock() + fake.mkdirAllMutex.RLock() + defer fake.mkdirAllMutex.RUnlock() + fake.removeMutex.RLock() + defer fake.removeMutex.RUnlock() + fake.removeAllMutex.RLock() + defer fake.removeAllMutex.RUnlock() + fake.statMutex.RLock() + defer fake.statMutex.RUnlock() fake.symlinkMutex.RLock() defer fake.symlinkMutex.RUnlock() - fake.isSlinkMutex.RLock() - defer fake.isSlinkMutex.RUnlock() - fake.getGlobFilesMutex.RLock() - defer fake.getGlobFilesMutex.RUnlock() - fake.isSameFileMutex.RLock() - defer fake.isSameFileMutex.RUnlock() - fake.isDirEmptyMutex.RLock() - defer fake.isDirEmptyMutex.RUnlock() - fake.getDeviceForFileStatMutex.RLock() - defer fake.getDeviceForFileStatMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} for key, value := range fake.invocations { copiedInvocations[key] = value diff --git a/fakes/fake_initiator.go b/fakes/fake_initiator.go new file mode 100644 index 00000000..b0823a79 --- /dev/null +++ b/fakes/fake_initiator.go @@ -0,0 +1,184 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package fakes + +import ( + "sync" + + "github.com/IBM/ubiquity/remote/mounter/initiator" + "github.com/IBM/ubiquity/resources" +) + +type FakeConnector struct { + ConnectVolumeStub func(*resources.VolumeMountProperties) error + connectVolumeMutex sync.RWMutex + connectVolumeArgsForCall []struct { + arg1 *resources.VolumeMountProperties + } + connectVolumeReturns struct { + result1 error + } + connectVolumeReturnsOnCall map[int]struct { + result1 error + } + DisconnectVolumeStub func(*resources.VolumeMountProperties) error + disconnectVolumeMutex sync.RWMutex + disconnectVolumeArgsForCall []struct { + arg1 *resources.VolumeMountProperties + } + disconnectVolumeReturns struct { + result1 error + } + disconnectVolumeReturnsOnCall map[int]struct { + result1 error + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakeConnector) ConnectVolume(arg1 *resources.VolumeMountProperties) error { + fake.connectVolumeMutex.Lock() + ret, specificReturn := fake.connectVolumeReturnsOnCall[len(fake.connectVolumeArgsForCall)] + fake.connectVolumeArgsForCall = append(fake.connectVolumeArgsForCall, struct { + arg1 *resources.VolumeMountProperties + }{arg1}) + fake.recordInvocation("ConnectVolume", []interface{}{arg1}) + fake.connectVolumeMutex.Unlock() + if fake.ConnectVolumeStub != nil { + return fake.ConnectVolumeStub(arg1) + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.connectVolumeReturns + return fakeReturns.result1 +} + +func (fake *FakeConnector) ConnectVolumeCallCount() int { + fake.connectVolumeMutex.RLock() + defer fake.connectVolumeMutex.RUnlock() + return len(fake.connectVolumeArgsForCall) +} + +func (fake *FakeConnector) ConnectVolumeCalls(stub func(*resources.VolumeMountProperties) error) { + fake.connectVolumeMutex.Lock() + defer fake.connectVolumeMutex.Unlock() + fake.ConnectVolumeStub = stub +} + +func (fake *FakeConnector) ConnectVolumeArgsForCall(i int) *resources.VolumeMountProperties { + fake.connectVolumeMutex.RLock() + defer fake.connectVolumeMutex.RUnlock() + argsForCall := fake.connectVolumeArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeConnector) ConnectVolumeReturns(result1 error) { + fake.connectVolumeMutex.Lock() + defer fake.connectVolumeMutex.Unlock() + fake.ConnectVolumeStub = nil + fake.connectVolumeReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeConnector) ConnectVolumeReturnsOnCall(i int, result1 error) { + fake.connectVolumeMutex.Lock() + defer fake.connectVolumeMutex.Unlock() + fake.ConnectVolumeStub = nil + if fake.connectVolumeReturnsOnCall == nil { + fake.connectVolumeReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.connectVolumeReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeConnector) DisconnectVolume(arg1 *resources.VolumeMountProperties) error { + fake.disconnectVolumeMutex.Lock() + ret, specificReturn := fake.disconnectVolumeReturnsOnCall[len(fake.disconnectVolumeArgsForCall)] + fake.disconnectVolumeArgsForCall = append(fake.disconnectVolumeArgsForCall, struct { + arg1 *resources.VolumeMountProperties + }{arg1}) + fake.recordInvocation("DisconnectVolume", []interface{}{arg1}) + fake.disconnectVolumeMutex.Unlock() + if fake.DisconnectVolumeStub != nil { + return fake.DisconnectVolumeStub(arg1) + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.disconnectVolumeReturns + return fakeReturns.result1 +} + +func (fake *FakeConnector) DisconnectVolumeCallCount() int { + fake.disconnectVolumeMutex.RLock() + defer fake.disconnectVolumeMutex.RUnlock() + return len(fake.disconnectVolumeArgsForCall) +} + +func (fake *FakeConnector) DisconnectVolumeCalls(stub func(*resources.VolumeMountProperties) error) { + fake.disconnectVolumeMutex.Lock() + defer fake.disconnectVolumeMutex.Unlock() + fake.DisconnectVolumeStub = stub +} + +func (fake *FakeConnector) DisconnectVolumeArgsForCall(i int) *resources.VolumeMountProperties { + fake.disconnectVolumeMutex.RLock() + defer fake.disconnectVolumeMutex.RUnlock() + argsForCall := fake.disconnectVolumeArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeConnector) DisconnectVolumeReturns(result1 error) { + fake.disconnectVolumeMutex.Lock() + defer fake.disconnectVolumeMutex.Unlock() + fake.DisconnectVolumeStub = nil + fake.disconnectVolumeReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeConnector) DisconnectVolumeReturnsOnCall(i int, result1 error) { + fake.disconnectVolumeMutex.Lock() + defer fake.disconnectVolumeMutex.Unlock() + fake.DisconnectVolumeStub = nil + if fake.disconnectVolumeReturnsOnCall == nil { + fake.disconnectVolumeReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.disconnectVolumeReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeConnector) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.connectVolumeMutex.RLock() + defer fake.connectVolumeMutex.RUnlock() + fake.disconnectVolumeMutex.RLock() + defer fake.disconnectVolumeMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *FakeConnector) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +} + +var _ initiator.Connector = new(FakeConnector) diff --git a/fakes/fake_mounter.go b/fakes/fake_mounter.go index 482dc368..44248463 100644 --- a/fakes/fake_mounter.go +++ b/fakes/fake_mounter.go @@ -1,19 +1,3 @@ -/** - * Copyright 2017 IBM Corp. - * - * 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. - */ - // Code generated by counterfeiter. DO NOT EDIT. package fakes @@ -24,10 +8,21 @@ import ( ) type FakeMounter struct { - MountStub func(mountRequest resources.MountRequest) (string, error) + ActionAfterDetachStub func(resources.AfterDetachRequest) error + actionAfterDetachMutex sync.RWMutex + actionAfterDetachArgsForCall []struct { + arg1 resources.AfterDetachRequest + } + actionAfterDetachReturns struct { + result1 error + } + actionAfterDetachReturnsOnCall map[int]struct { + result1 error + } + MountStub func(resources.MountRequest) (string, error) mountMutex sync.RWMutex mountArgsForCall []struct { - mountRequest resources.MountRequest + arg1 resources.MountRequest } mountReturns struct { result1 string @@ -37,10 +32,10 @@ type FakeMounter struct { result1 string result2 error } - UnmountStub func(unmountRequest resources.UnmountRequest) error + UnmountStub func(resources.UnmountRequest) error unmountMutex sync.RWMutex unmountArgsForCall []struct { - unmountRequest resources.UnmountRequest + arg1 resources.UnmountRequest } unmountReturns struct { result1 error @@ -48,36 +43,86 @@ type FakeMounter struct { unmountReturnsOnCall map[int]struct { result1 error } - ActionAfterDetachStub func(request resources.AfterDetachRequest) error - actionAfterDetachMutex sync.RWMutex - actionAfterDetachArgsForCall []struct { - request resources.AfterDetachRequest + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakeMounter) ActionAfterDetach(arg1 resources.AfterDetachRequest) error { + fake.actionAfterDetachMutex.Lock() + ret, specificReturn := fake.actionAfterDetachReturnsOnCall[len(fake.actionAfterDetachArgsForCall)] + fake.actionAfterDetachArgsForCall = append(fake.actionAfterDetachArgsForCall, struct { + arg1 resources.AfterDetachRequest + }{arg1}) + fake.recordInvocation("ActionAfterDetach", []interface{}{arg1}) + fake.actionAfterDetachMutex.Unlock() + if fake.ActionAfterDetachStub != nil { + return fake.ActionAfterDetachStub(arg1) } - actionAfterDetachReturns struct { - result1 error + if specificReturn { + return ret.result1 } - actionAfterDetachReturnsOnCall map[int]struct { + fakeReturns := fake.actionAfterDetachReturns + return fakeReturns.result1 +} + +func (fake *FakeMounter) ActionAfterDetachCallCount() int { + fake.actionAfterDetachMutex.RLock() + defer fake.actionAfterDetachMutex.RUnlock() + return len(fake.actionAfterDetachArgsForCall) +} + +func (fake *FakeMounter) ActionAfterDetachCalls(stub func(resources.AfterDetachRequest) error) { + fake.actionAfterDetachMutex.Lock() + defer fake.actionAfterDetachMutex.Unlock() + fake.ActionAfterDetachStub = stub +} + +func (fake *FakeMounter) ActionAfterDetachArgsForCall(i int) resources.AfterDetachRequest { + fake.actionAfterDetachMutex.RLock() + defer fake.actionAfterDetachMutex.RUnlock() + argsForCall := fake.actionAfterDetachArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeMounter) ActionAfterDetachReturns(result1 error) { + fake.actionAfterDetachMutex.Lock() + defer fake.actionAfterDetachMutex.Unlock() + fake.ActionAfterDetachStub = nil + fake.actionAfterDetachReturns = struct { result1 error + }{result1} +} + +func (fake *FakeMounter) ActionAfterDetachReturnsOnCall(i int, result1 error) { + fake.actionAfterDetachMutex.Lock() + defer fake.actionAfterDetachMutex.Unlock() + fake.ActionAfterDetachStub = nil + if fake.actionAfterDetachReturnsOnCall == nil { + fake.actionAfterDetachReturnsOnCall = make(map[int]struct { + result1 error + }) } - invocations map[string][][]interface{} - invocationsMutex sync.RWMutex + fake.actionAfterDetachReturnsOnCall[i] = struct { + result1 error + }{result1} } -func (fake *FakeMounter) Mount(mountRequest resources.MountRequest) (string, error) { +func (fake *FakeMounter) Mount(arg1 resources.MountRequest) (string, error) { fake.mountMutex.Lock() ret, specificReturn := fake.mountReturnsOnCall[len(fake.mountArgsForCall)] fake.mountArgsForCall = append(fake.mountArgsForCall, struct { - mountRequest resources.MountRequest - }{mountRequest}) - fake.recordInvocation("Mount", []interface{}{mountRequest}) + arg1 resources.MountRequest + }{arg1}) + fake.recordInvocation("Mount", []interface{}{arg1}) fake.mountMutex.Unlock() if fake.MountStub != nil { - return fake.MountStub(mountRequest) + return fake.MountStub(arg1) } if specificReturn { return ret.result1, ret.result2 } - return fake.mountReturns.result1, fake.mountReturns.result2 + fakeReturns := fake.mountReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeMounter) MountCallCount() int { @@ -86,13 +131,22 @@ func (fake *FakeMounter) MountCallCount() int { return len(fake.mountArgsForCall) } +func (fake *FakeMounter) MountCalls(stub func(resources.MountRequest) (string, error)) { + fake.mountMutex.Lock() + defer fake.mountMutex.Unlock() + fake.MountStub = stub +} + func (fake *FakeMounter) MountArgsForCall(i int) resources.MountRequest { fake.mountMutex.RLock() defer fake.mountMutex.RUnlock() - return fake.mountArgsForCall[i].mountRequest + argsForCall := fake.mountArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeMounter) MountReturns(result1 string, result2 error) { + fake.mountMutex.Lock() + defer fake.mountMutex.Unlock() fake.MountStub = nil fake.mountReturns = struct { result1 string @@ -101,6 +155,8 @@ func (fake *FakeMounter) MountReturns(result1 string, result2 error) { } func (fake *FakeMounter) MountReturnsOnCall(i int, result1 string, result2 error) { + fake.mountMutex.Lock() + defer fake.mountMutex.Unlock() fake.MountStub = nil if fake.mountReturnsOnCall == nil { fake.mountReturnsOnCall = make(map[int]struct { @@ -114,21 +170,22 @@ func (fake *FakeMounter) MountReturnsOnCall(i int, result1 string, result2 error }{result1, result2} } -func (fake *FakeMounter) Unmount(unmountRequest resources.UnmountRequest) error { +func (fake *FakeMounter) Unmount(arg1 resources.UnmountRequest) error { fake.unmountMutex.Lock() ret, specificReturn := fake.unmountReturnsOnCall[len(fake.unmountArgsForCall)] fake.unmountArgsForCall = append(fake.unmountArgsForCall, struct { - unmountRequest resources.UnmountRequest - }{unmountRequest}) - fake.recordInvocation("Unmount", []interface{}{unmountRequest}) + arg1 resources.UnmountRequest + }{arg1}) + fake.recordInvocation("Unmount", []interface{}{arg1}) fake.unmountMutex.Unlock() if fake.UnmountStub != nil { - return fake.UnmountStub(unmountRequest) + return fake.UnmountStub(arg1) } if specificReturn { return ret.result1 } - return fake.unmountReturns.result1 + fakeReturns := fake.unmountReturns + return fakeReturns.result1 } func (fake *FakeMounter) UnmountCallCount() int { @@ -137,13 +194,22 @@ func (fake *FakeMounter) UnmountCallCount() int { return len(fake.unmountArgsForCall) } +func (fake *FakeMounter) UnmountCalls(stub func(resources.UnmountRequest) error) { + fake.unmountMutex.Lock() + defer fake.unmountMutex.Unlock() + fake.UnmountStub = stub +} + func (fake *FakeMounter) UnmountArgsForCall(i int) resources.UnmountRequest { fake.unmountMutex.RLock() defer fake.unmountMutex.RUnlock() - return fake.unmountArgsForCall[i].unmountRequest + argsForCall := fake.unmountArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeMounter) UnmountReturns(result1 error) { + fake.unmountMutex.Lock() + defer fake.unmountMutex.Unlock() fake.UnmountStub = nil fake.unmountReturns = struct { result1 error @@ -151,6 +217,8 @@ func (fake *FakeMounter) UnmountReturns(result1 error) { } func (fake *FakeMounter) UnmountReturnsOnCall(i int, result1 error) { + fake.unmountMutex.Lock() + defer fake.unmountMutex.Unlock() fake.UnmountStub = nil if fake.unmountReturnsOnCall == nil { fake.unmountReturnsOnCall = make(map[int]struct { @@ -162,63 +230,15 @@ func (fake *FakeMounter) UnmountReturnsOnCall(i int, result1 error) { }{result1} } -func (fake *FakeMounter) ActionAfterDetach(request resources.AfterDetachRequest) error { - fake.actionAfterDetachMutex.Lock() - ret, specificReturn := fake.actionAfterDetachReturnsOnCall[len(fake.actionAfterDetachArgsForCall)] - fake.actionAfterDetachArgsForCall = append(fake.actionAfterDetachArgsForCall, struct { - request resources.AfterDetachRequest - }{request}) - fake.recordInvocation("ActionAfterDetach", []interface{}{request}) - fake.actionAfterDetachMutex.Unlock() - if fake.ActionAfterDetachStub != nil { - return fake.ActionAfterDetachStub(request) - } - if specificReturn { - return ret.result1 - } - return fake.actionAfterDetachReturns.result1 -} - -func (fake *FakeMounter) ActionAfterDetachCallCount() int { - fake.actionAfterDetachMutex.RLock() - defer fake.actionAfterDetachMutex.RUnlock() - return len(fake.actionAfterDetachArgsForCall) -} - -func (fake *FakeMounter) ActionAfterDetachArgsForCall(i int) resources.AfterDetachRequest { - fake.actionAfterDetachMutex.RLock() - defer fake.actionAfterDetachMutex.RUnlock() - return fake.actionAfterDetachArgsForCall[i].request -} - -func (fake *FakeMounter) ActionAfterDetachReturns(result1 error) { - fake.ActionAfterDetachStub = nil - fake.actionAfterDetachReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeMounter) ActionAfterDetachReturnsOnCall(i int, result1 error) { - fake.ActionAfterDetachStub = nil - if fake.actionAfterDetachReturnsOnCall == nil { - fake.actionAfterDetachReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.actionAfterDetachReturnsOnCall[i] = struct { - result1 error - }{result1} -} - func (fake *FakeMounter) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() + fake.actionAfterDetachMutex.RLock() + defer fake.actionAfterDetachMutex.RUnlock() fake.mountMutex.RLock() defer fake.mountMutex.RUnlock() fake.unmountMutex.RLock() defer fake.unmountMutex.RUnlock() - fake.actionAfterDetachMutex.RLock() - defer fake.actionAfterDetachMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} for key, value := range fake.invocations { copiedInvocations[key] = value diff --git a/fakes/fake_mounter_factory.go b/fakes/fake_mounter_factory.go index 1760d5b0..0576c79b 100644 --- a/fakes/fake_mounter_factory.go +++ b/fakes/fake_mounter_factory.go @@ -10,13 +10,13 @@ import ( ) type FakeMounterFactory struct { - GetMounterPerBackendStub func(backend string, legacyLogger *log.Logger, pluginConfig resources.UbiquityPluginConfig, requestContext resources.RequestContext) (resources.Mounter, error) + GetMounterPerBackendStub func(string, *log.Logger, resources.UbiquityPluginConfig, resources.RequestContext) (resources.Mounter, error) getMounterPerBackendMutex sync.RWMutex getMounterPerBackendArgsForCall []struct { - backend string - legacyLogger *log.Logger - pluginConfig resources.UbiquityPluginConfig - requestContext resources.RequestContext + arg1 string + arg2 *log.Logger + arg3 resources.UbiquityPluginConfig + arg4 resources.RequestContext } getMounterPerBackendReturns struct { result1 resources.Mounter @@ -30,24 +30,25 @@ type FakeMounterFactory struct { invocationsMutex sync.RWMutex } -func (fake *FakeMounterFactory) GetMounterPerBackend(backend string, legacyLogger *log.Logger, pluginConfig resources.UbiquityPluginConfig, requestContext resources.RequestContext) (resources.Mounter, error) { +func (fake *FakeMounterFactory) GetMounterPerBackend(arg1 string, arg2 *log.Logger, arg3 resources.UbiquityPluginConfig, arg4 resources.RequestContext) (resources.Mounter, error) { fake.getMounterPerBackendMutex.Lock() ret, specificReturn := fake.getMounterPerBackendReturnsOnCall[len(fake.getMounterPerBackendArgsForCall)] fake.getMounterPerBackendArgsForCall = append(fake.getMounterPerBackendArgsForCall, struct { - backend string - legacyLogger *log.Logger - pluginConfig resources.UbiquityPluginConfig - requestContext resources.RequestContext - }{backend, legacyLogger, pluginConfig, requestContext}) - fake.recordInvocation("GetMounterPerBackend", []interface{}{backend, legacyLogger, pluginConfig, requestContext}) + arg1 string + arg2 *log.Logger + arg3 resources.UbiquityPluginConfig + arg4 resources.RequestContext + }{arg1, arg2, arg3, arg4}) + fake.recordInvocation("GetMounterPerBackend", []interface{}{arg1, arg2, arg3, arg4}) fake.getMounterPerBackendMutex.Unlock() if fake.GetMounterPerBackendStub != nil { - return fake.GetMounterPerBackendStub(backend, legacyLogger, pluginConfig, requestContext) + return fake.GetMounterPerBackendStub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2 } - return fake.getMounterPerBackendReturns.result1, fake.getMounterPerBackendReturns.result2 + fakeReturns := fake.getMounterPerBackendReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeMounterFactory) GetMounterPerBackendCallCount() int { @@ -56,13 +57,22 @@ func (fake *FakeMounterFactory) GetMounterPerBackendCallCount() int { return len(fake.getMounterPerBackendArgsForCall) } +func (fake *FakeMounterFactory) GetMounterPerBackendCalls(stub func(string, *log.Logger, resources.UbiquityPluginConfig, resources.RequestContext) (resources.Mounter, error)) { + fake.getMounterPerBackendMutex.Lock() + defer fake.getMounterPerBackendMutex.Unlock() + fake.GetMounterPerBackendStub = stub +} + func (fake *FakeMounterFactory) GetMounterPerBackendArgsForCall(i int) (string, *log.Logger, resources.UbiquityPluginConfig, resources.RequestContext) { fake.getMounterPerBackendMutex.RLock() defer fake.getMounterPerBackendMutex.RUnlock() - return fake.getMounterPerBackendArgsForCall[i].backend, fake.getMounterPerBackendArgsForCall[i].legacyLogger, fake.getMounterPerBackendArgsForCall[i].pluginConfig, fake.getMounterPerBackendArgsForCall[i].requestContext + argsForCall := fake.getMounterPerBackendArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4 } func (fake *FakeMounterFactory) GetMounterPerBackendReturns(result1 resources.Mounter, result2 error) { + fake.getMounterPerBackendMutex.Lock() + defer fake.getMounterPerBackendMutex.Unlock() fake.GetMounterPerBackendStub = nil fake.getMounterPerBackendReturns = struct { result1 resources.Mounter @@ -71,6 +81,8 @@ func (fake *FakeMounterFactory) GetMounterPerBackendReturns(result1 resources.Mo } func (fake *FakeMounterFactory) GetMounterPerBackendReturnsOnCall(i int, result1 resources.Mounter, result2 error) { + fake.getMounterPerBackendMutex.Lock() + defer fake.getMounterPerBackendMutex.Unlock() fake.GetMounterPerBackendStub = nil if fake.getMounterPerBackendReturnsOnCall == nil { fake.getMounterPerBackendReturnsOnCall = make(map[int]struct { diff --git a/fakes/fake_scbe_rest_client.go b/fakes/fake_scbe_rest_client.go index 56c9f081..b44065f3 100644 --- a/fakes/fake_scbe_rest_client.go +++ b/fakes/fake_scbe_rest_client.go @@ -8,21 +8,12 @@ import ( ) type FakeScbeRestClient struct { - LoginStub func() error - loginMutex sync.RWMutex - loginArgsForCall []struct{} - loginReturns struct { - result1 error - } - loginReturnsOnCall map[int]struct { - result1 error - } - CreateVolumeStub func(volName string, serviceName string, size int) (scbe.ScbeVolumeInfo, error) + CreateVolumeStub func(string, string, int) (scbe.ScbeVolumeInfo, error) createVolumeMutex sync.RWMutex createVolumeArgsForCall []struct { - volName string - serviceName string - size int + arg1 string + arg2 string + arg3 int } createVolumeReturns struct { result1 scbe.ScbeVolumeInfo @@ -32,10 +23,34 @@ type FakeScbeRestClient struct { result1 scbe.ScbeVolumeInfo result2 error } - GetVolumesStub func(wwn string) ([]scbe.ScbeVolumeInfo, error) + DeleteVolumeStub func(string) error + deleteVolumeMutex sync.RWMutex + deleteVolumeArgsForCall []struct { + arg1 string + } + deleteVolumeReturns struct { + result1 error + } + deleteVolumeReturnsOnCall map[int]struct { + result1 error + } + GetVolMappingStub func(string) (scbe.ScbeVolumeMapInfo, error) + getVolMappingMutex sync.RWMutex + getVolMappingArgsForCall []struct { + arg1 string + } + getVolMappingReturns struct { + result1 scbe.ScbeVolumeMapInfo + result2 error + } + getVolMappingReturnsOnCall map[int]struct { + result1 scbe.ScbeVolumeMapInfo + result2 error + } + GetVolumesStub func(string) ([]scbe.ScbeVolumeInfo, error) getVolumesMutex sync.RWMutex getVolumesArgsForCall []struct { - wwn string + arg1 string } getVolumesReturns struct { result1 []scbe.ScbeVolumeInfo @@ -45,22 +60,21 @@ type FakeScbeRestClient struct { result1 []scbe.ScbeVolumeInfo result2 error } - DeleteVolumeStub func(wwn string) error - deleteVolumeMutex sync.RWMutex - deleteVolumeArgsForCall []struct { - wwn string + LoginStub func() error + loginMutex sync.RWMutex + loginArgsForCall []struct { } - deleteVolumeReturns struct { + loginReturns struct { result1 error } - deleteVolumeReturnsOnCall map[int]struct { + loginReturnsOnCall map[int]struct { result1 error } - MapVolumeStub func(wwn string, host string) (scbe.ScbeResponseMapping, error) + MapVolumeStub func(string, string) (scbe.ScbeResponseMapping, error) mapVolumeMutex sync.RWMutex mapVolumeArgsForCall []struct { - wwn string - host string + arg1 string + arg2 string } mapVolumeReturns struct { result1 scbe.ScbeResponseMapping @@ -70,35 +84,10 @@ type FakeScbeRestClient struct { result1 scbe.ScbeResponseMapping result2 error } - UnmapVolumeStub func(wwn string, host string) error - unmapVolumeMutex sync.RWMutex - unmapVolumeArgsForCall []struct { - wwn string - host string - } - unmapVolumeReturns struct { - result1 error - } - unmapVolumeReturnsOnCall map[int]struct { - result1 error - } - GetVolMappingStub func(wwn string) (scbe.ScbeVolumeMapInfo, error) - getVolMappingMutex sync.RWMutex - getVolMappingArgsForCall []struct { - wwn string - } - getVolMappingReturns struct { - result1 scbe.ScbeVolumeMapInfo - result2 error - } - getVolMappingReturnsOnCall map[int]struct { - result1 scbe.ScbeVolumeMapInfo - result2 error - } - ServiceExistStub func(serviceName string) (bool, error) + ServiceExistStub func(string) (bool, error) serviceExistMutex sync.RWMutex serviceExistArgsForCall []struct { - serviceName string + arg1 string } serviceExistReturns struct { result1 bool @@ -108,67 +97,40 @@ type FakeScbeRestClient struct { result1 bool result2 error } - invocations map[string][][]interface{} - invocationsMutex sync.RWMutex -} - -func (fake *FakeScbeRestClient) Login() error { - fake.loginMutex.Lock() - ret, specificReturn := fake.loginReturnsOnCall[len(fake.loginArgsForCall)] - fake.loginArgsForCall = append(fake.loginArgsForCall, struct{}{}) - fake.recordInvocation("Login", []interface{}{}) - fake.loginMutex.Unlock() - if fake.LoginStub != nil { - return fake.LoginStub() - } - if specificReturn { - return ret.result1 + UnmapVolumeStub func(string, string) error + unmapVolumeMutex sync.RWMutex + unmapVolumeArgsForCall []struct { + arg1 string + arg2 string } - return fake.loginReturns.result1 -} - -func (fake *FakeScbeRestClient) LoginCallCount() int { - fake.loginMutex.RLock() - defer fake.loginMutex.RUnlock() - return len(fake.loginArgsForCall) -} - -func (fake *FakeScbeRestClient) LoginReturns(result1 error) { - fake.LoginStub = nil - fake.loginReturns = struct { + unmapVolumeReturns struct { result1 error - }{result1} -} - -func (fake *FakeScbeRestClient) LoginReturnsOnCall(i int, result1 error) { - fake.LoginStub = nil - if fake.loginReturnsOnCall == nil { - fake.loginReturnsOnCall = make(map[int]struct { - result1 error - }) } - fake.loginReturnsOnCall[i] = struct { + unmapVolumeReturnsOnCall map[int]struct { result1 error - }{result1} + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex } -func (fake *FakeScbeRestClient) CreateVolume(volName string, serviceName string, size int) (scbe.ScbeVolumeInfo, error) { +func (fake *FakeScbeRestClient) CreateVolume(arg1 string, arg2 string, arg3 int) (scbe.ScbeVolumeInfo, error) { fake.createVolumeMutex.Lock() ret, specificReturn := fake.createVolumeReturnsOnCall[len(fake.createVolumeArgsForCall)] fake.createVolumeArgsForCall = append(fake.createVolumeArgsForCall, struct { - volName string - serviceName string - size int - }{volName, serviceName, size}) - fake.recordInvocation("CreateVolume", []interface{}{volName, serviceName, size}) + arg1 string + arg2 string + arg3 int + }{arg1, arg2, arg3}) + fake.recordInvocation("CreateVolume", []interface{}{arg1, arg2, arg3}) fake.createVolumeMutex.Unlock() if fake.CreateVolumeStub != nil { - return fake.CreateVolumeStub(volName, serviceName, size) + return fake.CreateVolumeStub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - return fake.createVolumeReturns.result1, fake.createVolumeReturns.result2 + fakeReturns := fake.createVolumeReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeScbeRestClient) CreateVolumeCallCount() int { @@ -177,13 +139,22 @@ func (fake *FakeScbeRestClient) CreateVolumeCallCount() int { return len(fake.createVolumeArgsForCall) } +func (fake *FakeScbeRestClient) CreateVolumeCalls(stub func(string, string, int) (scbe.ScbeVolumeInfo, error)) { + fake.createVolumeMutex.Lock() + defer fake.createVolumeMutex.Unlock() + fake.CreateVolumeStub = stub +} + func (fake *FakeScbeRestClient) CreateVolumeArgsForCall(i int) (string, string, int) { fake.createVolumeMutex.RLock() defer fake.createVolumeMutex.RUnlock() - return fake.createVolumeArgsForCall[i].volName, fake.createVolumeArgsForCall[i].serviceName, fake.createVolumeArgsForCall[i].size + argsForCall := fake.createVolumeArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 } func (fake *FakeScbeRestClient) CreateVolumeReturns(result1 scbe.ScbeVolumeInfo, result2 error) { + fake.createVolumeMutex.Lock() + defer fake.createVolumeMutex.Unlock() fake.CreateVolumeStub = nil fake.createVolumeReturns = struct { result1 scbe.ScbeVolumeInfo @@ -192,6 +163,8 @@ func (fake *FakeScbeRestClient) CreateVolumeReturns(result1 scbe.ScbeVolumeInfo, } func (fake *FakeScbeRestClient) CreateVolumeReturnsOnCall(i int, result1 scbe.ScbeVolumeInfo, result2 error) { + fake.createVolumeMutex.Lock() + defer fake.createVolumeMutex.Unlock() fake.CreateVolumeStub = nil if fake.createVolumeReturnsOnCall == nil { fake.createVolumeReturnsOnCall = make(map[int]struct { @@ -205,21 +178,145 @@ func (fake *FakeScbeRestClient) CreateVolumeReturnsOnCall(i int, result1 scbe.Sc }{result1, result2} } -func (fake *FakeScbeRestClient) GetVolumes(wwn string) ([]scbe.ScbeVolumeInfo, error) { +func (fake *FakeScbeRestClient) DeleteVolume(arg1 string) error { + fake.deleteVolumeMutex.Lock() + ret, specificReturn := fake.deleteVolumeReturnsOnCall[len(fake.deleteVolumeArgsForCall)] + fake.deleteVolumeArgsForCall = append(fake.deleteVolumeArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("DeleteVolume", []interface{}{arg1}) + fake.deleteVolumeMutex.Unlock() + if fake.DeleteVolumeStub != nil { + return fake.DeleteVolumeStub(arg1) + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.deleteVolumeReturns + return fakeReturns.result1 +} + +func (fake *FakeScbeRestClient) DeleteVolumeCallCount() int { + fake.deleteVolumeMutex.RLock() + defer fake.deleteVolumeMutex.RUnlock() + return len(fake.deleteVolumeArgsForCall) +} + +func (fake *FakeScbeRestClient) DeleteVolumeCalls(stub func(string) error) { + fake.deleteVolumeMutex.Lock() + defer fake.deleteVolumeMutex.Unlock() + fake.DeleteVolumeStub = stub +} + +func (fake *FakeScbeRestClient) DeleteVolumeArgsForCall(i int) string { + fake.deleteVolumeMutex.RLock() + defer fake.deleteVolumeMutex.RUnlock() + argsForCall := fake.deleteVolumeArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeScbeRestClient) DeleteVolumeReturns(result1 error) { + fake.deleteVolumeMutex.Lock() + defer fake.deleteVolumeMutex.Unlock() + fake.DeleteVolumeStub = nil + fake.deleteVolumeReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeScbeRestClient) DeleteVolumeReturnsOnCall(i int, result1 error) { + fake.deleteVolumeMutex.Lock() + defer fake.deleteVolumeMutex.Unlock() + fake.DeleteVolumeStub = nil + if fake.deleteVolumeReturnsOnCall == nil { + fake.deleteVolumeReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.deleteVolumeReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeScbeRestClient) GetVolMapping(arg1 string) (scbe.ScbeVolumeMapInfo, error) { + fake.getVolMappingMutex.Lock() + ret, specificReturn := fake.getVolMappingReturnsOnCall[len(fake.getVolMappingArgsForCall)] + fake.getVolMappingArgsForCall = append(fake.getVolMappingArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("GetVolMapping", []interface{}{arg1}) + fake.getVolMappingMutex.Unlock() + if fake.GetVolMappingStub != nil { + return fake.GetVolMappingStub(arg1) + } + if specificReturn { + return ret.result1, ret.result2 + } + fakeReturns := fake.getVolMappingReturns + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeScbeRestClient) GetVolMappingCallCount() int { + fake.getVolMappingMutex.RLock() + defer fake.getVolMappingMutex.RUnlock() + return len(fake.getVolMappingArgsForCall) +} + +func (fake *FakeScbeRestClient) GetVolMappingCalls(stub func(string) (scbe.ScbeVolumeMapInfo, error)) { + fake.getVolMappingMutex.Lock() + defer fake.getVolMappingMutex.Unlock() + fake.GetVolMappingStub = stub +} + +func (fake *FakeScbeRestClient) GetVolMappingArgsForCall(i int) string { + fake.getVolMappingMutex.RLock() + defer fake.getVolMappingMutex.RUnlock() + argsForCall := fake.getVolMappingArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeScbeRestClient) GetVolMappingReturns(result1 scbe.ScbeVolumeMapInfo, result2 error) { + fake.getVolMappingMutex.Lock() + defer fake.getVolMappingMutex.Unlock() + fake.GetVolMappingStub = nil + fake.getVolMappingReturns = struct { + result1 scbe.ScbeVolumeMapInfo + result2 error + }{result1, result2} +} + +func (fake *FakeScbeRestClient) GetVolMappingReturnsOnCall(i int, result1 scbe.ScbeVolumeMapInfo, result2 error) { + fake.getVolMappingMutex.Lock() + defer fake.getVolMappingMutex.Unlock() + fake.GetVolMappingStub = nil + if fake.getVolMappingReturnsOnCall == nil { + fake.getVolMappingReturnsOnCall = make(map[int]struct { + result1 scbe.ScbeVolumeMapInfo + result2 error + }) + } + fake.getVolMappingReturnsOnCall[i] = struct { + result1 scbe.ScbeVolumeMapInfo + result2 error + }{result1, result2} +} + +func (fake *FakeScbeRestClient) GetVolumes(arg1 string) ([]scbe.ScbeVolumeInfo, error) { fake.getVolumesMutex.Lock() ret, specificReturn := fake.getVolumesReturnsOnCall[len(fake.getVolumesArgsForCall)] fake.getVolumesArgsForCall = append(fake.getVolumesArgsForCall, struct { - wwn string - }{wwn}) - fake.recordInvocation("GetVolumes", []interface{}{wwn}) + arg1 string + }{arg1}) + fake.recordInvocation("GetVolumes", []interface{}{arg1}) fake.getVolumesMutex.Unlock() if fake.GetVolumesStub != nil { - return fake.GetVolumesStub(wwn) + return fake.GetVolumesStub(arg1) } if specificReturn { return ret.result1, ret.result2 } - return fake.getVolumesReturns.result1, fake.getVolumesReturns.result2 + fakeReturns := fake.getVolumesReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeScbeRestClient) GetVolumesCallCount() int { @@ -228,13 +325,22 @@ func (fake *FakeScbeRestClient) GetVolumesCallCount() int { return len(fake.getVolumesArgsForCall) } +func (fake *FakeScbeRestClient) GetVolumesCalls(stub func(string) ([]scbe.ScbeVolumeInfo, error)) { + fake.getVolumesMutex.Lock() + defer fake.getVolumesMutex.Unlock() + fake.GetVolumesStub = stub +} + func (fake *FakeScbeRestClient) GetVolumesArgsForCall(i int) string { fake.getVolumesMutex.RLock() defer fake.getVolumesMutex.RUnlock() - return fake.getVolumesArgsForCall[i].wwn + argsForCall := fake.getVolumesArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeScbeRestClient) GetVolumesReturns(result1 []scbe.ScbeVolumeInfo, result2 error) { + fake.getVolumesMutex.Lock() + defer fake.getVolumesMutex.Unlock() fake.GetVolumesStub = nil fake.getVolumesReturns = struct { result1 []scbe.ScbeVolumeInfo @@ -243,6 +349,8 @@ func (fake *FakeScbeRestClient) GetVolumesReturns(result1 []scbe.ScbeVolumeInfo, } func (fake *FakeScbeRestClient) GetVolumesReturnsOnCall(i int, result1 []scbe.ScbeVolumeInfo, result2 error) { + fake.getVolumesMutex.Lock() + defer fake.getVolumesMutex.Unlock() fake.GetVolumesStub = nil if fake.getVolumesReturnsOnCall == nil { fake.getVolumesReturnsOnCall = make(map[int]struct { @@ -256,70 +364,75 @@ func (fake *FakeScbeRestClient) GetVolumesReturnsOnCall(i int, result1 []scbe.Sc }{result1, result2} } -func (fake *FakeScbeRestClient) DeleteVolume(wwn string) error { - fake.deleteVolumeMutex.Lock() - ret, specificReturn := fake.deleteVolumeReturnsOnCall[len(fake.deleteVolumeArgsForCall)] - fake.deleteVolumeArgsForCall = append(fake.deleteVolumeArgsForCall, struct { - wwn string - }{wwn}) - fake.recordInvocation("DeleteVolume", []interface{}{wwn}) - fake.deleteVolumeMutex.Unlock() - if fake.DeleteVolumeStub != nil { - return fake.DeleteVolumeStub(wwn) +func (fake *FakeScbeRestClient) Login() error { + fake.loginMutex.Lock() + ret, specificReturn := fake.loginReturnsOnCall[len(fake.loginArgsForCall)] + fake.loginArgsForCall = append(fake.loginArgsForCall, struct { + }{}) + fake.recordInvocation("Login", []interface{}{}) + fake.loginMutex.Unlock() + if fake.LoginStub != nil { + return fake.LoginStub() } if specificReturn { return ret.result1 } - return fake.deleteVolumeReturns.result1 + fakeReturns := fake.loginReturns + return fakeReturns.result1 } -func (fake *FakeScbeRestClient) DeleteVolumeCallCount() int { - fake.deleteVolumeMutex.RLock() - defer fake.deleteVolumeMutex.RUnlock() - return len(fake.deleteVolumeArgsForCall) +func (fake *FakeScbeRestClient) LoginCallCount() int { + fake.loginMutex.RLock() + defer fake.loginMutex.RUnlock() + return len(fake.loginArgsForCall) } -func (fake *FakeScbeRestClient) DeleteVolumeArgsForCall(i int) string { - fake.deleteVolumeMutex.RLock() - defer fake.deleteVolumeMutex.RUnlock() - return fake.deleteVolumeArgsForCall[i].wwn +func (fake *FakeScbeRestClient) LoginCalls(stub func() error) { + fake.loginMutex.Lock() + defer fake.loginMutex.Unlock() + fake.LoginStub = stub } -func (fake *FakeScbeRestClient) DeleteVolumeReturns(result1 error) { - fake.DeleteVolumeStub = nil - fake.deleteVolumeReturns = struct { +func (fake *FakeScbeRestClient) LoginReturns(result1 error) { + fake.loginMutex.Lock() + defer fake.loginMutex.Unlock() + fake.LoginStub = nil + fake.loginReturns = struct { result1 error }{result1} } -func (fake *FakeScbeRestClient) DeleteVolumeReturnsOnCall(i int, result1 error) { - fake.DeleteVolumeStub = nil - if fake.deleteVolumeReturnsOnCall == nil { - fake.deleteVolumeReturnsOnCall = make(map[int]struct { +func (fake *FakeScbeRestClient) LoginReturnsOnCall(i int, result1 error) { + fake.loginMutex.Lock() + defer fake.loginMutex.Unlock() + fake.LoginStub = nil + if fake.loginReturnsOnCall == nil { + fake.loginReturnsOnCall = make(map[int]struct { result1 error }) } - fake.deleteVolumeReturnsOnCall[i] = struct { + fake.loginReturnsOnCall[i] = struct { result1 error }{result1} } -func (fake *FakeScbeRestClient) MapVolume(wwn string, host string) (scbe.ScbeResponseMapping, error) { +func (fake *FakeScbeRestClient) MapVolume(arg1 string, arg2 string) (scbe.ScbeResponseMapping, error) { fake.mapVolumeMutex.Lock() ret, specificReturn := fake.mapVolumeReturnsOnCall[len(fake.mapVolumeArgsForCall)] fake.mapVolumeArgsForCall = append(fake.mapVolumeArgsForCall, struct { - wwn string - host string - }{wwn, host}) - fake.recordInvocation("MapVolume", []interface{}{wwn, host}) + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("MapVolume", []interface{}{arg1, arg2}) fake.mapVolumeMutex.Unlock() if fake.MapVolumeStub != nil { - return fake.MapVolumeStub(wwn, host) + return fake.MapVolumeStub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - return fake.mapVolumeReturns.result1, fake.mapVolumeReturns.result2 + fakeReturns := fake.mapVolumeReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeScbeRestClient) MapVolumeCallCount() int { @@ -328,13 +441,22 @@ func (fake *FakeScbeRestClient) MapVolumeCallCount() int { return len(fake.mapVolumeArgsForCall) } +func (fake *FakeScbeRestClient) MapVolumeCalls(stub func(string, string) (scbe.ScbeResponseMapping, error)) { + fake.mapVolumeMutex.Lock() + defer fake.mapVolumeMutex.Unlock() + fake.MapVolumeStub = stub +} + func (fake *FakeScbeRestClient) MapVolumeArgsForCall(i int) (string, string) { fake.mapVolumeMutex.RLock() defer fake.mapVolumeMutex.RUnlock() - return fake.mapVolumeArgsForCall[i].wwn, fake.mapVolumeArgsForCall[i].host + argsForCall := fake.mapVolumeArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } func (fake *FakeScbeRestClient) MapVolumeReturns(result1 scbe.ScbeResponseMapping, result2 error) { + fake.mapVolumeMutex.Lock() + defer fake.mapVolumeMutex.Unlock() fake.MapVolumeStub = nil fake.mapVolumeReturns = struct { result1 scbe.ScbeResponseMapping @@ -343,6 +465,8 @@ func (fake *FakeScbeRestClient) MapVolumeReturns(result1 scbe.ScbeResponseMappin } func (fake *FakeScbeRestClient) MapVolumeReturnsOnCall(i int, result1 scbe.ScbeResponseMapping, result2 error) { + fake.mapVolumeMutex.Lock() + defer fake.mapVolumeMutex.Unlock() fake.MapVolumeStub = nil if fake.mapVolumeReturnsOnCall == nil { fake.mapVolumeReturnsOnCall = make(map[int]struct { @@ -356,121 +480,22 @@ func (fake *FakeScbeRestClient) MapVolumeReturnsOnCall(i int, result1 scbe.ScbeR }{result1, result2} } -func (fake *FakeScbeRestClient) UnmapVolume(wwn string, host string) error { - fake.unmapVolumeMutex.Lock() - ret, specificReturn := fake.unmapVolumeReturnsOnCall[len(fake.unmapVolumeArgsForCall)] - fake.unmapVolumeArgsForCall = append(fake.unmapVolumeArgsForCall, struct { - wwn string - host string - }{wwn, host}) - fake.recordInvocation("UnmapVolume", []interface{}{wwn, host}) - fake.unmapVolumeMutex.Unlock() - if fake.UnmapVolumeStub != nil { - return fake.UnmapVolumeStub(wwn, host) - } - if specificReturn { - return ret.result1 - } - return fake.unmapVolumeReturns.result1 -} - -func (fake *FakeScbeRestClient) UnmapVolumeCallCount() int { - fake.unmapVolumeMutex.RLock() - defer fake.unmapVolumeMutex.RUnlock() - return len(fake.unmapVolumeArgsForCall) -} - -func (fake *FakeScbeRestClient) UnmapVolumeArgsForCall(i int) (string, string) { - fake.unmapVolumeMutex.RLock() - defer fake.unmapVolumeMutex.RUnlock() - return fake.unmapVolumeArgsForCall[i].wwn, fake.unmapVolumeArgsForCall[i].host -} - -func (fake *FakeScbeRestClient) UnmapVolumeReturns(result1 error) { - fake.UnmapVolumeStub = nil - fake.unmapVolumeReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeScbeRestClient) UnmapVolumeReturnsOnCall(i int, result1 error) { - fake.UnmapVolumeStub = nil - if fake.unmapVolumeReturnsOnCall == nil { - fake.unmapVolumeReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.unmapVolumeReturnsOnCall[i] = struct { - result1 error - }{result1} -} - -func (fake *FakeScbeRestClient) GetVolMapping(wwn string) (scbe.ScbeVolumeMapInfo, error) { - fake.getVolMappingMutex.Lock() - ret, specificReturn := fake.getVolMappingReturnsOnCall[len(fake.getVolMappingArgsForCall)] - fake.getVolMappingArgsForCall = append(fake.getVolMappingArgsForCall, struct { - wwn string - }{wwn}) - fake.recordInvocation("GetVolMapping", []interface{}{wwn}) - fake.getVolMappingMutex.Unlock() - if fake.GetVolMappingStub != nil { - return fake.GetVolMappingStub(wwn) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fake.getVolMappingReturns.result1, fake.getVolMappingReturns.result2 -} - -func (fake *FakeScbeRestClient) GetVolMappingCallCount() int { - fake.getVolMappingMutex.RLock() - defer fake.getVolMappingMutex.RUnlock() - return len(fake.getVolMappingArgsForCall) -} - -func (fake *FakeScbeRestClient) GetVolMappingArgsForCall(i int) string { - fake.getVolMappingMutex.RLock() - defer fake.getVolMappingMutex.RUnlock() - return fake.getVolMappingArgsForCall[i].wwn -} - -func (fake *FakeScbeRestClient) GetVolMappingReturns(result1 scbe.ScbeVolumeMapInfo, result2 error) { - fake.GetVolMappingStub = nil - fake.getVolMappingReturns = struct { - result1 scbe.ScbeVolumeMapInfo - result2 error - }{result1, result2} -} - -func (fake *FakeScbeRestClient) GetVolMappingReturnsOnCall(i int, result1 scbe.ScbeVolumeMapInfo, result2 error) { - fake.GetVolMappingStub = nil - if fake.getVolMappingReturnsOnCall == nil { - fake.getVolMappingReturnsOnCall = make(map[int]struct { - result1 scbe.ScbeVolumeMapInfo - result2 error - }) - } - fake.getVolMappingReturnsOnCall[i] = struct { - result1 scbe.ScbeVolumeMapInfo - result2 error - }{result1, result2} -} - -func (fake *FakeScbeRestClient) ServiceExist(serviceName string) (bool, error) { +func (fake *FakeScbeRestClient) ServiceExist(arg1 string) (bool, error) { fake.serviceExistMutex.Lock() ret, specificReturn := fake.serviceExistReturnsOnCall[len(fake.serviceExistArgsForCall)] fake.serviceExistArgsForCall = append(fake.serviceExistArgsForCall, struct { - serviceName string - }{serviceName}) - fake.recordInvocation("ServiceExist", []interface{}{serviceName}) + arg1 string + }{arg1}) + fake.recordInvocation("ServiceExist", []interface{}{arg1}) fake.serviceExistMutex.Unlock() if fake.ServiceExistStub != nil { - return fake.ServiceExistStub(serviceName) + return fake.ServiceExistStub(arg1) } if specificReturn { return ret.result1, ret.result2 } - return fake.serviceExistReturns.result1, fake.serviceExistReturns.result2 + fakeReturns := fake.serviceExistReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeScbeRestClient) ServiceExistCallCount() int { @@ -479,13 +504,22 @@ func (fake *FakeScbeRestClient) ServiceExistCallCount() int { return len(fake.serviceExistArgsForCall) } +func (fake *FakeScbeRestClient) ServiceExistCalls(stub func(string) (bool, error)) { + fake.serviceExistMutex.Lock() + defer fake.serviceExistMutex.Unlock() + fake.ServiceExistStub = stub +} + func (fake *FakeScbeRestClient) ServiceExistArgsForCall(i int) string { fake.serviceExistMutex.RLock() defer fake.serviceExistMutex.RUnlock() - return fake.serviceExistArgsForCall[i].serviceName + argsForCall := fake.serviceExistArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeScbeRestClient) ServiceExistReturns(result1 bool, result2 error) { + fake.serviceExistMutex.Lock() + defer fake.serviceExistMutex.Unlock() fake.ServiceExistStub = nil fake.serviceExistReturns = struct { result1 bool @@ -494,6 +528,8 @@ func (fake *FakeScbeRestClient) ServiceExistReturns(result1 bool, result2 error) } func (fake *FakeScbeRestClient) ServiceExistReturnsOnCall(i int, result1 bool, result2 error) { + fake.serviceExistMutex.Lock() + defer fake.serviceExistMutex.Unlock() fake.ServiceExistStub = nil if fake.serviceExistReturnsOnCall == nil { fake.serviceExistReturnsOnCall = make(map[int]struct { @@ -507,25 +543,86 @@ func (fake *FakeScbeRestClient) ServiceExistReturnsOnCall(i int, result1 bool, r }{result1, result2} } +func (fake *FakeScbeRestClient) UnmapVolume(arg1 string, arg2 string) error { + fake.unmapVolumeMutex.Lock() + ret, specificReturn := fake.unmapVolumeReturnsOnCall[len(fake.unmapVolumeArgsForCall)] + fake.unmapVolumeArgsForCall = append(fake.unmapVolumeArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("UnmapVolume", []interface{}{arg1, arg2}) + fake.unmapVolumeMutex.Unlock() + if fake.UnmapVolumeStub != nil { + return fake.UnmapVolumeStub(arg1, arg2) + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.unmapVolumeReturns + return fakeReturns.result1 +} + +func (fake *FakeScbeRestClient) UnmapVolumeCallCount() int { + fake.unmapVolumeMutex.RLock() + defer fake.unmapVolumeMutex.RUnlock() + return len(fake.unmapVolumeArgsForCall) +} + +func (fake *FakeScbeRestClient) UnmapVolumeCalls(stub func(string, string) error) { + fake.unmapVolumeMutex.Lock() + defer fake.unmapVolumeMutex.Unlock() + fake.UnmapVolumeStub = stub +} + +func (fake *FakeScbeRestClient) UnmapVolumeArgsForCall(i int) (string, string) { + fake.unmapVolumeMutex.RLock() + defer fake.unmapVolumeMutex.RUnlock() + argsForCall := fake.unmapVolumeArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeScbeRestClient) UnmapVolumeReturns(result1 error) { + fake.unmapVolumeMutex.Lock() + defer fake.unmapVolumeMutex.Unlock() + fake.UnmapVolumeStub = nil + fake.unmapVolumeReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeScbeRestClient) UnmapVolumeReturnsOnCall(i int, result1 error) { + fake.unmapVolumeMutex.Lock() + defer fake.unmapVolumeMutex.Unlock() + fake.UnmapVolumeStub = nil + if fake.unmapVolumeReturnsOnCall == nil { + fake.unmapVolumeReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.unmapVolumeReturnsOnCall[i] = struct { + result1 error + }{result1} +} + func (fake *FakeScbeRestClient) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() - fake.loginMutex.RLock() - defer fake.loginMutex.RUnlock() fake.createVolumeMutex.RLock() defer fake.createVolumeMutex.RUnlock() - fake.getVolumesMutex.RLock() - defer fake.getVolumesMutex.RUnlock() fake.deleteVolumeMutex.RLock() defer fake.deleteVolumeMutex.RUnlock() - fake.mapVolumeMutex.RLock() - defer fake.mapVolumeMutex.RUnlock() - fake.unmapVolumeMutex.RLock() - defer fake.unmapVolumeMutex.RUnlock() fake.getVolMappingMutex.RLock() defer fake.getVolMappingMutex.RUnlock() + fake.getVolumesMutex.RLock() + defer fake.getVolumesMutex.RUnlock() + fake.loginMutex.RLock() + defer fake.loginMutex.RUnlock() + fake.mapVolumeMutex.RLock() + defer fake.mapVolumeMutex.RUnlock() fake.serviceExistMutex.RLock() defer fake.serviceExistMutex.RUnlock() + fake.unmapVolumeMutex.RLock() + defer fake.unmapVolumeMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} for key, value := range fake.invocations { copiedInvocations[key] = value diff --git a/fakes/fake_simple_rest_client.go b/fakes/fake_simple_rest_client.go index e961f6c8..8b03ddd4 100644 --- a/fakes/fake_simple_rest_client.go +++ b/fakes/fake_simple_rest_client.go @@ -8,36 +8,26 @@ import ( ) type FakeSimpleRestClient struct { - LoginStub func() error - loginMutex sync.RWMutex - loginArgsForCall []struct{} - loginReturns struct { - result1 error - } - loginReturnsOnCall map[int]struct { - result1 error - } - PostStub func(resource_url string, payload []byte, exitStatus int, v interface{}) error - postMutex sync.RWMutex - postArgsForCall []struct { - resource_url string - payload []byte - exitStatus int - v interface{} + DeleteStub func(string, []byte, int) error + deleteMutex sync.RWMutex + deleteArgsForCall []struct { + arg1 string + arg2 []byte + arg3 int } - postReturns struct { + deleteReturns struct { result1 error } - postReturnsOnCall map[int]struct { + deleteReturnsOnCall map[int]struct { result1 error } - GetStub func(resource_url string, params map[string]string, exitStatus int, v interface{}) error + GetStub func(string, map[string]string, int, interface{}) error getMutex sync.RWMutex getArgsForCall []struct { - resource_url string - params map[string]string - exitStatus int - v interface{} + arg1 string + arg2 map[string]string + arg3 int + arg4 interface{} } getReturns struct { result1 error @@ -45,137 +35,120 @@ type FakeSimpleRestClient struct { getReturnsOnCall map[int]struct { result1 error } - DeleteStub func(resource_url string, payload []byte, exitStatus int) error - deleteMutex sync.RWMutex - deleteArgsForCall []struct { - resource_url string - payload []byte - exitStatus int + LoginStub func() error + loginMutex sync.RWMutex + loginArgsForCall []struct { } - deleteReturns struct { + loginReturns struct { result1 error } - deleteReturnsOnCall map[int]struct { + loginReturnsOnCall map[int]struct { result1 error } - invocations map[string][][]interface{} - invocationsMutex sync.RWMutex -} - -func (fake *FakeSimpleRestClient) Login() error { - fake.loginMutex.Lock() - ret, specificReturn := fake.loginReturnsOnCall[len(fake.loginArgsForCall)] - fake.loginArgsForCall = append(fake.loginArgsForCall, struct{}{}) - fake.recordInvocation("Login", []interface{}{}) - fake.loginMutex.Unlock() - if fake.LoginStub != nil { - return fake.LoginStub() - } - if specificReturn { - return ret.result1 + PostStub func(string, []byte, int, interface{}) error + postMutex sync.RWMutex + postArgsForCall []struct { + arg1 string + arg2 []byte + arg3 int + arg4 interface{} } - return fake.loginReturns.result1 -} - -func (fake *FakeSimpleRestClient) LoginCallCount() int { - fake.loginMutex.RLock() - defer fake.loginMutex.RUnlock() - return len(fake.loginArgsForCall) -} - -func (fake *FakeSimpleRestClient) LoginReturns(result1 error) { - fake.LoginStub = nil - fake.loginReturns = struct { + postReturns struct { result1 error - }{result1} -} - -func (fake *FakeSimpleRestClient) LoginReturnsOnCall(i int, result1 error) { - fake.LoginStub = nil - if fake.loginReturnsOnCall == nil { - fake.loginReturnsOnCall = make(map[int]struct { - result1 error - }) } - fake.loginReturnsOnCall[i] = struct { + postReturnsOnCall map[int]struct { result1 error - }{result1} + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex } -func (fake *FakeSimpleRestClient) Post(resource_url string, payload []byte, exitStatus int, v interface{}) error { - var payloadCopy []byte - if payload != nil { - payloadCopy = make([]byte, len(payload)) - copy(payloadCopy, payload) +func (fake *FakeSimpleRestClient) Delete(arg1 string, arg2 []byte, arg3 int) error { + var arg2Copy []byte + if arg2 != nil { + arg2Copy = make([]byte, len(arg2)) + copy(arg2Copy, arg2) } - fake.postMutex.Lock() - ret, specificReturn := fake.postReturnsOnCall[len(fake.postArgsForCall)] - fake.postArgsForCall = append(fake.postArgsForCall, struct { - resource_url string - payload []byte - exitStatus int - v interface{} - }{resource_url, payloadCopy, exitStatus, v}) - fake.recordInvocation("Post", []interface{}{resource_url, payloadCopy, exitStatus, v}) - fake.postMutex.Unlock() - if fake.PostStub != nil { - return fake.PostStub(resource_url, payload, exitStatus, v) + fake.deleteMutex.Lock() + ret, specificReturn := fake.deleteReturnsOnCall[len(fake.deleteArgsForCall)] + fake.deleteArgsForCall = append(fake.deleteArgsForCall, struct { + arg1 string + arg2 []byte + arg3 int + }{arg1, arg2Copy, arg3}) + fake.recordInvocation("Delete", []interface{}{arg1, arg2Copy, arg3}) + fake.deleteMutex.Unlock() + if fake.DeleteStub != nil { + return fake.DeleteStub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - return fake.postReturns.result1 + fakeReturns := fake.deleteReturns + return fakeReturns.result1 } -func (fake *FakeSimpleRestClient) PostCallCount() int { - fake.postMutex.RLock() - defer fake.postMutex.RUnlock() - return len(fake.postArgsForCall) +func (fake *FakeSimpleRestClient) DeleteCallCount() int { + fake.deleteMutex.RLock() + defer fake.deleteMutex.RUnlock() + return len(fake.deleteArgsForCall) } -func (fake *FakeSimpleRestClient) PostArgsForCall(i int) (string, []byte, int, interface{}) { - fake.postMutex.RLock() - defer fake.postMutex.RUnlock() - return fake.postArgsForCall[i].resource_url, fake.postArgsForCall[i].payload, fake.postArgsForCall[i].exitStatus, fake.postArgsForCall[i].v +func (fake *FakeSimpleRestClient) DeleteCalls(stub func(string, []byte, int) error) { + fake.deleteMutex.Lock() + defer fake.deleteMutex.Unlock() + fake.DeleteStub = stub } -func (fake *FakeSimpleRestClient) PostReturns(result1 error) { - fake.PostStub = nil - fake.postReturns = struct { +func (fake *FakeSimpleRestClient) DeleteArgsForCall(i int) (string, []byte, int) { + fake.deleteMutex.RLock() + defer fake.deleteMutex.RUnlock() + argsForCall := fake.deleteArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 +} + +func (fake *FakeSimpleRestClient) DeleteReturns(result1 error) { + fake.deleteMutex.Lock() + defer fake.deleteMutex.Unlock() + fake.DeleteStub = nil + fake.deleteReturns = struct { result1 error }{result1} } -func (fake *FakeSimpleRestClient) PostReturnsOnCall(i int, result1 error) { - fake.PostStub = nil - if fake.postReturnsOnCall == nil { - fake.postReturnsOnCall = make(map[int]struct { +func (fake *FakeSimpleRestClient) DeleteReturnsOnCall(i int, result1 error) { + fake.deleteMutex.Lock() + defer fake.deleteMutex.Unlock() + fake.DeleteStub = nil + if fake.deleteReturnsOnCall == nil { + fake.deleteReturnsOnCall = make(map[int]struct { result1 error }) } - fake.postReturnsOnCall[i] = struct { + fake.deleteReturnsOnCall[i] = struct { result1 error }{result1} } -func (fake *FakeSimpleRestClient) Get(resource_url string, params map[string]string, exitStatus int, v interface{}) error { +func (fake *FakeSimpleRestClient) Get(arg1 string, arg2 map[string]string, arg3 int, arg4 interface{}) error { fake.getMutex.Lock() ret, specificReturn := fake.getReturnsOnCall[len(fake.getArgsForCall)] fake.getArgsForCall = append(fake.getArgsForCall, struct { - resource_url string - params map[string]string - exitStatus int - v interface{} - }{resource_url, params, exitStatus, v}) - fake.recordInvocation("Get", []interface{}{resource_url, params, exitStatus, v}) + arg1 string + arg2 map[string]string + arg3 int + arg4 interface{} + }{arg1, arg2, arg3, arg4}) + fake.recordInvocation("Get", []interface{}{arg1, arg2, arg3, arg4}) fake.getMutex.Unlock() if fake.GetStub != nil { - return fake.GetStub(resource_url, params, exitStatus, v) + return fake.GetStub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1 } - return fake.getReturns.result1 + fakeReturns := fake.getReturns + return fakeReturns.result1 } func (fake *FakeSimpleRestClient) GetCallCount() int { @@ -184,13 +157,22 @@ func (fake *FakeSimpleRestClient) GetCallCount() int { return len(fake.getArgsForCall) } +func (fake *FakeSimpleRestClient) GetCalls(stub func(string, map[string]string, int, interface{}) error) { + fake.getMutex.Lock() + defer fake.getMutex.Unlock() + fake.GetStub = stub +} + func (fake *FakeSimpleRestClient) GetArgsForCall(i int) (string, map[string]string, int, interface{}) { fake.getMutex.RLock() defer fake.getMutex.RUnlock() - return fake.getArgsForCall[i].resource_url, fake.getArgsForCall[i].params, fake.getArgsForCall[i].exitStatus, fake.getArgsForCall[i].v + argsForCall := fake.getArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4 } func (fake *FakeSimpleRestClient) GetReturns(result1 error) { + fake.getMutex.Lock() + defer fake.getMutex.Unlock() fake.GetStub = nil fake.getReturns = struct { result1 error @@ -198,6 +180,8 @@ func (fake *FakeSimpleRestClient) GetReturns(result1 error) { } func (fake *FakeSimpleRestClient) GetReturnsOnCall(i int, result1 error) { + fake.getMutex.Lock() + defer fake.getMutex.Unlock() fake.GetStub = nil if fake.getReturnsOnCall == nil { fake.getReturnsOnCall = make(map[int]struct { @@ -209,57 +193,122 @@ func (fake *FakeSimpleRestClient) GetReturnsOnCall(i int, result1 error) { }{result1} } -func (fake *FakeSimpleRestClient) Delete(resource_url string, payload []byte, exitStatus int) error { - var payloadCopy []byte - if payload != nil { - payloadCopy = make([]byte, len(payload)) - copy(payloadCopy, payload) +func (fake *FakeSimpleRestClient) Login() error { + fake.loginMutex.Lock() + ret, specificReturn := fake.loginReturnsOnCall[len(fake.loginArgsForCall)] + fake.loginArgsForCall = append(fake.loginArgsForCall, struct { + }{}) + fake.recordInvocation("Login", []interface{}{}) + fake.loginMutex.Unlock() + if fake.LoginStub != nil { + return fake.LoginStub() } - fake.deleteMutex.Lock() - ret, specificReturn := fake.deleteReturnsOnCall[len(fake.deleteArgsForCall)] - fake.deleteArgsForCall = append(fake.deleteArgsForCall, struct { - resource_url string - payload []byte - exitStatus int - }{resource_url, payloadCopy, exitStatus}) - fake.recordInvocation("Delete", []interface{}{resource_url, payloadCopy, exitStatus}) - fake.deleteMutex.Unlock() - if fake.DeleteStub != nil { - return fake.DeleteStub(resource_url, payload, exitStatus) + if specificReturn { + return ret.result1 + } + fakeReturns := fake.loginReturns + return fakeReturns.result1 +} + +func (fake *FakeSimpleRestClient) LoginCallCount() int { + fake.loginMutex.RLock() + defer fake.loginMutex.RUnlock() + return len(fake.loginArgsForCall) +} + +func (fake *FakeSimpleRestClient) LoginCalls(stub func() error) { + fake.loginMutex.Lock() + defer fake.loginMutex.Unlock() + fake.LoginStub = stub +} + +func (fake *FakeSimpleRestClient) LoginReturns(result1 error) { + fake.loginMutex.Lock() + defer fake.loginMutex.Unlock() + fake.LoginStub = nil + fake.loginReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeSimpleRestClient) LoginReturnsOnCall(i int, result1 error) { + fake.loginMutex.Lock() + defer fake.loginMutex.Unlock() + fake.LoginStub = nil + if fake.loginReturnsOnCall == nil { + fake.loginReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.loginReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeSimpleRestClient) Post(arg1 string, arg2 []byte, arg3 int, arg4 interface{}) error { + var arg2Copy []byte + if arg2 != nil { + arg2Copy = make([]byte, len(arg2)) + copy(arg2Copy, arg2) + } + fake.postMutex.Lock() + ret, specificReturn := fake.postReturnsOnCall[len(fake.postArgsForCall)] + fake.postArgsForCall = append(fake.postArgsForCall, struct { + arg1 string + arg2 []byte + arg3 int + arg4 interface{} + }{arg1, arg2Copy, arg3, arg4}) + fake.recordInvocation("Post", []interface{}{arg1, arg2Copy, arg3, arg4}) + fake.postMutex.Unlock() + if fake.PostStub != nil { + return fake.PostStub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1 } - return fake.deleteReturns.result1 + fakeReturns := fake.postReturns + return fakeReturns.result1 } -func (fake *FakeSimpleRestClient) DeleteCallCount() int { - fake.deleteMutex.RLock() - defer fake.deleteMutex.RUnlock() - return len(fake.deleteArgsForCall) +func (fake *FakeSimpleRestClient) PostCallCount() int { + fake.postMutex.RLock() + defer fake.postMutex.RUnlock() + return len(fake.postArgsForCall) } -func (fake *FakeSimpleRestClient) DeleteArgsForCall(i int) (string, []byte, int) { - fake.deleteMutex.RLock() - defer fake.deleteMutex.RUnlock() - return fake.deleteArgsForCall[i].resource_url, fake.deleteArgsForCall[i].payload, fake.deleteArgsForCall[i].exitStatus +func (fake *FakeSimpleRestClient) PostCalls(stub func(string, []byte, int, interface{}) error) { + fake.postMutex.Lock() + defer fake.postMutex.Unlock() + fake.PostStub = stub } -func (fake *FakeSimpleRestClient) DeleteReturns(result1 error) { - fake.DeleteStub = nil - fake.deleteReturns = struct { +func (fake *FakeSimpleRestClient) PostArgsForCall(i int) (string, []byte, int, interface{}) { + fake.postMutex.RLock() + defer fake.postMutex.RUnlock() + argsForCall := fake.postArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4 +} + +func (fake *FakeSimpleRestClient) PostReturns(result1 error) { + fake.postMutex.Lock() + defer fake.postMutex.Unlock() + fake.PostStub = nil + fake.postReturns = struct { result1 error }{result1} } -func (fake *FakeSimpleRestClient) DeleteReturnsOnCall(i int, result1 error) { - fake.DeleteStub = nil - if fake.deleteReturnsOnCall == nil { - fake.deleteReturnsOnCall = make(map[int]struct { +func (fake *FakeSimpleRestClient) PostReturnsOnCall(i int, result1 error) { + fake.postMutex.Lock() + defer fake.postMutex.Unlock() + fake.PostStub = nil + if fake.postReturnsOnCall == nil { + fake.postReturnsOnCall = make(map[int]struct { result1 error }) } - fake.deleteReturnsOnCall[i] = struct { + fake.postReturnsOnCall[i] = struct { result1 error }{result1} } @@ -267,14 +316,14 @@ func (fake *FakeSimpleRestClient) DeleteReturnsOnCall(i int, result1 error) { func (fake *FakeSimpleRestClient) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() + fake.deleteMutex.RLock() + defer fake.deleteMutex.RUnlock() + fake.getMutex.RLock() + defer fake.getMutex.RUnlock() fake.loginMutex.RLock() defer fake.loginMutex.RUnlock() fake.postMutex.RLock() defer fake.postMutex.RUnlock() - fake.getMutex.RLock() - defer fake.getMutex.RUnlock() - fake.deleteMutex.RLock() - defer fake.deleteMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} for key, value := range fake.invocations { copiedInvocations[key] = value diff --git a/fakes/fake_spectrum.go b/fakes/fake_spectrum.go index 40a177bc..4e637afc 100644 --- a/fakes/fake_spectrum.go +++ b/fakes/fake_spectrum.go @@ -1,19 +1,3 @@ -/** - * Copyright 2017 IBM Corp. - * - * 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. - */ - // Code generated by counterfeiter. DO NOT EDIT. package fakes @@ -25,45 +9,58 @@ import ( ) type FakeSpectrumScaleConnector struct { - GetClusterIdStub func() (string, error) - getClusterIdMutex sync.RWMutex - getClusterIdArgsForCall []struct{} - getClusterIdReturns struct { - result1 string - result2 error + CheckIfFSQuotaEnabledStub func(string) error + checkIfFSQuotaEnabledMutex sync.RWMutex + checkIfFSQuotaEnabledArgsForCall []struct { + arg1 string } - getClusterIdReturnsOnCall map[int]struct { - result1 string - result2 error + checkIfFSQuotaEnabledReturns struct { + result1 error } - IsFilesystemMountedStub func(filesystemName string) (bool, error) - isFilesystemMountedMutex sync.RWMutex - isFilesystemMountedArgsForCall []struct { - filesystemName string + checkIfFSQuotaEnabledReturnsOnCall map[int]struct { + result1 error } - isFilesystemMountedReturns struct { - result1 bool - result2 error + CreateFilesetStub func(string, string, map[string]interface{}) error + createFilesetMutex sync.RWMutex + createFilesetArgsForCall []struct { + arg1 string + arg2 string + arg3 map[string]interface{} } - isFilesystemMountedReturnsOnCall map[int]struct { - result1 bool - result2 error + createFilesetReturns struct { + result1 error } - ListFilesystemsStub func() ([]string, error) - listFilesystemsMutex sync.RWMutex - listFilesystemsArgsForCall []struct{} - listFilesystemsReturns struct { - result1 []string + createFilesetReturnsOnCall map[int]struct { + result1 error + } + DeleteFilesetStub func(string, string) error + deleteFilesetMutex sync.RWMutex + deleteFilesetArgsForCall []struct { + arg1 string + arg2 string + } + deleteFilesetReturns struct { + result1 error + } + deleteFilesetReturnsOnCall map[int]struct { + result1 error + } + GetClusterIdStub func() (string, error) + getClusterIdMutex sync.RWMutex + getClusterIdArgsForCall []struct { + } + getClusterIdReturns struct { + result1 string result2 error } - listFilesystemsReturnsOnCall map[int]struct { - result1 []string + getClusterIdReturnsOnCall map[int]struct { + result1 string result2 error } - GetFilesystemMountpointStub func(filesystemName string) (string, error) + GetFilesystemMountpointStub func(string) (string, error) getFilesystemMountpointMutex sync.RWMutex getFilesystemMountpointArgsForCall []struct { - filesystemName string + arg1 string } getFilesystemMountpointReturns struct { result1 string @@ -73,36 +70,38 @@ type FakeSpectrumScaleConnector struct { result1 string result2 error } - CreateFilesetStub func(filesystemName string, filesetName string, opts map[string]interface{}) error - createFilesetMutex sync.RWMutex - createFilesetArgsForCall []struct { - filesystemName string - filesetName string - opts map[string]interface{} + IsFilesetLinkedStub func(string, string) (bool, error) + isFilesetLinkedMutex sync.RWMutex + isFilesetLinkedArgsForCall []struct { + arg1 string + arg2 string } - createFilesetReturns struct { - result1 error + isFilesetLinkedReturns struct { + result1 bool + result2 error } - createFilesetReturnsOnCall map[int]struct { - result1 error + isFilesetLinkedReturnsOnCall map[int]struct { + result1 bool + result2 error } - DeleteFilesetStub func(filesystemName string, filesetName string) error - deleteFilesetMutex sync.RWMutex - deleteFilesetArgsForCall []struct { - filesystemName string - filesetName string + IsFilesystemMountedStub func(string) (bool, error) + isFilesystemMountedMutex sync.RWMutex + isFilesystemMountedArgsForCall []struct { + arg1 string } - deleteFilesetReturns struct { - result1 error + isFilesystemMountedReturns struct { + result1 bool + result2 error } - deleteFilesetReturnsOnCall map[int]struct { - result1 error + isFilesystemMountedReturnsOnCall map[int]struct { + result1 bool + result2 error } - LinkFilesetStub func(filesystemName string, filesetName string) error + LinkFilesetStub func(string, string) error linkFilesetMutex sync.RWMutex linkFilesetArgsForCall []struct { - filesystemName string - filesetName string + arg1 string + arg2 string } linkFilesetReturns struct { result1 error @@ -110,22 +109,38 @@ type FakeSpectrumScaleConnector struct { linkFilesetReturnsOnCall map[int]struct { result1 error } - UnlinkFilesetStub func(filesystemName string, filesetName string) error - unlinkFilesetMutex sync.RWMutex - unlinkFilesetArgsForCall []struct { - filesystemName string - filesetName string + ListFilesetStub func(string, string) (resources.Volume, error) + listFilesetMutex sync.RWMutex + listFilesetArgsForCall []struct { + arg1 string + arg2 string } - unlinkFilesetReturns struct { - result1 error + listFilesetReturns struct { + result1 resources.Volume + result2 error } - unlinkFilesetReturnsOnCall map[int]struct { - result1 error + listFilesetReturnsOnCall map[int]struct { + result1 resources.Volume + result2 error + } + ListFilesetQuotaStub func(string, string) (string, error) + listFilesetQuotaMutex sync.RWMutex + listFilesetQuotaArgsForCall []struct { + arg1 string + arg2 string + } + listFilesetQuotaReturns struct { + result1 string + result2 error + } + listFilesetQuotaReturnsOnCall map[int]struct { + result1 string + result2 error } - ListFilesetsStub func(filesystemName string) ([]resources.Volume, error) + ListFilesetsStub func(string) ([]resources.Volume, error) listFilesetsMutex sync.RWMutex listFilesetsArgsForCall []struct { - filesystemName string + arg1 string } listFilesetsReturns struct { result1 []resources.Volume @@ -135,68 +150,24 @@ type FakeSpectrumScaleConnector struct { result1 []resources.Volume result2 error } - ListFilesetStub func(filesystemName string, filesetName string) (resources.Volume, error) - listFilesetMutex sync.RWMutex - listFilesetArgsForCall []struct { - filesystemName string - filesetName string - } - listFilesetReturns struct { - result1 resources.Volume - result2 error - } - listFilesetReturnsOnCall map[int]struct { - result1 resources.Volume - result2 error - } - IsFilesetLinkedStub func(filesystemName string, filesetName string) (bool, error) - isFilesetLinkedMutex sync.RWMutex - isFilesetLinkedArgsForCall []struct { - filesystemName string - filesetName string + ListFilesystemsStub func() ([]string, error) + listFilesystemsMutex sync.RWMutex + listFilesystemsArgsForCall []struct { } - isFilesetLinkedReturns struct { - result1 bool + listFilesystemsReturns struct { + result1 []string result2 error } - isFilesetLinkedReturnsOnCall map[int]struct { - result1 bool + listFilesystemsReturnsOnCall map[int]struct { + result1 []string result2 error } - - CheckIfFSQuotaEnabledStub func(filesystemName string) (error) - checkIfFSQuotaEnabledMutex sync.RWMutex - checkIfFSQuotaEnabledArgsForCall []struct { - filesystemName string - } - checkIfFSQuotaEnabledReturns struct { - result1 error - } - checkIfFSQuotaEnabledReturnsOnCall map[int]struct { - result1 error - } - - ListFilesetQuotaStub func(filesystemName string, filesetName string) (string, error) - listFilesetQuotaMutex sync.RWMutex - listFilesetQuotaArgsForCall []struct { - filesystemName string - filesetName string - } - listFilesetQuotaReturns struct { - result1 string - result2 error - } - listFilesetQuotaReturnsOnCall map[int]struct { - result1 string - result2 error - } - - SetFilesetQuotaStub func(filesystemName string, filesetName string, quota string) error + SetFilesetQuotaStub func(string, string, string) error setFilesetQuotaMutex sync.RWMutex setFilesetQuotaArgsForCall []struct { - filesystemName string - filesetName string - quota string + arg1 string + arg2 string + arg3 string } setFilesetQuotaReturns struct { result1 error @@ -204,238 +175,100 @@ type FakeSpectrumScaleConnector struct { setFilesetQuotaReturnsOnCall map[int]struct { result1 error } - ExportNfsStub func(volumeMountpoint string, clientConfig string) error - exportNfsMutex sync.RWMutex - exportNfsArgsForCall []struct { - volumeMountpoint string - clientConfig string - } - exportNfsReturns struct { - result1 error - } - exportNfsReturnsOnCall map[int]struct { - result1 error - } - UnexportNfsStub func(volumeMountpoint string) error - unexportNfsMutex sync.RWMutex - unexportNfsArgsForCall []struct { - volumeMountpoint string + UnlinkFilesetStub func(string, string) error + unlinkFilesetMutex sync.RWMutex + unlinkFilesetArgsForCall []struct { + arg1 string + arg2 string } - unexportNfsReturns struct { + unlinkFilesetReturns struct { result1 error } - unexportNfsReturnsOnCall map[int]struct { + unlinkFilesetReturnsOnCall map[int]struct { result1 error } invocations map[string][][]interface{} invocationsMutex sync.RWMutex } -func (fake *FakeSpectrumScaleConnector) GetClusterId() (string, error) { - fake.getClusterIdMutex.Lock() - ret, specificReturn := fake.getClusterIdReturnsOnCall[len(fake.getClusterIdArgsForCall)] - fake.getClusterIdArgsForCall = append(fake.getClusterIdArgsForCall, struct{}{}) - fake.recordInvocation("GetClusterId", []interface{}{}) - fake.getClusterIdMutex.Unlock() - if fake.GetClusterIdStub != nil { - return fake.GetClusterIdStub() - } - if specificReturn { - return ret.result1, ret.result2 - } - return fake.getClusterIdReturns.result1, fake.getClusterIdReturns.result2 -} - -func (fake *FakeSpectrumScaleConnector) GetClusterIdCallCount() int { - fake.getClusterIdMutex.RLock() - defer fake.getClusterIdMutex.RUnlock() - return len(fake.getClusterIdArgsForCall) -} - -func (fake *FakeSpectrumScaleConnector) GetClusterIdReturns(result1 string, result2 error) { - fake.GetClusterIdStub = nil - fake.getClusterIdReturns = struct { - result1 string - result2 error - }{result1, result2} -} - -func (fake *FakeSpectrumScaleConnector) GetClusterIdReturnsOnCall(i int, result1 string, result2 error) { - fake.GetClusterIdStub = nil - if fake.getClusterIdReturnsOnCall == nil { - fake.getClusterIdReturnsOnCall = make(map[int]struct { - result1 string - result2 error - }) - } - fake.getClusterIdReturnsOnCall[i] = struct { - result1 string - result2 error - }{result1, result2} -} - -func (fake *FakeSpectrumScaleConnector) IsFilesystemMounted(filesystemName string) (bool, error) { - fake.isFilesystemMountedMutex.Lock() - ret, specificReturn := fake.isFilesystemMountedReturnsOnCall[len(fake.isFilesystemMountedArgsForCall)] - fake.isFilesystemMountedArgsForCall = append(fake.isFilesystemMountedArgsForCall, struct { - filesystemName string - }{filesystemName}) - fake.recordInvocation("IsFilesystemMounted", []interface{}{filesystemName}) - fake.isFilesystemMountedMutex.Unlock() - if fake.IsFilesystemMountedStub != nil { - return fake.IsFilesystemMountedStub(filesystemName) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fake.isFilesystemMountedReturns.result1, fake.isFilesystemMountedReturns.result2 -} - -func (fake *FakeSpectrumScaleConnector) IsFilesystemMountedCallCount() int { - fake.isFilesystemMountedMutex.RLock() - defer fake.isFilesystemMountedMutex.RUnlock() - return len(fake.isFilesystemMountedArgsForCall) -} - -func (fake *FakeSpectrumScaleConnector) IsFilesystemMountedArgsForCall(i int) string { - fake.isFilesystemMountedMutex.RLock() - defer fake.isFilesystemMountedMutex.RUnlock() - return fake.isFilesystemMountedArgsForCall[i].filesystemName -} - -func (fake *FakeSpectrumScaleConnector) IsFilesystemMountedReturns(result1 bool, result2 error) { - fake.IsFilesystemMountedStub = nil - fake.isFilesystemMountedReturns = struct { - result1 bool - result2 error - }{result1, result2} -} - -func (fake *FakeSpectrumScaleConnector) IsFilesystemMountedReturnsOnCall(i int, result1 bool, result2 error) { - fake.IsFilesystemMountedStub = nil - if fake.isFilesystemMountedReturnsOnCall == nil { - fake.isFilesystemMountedReturnsOnCall = make(map[int]struct { - result1 bool - result2 error - }) - } - fake.isFilesystemMountedReturnsOnCall[i] = struct { - result1 bool - result2 error - }{result1, result2} -} - -func (fake *FakeSpectrumScaleConnector) ListFilesystems() ([]string, error) { - fake.listFilesystemsMutex.Lock() - ret, specificReturn := fake.listFilesystemsReturnsOnCall[len(fake.listFilesystemsArgsForCall)] - fake.listFilesystemsArgsForCall = append(fake.listFilesystemsArgsForCall, struct{}{}) - fake.recordInvocation("ListFilesystems", []interface{}{}) - fake.listFilesystemsMutex.Unlock() - if fake.ListFilesystemsStub != nil { - return fake.ListFilesystemsStub() +func (fake *FakeSpectrumScaleConnector) CheckIfFSQuotaEnabled(arg1 string) error { + fake.checkIfFSQuotaEnabledMutex.Lock() + ret, specificReturn := fake.checkIfFSQuotaEnabledReturnsOnCall[len(fake.checkIfFSQuotaEnabledArgsForCall)] + fake.checkIfFSQuotaEnabledArgsForCall = append(fake.checkIfFSQuotaEnabledArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("CheckIfFSQuotaEnabled", []interface{}{arg1}) + fake.checkIfFSQuotaEnabledMutex.Unlock() + if fake.CheckIfFSQuotaEnabledStub != nil { + return fake.CheckIfFSQuotaEnabledStub(arg1) } if specificReturn { - return ret.result1, ret.result2 - } - return fake.listFilesystemsReturns.result1, fake.listFilesystemsReturns.result2 -} - -func (fake *FakeSpectrumScaleConnector) ListFilesystemsCallCount() int { - fake.listFilesystemsMutex.RLock() - defer fake.listFilesystemsMutex.RUnlock() - return len(fake.listFilesystemsArgsForCall) -} - -func (fake *FakeSpectrumScaleConnector) ListFilesystemsReturns(result1 []string, result2 error) { - fake.ListFilesystemsStub = nil - fake.listFilesystemsReturns = struct { - result1 []string - result2 error - }{result1, result2} -} - -func (fake *FakeSpectrumScaleConnector) ListFilesystemsReturnsOnCall(i int, result1 []string, result2 error) { - fake.ListFilesystemsStub = nil - if fake.listFilesystemsReturnsOnCall == nil { - fake.listFilesystemsReturnsOnCall = make(map[int]struct { - result1 []string - result2 error - }) + return ret.result1 } - fake.listFilesystemsReturnsOnCall[i] = struct { - result1 []string - result2 error - }{result1, result2} + fakeReturns := fake.checkIfFSQuotaEnabledReturns + return fakeReturns.result1 } -func (fake *FakeSpectrumScaleConnector) GetFilesystemMountpoint(filesystemName string) (string, error) { - fake.getFilesystemMountpointMutex.Lock() - ret, specificReturn := fake.getFilesystemMountpointReturnsOnCall[len(fake.getFilesystemMountpointArgsForCall)] - fake.getFilesystemMountpointArgsForCall = append(fake.getFilesystemMountpointArgsForCall, struct { - filesystemName string - }{filesystemName}) - fake.recordInvocation("GetFilesystemMountpoint", []interface{}{filesystemName}) - fake.getFilesystemMountpointMutex.Unlock() - if fake.GetFilesystemMountpointStub != nil { - return fake.GetFilesystemMountpointStub(filesystemName) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fake.getFilesystemMountpointReturns.result1, fake.getFilesystemMountpointReturns.result2 +func (fake *FakeSpectrumScaleConnector) CheckIfFSQuotaEnabledCallCount() int { + fake.checkIfFSQuotaEnabledMutex.RLock() + defer fake.checkIfFSQuotaEnabledMutex.RUnlock() + return len(fake.checkIfFSQuotaEnabledArgsForCall) } -func (fake *FakeSpectrumScaleConnector) GetFilesystemMountpointCallCount() int { - fake.getFilesystemMountpointMutex.RLock() - defer fake.getFilesystemMountpointMutex.RUnlock() - return len(fake.getFilesystemMountpointArgsForCall) +func (fake *FakeSpectrumScaleConnector) CheckIfFSQuotaEnabledCalls(stub func(string) error) { + fake.checkIfFSQuotaEnabledMutex.Lock() + defer fake.checkIfFSQuotaEnabledMutex.Unlock() + fake.CheckIfFSQuotaEnabledStub = stub } -func (fake *FakeSpectrumScaleConnector) GetFilesystemMountpointArgsForCall(i int) string { - fake.getFilesystemMountpointMutex.RLock() - defer fake.getFilesystemMountpointMutex.RUnlock() - return fake.getFilesystemMountpointArgsForCall[i].filesystemName +func (fake *FakeSpectrumScaleConnector) CheckIfFSQuotaEnabledArgsForCall(i int) string { + fake.checkIfFSQuotaEnabledMutex.RLock() + defer fake.checkIfFSQuotaEnabledMutex.RUnlock() + argsForCall := fake.checkIfFSQuotaEnabledArgsForCall[i] + return argsForCall.arg1 } -func (fake *FakeSpectrumScaleConnector) GetFilesystemMountpointReturns(result1 string, result2 error) { - fake.GetFilesystemMountpointStub = nil - fake.getFilesystemMountpointReturns = struct { - result1 string - result2 error - }{result1, result2} +func (fake *FakeSpectrumScaleConnector) CheckIfFSQuotaEnabledReturns(result1 error) { + fake.checkIfFSQuotaEnabledMutex.Lock() + defer fake.checkIfFSQuotaEnabledMutex.Unlock() + fake.CheckIfFSQuotaEnabledStub = nil + fake.checkIfFSQuotaEnabledReturns = struct { + result1 error + }{result1} } -func (fake *FakeSpectrumScaleConnector) GetFilesystemMountpointReturnsOnCall(i int, result1 string, result2 error) { - fake.GetFilesystemMountpointStub = nil - if fake.getFilesystemMountpointReturnsOnCall == nil { - fake.getFilesystemMountpointReturnsOnCall = make(map[int]struct { - result1 string - result2 error +func (fake *FakeSpectrumScaleConnector) CheckIfFSQuotaEnabledReturnsOnCall(i int, result1 error) { + fake.checkIfFSQuotaEnabledMutex.Lock() + defer fake.checkIfFSQuotaEnabledMutex.Unlock() + fake.CheckIfFSQuotaEnabledStub = nil + if fake.checkIfFSQuotaEnabledReturnsOnCall == nil { + fake.checkIfFSQuotaEnabledReturnsOnCall = make(map[int]struct { + result1 error }) } - fake.getFilesystemMountpointReturnsOnCall[i] = struct { - result1 string - result2 error - }{result1, result2} + fake.checkIfFSQuotaEnabledReturnsOnCall[i] = struct { + result1 error + }{result1} } -func (fake *FakeSpectrumScaleConnector) CreateFileset(filesystemName string, filesetName string, opts map[string]interface{}) error { +func (fake *FakeSpectrumScaleConnector) CreateFileset(arg1 string, arg2 string, arg3 map[string]interface{}) error { fake.createFilesetMutex.Lock() ret, specificReturn := fake.createFilesetReturnsOnCall[len(fake.createFilesetArgsForCall)] fake.createFilesetArgsForCall = append(fake.createFilesetArgsForCall, struct { - filesystemName string - filesetName string - opts map[string]interface{} - }{filesystemName, filesetName, opts}) - fake.recordInvocation("CreateFileset", []interface{}{filesystemName, filesetName, opts}) + arg1 string + arg2 string + arg3 map[string]interface{} + }{arg1, arg2, arg3}) + fake.recordInvocation("CreateFileset", []interface{}{arg1, arg2, arg3}) fake.createFilesetMutex.Unlock() if fake.CreateFilesetStub != nil { - return fake.CreateFilesetStub(filesystemName, filesetName, opts) + return fake.CreateFilesetStub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - return fake.createFilesetReturns.result1 + fakeReturns := fake.createFilesetReturns + return fakeReturns.result1 } func (fake *FakeSpectrumScaleConnector) CreateFilesetCallCount() int { @@ -444,13 +277,22 @@ func (fake *FakeSpectrumScaleConnector) CreateFilesetCallCount() int { return len(fake.createFilesetArgsForCall) } +func (fake *FakeSpectrumScaleConnector) CreateFilesetCalls(stub func(string, string, map[string]interface{}) error) { + fake.createFilesetMutex.Lock() + defer fake.createFilesetMutex.Unlock() + fake.CreateFilesetStub = stub +} + func (fake *FakeSpectrumScaleConnector) CreateFilesetArgsForCall(i int) (string, string, map[string]interface{}) { fake.createFilesetMutex.RLock() defer fake.createFilesetMutex.RUnlock() - return fake.createFilesetArgsForCall[i].filesystemName, fake.createFilesetArgsForCall[i].filesetName, fake.createFilesetArgsForCall[i].opts + argsForCall := fake.createFilesetArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 } func (fake *FakeSpectrumScaleConnector) CreateFilesetReturns(result1 error) { + fake.createFilesetMutex.Lock() + defer fake.createFilesetMutex.Unlock() fake.CreateFilesetStub = nil fake.createFilesetReturns = struct { result1 error @@ -458,6 +300,8 @@ func (fake *FakeSpectrumScaleConnector) CreateFilesetReturns(result1 error) { } func (fake *FakeSpectrumScaleConnector) CreateFilesetReturnsOnCall(i int, result1 error) { + fake.createFilesetMutex.Lock() + defer fake.createFilesetMutex.Unlock() fake.CreateFilesetStub = nil if fake.createFilesetReturnsOnCall == nil { fake.createFilesetReturnsOnCall = make(map[int]struct { @@ -469,22 +313,23 @@ func (fake *FakeSpectrumScaleConnector) CreateFilesetReturnsOnCall(i int, result }{result1} } -func (fake *FakeSpectrumScaleConnector) DeleteFileset(filesystemName string, filesetName string) error { +func (fake *FakeSpectrumScaleConnector) DeleteFileset(arg1 string, arg2 string) error { fake.deleteFilesetMutex.Lock() ret, specificReturn := fake.deleteFilesetReturnsOnCall[len(fake.deleteFilesetArgsForCall)] fake.deleteFilesetArgsForCall = append(fake.deleteFilesetArgsForCall, struct { - filesystemName string - filesetName string - }{filesystemName, filesetName}) - fake.recordInvocation("DeleteFileset", []interface{}{filesystemName, filesetName}) + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("DeleteFileset", []interface{}{arg1, arg2}) fake.deleteFilesetMutex.Unlock() if fake.DeleteFilesetStub != nil { - return fake.DeleteFilesetStub(filesystemName, filesetName) + return fake.DeleteFilesetStub(arg1, arg2) } if specificReturn { return ret.result1 } - return fake.deleteFilesetReturns.result1 + fakeReturns := fake.deleteFilesetReturns + return fakeReturns.result1 } func (fake *FakeSpectrumScaleConnector) DeleteFilesetCallCount() int { @@ -493,13 +338,22 @@ func (fake *FakeSpectrumScaleConnector) DeleteFilesetCallCount() int { return len(fake.deleteFilesetArgsForCall) } +func (fake *FakeSpectrumScaleConnector) DeleteFilesetCalls(stub func(string, string) error) { + fake.deleteFilesetMutex.Lock() + defer fake.deleteFilesetMutex.Unlock() + fake.DeleteFilesetStub = stub +} + func (fake *FakeSpectrumScaleConnector) DeleteFilesetArgsForCall(i int) (string, string) { fake.deleteFilesetMutex.RLock() defer fake.deleteFilesetMutex.RUnlock() - return fake.deleteFilesetArgsForCall[i].filesystemName, fake.deleteFilesetArgsForCall[i].filesetName + argsForCall := fake.deleteFilesetArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } func (fake *FakeSpectrumScaleConnector) DeleteFilesetReturns(result1 error) { + fake.deleteFilesetMutex.Lock() + defer fake.deleteFilesetMutex.Unlock() fake.DeleteFilesetStub = nil fake.deleteFilesetReturns = struct { result1 error @@ -507,6 +361,8 @@ func (fake *FakeSpectrumScaleConnector) DeleteFilesetReturns(result1 error) { } func (fake *FakeSpectrumScaleConnector) DeleteFilesetReturnsOnCall(i int, result1 error) { + fake.deleteFilesetMutex.Lock() + defer fake.deleteFilesetMutex.Unlock() fake.DeleteFilesetStub = nil if fake.deleteFilesetReturnsOnCall == nil { fake.deleteFilesetReturnsOnCall = make(map[int]struct { @@ -518,171 +374,329 @@ func (fake *FakeSpectrumScaleConnector) DeleteFilesetReturnsOnCall(i int, result }{result1} } -func (fake *FakeSpectrumScaleConnector) LinkFileset(filesystemName string, filesetName string) error { - fake.linkFilesetMutex.Lock() - ret, specificReturn := fake.linkFilesetReturnsOnCall[len(fake.linkFilesetArgsForCall)] - fake.linkFilesetArgsForCall = append(fake.linkFilesetArgsForCall, struct { - filesystemName string - filesetName string - }{filesystemName, filesetName}) - fake.recordInvocation("LinkFileset", []interface{}{filesystemName, filesetName}) - fake.linkFilesetMutex.Unlock() - if fake.LinkFilesetStub != nil { - return fake.LinkFilesetStub(filesystemName, filesetName) +func (fake *FakeSpectrumScaleConnector) GetClusterId() (string, error) { + fake.getClusterIdMutex.Lock() + ret, specificReturn := fake.getClusterIdReturnsOnCall[len(fake.getClusterIdArgsForCall)] + fake.getClusterIdArgsForCall = append(fake.getClusterIdArgsForCall, struct { + }{}) + fake.recordInvocation("GetClusterId", []interface{}{}) + fake.getClusterIdMutex.Unlock() + if fake.GetClusterIdStub != nil { + return fake.GetClusterIdStub() } if specificReturn { - return ret.result1 + return ret.result1, ret.result2 } - return fake.linkFilesetReturns.result1 + fakeReturns := fake.getClusterIdReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeSpectrumScaleConnector) LinkFilesetCallCount() int { - fake.linkFilesetMutex.RLock() - defer fake.linkFilesetMutex.RUnlock() - return len(fake.linkFilesetArgsForCall) +func (fake *FakeSpectrumScaleConnector) GetClusterIdCallCount() int { + fake.getClusterIdMutex.RLock() + defer fake.getClusterIdMutex.RUnlock() + return len(fake.getClusterIdArgsForCall) } -func (fake *FakeSpectrumScaleConnector) LinkFilesetArgsForCall(i int) (string, string) { - fake.linkFilesetMutex.RLock() - defer fake.linkFilesetMutex.RUnlock() - return fake.linkFilesetArgsForCall[i].filesystemName, fake.linkFilesetArgsForCall[i].filesetName +func (fake *FakeSpectrumScaleConnector) GetClusterIdCalls(stub func() (string, error)) { + fake.getClusterIdMutex.Lock() + defer fake.getClusterIdMutex.Unlock() + fake.GetClusterIdStub = stub } -func (fake *FakeSpectrumScaleConnector) LinkFilesetReturns(result1 error) { - fake.LinkFilesetStub = nil - fake.linkFilesetReturns = struct { - result1 error - }{result1} +func (fake *FakeSpectrumScaleConnector) GetClusterIdReturns(result1 string, result2 error) { + fake.getClusterIdMutex.Lock() + defer fake.getClusterIdMutex.Unlock() + fake.GetClusterIdStub = nil + fake.getClusterIdReturns = struct { + result1 string + result2 error + }{result1, result2} } -func (fake *FakeSpectrumScaleConnector) LinkFilesetReturnsOnCall(i int, result1 error) { - fake.LinkFilesetStub = nil - if fake.linkFilesetReturnsOnCall == nil { - fake.linkFilesetReturnsOnCall = make(map[int]struct { - result1 error +func (fake *FakeSpectrumScaleConnector) GetClusterIdReturnsOnCall(i int, result1 string, result2 error) { + fake.getClusterIdMutex.Lock() + defer fake.getClusterIdMutex.Unlock() + fake.GetClusterIdStub = nil + if fake.getClusterIdReturnsOnCall == nil { + fake.getClusterIdReturnsOnCall = make(map[int]struct { + result1 string + result2 error }) } - fake.linkFilesetReturnsOnCall[i] = struct { - result1 error - }{result1} + fake.getClusterIdReturnsOnCall[i] = struct { + result1 string + result2 error + }{result1, result2} } -func (fake *FakeSpectrumScaleConnector) UnlinkFileset(filesystemName string, filesetName string) error { - fake.unlinkFilesetMutex.Lock() - ret, specificReturn := fake.unlinkFilesetReturnsOnCall[len(fake.unlinkFilesetArgsForCall)] - fake.unlinkFilesetArgsForCall = append(fake.unlinkFilesetArgsForCall, struct { - filesystemName string - filesetName string - }{filesystemName, filesetName}) - fake.recordInvocation("UnlinkFileset", []interface{}{filesystemName, filesetName}) - fake.unlinkFilesetMutex.Unlock() - if fake.UnlinkFilesetStub != nil { - return fake.UnlinkFilesetStub(filesystemName, filesetName) +func (fake *FakeSpectrumScaleConnector) GetFilesystemMountpoint(arg1 string) (string, error) { + fake.getFilesystemMountpointMutex.Lock() + ret, specificReturn := fake.getFilesystemMountpointReturnsOnCall[len(fake.getFilesystemMountpointArgsForCall)] + fake.getFilesystemMountpointArgsForCall = append(fake.getFilesystemMountpointArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("GetFilesystemMountpoint", []interface{}{arg1}) + fake.getFilesystemMountpointMutex.Unlock() + if fake.GetFilesystemMountpointStub != nil { + return fake.GetFilesystemMountpointStub(arg1) } if specificReturn { - return ret.result1 + return ret.result1, ret.result2 } - return fake.unlinkFilesetReturns.result1 + fakeReturns := fake.getFilesystemMountpointReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeSpectrumScaleConnector) UnlinkFilesetCallCount() int { - fake.unlinkFilesetMutex.RLock() - defer fake.unlinkFilesetMutex.RUnlock() - return len(fake.unlinkFilesetArgsForCall) +func (fake *FakeSpectrumScaleConnector) GetFilesystemMountpointCallCount() int { + fake.getFilesystemMountpointMutex.RLock() + defer fake.getFilesystemMountpointMutex.RUnlock() + return len(fake.getFilesystemMountpointArgsForCall) } -func (fake *FakeSpectrumScaleConnector) UnlinkFilesetArgsForCall(i int) (string, string) { - fake.unlinkFilesetMutex.RLock() - defer fake.unlinkFilesetMutex.RUnlock() - return fake.unlinkFilesetArgsForCall[i].filesystemName, fake.unlinkFilesetArgsForCall[i].filesetName +func (fake *FakeSpectrumScaleConnector) GetFilesystemMountpointCalls(stub func(string) (string, error)) { + fake.getFilesystemMountpointMutex.Lock() + defer fake.getFilesystemMountpointMutex.Unlock() + fake.GetFilesystemMountpointStub = stub } -func (fake *FakeSpectrumScaleConnector) UnlinkFilesetReturns(result1 error) { - fake.UnlinkFilesetStub = nil - fake.unlinkFilesetReturns = struct { - result1 error - }{result1} +func (fake *FakeSpectrumScaleConnector) GetFilesystemMountpointArgsForCall(i int) string { + fake.getFilesystemMountpointMutex.RLock() + defer fake.getFilesystemMountpointMutex.RUnlock() + argsForCall := fake.getFilesystemMountpointArgsForCall[i] + return argsForCall.arg1 } -func (fake *FakeSpectrumScaleConnector) UnlinkFilesetReturnsOnCall(i int, result1 error) { - fake.UnlinkFilesetStub = nil - if fake.unlinkFilesetReturnsOnCall == nil { - fake.unlinkFilesetReturnsOnCall = make(map[int]struct { - result1 error +func (fake *FakeSpectrumScaleConnector) GetFilesystemMountpointReturns(result1 string, result2 error) { + fake.getFilesystemMountpointMutex.Lock() + defer fake.getFilesystemMountpointMutex.Unlock() + fake.GetFilesystemMountpointStub = nil + fake.getFilesystemMountpointReturns = struct { + result1 string + result2 error + }{result1, result2} +} + +func (fake *FakeSpectrumScaleConnector) GetFilesystemMountpointReturnsOnCall(i int, result1 string, result2 error) { + fake.getFilesystemMountpointMutex.Lock() + defer fake.getFilesystemMountpointMutex.Unlock() + fake.GetFilesystemMountpointStub = nil + if fake.getFilesystemMountpointReturnsOnCall == nil { + fake.getFilesystemMountpointReturnsOnCall = make(map[int]struct { + result1 string + result2 error }) } - fake.unlinkFilesetReturnsOnCall[i] = struct { - result1 error - }{result1} + fake.getFilesystemMountpointReturnsOnCall[i] = struct { + result1 string + result2 error + }{result1, result2} } -func (fake *FakeSpectrumScaleConnector) ListFilesets(filesystemName string) ([]resources.Volume, error) { - fake.listFilesetsMutex.Lock() - ret, specificReturn := fake.listFilesetsReturnsOnCall[len(fake.listFilesetsArgsForCall)] - fake.listFilesetsArgsForCall = append(fake.listFilesetsArgsForCall, struct { - filesystemName string - }{filesystemName}) - fake.recordInvocation("ListFilesets", []interface{}{filesystemName}) - fake.listFilesetsMutex.Unlock() - if fake.ListFilesetsStub != nil { - return fake.ListFilesetsStub(filesystemName) +func (fake *FakeSpectrumScaleConnector) IsFilesetLinked(arg1 string, arg2 string) (bool, error) { + fake.isFilesetLinkedMutex.Lock() + ret, specificReturn := fake.isFilesetLinkedReturnsOnCall[len(fake.isFilesetLinkedArgsForCall)] + fake.isFilesetLinkedArgsForCall = append(fake.isFilesetLinkedArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("IsFilesetLinked", []interface{}{arg1, arg2}) + fake.isFilesetLinkedMutex.Unlock() + if fake.IsFilesetLinkedStub != nil { + return fake.IsFilesetLinkedStub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - return fake.listFilesetsReturns.result1, fake.listFilesetsReturns.result2 + fakeReturns := fake.isFilesetLinkedReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeSpectrumScaleConnector) ListFilesetsCallCount() int { - fake.listFilesetsMutex.RLock() - defer fake.listFilesetsMutex.RUnlock() - return len(fake.listFilesetsArgsForCall) +func (fake *FakeSpectrumScaleConnector) IsFilesetLinkedCallCount() int { + fake.isFilesetLinkedMutex.RLock() + defer fake.isFilesetLinkedMutex.RUnlock() + return len(fake.isFilesetLinkedArgsForCall) } -func (fake *FakeSpectrumScaleConnector) ListFilesetsArgsForCall(i int) string { - fake.listFilesetsMutex.RLock() - defer fake.listFilesetsMutex.RUnlock() - return fake.listFilesetsArgsForCall[i].filesystemName +func (fake *FakeSpectrumScaleConnector) IsFilesetLinkedCalls(stub func(string, string) (bool, error)) { + fake.isFilesetLinkedMutex.Lock() + defer fake.isFilesetLinkedMutex.Unlock() + fake.IsFilesetLinkedStub = stub +} + +func (fake *FakeSpectrumScaleConnector) IsFilesetLinkedArgsForCall(i int) (string, string) { + fake.isFilesetLinkedMutex.RLock() + defer fake.isFilesetLinkedMutex.RUnlock() + argsForCall := fake.isFilesetLinkedArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeSpectrumScaleConnector) IsFilesetLinkedReturns(result1 bool, result2 error) { + fake.isFilesetLinkedMutex.Lock() + defer fake.isFilesetLinkedMutex.Unlock() + fake.IsFilesetLinkedStub = nil + fake.isFilesetLinkedReturns = struct { + result1 bool + result2 error + }{result1, result2} +} + +func (fake *FakeSpectrumScaleConnector) IsFilesetLinkedReturnsOnCall(i int, result1 bool, result2 error) { + fake.isFilesetLinkedMutex.Lock() + defer fake.isFilesetLinkedMutex.Unlock() + fake.IsFilesetLinkedStub = nil + if fake.isFilesetLinkedReturnsOnCall == nil { + fake.isFilesetLinkedReturnsOnCall = make(map[int]struct { + result1 bool + result2 error + }) + } + fake.isFilesetLinkedReturnsOnCall[i] = struct { + result1 bool + result2 error + }{result1, result2} +} + +func (fake *FakeSpectrumScaleConnector) IsFilesystemMounted(arg1 string) (bool, error) { + fake.isFilesystemMountedMutex.Lock() + ret, specificReturn := fake.isFilesystemMountedReturnsOnCall[len(fake.isFilesystemMountedArgsForCall)] + fake.isFilesystemMountedArgsForCall = append(fake.isFilesystemMountedArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("IsFilesystemMounted", []interface{}{arg1}) + fake.isFilesystemMountedMutex.Unlock() + if fake.IsFilesystemMountedStub != nil { + return fake.IsFilesystemMountedStub(arg1) + } + if specificReturn { + return ret.result1, ret.result2 + } + fakeReturns := fake.isFilesystemMountedReturns + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeSpectrumScaleConnector) IsFilesystemMountedCallCount() int { + fake.isFilesystemMountedMutex.RLock() + defer fake.isFilesystemMountedMutex.RUnlock() + return len(fake.isFilesystemMountedArgsForCall) +} + +func (fake *FakeSpectrumScaleConnector) IsFilesystemMountedCalls(stub func(string) (bool, error)) { + fake.isFilesystemMountedMutex.Lock() + defer fake.isFilesystemMountedMutex.Unlock() + fake.IsFilesystemMountedStub = stub +} + +func (fake *FakeSpectrumScaleConnector) IsFilesystemMountedArgsForCall(i int) string { + fake.isFilesystemMountedMutex.RLock() + defer fake.isFilesystemMountedMutex.RUnlock() + argsForCall := fake.isFilesystemMountedArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeSpectrumScaleConnector) IsFilesystemMountedReturns(result1 bool, result2 error) { + fake.isFilesystemMountedMutex.Lock() + defer fake.isFilesystemMountedMutex.Unlock() + fake.IsFilesystemMountedStub = nil + fake.isFilesystemMountedReturns = struct { + result1 bool + result2 error + }{result1, result2} +} + +func (fake *FakeSpectrumScaleConnector) IsFilesystemMountedReturnsOnCall(i int, result1 bool, result2 error) { + fake.isFilesystemMountedMutex.Lock() + defer fake.isFilesystemMountedMutex.Unlock() + fake.IsFilesystemMountedStub = nil + if fake.isFilesystemMountedReturnsOnCall == nil { + fake.isFilesystemMountedReturnsOnCall = make(map[int]struct { + result1 bool + result2 error + }) + } + fake.isFilesystemMountedReturnsOnCall[i] = struct { + result1 bool + result2 error + }{result1, result2} +} + +func (fake *FakeSpectrumScaleConnector) LinkFileset(arg1 string, arg2 string) error { + fake.linkFilesetMutex.Lock() + ret, specificReturn := fake.linkFilesetReturnsOnCall[len(fake.linkFilesetArgsForCall)] + fake.linkFilesetArgsForCall = append(fake.linkFilesetArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("LinkFileset", []interface{}{arg1, arg2}) + fake.linkFilesetMutex.Unlock() + if fake.LinkFilesetStub != nil { + return fake.LinkFilesetStub(arg1, arg2) + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.linkFilesetReturns + return fakeReturns.result1 +} + +func (fake *FakeSpectrumScaleConnector) LinkFilesetCallCount() int { + fake.linkFilesetMutex.RLock() + defer fake.linkFilesetMutex.RUnlock() + return len(fake.linkFilesetArgsForCall) +} + +func (fake *FakeSpectrumScaleConnector) LinkFilesetCalls(stub func(string, string) error) { + fake.linkFilesetMutex.Lock() + defer fake.linkFilesetMutex.Unlock() + fake.LinkFilesetStub = stub +} + +func (fake *FakeSpectrumScaleConnector) LinkFilesetArgsForCall(i int) (string, string) { + fake.linkFilesetMutex.RLock() + defer fake.linkFilesetMutex.RUnlock() + argsForCall := fake.linkFilesetArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } -func (fake *FakeSpectrumScaleConnector) ListFilesetsReturns(result1 []resources.Volume, result2 error) { - fake.ListFilesetsStub = nil - fake.listFilesetsReturns = struct { - result1 []resources.Volume - result2 error - }{result1, result2} +func (fake *FakeSpectrumScaleConnector) LinkFilesetReturns(result1 error) { + fake.linkFilesetMutex.Lock() + defer fake.linkFilesetMutex.Unlock() + fake.LinkFilesetStub = nil + fake.linkFilesetReturns = struct { + result1 error + }{result1} } -func (fake *FakeSpectrumScaleConnector) ListFilesetsReturnsOnCall(i int, result1 []resources.Volume, result2 error) { - fake.ListFilesetsStub = nil - if fake.listFilesetsReturnsOnCall == nil { - fake.listFilesetsReturnsOnCall = make(map[int]struct { - result1 []resources.Volume - result2 error +func (fake *FakeSpectrumScaleConnector) LinkFilesetReturnsOnCall(i int, result1 error) { + fake.linkFilesetMutex.Lock() + defer fake.linkFilesetMutex.Unlock() + fake.LinkFilesetStub = nil + if fake.linkFilesetReturnsOnCall == nil { + fake.linkFilesetReturnsOnCall = make(map[int]struct { + result1 error }) } - fake.listFilesetsReturnsOnCall[i] = struct { - result1 []resources.Volume - result2 error - }{result1, result2} + fake.linkFilesetReturnsOnCall[i] = struct { + result1 error + }{result1} } -func (fake *FakeSpectrumScaleConnector) ListFileset(filesystemName string, filesetName string) (resources.Volume, error) { +func (fake *FakeSpectrumScaleConnector) ListFileset(arg1 string, arg2 string) (resources.Volume, error) { fake.listFilesetMutex.Lock() ret, specificReturn := fake.listFilesetReturnsOnCall[len(fake.listFilesetArgsForCall)] fake.listFilesetArgsForCall = append(fake.listFilesetArgsForCall, struct { - filesystemName string - filesetName string - }{filesystemName, filesetName}) - fake.recordInvocation("ListFileset", []interface{}{filesystemName, filesetName}) + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("ListFileset", []interface{}{arg1, arg2}) fake.listFilesetMutex.Unlock() if fake.ListFilesetStub != nil { - return fake.ListFilesetStub(filesystemName, filesetName) + return fake.ListFilesetStub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - return fake.listFilesetReturns.result1, fake.listFilesetReturns.result2 + fakeReturns := fake.listFilesetReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeSpectrumScaleConnector) ListFilesetCallCount() int { @@ -691,13 +705,22 @@ func (fake *FakeSpectrumScaleConnector) ListFilesetCallCount() int { return len(fake.listFilesetArgsForCall) } +func (fake *FakeSpectrumScaleConnector) ListFilesetCalls(stub func(string, string) (resources.Volume, error)) { + fake.listFilesetMutex.Lock() + defer fake.listFilesetMutex.Unlock() + fake.ListFilesetStub = stub +} + func (fake *FakeSpectrumScaleConnector) ListFilesetArgsForCall(i int) (string, string) { fake.listFilesetMutex.RLock() defer fake.listFilesetMutex.RUnlock() - return fake.listFilesetArgsForCall[i].filesystemName, fake.listFilesetArgsForCall[i].filesetName + argsForCall := fake.listFilesetArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } func (fake *FakeSpectrumScaleConnector) ListFilesetReturns(result1 resources.Volume, result2 error) { + fake.listFilesetMutex.Lock() + defer fake.listFilesetMutex.Unlock() fake.ListFilesetStub = nil fake.listFilesetReturns = struct { result1 resources.Volume @@ -706,6 +729,8 @@ func (fake *FakeSpectrumScaleConnector) ListFilesetReturns(result1 resources.Vol } func (fake *FakeSpectrumScaleConnector) ListFilesetReturnsOnCall(i int, result1 resources.Volume, result2 error) { + fake.listFilesetMutex.Lock() + defer fake.listFilesetMutex.Unlock() fake.ListFilesetStub = nil if fake.listFilesetReturnsOnCall == nil { fake.listFilesetReturnsOnCall = make(map[int]struct { @@ -719,176 +744,206 @@ func (fake *FakeSpectrumScaleConnector) ListFilesetReturnsOnCall(i int, result1 }{result1, result2} } -func (fake *FakeSpectrumScaleConnector) IsFilesetLinked(filesystemName string, filesetName string) (bool, error) { - fake.isFilesetLinkedMutex.Lock() - ret, specificReturn := fake.isFilesetLinkedReturnsOnCall[len(fake.isFilesetLinkedArgsForCall)] - fake.isFilesetLinkedArgsForCall = append(fake.isFilesetLinkedArgsForCall, struct { - filesystemName string - filesetName string - }{filesystemName, filesetName}) - fake.recordInvocation("IsFilesetLinked", []interface{}{filesystemName, filesetName}) - fake.isFilesetLinkedMutex.Unlock() - if fake.IsFilesetLinkedStub != nil { - return fake.IsFilesetLinkedStub(filesystemName, filesetName) +func (fake *FakeSpectrumScaleConnector) ListFilesetQuota(arg1 string, arg2 string) (string, error) { + fake.listFilesetQuotaMutex.Lock() + ret, specificReturn := fake.listFilesetQuotaReturnsOnCall[len(fake.listFilesetQuotaArgsForCall)] + fake.listFilesetQuotaArgsForCall = append(fake.listFilesetQuotaArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("ListFilesetQuota", []interface{}{arg1, arg2}) + fake.listFilesetQuotaMutex.Unlock() + if fake.ListFilesetQuotaStub != nil { + return fake.ListFilesetQuotaStub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - return fake.isFilesetLinkedReturns.result1, fake.isFilesetLinkedReturns.result2 + fakeReturns := fake.listFilesetQuotaReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeSpectrumScaleConnector) IsFilesetLinkedCallCount() int { - fake.isFilesetLinkedMutex.RLock() - defer fake.isFilesetLinkedMutex.RUnlock() - return len(fake.isFilesetLinkedArgsForCall) +func (fake *FakeSpectrumScaleConnector) ListFilesetQuotaCallCount() int { + fake.listFilesetQuotaMutex.RLock() + defer fake.listFilesetQuotaMutex.RUnlock() + return len(fake.listFilesetQuotaArgsForCall) } -func (fake *FakeSpectrumScaleConnector) IsFilesetLinkedArgsForCall(i int) (string, string) { - fake.isFilesetLinkedMutex.RLock() - defer fake.isFilesetLinkedMutex.RUnlock() - return fake.isFilesetLinkedArgsForCall[i].filesystemName, fake.isFilesetLinkedArgsForCall[i].filesetName +func (fake *FakeSpectrumScaleConnector) ListFilesetQuotaCalls(stub func(string, string) (string, error)) { + fake.listFilesetQuotaMutex.Lock() + defer fake.listFilesetQuotaMutex.Unlock() + fake.ListFilesetQuotaStub = stub } -func (fake *FakeSpectrumScaleConnector) IsFilesetLinkedReturns(result1 bool, result2 error) { - fake.IsFilesetLinkedStub = nil - fake.isFilesetLinkedReturns = struct { - result1 bool +func (fake *FakeSpectrumScaleConnector) ListFilesetQuotaArgsForCall(i int) (string, string) { + fake.listFilesetQuotaMutex.RLock() + defer fake.listFilesetQuotaMutex.RUnlock() + argsForCall := fake.listFilesetQuotaArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeSpectrumScaleConnector) ListFilesetQuotaReturns(result1 string, result2 error) { + fake.listFilesetQuotaMutex.Lock() + defer fake.listFilesetQuotaMutex.Unlock() + fake.ListFilesetQuotaStub = nil + fake.listFilesetQuotaReturns = struct { + result1 string result2 error }{result1, result2} } -func (fake *FakeSpectrumScaleConnector) IsFilesetLinkedReturnsOnCall(i int, result1 bool, result2 error) { - fake.IsFilesetLinkedStub = nil - if fake.isFilesetLinkedReturnsOnCall == nil { - fake.isFilesetLinkedReturnsOnCall = make(map[int]struct { - result1 bool +func (fake *FakeSpectrumScaleConnector) ListFilesetQuotaReturnsOnCall(i int, result1 string, result2 error) { + fake.listFilesetQuotaMutex.Lock() + defer fake.listFilesetQuotaMutex.Unlock() + fake.ListFilesetQuotaStub = nil + if fake.listFilesetQuotaReturnsOnCall == nil { + fake.listFilesetQuotaReturnsOnCall = make(map[int]struct { + result1 string result2 error }) } - fake.isFilesetLinkedReturnsOnCall[i] = struct { - result1 bool + fake.listFilesetQuotaReturnsOnCall[i] = struct { + result1 string result2 error }{result1, result2} } -func (fake *FakeSpectrumScaleConnector) CheckIfFSQuotaEnabled(filesystemName string) (error) { - fake.checkIfFSQuotaEnabledMutex.Lock() - ret, specificReturn := fake.checkIfFSQuotaEnabledReturnsOnCall[len(fake.checkIfFSQuotaEnabledArgsForCall)] - fake.checkIfFSQuotaEnabledArgsForCall = append(fake.checkIfFSQuotaEnabledArgsForCall, struct { - filesystemName string - }{filesystemName}) - fake.recordInvocation("CheckIfFSQuotaEnabled", []interface{}{filesystemName}) - fake.checkIfFSQuotaEnabledMutex.Unlock() - if fake.CheckIfFSQuotaEnabledStub != nil { - return fake.CheckIfFSQuotaEnabledStub(filesystemName) +func (fake *FakeSpectrumScaleConnector) ListFilesets(arg1 string) ([]resources.Volume, error) { + fake.listFilesetsMutex.Lock() + ret, specificReturn := fake.listFilesetsReturnsOnCall[len(fake.listFilesetsArgsForCall)] + fake.listFilesetsArgsForCall = append(fake.listFilesetsArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("ListFilesets", []interface{}{arg1}) + fake.listFilesetsMutex.Unlock() + if fake.ListFilesetsStub != nil { + return fake.ListFilesetsStub(arg1) } if specificReturn { - return ret.result1 + return ret.result1, ret.result2 } - return fake.checkIfFSQuotaEnabledReturns.result1 + fakeReturns := fake.listFilesetsReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeSpectrumScaleConnector) CheckIfFSQuotaEnabledCallCount() int { - fake.checkIfFSQuotaEnabledMutex.RLock() - defer fake.checkIfFSQuotaEnabledMutex.RUnlock() - return len(fake.checkIfFSQuotaEnabledArgsForCall) +func (fake *FakeSpectrumScaleConnector) ListFilesetsCallCount() int { + fake.listFilesetsMutex.RLock() + defer fake.listFilesetsMutex.RUnlock() + return len(fake.listFilesetsArgsForCall) } -func (fake *FakeSpectrumScaleConnector) CheckIfFSQuotaEnabledArgsForCall(i int) (string) { - fake.checkIfFSQuotaEnabledMutex.RLock() - defer fake.checkIfFSQuotaEnabledMutex.RUnlock() - return fake.checkIfFSQuotaEnabledArgsForCall[i].filesystemName +func (fake *FakeSpectrumScaleConnector) ListFilesetsCalls(stub func(string) ([]resources.Volume, error)) { + fake.listFilesetsMutex.Lock() + defer fake.listFilesetsMutex.Unlock() + fake.ListFilesetsStub = stub } -func (fake *FakeSpectrumScaleConnector) CheckIfFSQuotaEnabledReturns(result1 error) { - fake.CheckIfFSQuotaEnabledStub = nil - fake.checkIfFSQuotaEnabledReturns = struct { - result1 error - }{result1} +func (fake *FakeSpectrumScaleConnector) ListFilesetsArgsForCall(i int) string { + fake.listFilesetsMutex.RLock() + defer fake.listFilesetsMutex.RUnlock() + argsForCall := fake.listFilesetsArgsForCall[i] + return argsForCall.arg1 } -func (fake *FakeSpectrumScaleConnector) CheckIfFSQuotaEnabledReturnsOnCall(i int, result1 error) { - fake.CheckIfFSQuotaEnabledStub = nil - if fake.checkIfFSQuotaEnabledReturnsOnCall == nil { - fake.checkIfFSQuotaEnabledReturnsOnCall = make(map[int]struct { - result1 error +func (fake *FakeSpectrumScaleConnector) ListFilesetsReturns(result1 []resources.Volume, result2 error) { + fake.listFilesetsMutex.Lock() + defer fake.listFilesetsMutex.Unlock() + fake.ListFilesetsStub = nil + fake.listFilesetsReturns = struct { + result1 []resources.Volume + result2 error + }{result1, result2} +} + +func (fake *FakeSpectrumScaleConnector) ListFilesetsReturnsOnCall(i int, result1 []resources.Volume, result2 error) { + fake.listFilesetsMutex.Lock() + defer fake.listFilesetsMutex.Unlock() + fake.ListFilesetsStub = nil + if fake.listFilesetsReturnsOnCall == nil { + fake.listFilesetsReturnsOnCall = make(map[int]struct { + result1 []resources.Volume + result2 error }) } - fake.checkIfFSQuotaEnabledReturnsOnCall[i] = struct { - result1 error - }{result1} + fake.listFilesetsReturnsOnCall[i] = struct { + result1 []resources.Volume + result2 error + }{result1, result2} } +func (fake *FakeSpectrumScaleConnector) ListFilesystems() ([]string, error) { + fake.listFilesystemsMutex.Lock() + ret, specificReturn := fake.listFilesystemsReturnsOnCall[len(fake.listFilesystemsArgsForCall)] + fake.listFilesystemsArgsForCall = append(fake.listFilesystemsArgsForCall, struct { + }{}) + fake.recordInvocation("ListFilesystems", []interface{}{}) + fake.listFilesystemsMutex.Unlock() + if fake.ListFilesystemsStub != nil { + return fake.ListFilesystemsStub() + } + if specificReturn { + return ret.result1, ret.result2 + } + fakeReturns := fake.listFilesystemsReturns + return fakeReturns.result1, fakeReturns.result2 +} -func (fake *FakeSpectrumScaleConnector) ListFilesetQuota(filesystemName string, filesetName string) (string, error) { - fake.listFilesetQuotaMutex.Lock() - ret, specificReturn := fake.listFilesetQuotaReturnsOnCall[len(fake.listFilesetQuotaArgsForCall)] - fake.listFilesetQuotaArgsForCall = append(fake.listFilesetQuotaArgsForCall, struct { - filesystemName string - filesetName string - }{filesystemName, filesetName}) - fake.recordInvocation("ListFilesetQuota", []interface{}{filesystemName, filesetName}) - fake.listFilesetQuotaMutex.Unlock() - if fake.ListFilesetQuotaStub != nil { - return fake.ListFilesetQuotaStub(filesystemName, filesetName) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fake.listFilesetQuotaReturns.result1, fake.listFilesetQuotaReturns.result2 +func (fake *FakeSpectrumScaleConnector) ListFilesystemsCallCount() int { + fake.listFilesystemsMutex.RLock() + defer fake.listFilesystemsMutex.RUnlock() + return len(fake.listFilesystemsArgsForCall) } -func (fake *FakeSpectrumScaleConnector) ListFilesetQuotaCallCount() int { - fake.listFilesetQuotaMutex.RLock() - defer fake.listFilesetQuotaMutex.RUnlock() - return len(fake.listFilesetQuotaArgsForCall) +func (fake *FakeSpectrumScaleConnector) ListFilesystemsCalls(stub func() ([]string, error)) { + fake.listFilesystemsMutex.Lock() + defer fake.listFilesystemsMutex.Unlock() + fake.ListFilesystemsStub = stub } -func (fake *FakeSpectrumScaleConnector) ListFilesetQuotaArgsForCall(i int) (string, string) { - fake.listFilesetQuotaMutex.RLock() - defer fake.listFilesetQuotaMutex.RUnlock() - return fake.listFilesetQuotaArgsForCall[i].filesystemName, fake.listFilesetQuotaArgsForCall[i].filesetName +func (fake *FakeSpectrumScaleConnector) ListFilesystemsReturns(result1 []string, result2 error) { + fake.listFilesystemsMutex.Lock() + defer fake.listFilesystemsMutex.Unlock() + fake.ListFilesystemsStub = nil + fake.listFilesystemsReturns = struct { + result1 []string + result2 error + }{result1, result2} } -func (fake *FakeSpectrumScaleConnector) ListFilesetQuotaReturns(result1 string, result2 error) { - fake.ListFilesetQuotaStub = nil - fake.listFilesetQuotaReturns = struct { - result1 string - result2 error - }{result1, result2} +func (fake *FakeSpectrumScaleConnector) ListFilesystemsReturnsOnCall(i int, result1 []string, result2 error) { + fake.listFilesystemsMutex.Lock() + defer fake.listFilesystemsMutex.Unlock() + fake.ListFilesystemsStub = nil + if fake.listFilesystemsReturnsOnCall == nil { + fake.listFilesystemsReturnsOnCall = make(map[int]struct { + result1 []string + result2 error + }) + } + fake.listFilesystemsReturnsOnCall[i] = struct { + result1 []string + result2 error + }{result1, result2} } -func (fake *FakeSpectrumScaleConnector) ListFilesetQuotaReturnsOnCall(i int, result1 string, result2 error) { - fake.ListFilesetQuotaStub = nil - if fake.listFilesetQuotaReturnsOnCall == nil { - fake.listFilesetQuotaReturnsOnCall = make(map[int]struct { - result1 string - result2 error - }) - } - fake.listFilesetQuotaReturnsOnCall[i] = struct { - result1 string - result2 error - }{result1, result2} -} - -func (fake *FakeSpectrumScaleConnector) SetFilesetQuota(filesystemName string, filesetName string, quota string) error { +func (fake *FakeSpectrumScaleConnector) SetFilesetQuota(arg1 string, arg2 string, arg3 string) error { fake.setFilesetQuotaMutex.Lock() ret, specificReturn := fake.setFilesetQuotaReturnsOnCall[len(fake.setFilesetQuotaArgsForCall)] fake.setFilesetQuotaArgsForCall = append(fake.setFilesetQuotaArgsForCall, struct { - filesystemName string - filesetName string - quota string - }{filesystemName, filesetName, quota}) - fake.recordInvocation("SetFilesetQuota", []interface{}{filesystemName, filesetName, quota}) + arg1 string + arg2 string + arg3 string + }{arg1, arg2, arg3}) + fake.recordInvocation("SetFilesetQuota", []interface{}{arg1, arg2, arg3}) fake.setFilesetQuotaMutex.Unlock() if fake.SetFilesetQuotaStub != nil { - return fake.SetFilesetQuotaStub(filesystemName, filesetName, quota) + return fake.SetFilesetQuotaStub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - return fake.setFilesetQuotaReturns.result1 + fakeReturns := fake.setFilesetQuotaReturns + return fakeReturns.result1 } func (fake *FakeSpectrumScaleConnector) SetFilesetQuotaCallCount() int { @@ -897,13 +952,22 @@ func (fake *FakeSpectrumScaleConnector) SetFilesetQuotaCallCount() int { return len(fake.setFilesetQuotaArgsForCall) } +func (fake *FakeSpectrumScaleConnector) SetFilesetQuotaCalls(stub func(string, string, string) error) { + fake.setFilesetQuotaMutex.Lock() + defer fake.setFilesetQuotaMutex.Unlock() + fake.SetFilesetQuotaStub = stub +} + func (fake *FakeSpectrumScaleConnector) SetFilesetQuotaArgsForCall(i int) (string, string, string) { fake.setFilesetQuotaMutex.RLock() defer fake.setFilesetQuotaMutex.RUnlock() - return fake.setFilesetQuotaArgsForCall[i].filesystemName, fake.setFilesetQuotaArgsForCall[i].filesetName, fake.setFilesetQuotaArgsForCall[i].quota + argsForCall := fake.setFilesetQuotaArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 } func (fake *FakeSpectrumScaleConnector) SetFilesetQuotaReturns(result1 error) { + fake.setFilesetQuotaMutex.Lock() + defer fake.setFilesetQuotaMutex.Unlock() fake.SetFilesetQuotaStub = nil fake.setFilesetQuotaReturns = struct { result1 error @@ -911,6 +975,8 @@ func (fake *FakeSpectrumScaleConnector) SetFilesetQuotaReturns(result1 error) { } func (fake *FakeSpectrumScaleConnector) SetFilesetQuotaReturnsOnCall(i int, result1 error) { + fake.setFilesetQuotaMutex.Lock() + defer fake.setFilesetQuotaMutex.Unlock() fake.SetFilesetQuotaStub = nil if fake.setFilesetQuotaReturnsOnCall == nil { fake.setFilesetQuotaReturnsOnCall = make(map[int]struct { @@ -922,99 +988,63 @@ func (fake *FakeSpectrumScaleConnector) SetFilesetQuotaReturnsOnCall(i int, resu }{result1} } -func (fake *FakeSpectrumScaleConnector) ExportNfs(volumeMountpoint string, clientConfig string) error { - fake.exportNfsMutex.Lock() - ret, specificReturn := fake.exportNfsReturnsOnCall[len(fake.exportNfsArgsForCall)] - fake.exportNfsArgsForCall = append(fake.exportNfsArgsForCall, struct { - volumeMountpoint string - clientConfig string - }{volumeMountpoint, clientConfig}) - fake.recordInvocation("ExportNfs", []interface{}{volumeMountpoint, clientConfig}) - fake.exportNfsMutex.Unlock() - if fake.ExportNfsStub != nil { - return fake.ExportNfsStub(volumeMountpoint, clientConfig) +func (fake *FakeSpectrumScaleConnector) UnlinkFileset(arg1 string, arg2 string) error { + fake.unlinkFilesetMutex.Lock() + ret, specificReturn := fake.unlinkFilesetReturnsOnCall[len(fake.unlinkFilesetArgsForCall)] + fake.unlinkFilesetArgsForCall = append(fake.unlinkFilesetArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("UnlinkFileset", []interface{}{arg1, arg2}) + fake.unlinkFilesetMutex.Unlock() + if fake.UnlinkFilesetStub != nil { + return fake.UnlinkFilesetStub(arg1, arg2) } if specificReturn { return ret.result1 } - return fake.exportNfsReturns.result1 -} - -func (fake *FakeSpectrumScaleConnector) ExportNfsCallCount() int { - fake.exportNfsMutex.RLock() - defer fake.exportNfsMutex.RUnlock() - return len(fake.exportNfsArgsForCall) -} - -func (fake *FakeSpectrumScaleConnector) ExportNfsArgsForCall(i int) (string, string) { - fake.exportNfsMutex.RLock() - defer fake.exportNfsMutex.RUnlock() - return fake.exportNfsArgsForCall[i].volumeMountpoint, fake.exportNfsArgsForCall[i].clientConfig -} - -func (fake *FakeSpectrumScaleConnector) ExportNfsReturns(result1 error) { - fake.ExportNfsStub = nil - fake.exportNfsReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeSpectrumScaleConnector) ExportNfsReturnsOnCall(i int, result1 error) { - fake.ExportNfsStub = nil - if fake.exportNfsReturnsOnCall == nil { - fake.exportNfsReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.exportNfsReturnsOnCall[i] = struct { - result1 error - }{result1} + fakeReturns := fake.unlinkFilesetReturns + return fakeReturns.result1 } -func (fake *FakeSpectrumScaleConnector) UnexportNfs(volumeMountpoint string) error { - fake.unexportNfsMutex.Lock() - ret, specificReturn := fake.unexportNfsReturnsOnCall[len(fake.unexportNfsArgsForCall)] - fake.unexportNfsArgsForCall = append(fake.unexportNfsArgsForCall, struct { - volumeMountpoint string - }{volumeMountpoint}) - fake.recordInvocation("UnexportNfs", []interface{}{volumeMountpoint}) - fake.unexportNfsMutex.Unlock() - if fake.UnexportNfsStub != nil { - return fake.UnexportNfsStub(volumeMountpoint) - } - if specificReturn { - return ret.result1 - } - return fake.unexportNfsReturns.result1 +func (fake *FakeSpectrumScaleConnector) UnlinkFilesetCallCount() int { + fake.unlinkFilesetMutex.RLock() + defer fake.unlinkFilesetMutex.RUnlock() + return len(fake.unlinkFilesetArgsForCall) } -func (fake *FakeSpectrumScaleConnector) UnexportNfsCallCount() int { - fake.unexportNfsMutex.RLock() - defer fake.unexportNfsMutex.RUnlock() - return len(fake.unexportNfsArgsForCall) +func (fake *FakeSpectrumScaleConnector) UnlinkFilesetCalls(stub func(string, string) error) { + fake.unlinkFilesetMutex.Lock() + defer fake.unlinkFilesetMutex.Unlock() + fake.UnlinkFilesetStub = stub } -func (fake *FakeSpectrumScaleConnector) UnexportNfsArgsForCall(i int) string { - fake.unexportNfsMutex.RLock() - defer fake.unexportNfsMutex.RUnlock() - return fake.unexportNfsArgsForCall[i].volumeMountpoint +func (fake *FakeSpectrumScaleConnector) UnlinkFilesetArgsForCall(i int) (string, string) { + fake.unlinkFilesetMutex.RLock() + defer fake.unlinkFilesetMutex.RUnlock() + argsForCall := fake.unlinkFilesetArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } -func (fake *FakeSpectrumScaleConnector) UnexportNfsReturns(result1 error) { - fake.UnexportNfsStub = nil - fake.unexportNfsReturns = struct { +func (fake *FakeSpectrumScaleConnector) UnlinkFilesetReturns(result1 error) { + fake.unlinkFilesetMutex.Lock() + defer fake.unlinkFilesetMutex.Unlock() + fake.UnlinkFilesetStub = nil + fake.unlinkFilesetReturns = struct { result1 error }{result1} } -func (fake *FakeSpectrumScaleConnector) UnexportNfsReturnsOnCall(i int, result1 error) { - fake.UnexportNfsStub = nil - if fake.unexportNfsReturnsOnCall == nil { - fake.unexportNfsReturnsOnCall = make(map[int]struct { +func (fake *FakeSpectrumScaleConnector) UnlinkFilesetReturnsOnCall(i int, result1 error) { + fake.unlinkFilesetMutex.Lock() + defer fake.unlinkFilesetMutex.Unlock() + fake.UnlinkFilesetStub = nil + if fake.unlinkFilesetReturnsOnCall == nil { + fake.unlinkFilesetReturnsOnCall = make(map[int]struct { result1 error }) } - fake.unexportNfsReturnsOnCall[i] = struct { + fake.unlinkFilesetReturnsOnCall[i] = struct { result1 error }{result1} } @@ -1022,39 +1052,39 @@ func (fake *FakeSpectrumScaleConnector) UnexportNfsReturnsOnCall(i int, result1 func (fake *FakeSpectrumScaleConnector) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() - fake.getClusterIdMutex.RLock() - defer fake.getClusterIdMutex.RUnlock() - fake.isFilesystemMountedMutex.RLock() - defer fake.isFilesystemMountedMutex.RUnlock() - fake.listFilesystemsMutex.RLock() - defer fake.listFilesystemsMutex.RUnlock() - fake.getFilesystemMountpointMutex.RLock() - defer fake.getFilesystemMountpointMutex.RUnlock() + fake.checkIfFSQuotaEnabledMutex.RLock() + defer fake.checkIfFSQuotaEnabledMutex.RUnlock() fake.createFilesetMutex.RLock() defer fake.createFilesetMutex.RUnlock() fake.deleteFilesetMutex.RLock() defer fake.deleteFilesetMutex.RUnlock() + fake.getClusterIdMutex.RLock() + defer fake.getClusterIdMutex.RUnlock() + fake.getFilesystemMountpointMutex.RLock() + defer fake.getFilesystemMountpointMutex.RUnlock() + fake.isFilesetLinkedMutex.RLock() + defer fake.isFilesetLinkedMutex.RUnlock() + fake.isFilesystemMountedMutex.RLock() + defer fake.isFilesystemMountedMutex.RUnlock() fake.linkFilesetMutex.RLock() defer fake.linkFilesetMutex.RUnlock() - fake.unlinkFilesetMutex.RLock() - defer fake.unlinkFilesetMutex.RUnlock() - fake.listFilesetsMutex.RLock() - defer fake.listFilesetsMutex.RUnlock() fake.listFilesetMutex.RLock() defer fake.listFilesetMutex.RUnlock() - fake.isFilesetLinkedMutex.RLock() - defer fake.isFilesetLinkedMutex.RUnlock() fake.listFilesetQuotaMutex.RLock() defer fake.listFilesetQuotaMutex.RUnlock() + fake.listFilesetsMutex.RLock() + defer fake.listFilesetsMutex.RUnlock() + fake.listFilesystemsMutex.RLock() + defer fake.listFilesystemsMutex.RUnlock() fake.setFilesetQuotaMutex.RLock() defer fake.setFilesetQuotaMutex.RUnlock() - fake.checkIfFSQuotaEnabledMutex.RLock() - defer fake.checkIfFSQuotaEnabledMutex.RUnlock() - fake.exportNfsMutex.RLock() - defer fake.exportNfsMutex.RUnlock() - fake.unexportNfsMutex.RLock() - defer fake.unexportNfsMutex.RUnlock() - return fake.invocations + fake.unlinkFilesetMutex.RLock() + defer fake.unlinkFilesetMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations } func (fake *FakeSpectrumScaleConnector) recordInvocation(key string, args []interface{}) { diff --git a/fakes/fake_storage_client.go b/fakes/fake_storage_client.go index b33aec93..19eeffb1 100644 --- a/fakes/fake_storage_client.go +++ b/fakes/fake_storage_client.go @@ -1,20 +1,4 @@ -/** - * Copyright 2016, 2017 IBM Corp. - * - * 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. - */ - -// This file was generated by counterfeiter +// Code generated by counterfeiter. DO NOT EDIT. package fakes import ( @@ -24,10 +8,10 @@ import ( ) type FakeStorageClient struct { - ActivateStub func(activateRequest resources.ActivateRequest) error + ActivateStub func(resources.ActivateRequest) error activateMutex sync.RWMutex activateArgsForCall []struct { - activateRequest resources.ActivateRequest + arg1 resources.ActivateRequest } activateReturns struct { result1 error @@ -35,10 +19,23 @@ type FakeStorageClient struct { activateReturnsOnCall map[int]struct { result1 error } - CreateVolumeStub func(createVolumeRequest resources.CreateVolumeRequest) error + AttachStub func(resources.AttachRequest) (string, error) + attachMutex sync.RWMutex + attachArgsForCall []struct { + arg1 resources.AttachRequest + } + attachReturns struct { + result1 string + result2 error + } + attachReturnsOnCall map[int]struct { + result1 string + result2 error + } + CreateVolumeStub func(resources.CreateVolumeRequest) error createVolumeMutex sync.RWMutex createVolumeArgsForCall []struct { - createVolumeRequest resources.CreateVolumeRequest + arg1 resources.CreateVolumeRequest } createVolumeReturns struct { result1 error @@ -46,34 +43,21 @@ type FakeStorageClient struct { createVolumeReturnsOnCall map[int]struct { result1 error } - RemoveVolumeStub func(removeVolumeRequest resources.RemoveVolumeRequest) error - removeVolumeMutex sync.RWMutex - removeVolumeArgsForCall []struct { - removeVolumeRequest resources.RemoveVolumeRequest + DetachStub func(resources.DetachRequest) error + detachMutex sync.RWMutex + detachArgsForCall []struct { + arg1 resources.DetachRequest } - removeVolumeReturns struct { + detachReturns struct { result1 error } - removeVolumeReturnsOnCall map[int]struct { + detachReturnsOnCall map[int]struct { result1 error } - ListVolumesStub func(listVolumeRequest resources.ListVolumesRequest) ([]resources.Volume, error) - listVolumesMutex sync.RWMutex - listVolumesArgsForCall []struct { - listVolumeRequest resources.ListVolumesRequest - } - listVolumesReturns struct { - result1 []resources.Volume - result2 error - } - listVolumesReturnsOnCall map[int]struct { - result1 []resources.Volume - result2 error - } - GetVolumeStub func(getVolumeRequest resources.GetVolumeRequest) (resources.Volume, error) + GetVolumeStub func(resources.GetVolumeRequest) (resources.Volume, error) getVolumeMutex sync.RWMutex getVolumeArgsForCall []struct { - getVolumeRequest resources.GetVolumeRequest + arg1 resources.GetVolumeRequest } getVolumeReturns struct { result1 resources.Volume @@ -83,10 +67,10 @@ type FakeStorageClient struct { result1 resources.Volume result2 error } - GetVolumeConfigStub func(getVolumeConfigRequest resources.GetVolumeConfigRequest) (map[string]interface{}, error) + GetVolumeConfigStub func(resources.GetVolumeConfigRequest) (map[string]interface{}, error) getVolumeConfigMutex sync.RWMutex getVolumeConfigArgsForCall []struct { - getVolumeConfigRequest resources.GetVolumeConfigRequest + arg1 resources.GetVolumeConfigRequest } getVolumeConfigReturns struct { result1 map[string]interface{} @@ -96,49 +80,50 @@ type FakeStorageClient struct { result1 map[string]interface{} result2 error } - AttachStub func(attachRequest resources.AttachRequest) (string, error) - attachMutex sync.RWMutex - attachArgsForCall []struct { - attachRequest resources.AttachRequest + ListVolumesStub func(resources.ListVolumesRequest) ([]resources.Volume, error) + listVolumesMutex sync.RWMutex + listVolumesArgsForCall []struct { + arg1 resources.ListVolumesRequest } - attachReturns struct { - result1 string + listVolumesReturns struct { + result1 []resources.Volume result2 error } - attachReturnsOnCall map[int]struct { - result1 string + listVolumesReturnsOnCall map[int]struct { + result1 []resources.Volume result2 error } - DetachStub func(detachRequest resources.DetachRequest) error - detachMutex sync.RWMutex - detachArgsForCall []struct { - detachRequest resources.DetachRequest + RemoveVolumeStub func(resources.RemoveVolumeRequest) error + removeVolumeMutex sync.RWMutex + removeVolumeArgsForCall []struct { + arg1 resources.RemoveVolumeRequest } - detachReturns struct { + removeVolumeReturns struct { result1 error } - detachReturnsOnCall map[int]struct { + removeVolumeReturnsOnCall map[int]struct { result1 error } invocations map[string][][]interface{} invocationsMutex sync.RWMutex } -func (fake *FakeStorageClient) Activate(activateRequest resources.ActivateRequest) error { +func (fake *FakeStorageClient) Activate(arg1 resources.ActivateRequest) error { fake.activateMutex.Lock() ret, specificReturn := fake.activateReturnsOnCall[len(fake.activateArgsForCall)] fake.activateArgsForCall = append(fake.activateArgsForCall, struct { - activateRequest resources.ActivateRequest - }{activateRequest}) - fake.recordInvocation("Activate", []interface{}{activateRequest}) + arg1 resources.ActivateRequest + }{arg1}) + fake.recordInvocation("Activate", []interface{}{arg1}) fake.activateMutex.Unlock() if fake.ActivateStub != nil { - return fake.ActivateStub(activateRequest) + return fake.ActivateStub(arg1) } if specificReturn { return ret.result1 } - return fake.activateReturns.result1 + fakeReturns := fake.activateReturns + return fakeReturns.result1 } func (fake *FakeStorageClient) ActivateCallCount() int { @@ -147,13 +132,22 @@ func (fake *FakeStorageClient) ActivateCallCount() int { return len(fake.activateArgsForCall) } +func (fake *FakeStorageClient) ActivateCalls(stub func(resources.ActivateRequest) error) { + fake.activateMutex.Lock() + defer fake.activateMutex.Unlock() + fake.ActivateStub = stub +} + func (fake *FakeStorageClient) ActivateArgsForCall(i int) resources.ActivateRequest { fake.activateMutex.RLock() defer fake.activateMutex.RUnlock() - return fake.activateArgsForCall[i].activateRequest + argsForCall := fake.activateArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeStorageClient) ActivateReturns(result1 error) { + fake.activateMutex.Lock() + defer fake.activateMutex.Unlock() fake.ActivateStub = nil fake.activateReturns = struct { result1 error @@ -161,6 +155,8 @@ func (fake *FakeStorageClient) ActivateReturns(result1 error) { } func (fake *FakeStorageClient) ActivateReturnsOnCall(i int, result1 error) { + fake.activateMutex.Lock() + defer fake.activateMutex.Unlock() fake.ActivateStub = nil if fake.activateReturnsOnCall == nil { fake.activateReturnsOnCall = make(map[int]struct { @@ -172,21 +168,85 @@ func (fake *FakeStorageClient) ActivateReturnsOnCall(i int, result1 error) { }{result1} } -func (fake *FakeStorageClient) CreateVolume(createVolumeRequest resources.CreateVolumeRequest) error { +func (fake *FakeStorageClient) Attach(arg1 resources.AttachRequest) (string, error) { + fake.attachMutex.Lock() + ret, specificReturn := fake.attachReturnsOnCall[len(fake.attachArgsForCall)] + fake.attachArgsForCall = append(fake.attachArgsForCall, struct { + arg1 resources.AttachRequest + }{arg1}) + fake.recordInvocation("Attach", []interface{}{arg1}) + fake.attachMutex.Unlock() + if fake.AttachStub != nil { + return fake.AttachStub(arg1) + } + if specificReturn { + return ret.result1, ret.result2 + } + fakeReturns := fake.attachReturns + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeStorageClient) AttachCallCount() int { + fake.attachMutex.RLock() + defer fake.attachMutex.RUnlock() + return len(fake.attachArgsForCall) +} + +func (fake *FakeStorageClient) AttachCalls(stub func(resources.AttachRequest) (string, error)) { + fake.attachMutex.Lock() + defer fake.attachMutex.Unlock() + fake.AttachStub = stub +} + +func (fake *FakeStorageClient) AttachArgsForCall(i int) resources.AttachRequest { + fake.attachMutex.RLock() + defer fake.attachMutex.RUnlock() + argsForCall := fake.attachArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeStorageClient) AttachReturns(result1 string, result2 error) { + fake.attachMutex.Lock() + defer fake.attachMutex.Unlock() + fake.AttachStub = nil + fake.attachReturns = struct { + result1 string + result2 error + }{result1, result2} +} + +func (fake *FakeStorageClient) AttachReturnsOnCall(i int, result1 string, result2 error) { + fake.attachMutex.Lock() + defer fake.attachMutex.Unlock() + fake.AttachStub = nil + if fake.attachReturnsOnCall == nil { + fake.attachReturnsOnCall = make(map[int]struct { + result1 string + result2 error + }) + } + fake.attachReturnsOnCall[i] = struct { + result1 string + result2 error + }{result1, result2} +} + +func (fake *FakeStorageClient) CreateVolume(arg1 resources.CreateVolumeRequest) error { fake.createVolumeMutex.Lock() ret, specificReturn := fake.createVolumeReturnsOnCall[len(fake.createVolumeArgsForCall)] fake.createVolumeArgsForCall = append(fake.createVolumeArgsForCall, struct { - createVolumeRequest resources.CreateVolumeRequest - }{createVolumeRequest}) - fake.recordInvocation("CreateVolume", []interface{}{createVolumeRequest}) + arg1 resources.CreateVolumeRequest + }{arg1}) + fake.recordInvocation("CreateVolume", []interface{}{arg1}) fake.createVolumeMutex.Unlock() if fake.CreateVolumeStub != nil { - return fake.CreateVolumeStub(createVolumeRequest) + return fake.CreateVolumeStub(arg1) } if specificReturn { return ret.result1 } - return fake.createVolumeReturns.result1 + fakeReturns := fake.createVolumeReturns + return fakeReturns.result1 } func (fake *FakeStorageClient) CreateVolumeCallCount() int { @@ -195,13 +255,22 @@ func (fake *FakeStorageClient) CreateVolumeCallCount() int { return len(fake.createVolumeArgsForCall) } +func (fake *FakeStorageClient) CreateVolumeCalls(stub func(resources.CreateVolumeRequest) error) { + fake.createVolumeMutex.Lock() + defer fake.createVolumeMutex.Unlock() + fake.CreateVolumeStub = stub +} + func (fake *FakeStorageClient) CreateVolumeArgsForCall(i int) resources.CreateVolumeRequest { fake.createVolumeMutex.RLock() defer fake.createVolumeMutex.RUnlock() - return fake.createVolumeArgsForCall[i].createVolumeRequest + argsForCall := fake.createVolumeArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeStorageClient) CreateVolumeReturns(result1 error) { + fake.createVolumeMutex.Lock() + defer fake.createVolumeMutex.Unlock() fake.CreateVolumeStub = nil fake.createVolumeReturns = struct { result1 error @@ -209,6 +278,8 @@ func (fake *FakeStorageClient) CreateVolumeReturns(result1 error) { } func (fake *FakeStorageClient) CreateVolumeReturnsOnCall(i int, result1 error) { + fake.createVolumeMutex.Lock() + defer fake.createVolumeMutex.Unlock() fake.CreateVolumeStub = nil if fake.createVolumeReturnsOnCall == nil { fake.createVolumeReturnsOnCall = make(map[int]struct { @@ -220,120 +291,82 @@ func (fake *FakeStorageClient) CreateVolumeReturnsOnCall(i int, result1 error) { }{result1} } -func (fake *FakeStorageClient) RemoveVolume(removeVolumeRequest resources.RemoveVolumeRequest) error { - fake.removeVolumeMutex.Lock() - ret, specificReturn := fake.removeVolumeReturnsOnCall[len(fake.removeVolumeArgsForCall)] - fake.removeVolumeArgsForCall = append(fake.removeVolumeArgsForCall, struct { - removeVolumeRequest resources.RemoveVolumeRequest - }{removeVolumeRequest}) - fake.recordInvocation("RemoveVolume", []interface{}{removeVolumeRequest}) - fake.removeVolumeMutex.Unlock() - if fake.RemoveVolumeStub != nil { - return fake.RemoveVolumeStub(removeVolumeRequest) +func (fake *FakeStorageClient) Detach(arg1 resources.DetachRequest) error { + fake.detachMutex.Lock() + ret, specificReturn := fake.detachReturnsOnCall[len(fake.detachArgsForCall)] + fake.detachArgsForCall = append(fake.detachArgsForCall, struct { + arg1 resources.DetachRequest + }{arg1}) + fake.recordInvocation("Detach", []interface{}{arg1}) + fake.detachMutex.Unlock() + if fake.DetachStub != nil { + return fake.DetachStub(arg1) } if specificReturn { return ret.result1 } - return fake.removeVolumeReturns.result1 + fakeReturns := fake.detachReturns + return fakeReturns.result1 } -func (fake *FakeStorageClient) RemoveVolumeCallCount() int { - fake.removeVolumeMutex.RLock() - defer fake.removeVolumeMutex.RUnlock() - return len(fake.removeVolumeArgsForCall) +func (fake *FakeStorageClient) DetachCallCount() int { + fake.detachMutex.RLock() + defer fake.detachMutex.RUnlock() + return len(fake.detachArgsForCall) } -func (fake *FakeStorageClient) RemoveVolumeArgsForCall(i int) resources.RemoveVolumeRequest { - fake.removeVolumeMutex.RLock() - defer fake.removeVolumeMutex.RUnlock() - return fake.removeVolumeArgsForCall[i].removeVolumeRequest +func (fake *FakeStorageClient) DetachCalls(stub func(resources.DetachRequest) error) { + fake.detachMutex.Lock() + defer fake.detachMutex.Unlock() + fake.DetachStub = stub } -func (fake *FakeStorageClient) RemoveVolumeReturns(result1 error) { - fake.RemoveVolumeStub = nil - fake.removeVolumeReturns = struct { +func (fake *FakeStorageClient) DetachArgsForCall(i int) resources.DetachRequest { + fake.detachMutex.RLock() + defer fake.detachMutex.RUnlock() + argsForCall := fake.detachArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeStorageClient) DetachReturns(result1 error) { + fake.detachMutex.Lock() + defer fake.detachMutex.Unlock() + fake.DetachStub = nil + fake.detachReturns = struct { result1 error }{result1} } -func (fake *FakeStorageClient) RemoveVolumeReturnsOnCall(i int, result1 error) { - fake.RemoveVolumeStub = nil - if fake.removeVolumeReturnsOnCall == nil { - fake.removeVolumeReturnsOnCall = make(map[int]struct { +func (fake *FakeStorageClient) DetachReturnsOnCall(i int, result1 error) { + fake.detachMutex.Lock() + defer fake.detachMutex.Unlock() + fake.DetachStub = nil + if fake.detachReturnsOnCall == nil { + fake.detachReturnsOnCall = make(map[int]struct { result1 error }) } - fake.removeVolumeReturnsOnCall[i] = struct { + fake.detachReturnsOnCall[i] = struct { result1 error }{result1} } -func (fake *FakeStorageClient) ListVolumes(listVolumeRequest resources.ListVolumesRequest) ([]resources.Volume, error) { - fake.listVolumesMutex.Lock() - ret, specificReturn := fake.listVolumesReturnsOnCall[len(fake.listVolumesArgsForCall)] - fake.listVolumesArgsForCall = append(fake.listVolumesArgsForCall, struct { - listVolumeRequest resources.ListVolumesRequest - }{listVolumeRequest}) - fake.recordInvocation("ListVolumes", []interface{}{listVolumeRequest}) - fake.listVolumesMutex.Unlock() - if fake.ListVolumesStub != nil { - return fake.ListVolumesStub(listVolumeRequest) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fake.listVolumesReturns.result1, fake.listVolumesReturns.result2 -} - -func (fake *FakeStorageClient) ListVolumesCallCount() int { - fake.listVolumesMutex.RLock() - defer fake.listVolumesMutex.RUnlock() - return len(fake.listVolumesArgsForCall) -} - -func (fake *FakeStorageClient) ListVolumesArgsForCall(i int) resources.ListVolumesRequest { - fake.listVolumesMutex.RLock() - defer fake.listVolumesMutex.RUnlock() - return fake.listVolumesArgsForCall[i].listVolumeRequest -} - -func (fake *FakeStorageClient) ListVolumesReturns(result1 []resources.Volume, result2 error) { - fake.ListVolumesStub = nil - fake.listVolumesReturns = struct { - result1 []resources.Volume - result2 error - }{result1, result2} -} - -func (fake *FakeStorageClient) ListVolumesReturnsOnCall(i int, result1 []resources.Volume, result2 error) { - fake.ListVolumesStub = nil - if fake.listVolumesReturnsOnCall == nil { - fake.listVolumesReturnsOnCall = make(map[int]struct { - result1 []resources.Volume - result2 error - }) - } - fake.listVolumesReturnsOnCall[i] = struct { - result1 []resources.Volume - result2 error - }{result1, result2} -} - -func (fake *FakeStorageClient) GetVolume(getVolumeRequest resources.GetVolumeRequest) (resources.Volume, error) { +func (fake *FakeStorageClient) GetVolume(arg1 resources.GetVolumeRequest) (resources.Volume, error) { fake.getVolumeMutex.Lock() ret, specificReturn := fake.getVolumeReturnsOnCall[len(fake.getVolumeArgsForCall)] fake.getVolumeArgsForCall = append(fake.getVolumeArgsForCall, struct { - getVolumeRequest resources.GetVolumeRequest - }{getVolumeRequest}) - fake.recordInvocation("GetVolume", []interface{}{getVolumeRequest}) + arg1 resources.GetVolumeRequest + }{arg1}) + fake.recordInvocation("GetVolume", []interface{}{arg1}) fake.getVolumeMutex.Unlock() if fake.GetVolumeStub != nil { - return fake.GetVolumeStub(getVolumeRequest) + return fake.GetVolumeStub(arg1) } if specificReturn { return ret.result1, ret.result2 } - return fake.getVolumeReturns.result1, fake.getVolumeReturns.result2 + fakeReturns := fake.getVolumeReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeStorageClient) GetVolumeCallCount() int { @@ -342,13 +375,22 @@ func (fake *FakeStorageClient) GetVolumeCallCount() int { return len(fake.getVolumeArgsForCall) } +func (fake *FakeStorageClient) GetVolumeCalls(stub func(resources.GetVolumeRequest) (resources.Volume, error)) { + fake.getVolumeMutex.Lock() + defer fake.getVolumeMutex.Unlock() + fake.GetVolumeStub = stub +} + func (fake *FakeStorageClient) GetVolumeArgsForCall(i int) resources.GetVolumeRequest { fake.getVolumeMutex.RLock() defer fake.getVolumeMutex.RUnlock() - return fake.getVolumeArgsForCall[i].getVolumeRequest + argsForCall := fake.getVolumeArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeStorageClient) GetVolumeReturns(result1 resources.Volume, result2 error) { + fake.getVolumeMutex.Lock() + defer fake.getVolumeMutex.Unlock() fake.GetVolumeStub = nil fake.getVolumeReturns = struct { result1 resources.Volume @@ -357,6 +399,8 @@ func (fake *FakeStorageClient) GetVolumeReturns(result1 resources.Volume, result } func (fake *FakeStorageClient) GetVolumeReturnsOnCall(i int, result1 resources.Volume, result2 error) { + fake.getVolumeMutex.Lock() + defer fake.getVolumeMutex.Unlock() fake.GetVolumeStub = nil if fake.getVolumeReturnsOnCall == nil { fake.getVolumeReturnsOnCall = make(map[int]struct { @@ -370,21 +414,22 @@ func (fake *FakeStorageClient) GetVolumeReturnsOnCall(i int, result1 resources.V }{result1, result2} } -func (fake *FakeStorageClient) GetVolumeConfig(getVolumeConfigRequest resources.GetVolumeConfigRequest) (map[string]interface{}, error) { +func (fake *FakeStorageClient) GetVolumeConfig(arg1 resources.GetVolumeConfigRequest) (map[string]interface{}, error) { fake.getVolumeConfigMutex.Lock() ret, specificReturn := fake.getVolumeConfigReturnsOnCall[len(fake.getVolumeConfigArgsForCall)] fake.getVolumeConfigArgsForCall = append(fake.getVolumeConfigArgsForCall, struct { - getVolumeConfigRequest resources.GetVolumeConfigRequest - }{getVolumeConfigRequest}) - fake.recordInvocation("GetVolumeConfig", []interface{}{getVolumeConfigRequest}) + arg1 resources.GetVolumeConfigRequest + }{arg1}) + fake.recordInvocation("GetVolumeConfig", []interface{}{arg1}) fake.getVolumeConfigMutex.Unlock() if fake.GetVolumeConfigStub != nil { - return fake.GetVolumeConfigStub(getVolumeConfigRequest) + return fake.GetVolumeConfigStub(arg1) } if specificReturn { return ret.result1, ret.result2 } - return fake.getVolumeConfigReturns.result1, fake.getVolumeConfigReturns.result2 + fakeReturns := fake.getVolumeConfigReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeStorageClient) GetVolumeConfigCallCount() int { @@ -393,13 +438,22 @@ func (fake *FakeStorageClient) GetVolumeConfigCallCount() int { return len(fake.getVolumeConfigArgsForCall) } +func (fake *FakeStorageClient) GetVolumeConfigCalls(stub func(resources.GetVolumeConfigRequest) (map[string]interface{}, error)) { + fake.getVolumeConfigMutex.Lock() + defer fake.getVolumeConfigMutex.Unlock() + fake.GetVolumeConfigStub = stub +} + func (fake *FakeStorageClient) GetVolumeConfigArgsForCall(i int) resources.GetVolumeConfigRequest { fake.getVolumeConfigMutex.RLock() defer fake.getVolumeConfigMutex.RUnlock() - return fake.getVolumeConfigArgsForCall[i].getVolumeConfigRequest + argsForCall := fake.getVolumeConfigArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeStorageClient) GetVolumeConfigReturns(result1 map[string]interface{}, result2 error) { + fake.getVolumeConfigMutex.Lock() + defer fake.getVolumeConfigMutex.Unlock() fake.GetVolumeConfigStub = nil fake.getVolumeConfigReturns = struct { result1 map[string]interface{} @@ -408,6 +462,8 @@ func (fake *FakeStorageClient) GetVolumeConfigReturns(result1 map[string]interfa } func (fake *FakeStorageClient) GetVolumeConfigReturnsOnCall(i int, result1 map[string]interface{}, result2 error) { + fake.getVolumeConfigMutex.Lock() + defer fake.getVolumeConfigMutex.Unlock() fake.GetVolumeConfigStub = nil if fake.getVolumeConfigReturnsOnCall == nil { fake.getVolumeConfigReturnsOnCall = make(map[int]struct { @@ -421,101 +477,125 @@ func (fake *FakeStorageClient) GetVolumeConfigReturnsOnCall(i int, result1 map[s }{result1, result2} } -func (fake *FakeStorageClient) Attach(attachRequest resources.AttachRequest) (string, error) { - fake.attachMutex.Lock() - ret, specificReturn := fake.attachReturnsOnCall[len(fake.attachArgsForCall)] - fake.attachArgsForCall = append(fake.attachArgsForCall, struct { - attachRequest resources.AttachRequest - }{attachRequest}) - fake.recordInvocation("Attach", []interface{}{attachRequest}) - fake.attachMutex.Unlock() - if fake.AttachStub != nil { - return fake.AttachStub(attachRequest) +func (fake *FakeStorageClient) ListVolumes(arg1 resources.ListVolumesRequest) ([]resources.Volume, error) { + fake.listVolumesMutex.Lock() + ret, specificReturn := fake.listVolumesReturnsOnCall[len(fake.listVolumesArgsForCall)] + fake.listVolumesArgsForCall = append(fake.listVolumesArgsForCall, struct { + arg1 resources.ListVolumesRequest + }{arg1}) + fake.recordInvocation("ListVolumes", []interface{}{arg1}) + fake.listVolumesMutex.Unlock() + if fake.ListVolumesStub != nil { + return fake.ListVolumesStub(arg1) } if specificReturn { return ret.result1, ret.result2 } - return fake.attachReturns.result1, fake.attachReturns.result2 + fakeReturns := fake.listVolumesReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeStorageClient) AttachCallCount() int { - fake.attachMutex.RLock() - defer fake.attachMutex.RUnlock() - return len(fake.attachArgsForCall) +func (fake *FakeStorageClient) ListVolumesCallCount() int { + fake.listVolumesMutex.RLock() + defer fake.listVolumesMutex.RUnlock() + return len(fake.listVolumesArgsForCall) } -func (fake *FakeStorageClient) AttachArgsForCall(i int) resources.AttachRequest { - fake.attachMutex.RLock() - defer fake.attachMutex.RUnlock() - return fake.attachArgsForCall[i].attachRequest +func (fake *FakeStorageClient) ListVolumesCalls(stub func(resources.ListVolumesRequest) ([]resources.Volume, error)) { + fake.listVolumesMutex.Lock() + defer fake.listVolumesMutex.Unlock() + fake.ListVolumesStub = stub } -func (fake *FakeStorageClient) AttachReturns(result1 string, result2 error) { - fake.AttachStub = nil - fake.attachReturns = struct { - result1 string +func (fake *FakeStorageClient) ListVolumesArgsForCall(i int) resources.ListVolumesRequest { + fake.listVolumesMutex.RLock() + defer fake.listVolumesMutex.RUnlock() + argsForCall := fake.listVolumesArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeStorageClient) ListVolumesReturns(result1 []resources.Volume, result2 error) { + fake.listVolumesMutex.Lock() + defer fake.listVolumesMutex.Unlock() + fake.ListVolumesStub = nil + fake.listVolumesReturns = struct { + result1 []resources.Volume result2 error }{result1, result2} } -func (fake *FakeStorageClient) AttachReturnsOnCall(i int, result1 string, result2 error) { - fake.AttachStub = nil - if fake.attachReturnsOnCall == nil { - fake.attachReturnsOnCall = make(map[int]struct { - result1 string +func (fake *FakeStorageClient) ListVolumesReturnsOnCall(i int, result1 []resources.Volume, result2 error) { + fake.listVolumesMutex.Lock() + defer fake.listVolumesMutex.Unlock() + fake.ListVolumesStub = nil + if fake.listVolumesReturnsOnCall == nil { + fake.listVolumesReturnsOnCall = make(map[int]struct { + result1 []resources.Volume result2 error }) } - fake.attachReturnsOnCall[i] = struct { - result1 string + fake.listVolumesReturnsOnCall[i] = struct { + result1 []resources.Volume result2 error }{result1, result2} } -func (fake *FakeStorageClient) Detach(detachRequest resources.DetachRequest) error { - fake.detachMutex.Lock() - ret, specificReturn := fake.detachReturnsOnCall[len(fake.detachArgsForCall)] - fake.detachArgsForCall = append(fake.detachArgsForCall, struct { - detachRequest resources.DetachRequest - }{detachRequest}) - fake.recordInvocation("Detach", []interface{}{detachRequest}) - fake.detachMutex.Unlock() - if fake.DetachStub != nil { - return fake.DetachStub(detachRequest) +func (fake *FakeStorageClient) RemoveVolume(arg1 resources.RemoveVolumeRequest) error { + fake.removeVolumeMutex.Lock() + ret, specificReturn := fake.removeVolumeReturnsOnCall[len(fake.removeVolumeArgsForCall)] + fake.removeVolumeArgsForCall = append(fake.removeVolumeArgsForCall, struct { + arg1 resources.RemoveVolumeRequest + }{arg1}) + fake.recordInvocation("RemoveVolume", []interface{}{arg1}) + fake.removeVolumeMutex.Unlock() + if fake.RemoveVolumeStub != nil { + return fake.RemoveVolumeStub(arg1) } if specificReturn { return ret.result1 } - return fake.detachReturns.result1 + fakeReturns := fake.removeVolumeReturns + return fakeReturns.result1 } -func (fake *FakeStorageClient) DetachCallCount() int { - fake.detachMutex.RLock() - defer fake.detachMutex.RUnlock() - return len(fake.detachArgsForCall) +func (fake *FakeStorageClient) RemoveVolumeCallCount() int { + fake.removeVolumeMutex.RLock() + defer fake.removeVolumeMutex.RUnlock() + return len(fake.removeVolumeArgsForCall) } -func (fake *FakeStorageClient) DetachArgsForCall(i int) resources.DetachRequest { - fake.detachMutex.RLock() - defer fake.detachMutex.RUnlock() - return fake.detachArgsForCall[i].detachRequest +func (fake *FakeStorageClient) RemoveVolumeCalls(stub func(resources.RemoveVolumeRequest) error) { + fake.removeVolumeMutex.Lock() + defer fake.removeVolumeMutex.Unlock() + fake.RemoveVolumeStub = stub } -func (fake *FakeStorageClient) DetachReturns(result1 error) { - fake.DetachStub = nil - fake.detachReturns = struct { +func (fake *FakeStorageClient) RemoveVolumeArgsForCall(i int) resources.RemoveVolumeRequest { + fake.removeVolumeMutex.RLock() + defer fake.removeVolumeMutex.RUnlock() + argsForCall := fake.removeVolumeArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeStorageClient) RemoveVolumeReturns(result1 error) { + fake.removeVolumeMutex.Lock() + defer fake.removeVolumeMutex.Unlock() + fake.RemoveVolumeStub = nil + fake.removeVolumeReturns = struct { result1 error }{result1} } -func (fake *FakeStorageClient) DetachReturnsOnCall(i int, result1 error) { - fake.DetachStub = nil - if fake.detachReturnsOnCall == nil { - fake.detachReturnsOnCall = make(map[int]struct { +func (fake *FakeStorageClient) RemoveVolumeReturnsOnCall(i int, result1 error) { + fake.removeVolumeMutex.Lock() + defer fake.removeVolumeMutex.Unlock() + fake.RemoveVolumeStub = nil + if fake.removeVolumeReturnsOnCall == nil { + fake.removeVolumeReturnsOnCall = make(map[int]struct { result1 error }) } - fake.detachReturnsOnCall[i] = struct { + fake.removeVolumeReturnsOnCall[i] = struct { result1 error }{result1} } @@ -525,21 +605,25 @@ func (fake *FakeStorageClient) Invocations() map[string][][]interface{} { defer fake.invocationsMutex.RUnlock() fake.activateMutex.RLock() defer fake.activateMutex.RUnlock() + fake.attachMutex.RLock() + defer fake.attachMutex.RUnlock() fake.createVolumeMutex.RLock() defer fake.createVolumeMutex.RUnlock() - fake.removeVolumeMutex.RLock() - defer fake.removeVolumeMutex.RUnlock() - fake.listVolumesMutex.RLock() - defer fake.listVolumesMutex.RUnlock() + fake.detachMutex.RLock() + defer fake.detachMutex.RUnlock() fake.getVolumeMutex.RLock() defer fake.getVolumeMutex.RUnlock() fake.getVolumeConfigMutex.RLock() defer fake.getVolumeConfigMutex.RUnlock() - fake.attachMutex.RLock() - defer fake.attachMutex.RUnlock() - fake.detachMutex.RLock() - defer fake.detachMutex.RUnlock() - return fake.invocations + fake.listVolumesMutex.RLock() + defer fake.listVolumesMutex.RUnlock() + fake.removeVolumeMutex.RLock() + defer fake.removeVolumeMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations } func (fake *FakeStorageClient) recordInvocation(key string, args []interface{}) { diff --git a/local/scbe/datamodel_wrapper.go b/local/scbe/datamodel_wrapper.go index 83ac9709..3b84f479 100644 --- a/local/scbe/datamodel_wrapper.go +++ b/local/scbe/datamodel_wrapper.go @@ -22,7 +22,6 @@ import ( "github.com/IBM/ubiquity/utils/logs" ) -//go:generate counterfeiter -o ../../fakes/fake_ScbeDataModelWrapper.go . ScbeDataModelWrapper type ScbeDataModelWrapper interface { GetVolume(name string, mustExist bool) (ScbeVolume, error) DeleteVolume(name string) error @@ -96,7 +95,6 @@ func (d *scbeDataModelWrapper) DeleteVolume(name string) error { defer d.logger.Trace(logs.DEBUG)() var err error - if database.IsDatabaseVolume(name) { if d.dbVolume == nil { d.logger.Warning("Idempotent issue encountered - db volume is nil. continuing with deletion flow") diff --git a/local/scbe/scbe_rest_client.go b/local/scbe/scbe_rest_client.go index 93722a79..416aee7a 100644 --- a/local/scbe/scbe_rest_client.go +++ b/local/scbe/scbe_rest_client.go @@ -25,7 +25,7 @@ import ( "github.com/IBM/ubiquity/utils/logs" ) -//go:generate counterfeiter -o ../fakes/fake_scbe_rest_client.go . ScbeRestClient +//go:generate counterfeiter -o ../../fakes/fake_scbe_rest_client.go . ScbeRestClient type ScbeRestClient interface { Login() error CreateVolume(volName string, serviceName string, size int) (ScbeVolumeInfo, error) diff --git a/local/scbe/simple_rest_client.go b/local/scbe/simple_rest_client.go index 8410521f..194d9252 100644 --- a/local/scbe/simple_rest_client.go +++ b/local/scbe/simple_rest_client.go @@ -23,18 +23,19 @@ import ( "encoding/json" "errors" "fmt" - "github.com/IBM/ubiquity/resources" - "github.com/IBM/ubiquity/utils" - "github.com/IBM/ubiquity/utils/logs" "io/ioutil" "net/http" "os" "strings" "sync" + + "github.com/IBM/ubiquity/resources" + "github.com/IBM/ubiquity/utils" + "github.com/IBM/ubiquity/utils/logs" ) // SimpleRestClient is an interface that wrapper the http requests to provide easy REST API operations, -//go:generate counterfeiter -o ../fakes/fake_simple_rest_client.go . SimpleRestClient +//go:generate counterfeiter -o ../../fakes/fake_simple_rest_client.go . SimpleRestClient type SimpleRestClient interface { // Authenticate the server, prepare headers and save the token Login() error diff --git a/remote/mounter/block_device_mounter_utils/block_device_mounter_utils.go b/remote/mounter/block_device_mounter_utils/block_device_mounter_utils.go index 9b1d9186..c589bf14 100644 --- a/remote/mounter/block_device_mounter_utils/block_device_mounter_utils.go +++ b/remote/mounter/block_device_mounter_utils/block_device_mounter_utils.go @@ -22,6 +22,7 @@ import ( "time" "github.com/IBM/ubiquity/remote/mounter/block_device_utils" + "github.com/IBM/ubiquity/resources" "github.com/IBM/ubiquity/utils/logs" "github.com/nightlyone/lockfile" ) @@ -153,9 +154,11 @@ func (b *blockDeviceMounterUtils) UnmountDeviceFlow(devicePath string, volumeWwn // 2. SCSI rescan // 3. multipathing rescan // return error if one of the steps fail -func (b *blockDeviceMounterUtils) RescanAll(wwn string, rescanForCleanUp bool, extraLunZeroScanning bool) error { +func (b *blockDeviceMounterUtils) RescanAll(volumeMountProperties *resources.VolumeMountProperties) error { defer b.logger.Trace(logs.INFO) + wwn := volumeMountProperties.WWN + // locking for concurrent rescans and reduce rescans if no need b.logger.Debug("Ask for rescanLock for volumeWWN", logs.Args{{"volumeWWN", wwn}}) for { @@ -170,38 +173,40 @@ func (b *blockDeviceMounterUtils) RescanAll(wwn string, rescanForCleanUp bool, e defer b.rescanFlock.Unlock() defer b.logger.Debug("Released rescanLock for volumeWWN", logs.Args{{"volumeWWN", wwn}}) - if !rescanForCleanUp { - // Only when run rescan for new device, try to check if its already exist to reduce rescans - device, _ := b.Discover(wwn, false) // no deep discovery + // Only when run rescan for new device, try to check if its already exist to reduce rescans + device, _ := b.Discover(wwn, false) // no deep discovery - if device != "" { - // if need rescan for discover new device but the new device is already exist then skip the rescan - b.logger.Debug( - "Skip rescan, because there is already multiple device for volumeWWN", - logs.Args{{"volumeWWN", wwn}, {"multiple", device}}) - return nil - } + if device != "" { + // if need rescan for discover new device but the new device is already exist then skip the rescan + b.logger.Debug( + "Skip rescan, because there is already multiple device for volumeWWN", + logs.Args{{"volumeWWN", wwn}, {"multiple", device}}) + return nil } - // TODO : if rescanForCleanUp we need to check if block device is not longer exist and if so skip the rescan! // Do the rescans operations // in case of FC : if no iscsiadm on the machine or no session login - this will log a warning not fail! - if err := b.blockDeviceUtils.Rescan(block_device_utils.ISCSI); err != nil { + if err := b.blockDeviceUtils.Rescan(block_device_utils.ISCSI, volumeMountProperties); err != nil { return b.logger.ErrorRet(err, "ISCSI Rescan failed", logs.Args{{"protocol", block_device_utils.ISCSI}}) } - if extraLunZeroScanning { - if err := b.blockDeviceUtils.RescanSCSILun0(); err != nil { - return b.logger.ErrorRet(err, "Rescan failed for FC Lun0", logs.Args{{"protocol", block_device_utils.SCSI}}) - } - } else { - if err := b.blockDeviceUtils.Rescan(block_device_utils.SCSI); err != nil { - return b.logger.ErrorRet(err, "OS Rescan failed", logs.Args{{"protocol", block_device_utils.SCSI}}) - } + + if err := b.blockDeviceUtils.Rescan(block_device_utils.SCSI, volumeMountProperties); err != nil { + return b.logger.ErrorRet(err, "OS Rescan failed", logs.Args{{"protocol", block_device_utils.SCSI}}) } - if !rescanForCleanUp { - if err := b.blockDeviceUtils.ReloadMultipath(); err != nil { - return b.logger.ErrorRet(err, "ReloadMultipath failed") - } + if err := b.blockDeviceUtils.ReloadMultipath(); err != nil { + return b.logger.ErrorRet(err, "ReloadMultipath failed") + } + return nil +} + +func (b *blockDeviceMounterUtils) DisconnectAll(volumeMountProperties *resources.VolumeMountProperties) error { + // in case of FC : if no iscsiadm on the machine or no session login - this will log a warning not fail! + if err := b.blockDeviceUtils.Disconnect(block_device_utils.ISCSI, volumeMountProperties); err != nil { + return b.logger.ErrorRet(err, "ISCSI Disconnect failed", logs.Args{{"protocol", block_device_utils.ISCSI}}) + } + + if err := b.blockDeviceUtils.Disconnect(block_device_utils.SCSI, volumeMountProperties); err != nil { + return b.logger.ErrorRet(err, "OS Disconnect failed", logs.Args{{"protocol", block_device_utils.SCSI}}) } return nil } diff --git a/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go b/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go index 13dc5e8d..d363bbb0 100644 --- a/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go +++ b/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go @@ -24,6 +24,7 @@ import ( "github.com/IBM/ubiquity/fakes" "github.com/IBM/ubiquity/remote/mounter/block_device_mounter_utils" "github.com/IBM/ubiquity/remote/mounter/block_device_utils" + "github.com/IBM/ubiquity/resources" "github.com/IBM/ubiquity/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -36,6 +37,7 @@ var _ = Describe("block_device_mounter_utils_test", func() { err error callErr error = errors.New("error") ) + volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: 1} BeforeEach(func() { fakeBlockDeviceUtils = new(fakes.FakeBlockDeviceUtils) @@ -193,44 +195,31 @@ var _ = Describe("block_device_mounter_utils_test", func() { Context(".RescanAll", func() { It("should succeed to skip rescan we try to rescan(for discover) a wwn that is already descovered", func() { fakeBlockDeviceUtils.DiscoverReturns("wwn", nil) - err = blockDeviceMounterUtils.RescanAll("wwn", false, false) + err = blockDeviceMounterUtils.RescanAll(volumeMountProperties) Expect(err).NotTo(HaveOccurred()) Expect(fakeBlockDeviceUtils.RescanCallCount()).To(Equal(0)) }) It("should fail if iscsi rescan fail", func() { fakeBlockDeviceUtils.RescanReturnsOnCall(0, callErr) fakeBlockDeviceUtils.DiscoverReturns("", fmt.Errorf("device not exist yet")) - err = blockDeviceMounterUtils.RescanAll("wwn", false, false) + err = blockDeviceMounterUtils.RescanAll(volumeMountProperties) Expect(err).To(HaveOccurred()) Expect(err).To(MatchError(callErr)) Expect(fakeBlockDeviceUtils.RescanCallCount()).To(Equal(1)) - protocol := fakeBlockDeviceUtils.RescanArgsForCall(0) + protocol, _ := fakeBlockDeviceUtils.RescanArgsForCall(0) Expect(protocol).To(Equal(block_device_utils.ISCSI)) }) It("should fail if scsi rescan fail", func() { fakeBlockDeviceUtils.RescanReturnsOnCall(0, nil) fakeBlockDeviceUtils.RescanReturnsOnCall(1, callErr) fakeBlockDeviceUtils.DiscoverReturns("", fmt.Errorf("device not exist yet")) - err = blockDeviceMounterUtils.RescanAll("wwn", false, false) + err = blockDeviceMounterUtils.RescanAll(volumeMountProperties) Expect(err).To(HaveOccurred()) Expect(err).To(MatchError(callErr)) Expect(fakeBlockDeviceUtils.RescanCallCount()).To(Equal(2)) - protocol := fakeBlockDeviceUtils.RescanArgsForCall(0) + protocol, _ := fakeBlockDeviceUtils.RescanArgsForCall(0) Expect(protocol).To(Equal(block_device_utils.ISCSI)) - protocol = fakeBlockDeviceUtils.RescanArgsForCall(1) - Expect(protocol).To(Equal(block_device_utils.SCSI)) - }) - It("should fail if scsi rescan fail even if for clean up", func() { - fakeBlockDeviceUtils.RescanReturnsOnCall(0, nil) - fakeBlockDeviceUtils.RescanReturnsOnCall(1, callErr) - fakeBlockDeviceUtils.DiscoverReturns("", fmt.Errorf("device not exist yet")) - err = blockDeviceMounterUtils.RescanAll("wwn", true, false) - Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError(callErr)) - Expect(fakeBlockDeviceUtils.RescanCallCount()).To(Equal(2)) - protocol := fakeBlockDeviceUtils.RescanArgsForCall(0) - Expect(protocol).To(Equal(block_device_utils.ISCSI)) - protocol = fakeBlockDeviceUtils.RescanArgsForCall(1) + protocol, _ = fakeBlockDeviceUtils.RescanArgsForCall(1) Expect(protocol).To(Equal(block_device_utils.SCSI)) }) It("should fail if ReloadMultipath fail", func() { @@ -238,13 +227,13 @@ var _ = Describe("block_device_mounter_utils_test", func() { fakeBlockDeviceUtils.RescanReturnsOnCall(1, nil) fakeBlockDeviceUtils.ReloadMultipathReturns(callErr) fakeBlockDeviceUtils.DiscoverReturns("", fmt.Errorf("device not exist yet")) - err = blockDeviceMounterUtils.RescanAll("wwn", false, false) + err = blockDeviceMounterUtils.RescanAll(volumeMountProperties) Expect(err).To(HaveOccurred()) Expect(err).To(MatchError(callErr)) Expect(fakeBlockDeviceUtils.RescanCallCount()).To(Equal(2)) - protocol := fakeBlockDeviceUtils.RescanArgsForCall(0) + protocol, _ := fakeBlockDeviceUtils.RescanArgsForCall(0) Expect(protocol).To(Equal(block_device_utils.ISCSI)) - protocol = fakeBlockDeviceUtils.RescanArgsForCall(1) + protocol, _ = fakeBlockDeviceUtils.RescanArgsForCall(1) Expect(protocol).To(Equal(block_device_utils.SCSI)) Expect(fakeBlockDeviceUtils.ReloadMultipathCallCount()).To(Equal(1)) @@ -254,12 +243,12 @@ var _ = Describe("block_device_mounter_utils_test", func() { fakeBlockDeviceUtils.RescanReturnsOnCall(1, nil) fakeBlockDeviceUtils.ReloadMultipathReturns(nil) fakeBlockDeviceUtils.DiscoverReturns("", fmt.Errorf("device not exist yet")) - err = blockDeviceMounterUtils.RescanAll("wwn", false, false) + err = blockDeviceMounterUtils.RescanAll(volumeMountProperties) Expect(err).NotTo(HaveOccurred()) Expect(fakeBlockDeviceUtils.RescanCallCount()).To(Equal(2)) - protocol := fakeBlockDeviceUtils.RescanArgsForCall(0) + protocol, _ := fakeBlockDeviceUtils.RescanArgsForCall(0) Expect(protocol).To(Equal(block_device_utils.ISCSI)) - protocol = fakeBlockDeviceUtils.RescanArgsForCall(1) + protocol, _ = fakeBlockDeviceUtils.RescanArgsForCall(1) Expect(protocol).To(Equal(block_device_utils.SCSI)) Expect(fakeBlockDeviceUtils.ReloadMultipathCallCount()).To(Equal(1)) }) diff --git a/remote/mounter/block_device_mounter_utils/resources.go b/remote/mounter/block_device_mounter_utils/resources.go index 10022314..339c0902 100644 --- a/remote/mounter/block_device_mounter_utils/resources.go +++ b/remote/mounter/block_device_mounter_utils/resources.go @@ -16,9 +16,12 @@ package block_device_mounter_utils -//go:generate counterfeiter -o ../fakes/fake_block_device_mounter_utils.go . BlockDeviceMounterUtils +import "github.com/IBM/ubiquity/resources" + +//go:generate counterfeiter -o ../../../fakes/fake_block_device_mounter_utils.go . BlockDeviceMounterUtils type BlockDeviceMounterUtils interface { - RescanAll(wwn string, rescanForCleanUp bool, extraLunZeroScanning bool) error + RescanAll(volumeMountProperties *resources.VolumeMountProperties) error + DisconnectAll(volumeMountProperties *resources.VolumeMountProperties) error MountDeviceFlow(devicePath string, fsType string, mountPoint string) error Discover(volumeWwn string, deepDiscovery bool) (string, error) UnmountDeviceFlow(devicePath string, volumeWwn string) error diff --git a/remote/mounter/block_device_utils/block_device_utils.go b/remote/mounter/block_device_utils/block_device_utils.go index 94924fc8..22c37f87 100644 --- a/remote/mounter/block_device_utils/block_device_utils.go +++ b/remote/mounter/block_device_utils/block_device_utils.go @@ -1,15 +1,19 @@ package block_device_utils import ( + "regexp" + + "github.com/IBM/ubiquity/remote/mounter/initiator" + "github.com/IBM/ubiquity/remote/mounter/initiator/connectors" "github.com/IBM/ubiquity/utils" "github.com/IBM/ubiquity/utils/logs" - "regexp" ) type blockDeviceUtils struct { logger logs.Logger exec utils.Executor regExAlreadyMounted *regexp.Regexp + fcConnector initiator.Connector } func NewBlockDeviceUtils() BlockDeviceUtils { @@ -30,5 +34,7 @@ func newBlockDeviceUtils(executor utils.Executor) BlockDeviceUtils { panic("failed prepare Already unmount regex") } - return &blockDeviceUtils{logger: logger, exec: executor, regExAlreadyMounted: regex} + fcConnector := connectors.NewFibreChannelConnectorWithExecutorAndLogger(executor, logger) + + return &blockDeviceUtils{logger: logger, exec: executor, regExAlreadyMounted: regex, fcConnector: fcConnector} } diff --git a/remote/mounter/block_device_utils/block_device_utils_test.go b/remote/mounter/block_device_utils/block_device_utils_test.go index 0115ceca..3c3669bd 100644 --- a/remote/mounter/block_device_utils/block_device_utils_test.go +++ b/remote/mounter/block_device_utils/block_device_utils_test.go @@ -22,11 +22,11 @@ import ( "github.com/IBM/ubiquity/fakes" "github.com/IBM/ubiquity/remote/mounter/block_device_utils" + "github.com/IBM/ubiquity/resources" "github.com/IBM/ubiquity/utils" "context" "io/ioutil" - "os" "os/exec" "strings" "testing" @@ -42,6 +42,7 @@ var _ = Describe("block_device_utils_test", func() { err error cmdErr error = errors.New("command error") ) + volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: 1} BeforeEach(func() { fakeExec = new(fakes.FakeExecutor) @@ -50,7 +51,7 @@ var _ = Describe("block_device_utils_test", func() { Context(".Rescan", func() { It("Rescan ISCSI calls 'sudo iscsiadm -m session --rescan'", func() { - err = bdUtils.Rescan(block_device_utils.ISCSI) + err = bdUtils.Rescan(block_device_utils.ISCSI, volumeMountProperties) Expect(err).ToNot(HaveOccurred()) Expect(fakeExec.ExecuteWithTimeoutCallCount()).To(Equal(1)) _, cmd, args := fakeExec.ExecuteWithTimeoutArgsForCall(0) @@ -58,56 +59,33 @@ var _ = Describe("block_device_utils_test", func() { Expect(args).To(Equal([]string{"-m", "session", "--rescan"})) }) It("Rescan SCSI calls 'sudo rescan-scsi-bus -r'", func() { - err = bdUtils.Rescan(block_device_utils.SCSI) + // + fakeExec.ExecuteWithTimeoutReturns([]byte(volumeMountProperties.WWN), nil) + err = bdUtils.Rescan(block_device_utils.SCSI, volumeMountProperties) Expect(err).ToNot(HaveOccurred()) Expect(fakeExec.ExecuteWithTimeoutCallCount()).To(Equal(1)) _, cmd, args := fakeExec.ExecuteWithTimeoutArgsForCall(0) - Expect(cmd).To(Equal("rescan-scsi-bus")) - Expect(args).To(Equal([]string{"-r"})) + // check the existence of the new volume after rescan using multipath -ll + Expect(cmd).To(Equal("multipath")) + Expect(args).To(Equal([]string{"-ll"})) }) It("Rescan ISCSI does not fail if iscsiadm command missing", func() { fakeExec.IsExecutableReturns(cmdErr) - err = bdUtils.Rescan(block_device_utils.ISCSI) + err = bdUtils.Rescan(block_device_utils.ISCSI, volumeMountProperties) Expect(err).To(Not(HaveOccurred())) Expect(fakeExec.ExecuteCallCount()).To(Equal(0)) Expect(fakeExec.IsExecutableCallCount()).To(Equal(1)) Expect(fakeExec.IsExecutableArgsForCall(0)).To(Equal("iscsiadm")) }) - It("Rescan SCSI fails if rescan-scsi-bus command missing", func() { - fakeExec.IsExecutableReturns(cmdErr) - err = bdUtils.Rescan(block_device_utils.SCSI) - Expect(err).To(HaveOccurred()) - Expect(fakeExec.ExecuteWithTimeoutCallCount()).To(Equal(0)) - Expect(fakeExec.IsExecutableCallCount()).To(Equal(2)) - Expect(fakeExec.IsExecutableArgsForCall(0)).To(Equal("rescan-scsi-bus")) - Expect(fakeExec.IsExecutableArgsForCall(1)).To(Equal("rescan-scsi-bus.sh")) - }) It("Rescan ISCSI fails if iscsiadm execution fails", func() { fakeExec.ExecuteWithTimeoutReturns([]byte{}, cmdErr) - err = bdUtils.Rescan(block_device_utils.ISCSI) - Expect(err.Error()).To(MatchRegexp(cmdErr.Error())) - }) - It("Rescan SCSI fails if rescan-scsi-bus execution fails", func() { - fakeExec.ExecuteWithTimeoutReturns([]byte{}, cmdErr) - err = bdUtils.Rescan(block_device_utils.SCSI) + err = bdUtils.Rescan(block_device_utils.ISCSI, volumeMountProperties) Expect(err.Error()).To(MatchRegexp(cmdErr.Error())) }) It("Rescan fails if unknown protocol", func() { - err = bdUtils.Rescan(2) + err = bdUtils.Rescan(2, volumeMountProperties) Expect(err).To(HaveOccurred()) }) - It("Rescan SCSI lun0", func() { - dir, _ := ioutil.TempDir("", "") - os.Mkdir(dir+"/host33", os.ModePerm) - os.Mkdir(dir+"/host34", os.ModePerm) - block_device_utils.FcHostDir = dir + "/" - block_device_utils.ScsiHostDir = dir + "/" - err = bdUtils.RescanSCSILun0() - Expect(err).ToNot(HaveOccurred()) - os.RemoveAll(dir) - block_device_utils.FcHostDir = "/sys/class/fc_host/" - block_device_utils.ScsiHostDir = "/sys/class/scsi_host/" - }) }) Context(".ReloadMultipath", func() { It("ReloadMultipath calls multipath command", func() { diff --git a/remote/mounter/block_device_utils/mpath.go b/remote/mounter/block_device_utils/mpath.go index 87dc247a..beaa679a 100644 --- a/remote/mounter/block_device_utils/mpath.go +++ b/remote/mounter/block_device_utils/mpath.go @@ -54,21 +54,20 @@ func (b *blockDeviceUtils) ReloadMultipath() error { return nil } -func (b *blockDeviceUtils) Discover(volumeWwn string, deepDiscovery bool) (string, error) { - defer b.logger.Trace(logs.DEBUG, logs.Args{{"volumeWwn", volumeWwn}, {"deepDiscovery", deepDiscovery}})() +func (b *blockDeviceUtils) getMultipathOutputAndDeviceUid(volumeWwn string) ([]byte, string, error) { if err := b.exec.IsExecutable(multipathCmd); err != nil { - return "", b.logger.ErrorRet(&commandNotFoundError{multipathCmd, err}, "failed") + return []byte{}, "", b.logger.ErrorRet(&commandNotFoundError{multipathCmd, err}, "failed") } args := []string{"-ll"} outputBytes, err := b.exec.ExecuteWithTimeout(DiscoverTimeout, multipathCmd, args) if err != nil { - return "", b.logger.ErrorRet(&CommandExecuteError{multipathCmd, err}, "failed") + return []byte{}, "", b.logger.ErrorRet(&CommandExecuteError{multipathCmd, err}, "failed") } scanner := bufio.NewScanner(strings.NewReader(string(outputBytes[:]))) pattern := "(?i)" + volumeWwn regex, err := regexp.Compile(pattern) if err != nil { - return "", b.logger.ErrorRet(err, "failed") + return []byte{}, "", b.logger.ErrorRet(err, "failed") } dev := "" for scanner.Scan() { @@ -77,6 +76,17 @@ func (b *blockDeviceUtils) Discover(volumeWwn string, deepDiscovery bool) (strin break } } + return outputBytes, dev, nil +} + +func (b *blockDeviceUtils) Discover(volumeWwn string, deepDiscovery bool) (string, error) { + defer b.logger.Trace(logs.DEBUG, logs.Args{{"volumeWwn", volumeWwn}, {"deepDiscovery", deepDiscovery}})() + + outputBytes, dev, err := b.getMultipathOutputAndDeviceUid(volumeWwn) + if err != nil { + return "", err + } + mpath := "" if dev == "" { if !deepDiscovery { diff --git a/remote/mounter/block_device_utils/rescan.go b/remote/mounter/block_device_utils/rescan.go index 3ea1d4a9..b023f7f0 100644 --- a/remote/mounter/block_device_utils/rescan.go +++ b/remote/mounter/block_device_utils/rescan.go @@ -17,11 +17,10 @@ package block_device_utils import ( - "errors" - "fmt" - "io/ioutil" + "time" + "github.com/IBM/ubiquity/resources" "github.com/IBM/ubiquity/utils/logs" ) @@ -31,12 +30,12 @@ const rescanScsiTimeout = 2 * 60 * 1000 var FcHostDir = "/sys/class/fc_host/" var ScsiHostDir = "/sys/class/scsi_host/" -func (b *blockDeviceUtils) Rescan(protocol Protocol) error { +func (b *blockDeviceUtils) Rescan(protocol Protocol, volumeMountProperties *resources.VolumeMountProperties) error { defer b.logger.Trace(logs.DEBUG)() switch protocol { case SCSI: - return b.RescanSCSI() + return b.RescanSCSI(volumeMountProperties) case ISCSI: return b.RescanISCSI() default: @@ -44,6 +43,19 @@ func (b *blockDeviceUtils) Rescan(protocol Protocol) error { } } +func (b *blockDeviceUtils) Disconnect(protocol Protocol, volumeMountProperties *resources.VolumeMountProperties) error { + defer b.logger.Trace(logs.DEBUG)() + + switch protocol { + case SCSI: + return b.DisconnectSCSI(volumeMountProperties) + case ISCSI: + return b.DisconnectISCSI() + default: + return b.logger.ErrorRet(&unsupportedProtocolError{protocol}, "failed") + } +} + func (b *blockDeviceUtils) RescanISCSI() error { defer b.logger.Trace(logs.DEBUG)() rescanCmd := "iscsiadm" @@ -67,49 +79,26 @@ func (b *blockDeviceUtils) RescanISCSI() error { return nil } -func (b *blockDeviceUtils) RescanSCSI() error { - defer b.logger.Trace(logs.DEBUG)() - commands := []string{"rescan-scsi-bus", "rescan-scsi-bus.sh"} - rescanCmd := "" - for _, cmd := range commands { - if err := b.exec.IsExecutable(cmd); err == nil { - rescanCmd = cmd - break +func (b *blockDeviceUtils) RescanSCSI(volumeMountProperties *resources.VolumeMountProperties) error { + var err error + for i := 0; i < 6; i++ { + if err = b.fcConnector.ConnectVolume(volumeMountProperties); err != nil { + return b.logger.ErrorRet(err, "RescanSCSI failed", logs.Args{{"volumeWWN", volumeMountProperties.WWN}}) } + if _, _, err = b.getMultipathOutputAndDeviceUid(volumeMountProperties.WWN); err == nil { + return nil + } + b.logger.Warning("Can't find the new volume in multipath output after rescan, sleep one second and try again.") + time.Sleep(1 * time.Second) } - if rescanCmd == "" { - return b.logger.ErrorRet(&commandNotFoundError{commands[0], errors.New("")}, "failed") - } - args := []string{"-r"} // TODO should use -r only in clean up - if _, err := b.exec.ExecuteWithTimeout(rescanScsiTimeout, rescanCmd, args); err != nil { - return b.logger.ErrorRet(&CommandExecuteError{rescanCmd, err}, "failed") - } - return nil + return b.logger.ErrorRet(err, "RescanSCSI failed", logs.Args{{"volumeWWN", volumeMountProperties.WWN}}) } -func (b *blockDeviceUtils) RescanSCSILun0() error { - defer b.logger.Trace(logs.DEBUG)() - hostInfos, err := ioutil.ReadDir(FcHostDir) - if err != nil { - return b.logger.ErrorRet(err, "Getting fc_host failed.", logs.Args{{"FcHostDir", FcHostDir}}) - } - if len(hostInfos) == 0 { - err := fmt.Errorf("There is no fc_host found, please check the fc host.") - return b.logger.ErrorRet(err, "There is no fc_host found.", logs.Args{{"FcHostDir", FcHostDir}}) - } +// TODO: improve it to make it faster +func (b *blockDeviceUtils) DisconnectISCSI() error { + return b.RescanISCSI() +} - for _, host := range hostInfos { - b.logger.Debug("scan the host", logs.Args{{"name: ", host.Name()}}) - fcHostFile := FcHostDir + host.Name() + "/issue_lip" - if err := ioutil.WriteFile(fcHostFile, []byte("1"), 0200); err != nil { - b.logger.Debug("Write issue_lip failed", logs.Args{{"err", err}}) - } - filename := ScsiHostDir + host.Name() + "/scan" - b.logger.Debug("ScsiHostDir", logs.Args{{"ScsiHostDir", ScsiHostDir}}) - if err := ioutil.WriteFile(filename, []byte("- - -"), 0200); err != nil { - b.logger.Debug("Write file scan failed", logs.Args{{"err", err}}) - continue - } - } - return nil +func (b *blockDeviceUtils) DisconnectSCSI(volumeMountProperties *resources.VolumeMountProperties) error { + return b.fcConnector.DisconnectVolume(volumeMountProperties) } diff --git a/remote/mounter/block_device_utils/resources.go b/remote/mounter/block_device_utils/resources.go index 78945322..e2e947dd 100644 --- a/remote/mounter/block_device_utils/resources.go +++ b/remote/mounter/block_device_utils/resources.go @@ -16,6 +16,10 @@ package block_device_utils +import ( + "github.com/IBM/ubiquity/resources" +) + type Protocol int const ( @@ -23,10 +27,10 @@ const ( ISCSI ) -//go:generate counterfeiter -o ../fakes/fake_block_device_utils.go . BlockDeviceUtils +//go:generate counterfeiter -o ../../../fakes/fake_block_device_utils.go . BlockDeviceUtils type BlockDeviceUtils interface { - Rescan(protocol Protocol) error - RescanSCSILun0() error + Rescan(protocol Protocol, volumes *resources.VolumeMountProperties) error + Disconnect(protocol Protocol, volumes *resources.VolumeMountProperties) error ReloadMultipath() error Discover(volumeWwn string, deepDiscovery bool) (string, error) GetWwnByScsiInq(mpathOutput string, dev string) (string, error) diff --git a/remote/mounter/initiator/connectors/fibre_channel.go b/remote/mounter/initiator/connectors/fibre_channel.go new file mode 100644 index 00000000..c1eea176 --- /dev/null +++ b/remote/mounter/initiator/connectors/fibre_channel.go @@ -0,0 +1,115 @@ +package connectors + +import ( + "fmt" + "strings" + + "github.com/IBM/ubiquity/remote/mounter/initiator" + "github.com/IBM/ubiquity/resources" + "github.com/IBM/ubiquity/utils" + "github.com/IBM/ubiquity/utils/logs" +) + +type fibreChannelConnector struct { + exec utils.Executor + logger logs.Logger + linuxfc initiator.Initiator +} + +func NewFibreChannelConnector() initiator.Connector { + return newFibreChannelConnector() +} + +func NewFibreChannelConnectorWithExecutorAndLogger(executor utils.Executor, logger logs.Logger) initiator.Connector { + return newFibreChannelConnectorWithExecutorAndLogger(executor, logger) +} + +func newFibreChannelConnector() *fibreChannelConnector { + logger := logs.GetLogger() + executor := utils.NewExecutor() + return newFibreChannelConnectorWithExecutorAndLogger(executor, logger) +} + +func newFibreChannelConnectorWithExecutorAndLogger(executor utils.Executor, logger logs.Logger) *fibreChannelConnector { + linuxfc := initiator.NewLinuxFibreChannelWithExecutorAndLogger(executor, logger) + + return &fibreChannelConnector{logger: logger, exec: executor, linuxfc: linuxfc} +} + +// RemoveSCSIDevice removes a scsi device based upon /dev/sdX name. +func (c *fibreChannelConnector) ConnectVolume(volumeMountProperties *resources.VolumeMountProperties) error { + hbas := c.linuxfc.GetHBAs() + + if len(hbas) == 0 { + c.logger.Warning("No FC HBA is found.") + return nil + } + + return c.linuxfc.RescanHosts(hbas, volumeMountProperties) +} + +// RemoveSCSIDevice removes a scsi device based upon /dev/sdX name. +func (c *fibreChannelConnector) DisconnectVolume(volumeMountProperties *resources.VolumeMountProperties) error { + devices := []string{} + paths := c.findPathsFromMultipathTopology(volumeMountProperties) + for _, path := range paths { + device := fmt.Sprintf("/dev/%s", path) + devices = append(devices, device) + } + + c.logger.Debug("Remove devices", logs.Args{{"names", devices}}) + return c.removeDevices(devices) +} + +func (c *fibreChannelConnector) removeDevices(devices []string) error { + // Do we need to flush io? + var err error + for _, device := range devices { + err = c.linuxfc.RemoveSCSIDevice(device) + } + return err +} + +// TODO: it is not a good idea to find device paths in this way, try to improve it. +func (c *fibreChannelConnector) findPathsFromMultipathTopology(volumeMountProperties *resources.VolumeMountProperties) []string { + multipath := "multipath" + if err := c.exec.IsExecutable(multipath); err != nil { + c.logger.Warning("No multipath installed.") + return []string{} + } + + lunNumber := volumeMountProperties.LunNumber + out, err := c.exec.Execute(multipath, []string{"-ll", "|", fmt.Sprintf("grep %d", lunNumber)}) + if err != nil { + c.logger.Warning(fmt.Sprintf("Executing multipath failed with error: %v", err)) + return []string{} + } + return generatePathsFromMultipathOutput(out) +} + +/* +generatePathsFromMultipathOutput analysises the output of command "multipath -ll |grep lunNumber", +and generates a list of path. + +A sample output is: + |- 0:0:4:1076248592 sda 8:0 active ready running + |- 0:0:5:1076248592 sdb 8:16 active ready running + |- 0:0:6:1076248592 sdc 8:32 active ready running + |- 0:0:7:1076248592 sdd 8:48 active ready running + |- 1:0:4:1076248592 sde 8:64 active ready running + |- 1:0:5:1076248592 sdf 8:80 active ready running + |- 1:0:6:1076248592 sdg 8:96 active ready running + `- 1:0:7:1076248592 sdh 8:112 active ready running +*/ +func generatePathsFromMultipathOutput(out []byte) []string { + lines := strings.Split(string(out), "\n") + paths := []string{} + for _, line := range lines { + line = strings.TrimSpace(line) + path := strings.Split(line, " ")[2] + if strings.HasPrefix(path, "sd") { + paths = append(paths) + } + } + return paths +} diff --git a/remote/mounter/initiator/linuxfc.go b/remote/mounter/initiator/linuxfc.go new file mode 100644 index 00000000..e0b442e3 --- /dev/null +++ b/remote/mounter/initiator/linuxfc.go @@ -0,0 +1,204 @@ +package initiator + +import ( + "fmt" + "io/ioutil" + "os" + "strings" + + "github.com/IBM/ubiquity/resources" + "github.com/IBM/ubiquity/utils" + "github.com/IBM/ubiquity/utils/logs" +) + +const FC_HOST_SYSFS_PATH = "/sys/class/fc_host" +const SCSI_HOST_SYSFS_PATH = "/sys/class/scsi_host/" + +type linuxFibreChannel struct { + *linuxSCSI +} + +func NewLinuxFibreChannel() Initiator { + return newLinuxFibreChannel() +} + +func NewLinuxFibreChannelWithExecutorAndLogger(executor utils.Executor, logger logs.Logger) Initiator { + return newLinuxFibreChannelWithExecutorAndLogger(executor, logger) +} + +func newLinuxFibreChannel() *linuxFibreChannel { + logger := logs.GetLogger() + executor := utils.NewExecutor() + return newLinuxFibreChannelWithExecutorAndLogger(executor, logger) +} + +func newLinuxFibreChannelWithExecutorAndLogger(executor utils.Executor, logger logs.Logger) *linuxFibreChannel { + return &linuxFibreChannel{&linuxSCSI{logger: logger, exec: executor}} +} + +func (lfc *linuxFibreChannel) hasFCSupport() bool { + fileInfo, err := os.Stat(FC_HOST_SYSFS_PATH) + if err != nil { + return false + } + return fileInfo.IsDir() +} + +// Try to get the HBA channel and SCSI target for an HBA. +// return a string with "channel, target, lun" entries, the channel and target +// may be '-' wildcards if unable to determine them. +func (lfc *linuxFibreChannel) getHBAChannelScsiTarget(volumeMountProperties *resources.VolumeMountProperties) string { + //TODO: get channel and target + if volumeMountProperties.LunNumber == -1 { + return "- - -" + } + return fmt.Sprintf("- - %d", volumeMountProperties.LunNumber) +} + +// getHBAs return all the FC HBAs in the system +func (lfc *linuxFibreChannel) GetHBAs() []string { + if !lfc.hasFCSupport() { + return []string{} + } + + systool := "systool" + if err := lfc.exec.IsExecutable(systool); err != nil { + lfc.logger.Warning(fmt.Sprintf("No systool installed, get from path %s instead.", FC_HOST_SYSFS_PATH)) + return lfc.getFcHBAsByPath() + } + + out, err := lfc.exec.Execute(systool, []string{"-c", "fc_host", "-v"}) + if err != nil { + lfc.logger.Warning(fmt.Sprintf("Executing systool failed with error: %v. Get from path %s instead.", err, FC_HOST_SYSFS_PATH)) + return lfc.getFcHBAsByPath() + } + + // No FC HBAs were found + if len(out) == 0 { + return []string{} + } + hbas := generateHBAsInfoFromSystoolOutput(out) + hbaNames := []string{} + for _, hba := range hbas { + if hba["port_state"] == "Online" { + hbaNames = append(hbaNames, hba["ClassDevice"]) + } + } + return hbaNames +} + +// getFcHBAsByPath returns the FC HBA names under path /sys/class/fc_host +func (lfc *linuxFibreChannel) getFcHBAsByPath() []string { + hbas := []string{} + hostInfos, err := ioutil.ReadDir(FC_HOST_SYSFS_PATH) + if err != nil { + return []string{} + } + + for _, host := range hostInfos { + hbas = append(hbas, host.Name()) + } + return hbas +} + +// RescanHosts rescan all the host HBAs for a certain lun if LunNumber is specified, +// if not, means LunNumber is -1, rescan all the luns. +func (lfc *linuxFibreChannel) RescanHosts(hbas []string, volumeMountProperties *resources.VolumeMountProperties) error { + defer lfc.logger.Trace(logs.DEBUG)() + + ctl := lfc.getHBAChannelScsiTarget(volumeMountProperties) + + for _, hba := range hbas { + hbaPath := SCSI_HOST_SYSFS_PATH + hba + "/scan" + lfc.logger.Debug(fmt.Sprintf(`Scanning HBA with command: echo "%s" > %s`, ctl, hbaPath)) + if err := ioutil.WriteFile(hbaPath, []byte(ctl), 0666); err != nil { + lfc.logger.Debug("Failed to scan HBA", logs.Args{{"name", hba}, {"err", err}}) + continue + } + } + return nil +} + +/* +generateHBAsInfoFromSystoolOutput analysises the output of command "systool -c fc_host -v", +and generates a list of HBA info. + +A sample output is: +Class = "fc_host" + + Class Device = "host0" + Class Device path = "/sys/devices/css0/0.0.0000/0.0.a200/host0/fc_host/host0" + active_fc4s = "0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 " + dev_loss_tmo = "60" + maxframe_size = "2112 bytes" + node_name = "0x5005076400c1b2b8" + permanent_port_name = "0xc05076e5118011d1" + port_id = "0x0ecfd3" + port_name = "0xc05076e511803cb0" + port_state = "Online" + port_type = "NPIV VPORT" + serial_number = "IBM0200000001B2B8" + speed = "8 Gbit" + supported_classes = "Class 2, Class 3" + supported_fc4s = "0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 " + supported_speeds = "4 Gbit, 8 Gbit, 16 Gbit" + symbolic_name = "IBM 3906 0200000001B2B8 PCHID: 011D NPIV UlpId: 004C0308 DEVNO: 0.0.a200 NAME: stk8s008" + tgtid_bind_type = "wwpn (World Wide Port Name)" + uevent = + + Device = "host0" + Device path = "/sys/devices/css0/0.0.0000/0.0.a200/host0" + uevent = "DEVTYPE=scsi_host" + + + Class Device = "host1" + Class Device path = "/sys/devices/css0/0.0.0001/0.0.a300/host1/fc_host/host1" + active_fc4s = "0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 " + dev_loss_tmo = "60" + maxframe_size = "2112 bytes" + node_name = "0x5005076400c1b2b8" + permanent_port_name = "0xc05076e511801811" + port_id = "0x0fc613" + port_name = "0xc05076e511803b48" + port_state = "Online" + port_type = "NPIV VPORT" + serial_number = "IBM0200000001B2B8" + speed = "8 Gbit" + supported_classes = "Class 2, Class 3" + supported_fc4s = "0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 " + supported_speeds = "4 Gbit, 8 Gbit, 16 Gbit" + symbolic_name = "IBM 3906 0200000001B2B8 PCHID: 0181 NPIV UlpId: 00450308 DEVNO: 0.0.a300 NAME: stk8s008" + tgtid_bind_type = "wwpn (World Wide Port Name)" + uevent = + + Device = "host1" + Device path = "/sys/devices/css0/0.0.0001/0.0.a300/host1" + uevent = "DEVTYPE=scsi_host" +*/ +func generateHBAsInfoFromSystoolOutput(out []byte) []map[string]string { + lines := strings.Split(string(out), "\n") + // ignore the first 2 lines + lines = lines[2:] + hbas := []map[string]string{} + hba := map[string]string{} + lastline := "" + for _, line := range lines { + line = strings.TrimSpace(line) + // 2 newlines denotes a new hba port + if line == "" && lastline == "" { + if len(hba) > 0 { + hbas = append(hbas, hba) + hba = map[string]string{} + } + } else { + val := strings.Split(line, "=") + if len(val) == 2 { + key := strings.Replace(strings.TrimSpace(val[0]), " ", "", -1) + value := strings.Replace(strings.TrimSpace(val[1]), `"`, "", -1) + hba[key] = value + } + } + lastline = line + } + return hbas +} diff --git a/remote/mounter/initiator/linuxscsi.go b/remote/mounter/initiator/linuxscsi.go new file mode 100644 index 00000000..f1c5695b --- /dev/null +++ b/remote/mounter/initiator/linuxscsi.go @@ -0,0 +1,30 @@ +package initiator + +import ( + "fmt" + "io/ioutil" + "os" + "strings" + + "github.com/IBM/ubiquity/utils" + "github.com/IBM/ubiquity/utils/logs" +) + +type linuxSCSI struct { + exec utils.Executor + logger logs.Logger +} + +// RemoveSCSIDevice removes a scsi device based upon /dev/sdX name. +func (ls *linuxSCSI) RemoveSCSIDevice(device string) error { + deviceName := strings.Replace(device, "/dev/", "", 1) + path := fmt.Sprintf("/sys/block/%s/device/delete", deviceName) + if _, err := os.Stat(path); !os.IsNotExist(err) { + ls.logger.Debug(fmt.Sprintf("Remove SCSI device %s with %s", device, path)) + if err := ioutil.WriteFile(path, []byte("1"), 0666); err != nil { + cmd := fmt.Sprintf(`echo "1" > %s`, path) + return ls.logger.ErrorRet(&utils.CommandExecuteError{cmd, err}, "failed") + } + } + return nil +} diff --git a/remote/mounter/initiator/resources.go b/remote/mounter/initiator/resources.go new file mode 100644 index 00000000..b6734229 --- /dev/null +++ b/remote/mounter/initiator/resources.go @@ -0,0 +1,21 @@ +package initiator + +import "github.com/IBM/ubiquity/resources" + +//go:generate counterfeiter -o ../../../fakes/fake_initiator.go . BaseInitiator +type BaseInitiator interface { + RemoveSCSIDevice(device string) error +} + +//go:generate counterfeiter -o ../../../fakes/fake_initiator.go . Initiator +type Initiator interface { + BaseInitiator + GetHBAs() []string + RescanHosts(hbas []string, volumeMountProperties *resources.VolumeMountProperties) error +} + +//go:generate counterfeiter -o ../../../fakes/fake_initiator.go . Connector +type Connector interface { + ConnectVolume(volumeMountProperties *resources.VolumeMountProperties) error + DisconnectVolume(volumeMountProperties *resources.VolumeMountProperties) error +} diff --git a/remote/mounter/mounter_factory.go b/remote/mounter/mounter_factory.go index 7ee0c382..3f5a6943 100644 --- a/remote/mounter/mounter_factory.go +++ b/remote/mounter/mounter_factory.go @@ -1,12 +1,13 @@ package mounter import ( + "log" + "github.com/IBM/ubiquity/resources" "github.com/IBM/ubiquity/utils/logs" - "log" ) -//go:generate counterfeiter -o ../fakes/fake_mounter_factory.go . MounterFactory +//go:generate counterfeiter -o ../../fakes/fake_mounter_factory.go . MounterFactory type MounterFactory interface { GetMounterPerBackend(backend string, legacyLogger *log.Logger, pluginConfig resources.UbiquityPluginConfig, requestContext resources.RequestContext) (resources.Mounter, error) } diff --git a/remote/mounter/scbe.go b/remote/mounter/scbe.go index 54036c98..ae66841a 100644 --- a/remote/mounter/scbe.go +++ b/remote/mounter/scbe.go @@ -50,35 +50,28 @@ func NewScbeMounterWithExecuter(blockDeviceMounterUtils block_device_mounter_uti return newScbMounter(blockDeviceMounterUtils, executer) } +func (s *scbeMounter) prepareVolumeMountProperties(mountRequest resources.MountRequest) *resources.VolumeMountProperties { + volumeWWN := mountRequest.VolumeConfig["Wwn"].(string) + volumeLunNumber := -1 + if volumeLunNumberInterface, exists := mountRequest.VolumeConfig[resources.ScbeKeyVolAttachLunNumToHost]; exists { + volumeLunNumber = volumeLunNumberInterface.(int) + } + return &resources.VolumeMountProperties{WWN: volumeWWN, LunNumber: volumeLunNumber} +} + func (s *scbeMounter) Mount(mountRequest resources.MountRequest) (string, error) { defer s.logger.Trace(logs.DEBUG)() - volumeWWN := mountRequest.VolumeConfig["Wwn"].(string) + volumeMountProperties := s.prepareVolumeMountProperties(mountRequest) // Rescan OS - if err := s.blockDeviceMounterUtils.RescanAll(volumeWWN, false, false); err != nil { + if err := s.blockDeviceMounterUtils.RescanAll(volumeMountProperties); err != nil { return "", s.logger.ErrorRet(err, "RescanAll failed") } // Discover device - devicePath, err := s.blockDeviceMounterUtils.Discover(volumeWWN, true) + devicePath, err := s.blockDeviceMounterUtils.Discover(volumeMountProperties.WWN, true) if err != nil { - // Known issue: UB-1103 in https://www.ibm.com/support/knowledgecenter/SS6JWS_3.4.0/RN/sc_rn_knownissues.html - // XIV doesn't using Lun Number 0, We don't care the storage type here. - // For DS8k and Storwize Lun0, "rescan-scsi-bus.sh -r" cannot discover the LUN0, need to use rescanLun0 instead - s.logger.Info("volumeConfig: ", logs.Args{{"volumeConfig: ", mountRequest.VolumeConfig}}) - _, ok := err.(*block_device_utils.VolumeNotFoundError) - if ok && isLun0(mountRequest) { - s.logger.Info("It is the first lun of DS8K or Storwize, will try to rescan lun0") - if err := s.blockDeviceMounterUtils.RescanAll(volumeWWN, false, true); err != nil { - return "", s.logger.ErrorRet(err, "Rescan lun0 failed", logs.Args{{"volumeWWN", volumeWWN}}) - } - devicePath, err = s.blockDeviceMounterUtils.Discover(volumeWWN, true) - if err != nil { - return "", s.logger.ErrorRet(err, "Discover failed after run rescan and also additional rescan with special lun0 scanning", logs.Args{{"volumeWWN", volumeWWN}}) - } - } else { - return "", s.logger.ErrorRet(err, "Discover failed", logs.Args{{"volumeWWN", volumeWWN}}) - } + return "", s.logger.ErrorRet(err, "Discover failed", logs.Args{{"volumeWWN", volumeMountProperties.WWN}}) } // Create mount point if needed // TODO consider to move it inside the util @@ -158,24 +151,22 @@ func (s *scbeMounter) Unmount(unmountRequest resources.UnmountRequest) error { } -func (s *scbeMounter) ActionAfterDetach(request resources.AfterDetachRequest) error { - defer s.logger.Trace(logs.DEBUG)() +func (s *scbeMounter) prepareVolumeActionAfterDetachProperties(request resources.AfterDetachRequest) *resources.VolumeMountProperties { volumeWWN := request.VolumeConfig["Wwn"].(string) - - // Rescan OS - if err := s.blockDeviceMounterUtils.RescanAll(volumeWWN, true, false); err != nil { - return s.logger.ErrorRet(err, "RescanAll failed") + volumeLunNumber := -1 + if volumeLunNumberInterface, exists := request.VolumeConfig[resources.ScbeKeyVolAttachLunNumToHost]; exists { + volumeLunNumber = volumeLunNumberInterface.(int) } - return nil + return &resources.VolumeMountProperties{WWN: volumeWWN, LunNumber: volumeLunNumber} } -func isLun0(mountRequest resources.MountRequest) bool { - lunNumber, ok := mountRequest.VolumeConfig[resources.ScbeKeyVolAttachLunNumToHost] - if !ok { - return false - } - if int(lunNumber.(float64)) == 0 { - return true +func (s *scbeMounter) ActionAfterDetach(request resources.AfterDetachRequest) error { + defer s.logger.Trace(logs.DEBUG)() + volumeMountProperties := s.prepareVolumeActionAfterDetachProperties(request) + + // Disconnect volume + if err := s.blockDeviceMounterUtils.DisconnectAll(volumeMountProperties); err != nil { + return s.logger.ErrorRet(err, "DisconnectAll failed") } - return false + return nil } diff --git a/remote/mounter/scbe_test.go b/remote/mounter/scbe_test.go index e1131a1f..fc766074 100644 --- a/remote/mounter/scbe_test.go +++ b/remote/mounter/scbe_test.go @@ -32,21 +32,15 @@ var _ = Describe("scbe_mounter_test", func() { callErr error = &block_device_utils.VolumeNotFoundError{"wwn"} - mountRequestForDS8kLun0 = resources.MountRequest{Mountpoint: "test_mountpointDS8k", VolumeConfig: map[string]interface{}{"Name": "u_vol", "PhysicalCapacity": fakePhysicalCapacity, - "Profile": fakeProfile, "StorageType": fakeDS8kStoragetType, "UsedCapacity": fakeUsedCapacity, "Wwn": "wwn", "attach-to": "xnode1", - "LogicalCapacity": fakeLogicalCapacity, "LunNumber": float64(0), "PoolName": "pool", "StorageName": "IBM.2107", "fstype": "ext4"}} - mountRequestForSVCLun0 = resources.MountRequest{Mountpoint: "test_mountpointSVC", VolumeConfig: map[string]interface{}{"Name": "u_vol", "PhysicalCapacity": fakePhysicalCapacity, - "Profile": fakeProfile, "StorageType": fakeV7kStorageType, "UsedCapacity": fakeUsedCapacity, "Wwn": "wwn", "attach-to": "node1", - "LogicalCapacity": fakeLogicalCapacity, "LunNumber": float64(0), "PoolName": "pool", "StorageName": "IBM.2706", "fstype": "ext4"}} mountRequestForDS8kLun1 = resources.MountRequest{Mountpoint: "test_mountpointDS8k", VolumeConfig: map[string]interface{}{"Name": "u_vol", "PhysicalCapacity": fakePhysicalCapacity, "Profile": fakeProfile, "StorageType": fakeDS8kStoragetType, "UsedCapacity": fakeUsedCapacity, "Wwn": "wwn", "attach-to": "node1", - "LogicalCapacity": fakeLogicalCapacity, "LunNumber": float64(1), "PoolName": "pool", "StorageName": "IBM.2107", "fstype": "ext4"}} + "LogicalCapacity": fakeLogicalCapacity, "LunNumber": 1, "PoolName": "pool", "StorageName": "IBM.2107", "fstype": "ext4"}} mountRequestForSVCLun1 = resources.MountRequest{Mountpoint: "test_mountpointSVC", VolumeConfig: map[string]interface{}{"Name": "u_vol", "PhysicalCapacity": fakePhysicalCapacity, "Profile": fakeProfile, "StorageType": fakeV7kStorageType, "UsedCapacity": fakeUsedCapacity, "Wwn": "wwn", "attach-to": "node1", - "LogicalCapacity": fakeLogicalCapacity, "LunNumber": float64(1), "PoolName": "pool", "StorageName": "IBM.2706", "fstype": "ext4"}} + "LogicalCapacity": fakeLogicalCapacity, "LunNumber": 1, "PoolName": "pool", "StorageName": "IBM.2706", "fstype": "ext4"}} mountRequestForDS8kLun2 = resources.MountRequest{Mountpoint: "test_mountpointDS8k", VolumeConfig: map[string]interface{}{"Name": "u_vol", "PhysicalCapacity": fakePhysicalCapacity, "Profile": fakeProfile, "UsedCapacity": fakeUsedCapacity, "Wwn": "wwn", "attach-to": "node1", - "LogicalCapacity": fakeLogicalCapacity, "LunNumber": float64(1), "PoolName": "pool", "StorageName": "IBM.2107", "fstype": "ext4"}} + "LogicalCapacity": fakeLogicalCapacity, "LunNumber": 1, "PoolName": "pool", "StorageName": "IBM.2107", "fstype": "ext4"}} mountRequestForDS8kLun3 = resources.MountRequest{Mountpoint: "test_mountpointDS8k", VolumeConfig: map[string]interface{}{"Name": "u_vol", "PhysicalCapacity": fakePhysicalCapacity, "Profile": fakeProfile, "StorageType": fakeDS8kStoragetType, "UsedCapacity": fakeUsedCapacity, "Wwn": "wwn", "attach-to": "node1", "LogicalCapacity": fakeLogicalCapacity, "PoolName": "pool", "StorageName": "IBM.2107", "fstype": "ext4"}} @@ -159,22 +153,6 @@ var _ = Describe("scbe_mounter_test", func() { }) }) Context("Mount", func() { - It("should success to discover ds8k with lun0", func() { - fakeBdUtils.DiscoverReturnsOnCall(0, "", callErr) - fakeBdUtils.DiscoverReturnsOnCall(1, "wwn", nil) - fakeBdUtils.RescanAllReturnsOnCall(0, nil) - fakeBdUtils.RescanAllReturnsOnCall(1, nil) - _, err := scbeMounter.Mount(mountRequestForDS8kLun0) - Expect(err).ToNot(HaveOccurred()) - }) - It("should success to discover svc with lun0", func() { - fakeBdUtils.DiscoverReturnsOnCall(0, "wwn", nil) - fakeBdUtils.DiscoverReturnsOnCall(1, "wwn", nil) - fakeBdUtils.RescanAllReturnsOnCall(0, nil) - fakeBdUtils.RescanAllReturnsOnCall(1, nil) - _, err := scbeMounter.Mount(mountRequestForSVCLun0) - Expect(err).ToNot(HaveOccurred()) - }) It("should fail to discover ds8k with lun1 if failed to discover with '-r' ", func() { fakeBdUtils.DiscoverReturns("", callErr) fakeBdUtils.RescanAllReturns(nil) diff --git a/resources/resources.go b/resources/resources.go index 40f8849e..8eb8ccd1 100644 --- a/resources/resources.go +++ b/resources/resources.go @@ -338,3 +338,8 @@ type RequestContext struct { Id string ActionName string } + +type VolumeMountProperties struct { + WWN string + LunNumber int +} diff --git a/utils/error.go b/utils/error.go index b6e2987e..0b5bfbd3 100644 --- a/utils/error.go +++ b/utils/error.go @@ -14,7 +14,6 @@ * limitations under the License. */ - package utils import ( @@ -28,3 +27,12 @@ type NoENVKeyError struct { func (e *NoENVKeyError) Error() string { return fmt.Sprintf("ENV Key [%s] not exist.", e.EnvKeyName) } + +type CommandExecuteError struct { + Cmd string + Err error +} + +func (e *CommandExecuteError) Error() string { + return fmt.Sprintf("command [%v] execution failure [%v]", e.Cmd, e.Err) +} From fccbb3f8eac45f1934ea5c8217226086f6fe1650 Mon Sep 17 00:00:00 2001 From: 27149chen <7991675+27149chen@users.noreply.github.com> Date: Sat, 23 Feb 2019 23:17:54 +0800 Subject: [PATCH 11/36] update comments Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> --- .../block_device_mounter_utils.go | 1 + .../initiator/connectors/fibre_channel.go | 24 +++++++++---------- remote/mounter/initiator/linuxfc.go | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/remote/mounter/block_device_mounter_utils/block_device_mounter_utils.go b/remote/mounter/block_device_mounter_utils/block_device_mounter_utils.go index c589bf14..04d5fcd2 100644 --- a/remote/mounter/block_device_mounter_utils/block_device_mounter_utils.go +++ b/remote/mounter/block_device_mounter_utils/block_device_mounter_utils.go @@ -199,6 +199,7 @@ func (b *blockDeviceMounterUtils) RescanAll(volumeMountProperties *resources.Vol return nil } +// DisconnectAll remove the device from host after the volume is unmapped. func (b *blockDeviceMounterUtils) DisconnectAll(volumeMountProperties *resources.VolumeMountProperties) error { // in case of FC : if no iscsiadm on the machine or no session login - this will log a warning not fail! if err := b.blockDeviceUtils.Disconnect(block_device_utils.ISCSI, volumeMountProperties); err != nil { diff --git a/remote/mounter/initiator/connectors/fibre_channel.go b/remote/mounter/initiator/connectors/fibre_channel.go index c1eea176..a54b6042 100644 --- a/remote/mounter/initiator/connectors/fibre_channel.go +++ b/remote/mounter/initiator/connectors/fibre_channel.go @@ -36,7 +36,7 @@ func newFibreChannelConnectorWithExecutorAndLogger(executor utils.Executor, logg return &fibreChannelConnector{logger: logger, exec: executor, linuxfc: linuxfc} } -// RemoveSCSIDevice removes a scsi device based upon /dev/sdX name. +// ConnectVolume attach the volume to host by rescaning all the active FC HBAs. func (c *fibreChannelConnector) ConnectVolume(volumeMountProperties *resources.VolumeMountProperties) error { hbas := c.linuxfc.GetHBAs() @@ -48,10 +48,10 @@ func (c *fibreChannelConnector) ConnectVolume(volumeMountProperties *resources.V return c.linuxfc.RescanHosts(hbas, volumeMountProperties) } -// RemoveSCSIDevice removes a scsi device based upon /dev/sdX name. +// DisconnectVolume removes a volume from host by echo "1" to all scsi device's /delete func (c *fibreChannelConnector) DisconnectVolume(volumeMountProperties *resources.VolumeMountProperties) error { devices := []string{} - paths := c.findPathsFromMultipathTopology(volumeMountProperties) + paths := c.findPathsFromMultipathOutpot(volumeMountProperties) for _, path := range paths { device := fmt.Sprintf("/dev/%s", path) devices = append(devices, device) @@ -71,7 +71,7 @@ func (c *fibreChannelConnector) removeDevices(devices []string) error { } // TODO: it is not a good idea to find device paths in this way, try to improve it. -func (c *fibreChannelConnector) findPathsFromMultipathTopology(volumeMountProperties *resources.VolumeMountProperties) []string { +func (c *fibreChannelConnector) findPathsFromMultipathOutpot(volumeMountProperties *resources.VolumeMountProperties) []string { multipath := "multipath" if err := c.exec.IsExecutable(multipath); err != nil { c.logger.Warning("No multipath installed.") @@ -92,14 +92,14 @@ generatePathsFromMultipathOutput analysises the output of command "multipath -ll and generates a list of path. A sample output is: - |- 0:0:4:1076248592 sda 8:0 active ready running - |- 0:0:5:1076248592 sdb 8:16 active ready running - |- 0:0:6:1076248592 sdc 8:32 active ready running - |- 0:0:7:1076248592 sdd 8:48 active ready running - |- 1:0:4:1076248592 sde 8:64 active ready running - |- 1:0:5:1076248592 sdf 8:80 active ready running - |- 1:0:6:1076248592 sdg 8:96 active ready running - `- 1:0:7:1076248592 sdh 8:112 active ready running + |- 0:0:4:255 sda 8:0 active ready running + |- 0:0:5:255 sdb 8:16 active ready running + |- 0:0:6:255 sdc 8:32 active ready running + |- 0:0:7:255 sdd 8:48 active ready running + |- 1:0:4:255 sde 8:64 active ready running + |- 1:0:5:255 sdf 8:80 active ready running + |- 1:0:6:255 sdg 8:96 active ready running + `- 1:0:7:255 sdh 8:112 active ready running */ func generatePathsFromMultipathOutput(out []byte) []string { lines := strings.Split(string(out), "\n") diff --git a/remote/mounter/initiator/linuxfc.go b/remote/mounter/initiator/linuxfc.go index e0b442e3..9e9f06f3 100644 --- a/remote/mounter/initiator/linuxfc.go +++ b/remote/mounter/initiator/linuxfc.go @@ -55,7 +55,7 @@ func (lfc *linuxFibreChannel) getHBAChannelScsiTarget(volumeMountProperties *res return fmt.Sprintf("- - %d", volumeMountProperties.LunNumber) } -// getHBAs return all the FC HBAs in the system +// GetHBAs return all the FC HBAs in the system func (lfc *linuxFibreChannel) GetHBAs() []string { if !lfc.hasFCSupport() { return []string{} From 050050d2b0ed23f8b1cfb1bda4603fafb2a54fcf Mon Sep 17 00:00:00 2001 From: 27149chen <7991675+27149chen@users.noreply.github.com> Date: Sun, 24 Feb 2019 00:04:15 +0800 Subject: [PATCH 12/36] add more ut Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> --- .../block_device_utils_mounter_test.go | 34 +++++++++++++++++++ .../block_device_utils/block_device_utils.go | 15 +++++--- .../block_device_utils_test.go | 31 +++++++++++++---- remote/mounter/scbe_test.go | 8 +++++ 4 files changed, 76 insertions(+), 12 deletions(-) diff --git a/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go b/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go index d363bbb0..bcae89da 100644 --- a/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go +++ b/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go @@ -285,6 +285,40 @@ var _ = Describe("block_device_mounter_utils_test", func() { Expect(fakeBlockDeviceUtils.CleanupCallCount()).To(Equal(1)) }) }) + Context(".DisconnectAll", func() { + It("should fail if iscsi disconnect fail", func() { + fakeBlockDeviceUtils.DisconnectReturnsOnCall(0, callErr) + err = blockDeviceMounterUtils.DisconnectAll(volumeMountProperties) + Expect(err).To(HaveOccurred()) + Expect(err).To(MatchError(callErr)) + Expect(fakeBlockDeviceUtils.DisconnectCallCount()).To(Equal(1)) + protocol, _ := fakeBlockDeviceUtils.DisconnectArgsForCall(0) + Expect(protocol).To(Equal(block_device_utils.ISCSI)) + }) + It("should fail if scsi disconnect fail", func() { + fakeBlockDeviceUtils.DisconnectReturnsOnCall(0, nil) + fakeBlockDeviceUtils.DisconnectReturnsOnCall(1, callErr) + err = blockDeviceMounterUtils.DisconnectAll(volumeMountProperties) + Expect(err).To(HaveOccurred()) + Expect(err).To(MatchError(callErr)) + Expect(fakeBlockDeviceUtils.DisconnectCallCount()).To(Equal(2)) + protocol, _ := fakeBlockDeviceUtils.DisconnectArgsForCall(0) + Expect(protocol).To(Equal(block_device_utils.ISCSI)) + protocol, _ = fakeBlockDeviceUtils.DisconnectArgsForCall(1) + Expect(protocol).To(Equal(block_device_utils.SCSI)) + }) + It("should succeed to disconnect all", func() { + fakeBlockDeviceUtils.DisconnectReturnsOnCall(0, nil) + fakeBlockDeviceUtils.DisconnectReturnsOnCall(1, nil) + err = blockDeviceMounterUtils.DisconnectAll(volumeMountProperties) + Expect(err).NotTo(HaveOccurred()) + Expect(fakeBlockDeviceUtils.DisconnectCallCount()).To(Equal(2)) + protocol, _ := fakeBlockDeviceUtils.DisconnectArgsForCall(0) + Expect(protocol).To(Equal(block_device_utils.ISCSI)) + protocol, _ = fakeBlockDeviceUtils.DisconnectArgsForCall(1) + Expect(protocol).To(Equal(block_device_utils.SCSI)) + }) + }) }) func TestGetBlockDeviceMounterUtils(t *testing.T) { diff --git a/remote/mounter/block_device_utils/block_device_utils.go b/remote/mounter/block_device_utils/block_device_utils.go index 22c37f87..c955e935 100644 --- a/remote/mounter/block_device_utils/block_device_utils.go +++ b/remote/mounter/block_device_utils/block_device_utils.go @@ -17,14 +17,18 @@ type blockDeviceUtils struct { } func NewBlockDeviceUtils() BlockDeviceUtils { - return newBlockDeviceUtils(utils.NewExecutor()) + return newBlockDeviceUtils(utils.NewExecutor(), nil) } func NewBlockDeviceUtilsWithExecutor(executor utils.Executor) BlockDeviceUtils { - return newBlockDeviceUtils(executor) + return newBlockDeviceUtils(executor, nil) } -func newBlockDeviceUtils(executor utils.Executor) BlockDeviceUtils { +func NewBlockDeviceUtilsWithExecutorAndConnector(executor utils.Executor, fcConnector initiator.Connector) BlockDeviceUtils { + return newBlockDeviceUtils(executor, fcConnector) +} + +func newBlockDeviceUtils(executor utils.Executor, fcConnector initiator.Connector) BlockDeviceUtils { logger := logs.GetLogger() // Prepare regex that going to be used in unmount interface @@ -34,7 +38,8 @@ func newBlockDeviceUtils(executor utils.Executor) BlockDeviceUtils { panic("failed prepare Already unmount regex") } - fcConnector := connectors.NewFibreChannelConnectorWithExecutorAndLogger(executor, logger) - + if fcConnector == nil { + fcConnector = connectors.NewFibreChannelConnectorWithExecutorAndLogger(executor, logger) + } return &blockDeviceUtils{logger: logger, exec: executor, regExAlreadyMounted: regex, fcConnector: fcConnector} } diff --git a/remote/mounter/block_device_utils/block_device_utils_test.go b/remote/mounter/block_device_utils/block_device_utils_test.go index 3c3669bd..1000a937 100644 --- a/remote/mounter/block_device_utils/block_device_utils_test.go +++ b/remote/mounter/block_device_utils/block_device_utils_test.go @@ -37,16 +37,18 @@ import ( var _ = Describe("block_device_utils_test", func() { var ( - fakeExec *fakes.FakeExecutor - bdUtils block_device_utils.BlockDeviceUtils - err error - cmdErr error = errors.New("command error") + fakeExec *fakes.FakeExecutor + fakeFcConnector *fakes.FakeConnector + bdUtils block_device_utils.BlockDeviceUtils + err error + cmdErr error = errors.New("command error") ) volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: 1} BeforeEach(func() { fakeExec = new(fakes.FakeExecutor) - bdUtils = block_device_utils.NewBlockDeviceUtilsWithExecutor(fakeExec) + fakeFcConnector = new(fakes.FakeConnector) + bdUtils = block_device_utils.NewBlockDeviceUtilsWithExecutorAndConnector(fakeExec, fakeFcConnector) }) Context(".Rescan", func() { @@ -58,8 +60,7 @@ var _ = Describe("block_device_utils_test", func() { Expect(cmd).To(Equal("iscsiadm")) Expect(args).To(Equal([]string{"-m", "session", "--rescan"})) }) - It("Rescan SCSI calls 'sudo rescan-scsi-bus -r'", func() { - // + It(`Rescan SCSI calls fcConnector.ConnectVolume`, func() { fakeExec.ExecuteWithTimeoutReturns([]byte(volumeMountProperties.WWN), nil) err = bdUtils.Rescan(block_device_utils.SCSI, volumeMountProperties) Expect(err).ToNot(HaveOccurred()) @@ -68,6 +69,7 @@ var _ = Describe("block_device_utils_test", func() { // check the existence of the new volume after rescan using multipath -ll Expect(cmd).To(Equal("multipath")) Expect(args).To(Equal([]string{"-ll"})) + Expect(fakeFcConnector.ConnectVolumeCallCount()).To(Equal(1)) }) It("Rescan ISCSI does not fail if iscsiadm command missing", func() { fakeExec.IsExecutableReturns(cmdErr) @@ -87,6 +89,21 @@ var _ = Describe("block_device_utils_test", func() { Expect(err).To(HaveOccurred()) }) }) + Context(".Disconnect", func() { + It("Disconnect ISCSI calls 'sudo iscsiadm -m session --rescan'", func() { + err = bdUtils.Disconnect(block_device_utils.ISCSI, volumeMountProperties) + Expect(err).ToNot(HaveOccurred()) + Expect(fakeExec.ExecuteWithTimeoutCallCount()).To(Equal(1)) + _, cmd, args := fakeExec.ExecuteWithTimeoutArgsForCall(0) + Expect(cmd).To(Equal("iscsiadm")) + Expect(args).To(Equal([]string{"-m", "session", "--rescan"})) + }) + It(`Disconnect SCSI calls fcConnector.DisconnectVolume`, func() { + err = bdUtils.Disconnect(block_device_utils.SCSI, volumeMountProperties) + Expect(err).ToNot(HaveOccurred()) + Expect(fakeFcConnector.DisconnectVolumeCallCount()).To(Equal(1)) + }) + }) Context(".ReloadMultipath", func() { It("ReloadMultipath calls multipath command", func() { err = bdUtils.ReloadMultipath() diff --git a/remote/mounter/scbe_test.go b/remote/mounter/scbe_test.go index fc766074..4f619917 100644 --- a/remote/mounter/scbe_test.go +++ b/remote/mounter/scbe_test.go @@ -184,6 +184,14 @@ var _ = Describe("scbe_mounter_test", func() { Expect(err).To(HaveOccurred()) }) }) + Context("ActionAfterDetach", func() { + It("should call DisconnectAll ", func() { + req := resources.AfterDetachRequest{VolumeConfig: map[string]interface{}{"Wwn": "wwn", "LunNumber": 1}} + err := scbeMounter.ActionAfterDetach(req) + Expect(err).NotTo(HaveOccurred()) + Expect(fakeBdUtils.DisconnectAllCallCount()).To(Equal(1)) + }) + }) }) func TestSCBEMounter(t *testing.T) { From 4e8c76eaebd4800f0f6f420066455ee33167b948 Mon Sep 17 00:00:00 2001 From: 27149chen <7991675+27149chen@users.noreply.github.com> Date: Mon, 25 Feb 2019 00:45:57 +0800 Subject: [PATCH 13/36] added ut for fc connector Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> --- .../block_device_utils/block_device_utils.go | 2 +- .../connectors/connectors_suite_test.go | 16 ++ .../initiator/connectors/fibre_channel.go | 20 +- .../connectors/fibre_channel_test.go | 75 ++++++ .../initiator/fakes/fake_base_initiator.go | 110 ++++++++ .../mounter/initiator/fakes/fake_connector.go | 0 .../mounter/initiator/fakes/fake_initiator.go | 255 ++++++++++++++++++ remote/mounter/initiator/resources.go | 6 +- 8 files changed, 474 insertions(+), 10 deletions(-) create mode 100644 remote/mounter/initiator/connectors/connectors_suite_test.go create mode 100644 remote/mounter/initiator/connectors/fibre_channel_test.go create mode 100644 remote/mounter/initiator/fakes/fake_base_initiator.go rename fakes/fake_initiator.go => remote/mounter/initiator/fakes/fake_connector.go (100%) create mode 100644 remote/mounter/initiator/fakes/fake_initiator.go diff --git a/remote/mounter/block_device_utils/block_device_utils.go b/remote/mounter/block_device_utils/block_device_utils.go index c955e935..98651211 100644 --- a/remote/mounter/block_device_utils/block_device_utils.go +++ b/remote/mounter/block_device_utils/block_device_utils.go @@ -39,7 +39,7 @@ func newBlockDeviceUtils(executor utils.Executor, fcConnector initiator.Connecto } if fcConnector == nil { - fcConnector = connectors.NewFibreChannelConnectorWithExecutorAndLogger(executor, logger) + fcConnector = connectors.NewFibreChannelConnectorWithExecutor(executor) } return &blockDeviceUtils{logger: logger, exec: executor, regExAlreadyMounted: regex, fcConnector: fcConnector} } diff --git a/remote/mounter/initiator/connectors/connectors_suite_test.go b/remote/mounter/initiator/connectors/connectors_suite_test.go new file mode 100644 index 00000000..5b4a4a1b --- /dev/null +++ b/remote/mounter/initiator/connectors/connectors_suite_test.go @@ -0,0 +1,16 @@ +package connectors_test + +import ( + "testing" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + + "github.com/IBM/ubiquity/utils" +) + +func TestConnectors(t *testing.T) { + RegisterFailHandler(Fail) + defer utils.InitUbiquityServerTestLogger()() + RunSpecs(t, "Connectors Suite") +} diff --git a/remote/mounter/initiator/connectors/fibre_channel.go b/remote/mounter/initiator/connectors/fibre_channel.go index a54b6042..506e888d 100644 --- a/remote/mounter/initiator/connectors/fibre_channel.go +++ b/remote/mounter/initiator/connectors/fibre_channel.go @@ -20,17 +20,22 @@ func NewFibreChannelConnector() initiator.Connector { return newFibreChannelConnector() } -func NewFibreChannelConnectorWithExecutorAndLogger(executor utils.Executor, logger logs.Logger) initiator.Connector { - return newFibreChannelConnectorWithExecutorAndLogger(executor, logger) +func NewFibreChannelConnectorWithExecutor(executor utils.Executor) initiator.Connector { + return newFibreChannelConnectorWithExecutorAndLogger(executor) } -func newFibreChannelConnector() *fibreChannelConnector { +func NewFibreChannelConnectorWithAllFields(executor utils.Executor, linuxfc initiator.Initiator) initiator.Connector { logger := logs.GetLogger() + return &fibreChannelConnector{logger: logger, exec: executor, linuxfc: linuxfc} +} + +func newFibreChannelConnector() *fibreChannelConnector { executor := utils.NewExecutor() - return newFibreChannelConnectorWithExecutorAndLogger(executor, logger) + return newFibreChannelConnectorWithExecutorAndLogger(executor) } -func newFibreChannelConnectorWithExecutorAndLogger(executor utils.Executor, logger logs.Logger) *fibreChannelConnector { +func newFibreChannelConnectorWithExecutorAndLogger(executor utils.Executor) *fibreChannelConnector { + logger := logs.GetLogger() linuxfc := initiator.NewLinuxFibreChannelWithExecutorAndLogger(executor, logger) return &fibreChannelConnector{logger: logger, exec: executor, linuxfc: linuxfc} @@ -106,9 +111,12 @@ func generatePathsFromMultipathOutput(out []byte) []string { paths := []string{} for _, line := range lines { line = strings.TrimSpace(line) + if line == "" { + continue + } path := strings.Split(line, " ")[2] if strings.HasPrefix(path, "sd") { - paths = append(paths) + paths = append(paths, path) } } return paths diff --git a/remote/mounter/initiator/connectors/fibre_channel_test.go b/remote/mounter/initiator/connectors/fibre_channel_test.go new file mode 100644 index 00000000..6b14e6ba --- /dev/null +++ b/remote/mounter/initiator/connectors/fibre_channel_test.go @@ -0,0 +1,75 @@ +package connectors_test + +import ( + "fmt" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + + "github.com/IBM/ubiquity/fakes" + "github.com/IBM/ubiquity/remote/mounter/initiator" + "github.com/IBM/ubiquity/remote/mounter/initiator/connectors" + fakeinitiator "github.com/IBM/ubiquity/remote/mounter/initiator/fakes" + "github.com/IBM/ubiquity/resources" +) + +var fakeMpathOutput = ` + |- 0:0:4:255 sda 8:0 active ready running + |- 0:0:5:255 sdb 8:16 active ready running + |- 0:0:6:255 sdc 8:32 active ready running + |- 0:0:7:255 sdd 8:48 active ready running + |- 1:0:4:255 sde 8:64 active ready running + |- 1:0:5:255 sdf 8:80 active ready running + |- 1:0:6:255 sdg 8:96 active ready running + ` + "`- 1:0:7:255 sdh 8:112 active ready running\n" + +var _ = Describe("Test Fibre Channel Connector", func() { + var ( + fakeExec *fakes.FakeExecutor + fakeInitiator *fakeinitiator.FakeInitiator + fcConnector initiator.Connector + ) + volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: 1} + + BeforeEach(func() { + fakeExec = new(fakes.FakeExecutor) + fakeInitiator = new(fakeinitiator.FakeInitiator) + fcConnector = connectors.NewFibreChannelConnectorWithAllFields(fakeExec, fakeInitiator) + }) + + Context("ConnectVolume", func() { + + BeforeEach(func() { + fakeInitiator.GetHBAsReturns([]string{"host0"}) + }) + + It("should rescan all host HBAs", func() { + err := fcConnector.ConnectVolume(volumeMountProperties) + Ω(err).ShouldNot(HaveOccurred()) + Expect(fakeInitiator.RescanHostsCallCount()).To(Equal(1)) + }) + }) + + Context("DisconnectVolume", func() { + + BeforeEach(func() { + fakeExec.ExecuteReturns([]byte(fakeMpathOutput), nil) + }) + + It("should remove all the scsi devices", func() { + err := fcConnector.DisconnectVolume(volumeMountProperties) + Ω(err).ShouldNot(HaveOccurred()) + cmd, args := fakeExec.ExecuteArgsForCall(0) + Expect(cmd).To(Equal("multipath")) + Expect(args).To(Equal([]string{"-ll", "|", fmt.Sprintf("grep %d", volumeMountProperties.LunNumber)})) + + Expect(fakeInitiator.RemoveSCSIDeviceCallCount()).To(Equal(8)) + var a byte = 97 + for i := 0; i < 8; i++ { + expectDev := "/dev/sd" + string(a+byte(i)) + dev := fakeInitiator.RemoveSCSIDeviceArgsForCall(i) + Expect(dev).To(Equal(expectDev)) + } + }) + }) +}) diff --git a/remote/mounter/initiator/fakes/fake_base_initiator.go b/remote/mounter/initiator/fakes/fake_base_initiator.go new file mode 100644 index 00000000..4ff0a578 --- /dev/null +++ b/remote/mounter/initiator/fakes/fake_base_initiator.go @@ -0,0 +1,110 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package fakes + +import ( + "sync" + + "github.com/IBM/ubiquity/remote/mounter/initiator" +) + +type FakeBaseInitiator struct { + RemoveSCSIDeviceStub func(string) error + removeSCSIDeviceMutex sync.RWMutex + removeSCSIDeviceArgsForCall []struct { + arg1 string + } + removeSCSIDeviceReturns struct { + result1 error + } + removeSCSIDeviceReturnsOnCall map[int]struct { + result1 error + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakeBaseInitiator) RemoveSCSIDevice(arg1 string) error { + fake.removeSCSIDeviceMutex.Lock() + ret, specificReturn := fake.removeSCSIDeviceReturnsOnCall[len(fake.removeSCSIDeviceArgsForCall)] + fake.removeSCSIDeviceArgsForCall = append(fake.removeSCSIDeviceArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("RemoveSCSIDevice", []interface{}{arg1}) + fake.removeSCSIDeviceMutex.Unlock() + if fake.RemoveSCSIDeviceStub != nil { + return fake.RemoveSCSIDeviceStub(arg1) + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.removeSCSIDeviceReturns + return fakeReturns.result1 +} + +func (fake *FakeBaseInitiator) RemoveSCSIDeviceCallCount() int { + fake.removeSCSIDeviceMutex.RLock() + defer fake.removeSCSIDeviceMutex.RUnlock() + return len(fake.removeSCSIDeviceArgsForCall) +} + +func (fake *FakeBaseInitiator) RemoveSCSIDeviceCalls(stub func(string) error) { + fake.removeSCSIDeviceMutex.Lock() + defer fake.removeSCSIDeviceMutex.Unlock() + fake.RemoveSCSIDeviceStub = stub +} + +func (fake *FakeBaseInitiator) RemoveSCSIDeviceArgsForCall(i int) string { + fake.removeSCSIDeviceMutex.RLock() + defer fake.removeSCSIDeviceMutex.RUnlock() + argsForCall := fake.removeSCSIDeviceArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeBaseInitiator) RemoveSCSIDeviceReturns(result1 error) { + fake.removeSCSIDeviceMutex.Lock() + defer fake.removeSCSIDeviceMutex.Unlock() + fake.RemoveSCSIDeviceStub = nil + fake.removeSCSIDeviceReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeBaseInitiator) RemoveSCSIDeviceReturnsOnCall(i int, result1 error) { + fake.removeSCSIDeviceMutex.Lock() + defer fake.removeSCSIDeviceMutex.Unlock() + fake.RemoveSCSIDeviceStub = nil + if fake.removeSCSIDeviceReturnsOnCall == nil { + fake.removeSCSIDeviceReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.removeSCSIDeviceReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeBaseInitiator) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.removeSCSIDeviceMutex.RLock() + defer fake.removeSCSIDeviceMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *FakeBaseInitiator) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +} + +var _ initiator.BaseInitiator = new(FakeBaseInitiator) diff --git a/fakes/fake_initiator.go b/remote/mounter/initiator/fakes/fake_connector.go similarity index 100% rename from fakes/fake_initiator.go rename to remote/mounter/initiator/fakes/fake_connector.go diff --git a/remote/mounter/initiator/fakes/fake_initiator.go b/remote/mounter/initiator/fakes/fake_initiator.go new file mode 100644 index 00000000..227155ad --- /dev/null +++ b/remote/mounter/initiator/fakes/fake_initiator.go @@ -0,0 +1,255 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package fakes + +import ( + "sync" + + "github.com/IBM/ubiquity/remote/mounter/initiator" + "github.com/IBM/ubiquity/resources" +) + +type FakeInitiator struct { + GetHBAsStub func() []string + getHBAsMutex sync.RWMutex + getHBAsArgsForCall []struct { + } + getHBAsReturns struct { + result1 []string + } + getHBAsReturnsOnCall map[int]struct { + result1 []string + } + RemoveSCSIDeviceStub func(string) error + removeSCSIDeviceMutex sync.RWMutex + removeSCSIDeviceArgsForCall []struct { + arg1 string + } + removeSCSIDeviceReturns struct { + result1 error + } + removeSCSIDeviceReturnsOnCall map[int]struct { + result1 error + } + RescanHostsStub func([]string, *resources.VolumeMountProperties) error + rescanHostsMutex sync.RWMutex + rescanHostsArgsForCall []struct { + arg1 []string + arg2 *resources.VolumeMountProperties + } + rescanHostsReturns struct { + result1 error + } + rescanHostsReturnsOnCall map[int]struct { + result1 error + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakeInitiator) GetHBAs() []string { + fake.getHBAsMutex.Lock() + ret, specificReturn := fake.getHBAsReturnsOnCall[len(fake.getHBAsArgsForCall)] + fake.getHBAsArgsForCall = append(fake.getHBAsArgsForCall, struct { + }{}) + fake.recordInvocation("GetHBAs", []interface{}{}) + fake.getHBAsMutex.Unlock() + if fake.GetHBAsStub != nil { + return fake.GetHBAsStub() + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.getHBAsReturns + return fakeReturns.result1 +} + +func (fake *FakeInitiator) GetHBAsCallCount() int { + fake.getHBAsMutex.RLock() + defer fake.getHBAsMutex.RUnlock() + return len(fake.getHBAsArgsForCall) +} + +func (fake *FakeInitiator) GetHBAsCalls(stub func() []string) { + fake.getHBAsMutex.Lock() + defer fake.getHBAsMutex.Unlock() + fake.GetHBAsStub = stub +} + +func (fake *FakeInitiator) GetHBAsReturns(result1 []string) { + fake.getHBAsMutex.Lock() + defer fake.getHBAsMutex.Unlock() + fake.GetHBAsStub = nil + fake.getHBAsReturns = struct { + result1 []string + }{result1} +} + +func (fake *FakeInitiator) GetHBAsReturnsOnCall(i int, result1 []string) { + fake.getHBAsMutex.Lock() + defer fake.getHBAsMutex.Unlock() + fake.GetHBAsStub = nil + if fake.getHBAsReturnsOnCall == nil { + fake.getHBAsReturnsOnCall = make(map[int]struct { + result1 []string + }) + } + fake.getHBAsReturnsOnCall[i] = struct { + result1 []string + }{result1} +} + +func (fake *FakeInitiator) RemoveSCSIDevice(arg1 string) error { + fake.removeSCSIDeviceMutex.Lock() + ret, specificReturn := fake.removeSCSIDeviceReturnsOnCall[len(fake.removeSCSIDeviceArgsForCall)] + fake.removeSCSIDeviceArgsForCall = append(fake.removeSCSIDeviceArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("RemoveSCSIDevice", []interface{}{arg1}) + fake.removeSCSIDeviceMutex.Unlock() + if fake.RemoveSCSIDeviceStub != nil { + return fake.RemoveSCSIDeviceStub(arg1) + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.removeSCSIDeviceReturns + return fakeReturns.result1 +} + +func (fake *FakeInitiator) RemoveSCSIDeviceCallCount() int { + fake.removeSCSIDeviceMutex.RLock() + defer fake.removeSCSIDeviceMutex.RUnlock() + return len(fake.removeSCSIDeviceArgsForCall) +} + +func (fake *FakeInitiator) RemoveSCSIDeviceCalls(stub func(string) error) { + fake.removeSCSIDeviceMutex.Lock() + defer fake.removeSCSIDeviceMutex.Unlock() + fake.RemoveSCSIDeviceStub = stub +} + +func (fake *FakeInitiator) RemoveSCSIDeviceArgsForCall(i int) string { + fake.removeSCSIDeviceMutex.RLock() + defer fake.removeSCSIDeviceMutex.RUnlock() + argsForCall := fake.removeSCSIDeviceArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeInitiator) RemoveSCSIDeviceReturns(result1 error) { + fake.removeSCSIDeviceMutex.Lock() + defer fake.removeSCSIDeviceMutex.Unlock() + fake.RemoveSCSIDeviceStub = nil + fake.removeSCSIDeviceReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeInitiator) RemoveSCSIDeviceReturnsOnCall(i int, result1 error) { + fake.removeSCSIDeviceMutex.Lock() + defer fake.removeSCSIDeviceMutex.Unlock() + fake.RemoveSCSIDeviceStub = nil + if fake.removeSCSIDeviceReturnsOnCall == nil { + fake.removeSCSIDeviceReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.removeSCSIDeviceReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeInitiator) RescanHosts(arg1 []string, arg2 *resources.VolumeMountProperties) error { + var arg1Copy []string + if arg1 != nil { + arg1Copy = make([]string, len(arg1)) + copy(arg1Copy, arg1) + } + fake.rescanHostsMutex.Lock() + ret, specificReturn := fake.rescanHostsReturnsOnCall[len(fake.rescanHostsArgsForCall)] + fake.rescanHostsArgsForCall = append(fake.rescanHostsArgsForCall, struct { + arg1 []string + arg2 *resources.VolumeMountProperties + }{arg1Copy, arg2}) + fake.recordInvocation("RescanHosts", []interface{}{arg1Copy, arg2}) + fake.rescanHostsMutex.Unlock() + if fake.RescanHostsStub != nil { + return fake.RescanHostsStub(arg1, arg2) + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.rescanHostsReturns + return fakeReturns.result1 +} + +func (fake *FakeInitiator) RescanHostsCallCount() int { + fake.rescanHostsMutex.RLock() + defer fake.rescanHostsMutex.RUnlock() + return len(fake.rescanHostsArgsForCall) +} + +func (fake *FakeInitiator) RescanHostsCalls(stub func([]string, *resources.VolumeMountProperties) error) { + fake.rescanHostsMutex.Lock() + defer fake.rescanHostsMutex.Unlock() + fake.RescanHostsStub = stub +} + +func (fake *FakeInitiator) RescanHostsArgsForCall(i int) ([]string, *resources.VolumeMountProperties) { + fake.rescanHostsMutex.RLock() + defer fake.rescanHostsMutex.RUnlock() + argsForCall := fake.rescanHostsArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeInitiator) RescanHostsReturns(result1 error) { + fake.rescanHostsMutex.Lock() + defer fake.rescanHostsMutex.Unlock() + fake.RescanHostsStub = nil + fake.rescanHostsReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeInitiator) RescanHostsReturnsOnCall(i int, result1 error) { + fake.rescanHostsMutex.Lock() + defer fake.rescanHostsMutex.Unlock() + fake.RescanHostsStub = nil + if fake.rescanHostsReturnsOnCall == nil { + fake.rescanHostsReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.rescanHostsReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeInitiator) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.getHBAsMutex.RLock() + defer fake.getHBAsMutex.RUnlock() + fake.removeSCSIDeviceMutex.RLock() + defer fake.removeSCSIDeviceMutex.RUnlock() + fake.rescanHostsMutex.RLock() + defer fake.rescanHostsMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *FakeInitiator) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +} + +var _ initiator.Initiator = new(FakeInitiator) diff --git a/remote/mounter/initiator/resources.go b/remote/mounter/initiator/resources.go index b6734229..a4da4811 100644 --- a/remote/mounter/initiator/resources.go +++ b/remote/mounter/initiator/resources.go @@ -2,19 +2,19 @@ package initiator import "github.com/IBM/ubiquity/resources" -//go:generate counterfeiter -o ../../../fakes/fake_initiator.go . BaseInitiator +//go:generate counterfeiter -o fakes/fake_base_initiator.go . BaseInitiator type BaseInitiator interface { RemoveSCSIDevice(device string) error } -//go:generate counterfeiter -o ../../../fakes/fake_initiator.go . Initiator +//go:generate counterfeiter -o fakes/fake_initiator.go . Initiator type Initiator interface { BaseInitiator GetHBAs() []string RescanHosts(hbas []string, volumeMountProperties *resources.VolumeMountProperties) error } -//go:generate counterfeiter -o ../../../fakes/fake_initiator.go . Connector +//go:generate counterfeiter -o fakes/fake_connector.go . Connector type Connector interface { ConnectVolume(volumeMountProperties *resources.VolumeMountProperties) error DisconnectVolume(volumeMountProperties *resources.VolumeMountProperties) error From 7017b877c9b4470b3acbf8215b6b8b783a62fc47 Mon Sep 17 00:00:00 2001 From: 27149chen <7991675+27149chen@users.noreply.github.com> Date: Mon, 25 Feb 2019 02:11:19 +0800 Subject: [PATCH 14/36] add ut for fc initiator Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> --- .../initiator/connectors/fibre_channel.go | 2 +- .../mounter/initiator/initiator_suite_test.go | 16 ++ remote/mounter/initiator/linuxfc.go | 17 +- remote/mounter/initiator/linuxfc_test.go | 171 ++++++++++++++++++ remote/mounter/initiator/linuxscsi.go | 4 +- 5 files changed, 200 insertions(+), 10 deletions(-) create mode 100644 remote/mounter/initiator/initiator_suite_test.go create mode 100644 remote/mounter/initiator/linuxfc_test.go diff --git a/remote/mounter/initiator/connectors/fibre_channel.go b/remote/mounter/initiator/connectors/fibre_channel.go index 506e888d..edcc8c3d 100644 --- a/remote/mounter/initiator/connectors/fibre_channel.go +++ b/remote/mounter/initiator/connectors/fibre_channel.go @@ -36,7 +36,7 @@ func newFibreChannelConnector() *fibreChannelConnector { func newFibreChannelConnectorWithExecutorAndLogger(executor utils.Executor) *fibreChannelConnector { logger := logs.GetLogger() - linuxfc := initiator.NewLinuxFibreChannelWithExecutorAndLogger(executor, logger) + linuxfc := initiator.NewLinuxFibreChannelWithExecutor(executor) return &fibreChannelConnector{logger: logger, exec: executor, linuxfc: linuxfc} } diff --git a/remote/mounter/initiator/initiator_suite_test.go b/remote/mounter/initiator/initiator_suite_test.go new file mode 100644 index 00000000..faf4396c --- /dev/null +++ b/remote/mounter/initiator/initiator_suite_test.go @@ -0,0 +1,16 @@ +package initiator_test + +import ( + "testing" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + + "github.com/IBM/ubiquity/utils" +) + +func TestInitiators(t *testing.T) { + RegisterFailHandler(Fail) + defer utils.InitUbiquityServerTestLogger()() + RunSpecs(t, "Initiators Suite") +} diff --git a/remote/mounter/initiator/linuxfc.go b/remote/mounter/initiator/linuxfc.go index 9e9f06f3..a66ecccf 100644 --- a/remote/mounter/initiator/linuxfc.go +++ b/remote/mounter/initiator/linuxfc.go @@ -11,8 +11,8 @@ import ( "github.com/IBM/ubiquity/utils/logs" ) -const FC_HOST_SYSFS_PATH = "/sys/class/fc_host" -const SCSI_HOST_SYSFS_PATH = "/sys/class/scsi_host/" +var FC_HOST_SYSFS_PATH = "/sys/class/fc_host" +var SCSI_HOST_SYSFS_PATH = "/sys/class/scsi_host" type linuxFibreChannel struct { *linuxSCSI @@ -22,17 +22,17 @@ func NewLinuxFibreChannel() Initiator { return newLinuxFibreChannel() } -func NewLinuxFibreChannelWithExecutorAndLogger(executor utils.Executor, logger logs.Logger) Initiator { - return newLinuxFibreChannelWithExecutorAndLogger(executor, logger) +func NewLinuxFibreChannelWithExecutor(executor utils.Executor) Initiator { + return newLinuxFibreChannelWithExecutor(executor) } func newLinuxFibreChannel() *linuxFibreChannel { - logger := logs.GetLogger() executor := utils.NewExecutor() - return newLinuxFibreChannelWithExecutorAndLogger(executor, logger) + return newLinuxFibreChannelWithExecutor(executor) } -func newLinuxFibreChannelWithExecutorAndLogger(executor utils.Executor, logger logs.Logger) *linuxFibreChannel { +func newLinuxFibreChannelWithExecutor(executor utils.Executor) *linuxFibreChannel { + logger := logs.GetLogger() return &linuxFibreChannel{&linuxSCSI{logger: logger, exec: executor}} } @@ -78,6 +78,7 @@ func (lfc *linuxFibreChannel) GetHBAs() []string { return []string{} } hbas := generateHBAsInfoFromSystoolOutput(out) + lfc.logger.Debug(fmt.Sprintf("Find %d HBAs from systool output, getting the name of the online one(s)", len(hbas))) hbaNames := []string{} for _, hba := range hbas { if hba["port_state"] == "Online" { @@ -109,7 +110,7 @@ func (lfc *linuxFibreChannel) RescanHosts(hbas []string, volumeMountProperties * ctl := lfc.getHBAChannelScsiTarget(volumeMountProperties) for _, hba := range hbas { - hbaPath := SCSI_HOST_SYSFS_PATH + hba + "/scan" + hbaPath := SCSI_HOST_SYSFS_PATH + "/" + hba + "/scan" lfc.logger.Debug(fmt.Sprintf(`Scanning HBA with command: echo "%s" > %s`, ctl, hbaPath)) if err := ioutil.WriteFile(hbaPath, []byte(ctl), 0666); err != nil { lfc.logger.Debug("Failed to scan HBA", logs.Args{{"name", hba}, {"err", err}}) diff --git a/remote/mounter/initiator/linuxfc_test.go b/remote/mounter/initiator/linuxfc_test.go new file mode 100644 index 00000000..e1f8a42f --- /dev/null +++ b/remote/mounter/initiator/linuxfc_test.go @@ -0,0 +1,171 @@ +package initiator_test + +import ( + "fmt" + "io/ioutil" + "os" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + + "github.com/IBM/ubiquity/fakes" + "github.com/IBM/ubiquity/remote/mounter/initiator" + "github.com/IBM/ubiquity/resources" +) + +const tmp_prefix = "/tmp/ubiquity_test" + +const FAKE_FC_HOST_SYSFS_PATH = tmp_prefix + "/sys/class/fc_host" +const FAKE_SCSI_HOST_SYSFS_PATH = tmp_prefix + "/sys/class/scsi_host" +const FAKE_SYS_BLOCK_PATH = tmp_prefix + "/sys/block" + +var fakeSystoolOutput = `Class = "fc_host" + + Class Device = "host0" + Class Device path = "/sys/devices/css0/0.0.0000/0.0.a200/host0/fc_host/host0" + active_fc4s = "0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 " + dev_loss_tmo = "60" + maxframe_size = "2112 bytes" + node_name = "0x5005076400c1b2b8" + permanent_port_name = "0xc05076e5118011d1" + port_id = "0x0ecfd3" + port_name = "0xc05076e511803cb0" + port_state = "Online" + port_type = "NPIV VPORT" + serial_number = "IBM0200000001B2B8" + speed = "8 Gbit" + supported_classes = "Class 2, Class 3" + supported_fc4s = "0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 " + supported_speeds = "4 Gbit, 8 Gbit, 16 Gbit" + symbolic_name = "IBM 3906 0200000001B2B8 PCHID: 011D NPIV UlpId: 004C0308 DEVNO: 0.0.a200 NAME: stk8s008" + tgtid_bind_type = "wwpn (World Wide Port Name)" + uevent = + + Device = "host0" + Device path = "/sys/devices/css0/0.0.0000/0.0.a200/host0" + uevent = "DEVTYPE=scsi_host" + + + Class Device = "host1" + Class Device path = "/sys/devices/css0/0.0.0001/0.0.a300/host1/fc_host/host1" + active_fc4s = "0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 " + dev_loss_tmo = "60" + maxframe_size = "2112 bytes" + node_name = "0x5005076400c1b2b8" + permanent_port_name = "0xc05076e511801811" + port_id = "0x0fc613" + port_name = "0xc05076e511803b48" + port_state = "Online" + port_type = "NPIV VPORT" + serial_number = "IBM0200000001B2B8" + speed = "8 Gbit" + supported_classes = "Class 2, Class 3" + supported_fc4s = "0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 " + supported_speeds = "4 Gbit, 8 Gbit, 16 Gbit" + symbolic_name = "IBM 3906 0200000001B2B8 PCHID: 0181 NPIV UlpId: 00450308 DEVNO: 0.0.a300 NAME: stk8s008" + tgtid_bind_type = "wwpn (World Wide Port Name)" + uevent = + + Device = "host1" + Device path = "/sys/devices/css0/0.0.0001/0.0.a300/host1" + uevent = "DEVTYPE=scsi_host" +` + +var _ = Describe("Test FC Initiator", func() { + var ( + fakeExec *fakes.FakeExecutor + fcInitiator initiator.Initiator + realFcSysPath string + realScsiSysPath string + realSysBlockPath string + ) + volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: 1} + + BeforeEach(func() { + err := os.MkdirAll(FAKE_FC_HOST_SYSFS_PATH, os.ModePerm) + Ω(err).ShouldNot(HaveOccurred()) + + err = os.MkdirAll(FAKE_SCSI_HOST_SYSFS_PATH, os.ModePerm) + Ω(err).ShouldNot(HaveOccurred()) + + err = os.MkdirAll(FAKE_SYS_BLOCK_PATH, os.ModePerm) + Ω(err).ShouldNot(HaveOccurred()) + + realFcSysPath = initiator.FC_HOST_SYSFS_PATH + realScsiSysPath = initiator.SCSI_HOST_SYSFS_PATH + realSysBlockPath = initiator.SYS_BLOCK_PATH + initiator.FC_HOST_SYSFS_PATH = FAKE_FC_HOST_SYSFS_PATH + initiator.SCSI_HOST_SYSFS_PATH = FAKE_SCSI_HOST_SYSFS_PATH + initiator.SYS_BLOCK_PATH = FAKE_SYS_BLOCK_PATH + + fakeExec = new(fakes.FakeExecutor) + fcInitiator = initiator.NewLinuxFibreChannelWithExecutor(fakeExec) + }) + + AfterEach(func() { + initiator.FC_HOST_SYSFS_PATH = realFcSysPath + initiator.SCSI_HOST_SYSFS_PATH = realScsiSysPath + initiator.SYS_BLOCK_PATH = realSysBlockPath + + err := os.RemoveAll(tmp_prefix) + Ω(err).ShouldNot(HaveOccurred()) + }) + + Context("GetHBAs", func() { + + Context("get HBAs from systool", func() { + BeforeEach(func() { + fakeExec.ExecuteReturns([]byte(fakeSystoolOutput), nil) + }) + + It("should get from systool if it is installed", func() { + hbas := fcInitiator.GetHBAs() + Expect(hbas).To(Equal([]string{"host0", "host1"})) + }) + }) + + }) + + Context("RescanHosts", func() { + var hbas = []string{"host0"} + var scanPath = FAKE_SCSI_HOST_SYSFS_PATH + "/" + hbas[0] + var scanFile = scanPath + "/scan" + + BeforeEach(func() { + err := os.MkdirAll(scanPath, os.ModePerm) + Ω(err).ShouldNot(HaveOccurred()) + _, err = os.Create(scanFile) + Ω(err).ShouldNot(HaveOccurred()) + }) + + It("should write '- - lunid' to the hba scan file", func() { + err := fcInitiator.RescanHosts(hbas, volumeMountProperties) + Ω(err).ShouldNot(HaveOccurred()) + data, err := ioutil.ReadFile(scanFile) + Ω(err).ShouldNot(HaveOccurred()) + Expect(string(data)).To(Equal(fmt.Sprintf("- - %d", volumeMountProperties.LunNumber))) + }) + }) + + Context("RemoveSCSIDevice", func() { + var devName = "sda" + var dev = "/dev/" + devName + var deletePath = FAKE_SYS_BLOCK_PATH + fmt.Sprintf("/%s/device", devName) + var deleteFile = deletePath + "/delete" + + BeforeEach(func() { + err := os.MkdirAll(deletePath, os.ModePerm) + Ω(err).ShouldNot(HaveOccurred()) + _, err = os.Create(deleteFile) + Ω(err).ShouldNot(HaveOccurred()) + }) + + It("should write 1 to the device delete file", func() { + err := fcInitiator.RemoveSCSIDevice(dev) + Ω(err).ShouldNot(HaveOccurred()) + data, err := ioutil.ReadFile(deleteFile) + Ω(err).ShouldNot(HaveOccurred()) + Expect(string(data)).To(Equal("1")) + }) + }) +}) diff --git a/remote/mounter/initiator/linuxscsi.go b/remote/mounter/initiator/linuxscsi.go index f1c5695b..fc94f0fc 100644 --- a/remote/mounter/initiator/linuxscsi.go +++ b/remote/mounter/initiator/linuxscsi.go @@ -10,6 +10,8 @@ import ( "github.com/IBM/ubiquity/utils/logs" ) +var SYS_BLOCK_PATH = "/sys/block" + type linuxSCSI struct { exec utils.Executor logger logs.Logger @@ -18,7 +20,7 @@ type linuxSCSI struct { // RemoveSCSIDevice removes a scsi device based upon /dev/sdX name. func (ls *linuxSCSI) RemoveSCSIDevice(device string) error { deviceName := strings.Replace(device, "/dev/", "", 1) - path := fmt.Sprintf("/sys/block/%s/device/delete", deviceName) + path := SYS_BLOCK_PATH + fmt.Sprintf("/%s/device/delete", deviceName) if _, err := os.Stat(path); !os.IsNotExist(err) { ls.logger.Debug(fmt.Sprintf("Remove SCSI device %s with %s", device, path)) if err := ioutil.WriteFile(path, []byte("1"), 0666); err != nil { From 197718581f418fd8bae52d69fd6ffb8346ccdfae Mon Sep 17 00:00:00 2001 From: 27149chen <7991675+27149chen@users.noreply.github.com> Date: Mon, 25 Feb 2019 17:04:23 +0800 Subject: [PATCH 15/36] added ut for fc initiator Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> --- .../block_device_utils_test.go | 5 ++-- .../initiator/connectors/fibre_channel.go | 4 +-- .../connectors/fibre_channel_test.go | 2 +- remote/mounter/initiator/linuxfc.go | 2 ++ remote/mounter/initiator/linuxfc_test.go | 28 +++++++++++++++++++ 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/remote/mounter/block_device_utils/block_device_utils_test.go b/remote/mounter/block_device_utils/block_device_utils_test.go index 1000a937..afba946d 100644 --- a/remote/mounter/block_device_utils/block_device_utils_test.go +++ b/remote/mounter/block_device_utils/block_device_utils_test.go @@ -22,6 +22,7 @@ import ( "github.com/IBM/ubiquity/fakes" "github.com/IBM/ubiquity/remote/mounter/block_device_utils" + fakeinitiator "github.com/IBM/ubiquity/remote/mounter/initiator/fakes" "github.com/IBM/ubiquity/resources" "github.com/IBM/ubiquity/utils" @@ -38,7 +39,7 @@ import ( var _ = Describe("block_device_utils_test", func() { var ( fakeExec *fakes.FakeExecutor - fakeFcConnector *fakes.FakeConnector + fakeFcConnector *fakeinitiator.FakeConnector bdUtils block_device_utils.BlockDeviceUtils err error cmdErr error = errors.New("command error") @@ -47,7 +48,7 @@ var _ = Describe("block_device_utils_test", func() { BeforeEach(func() { fakeExec = new(fakes.FakeExecutor) - fakeFcConnector = new(fakes.FakeConnector) + fakeFcConnector = new(fakeinitiator.FakeConnector) bdUtils = block_device_utils.NewBlockDeviceUtilsWithExecutorAndConnector(fakeExec, fakeFcConnector) }) diff --git a/remote/mounter/initiator/connectors/fibre_channel.go b/remote/mounter/initiator/connectors/fibre_channel.go index edcc8c3d..eb2aa5a5 100644 --- a/remote/mounter/initiator/connectors/fibre_channel.go +++ b/remote/mounter/initiator/connectors/fibre_channel.go @@ -84,7 +84,7 @@ func (c *fibreChannelConnector) findPathsFromMultipathOutpot(volumeMountProperti } lunNumber := volumeMountProperties.LunNumber - out, err := c.exec.Execute(multipath, []string{"-ll", "|", fmt.Sprintf("grep %d", lunNumber)}) + out, err := c.exec.Execute(multipath, []string{"-ll", "|", fmt.Sprintf(`egrep "[0-9]+:[0-9]+:[0-9]+:%d "`, lunNumber)}) if err != nil { c.logger.Warning(fmt.Sprintf("Executing multipath failed with error: %v", err)) return []string{} @@ -93,7 +93,7 @@ func (c *fibreChannelConnector) findPathsFromMultipathOutpot(volumeMountProperti } /* -generatePathsFromMultipathOutput analysises the output of command "multipath -ll |grep lunNumber", +generatePathsFromMultipathOutput analysises the output of command "multipath -ll | egrep '[0-9]+:[0-9]+:[0-9]+lunNumber '", and generates a list of path. A sample output is: diff --git a/remote/mounter/initiator/connectors/fibre_channel_test.go b/remote/mounter/initiator/connectors/fibre_channel_test.go index 6b14e6ba..b508d611 100644 --- a/remote/mounter/initiator/connectors/fibre_channel_test.go +++ b/remote/mounter/initiator/connectors/fibre_channel_test.go @@ -61,7 +61,7 @@ var _ = Describe("Test Fibre Channel Connector", func() { Ω(err).ShouldNot(HaveOccurred()) cmd, args := fakeExec.ExecuteArgsForCall(0) Expect(cmd).To(Equal("multipath")) - Expect(args).To(Equal([]string{"-ll", "|", fmt.Sprintf("grep %d", volumeMountProperties.LunNumber)})) + Expect(args).To(Equal([]string{"-ll", "|", fmt.Sprintf(`egrep "[0-9]+:[0-9]+:[0-9]+:%d "`, volumeMountProperties.LunNumber)})) Expect(fakeInitiator.RemoveSCSIDeviceCallCount()).To(Equal(8)) var a byte = 97 diff --git a/remote/mounter/initiator/linuxfc.go b/remote/mounter/initiator/linuxfc.go index a66ecccf..2b2c5a73 100644 --- a/remote/mounter/initiator/linuxfc.go +++ b/remote/mounter/initiator/linuxfc.go @@ -175,6 +175,8 @@ Class = "fc_host" Device = "host1" Device path = "/sys/devices/css0/0.0.0001/0.0.a300/host1" uevent = "DEVTYPE=scsi_host" + + */ func generateHBAsInfoFromSystoolOutput(out []byte) []map[string]string { lines := strings.Split(string(out), "\n") diff --git a/remote/mounter/initiator/linuxfc_test.go b/remote/mounter/initiator/linuxfc_test.go index e1f8a42f..d1ae4267 100644 --- a/remote/mounter/initiator/linuxfc_test.go +++ b/remote/mounter/initiator/linuxfc_test.go @@ -1,6 +1,7 @@ package initiator_test import ( + "errors" "fmt" "io/ioutil" "os" @@ -69,6 +70,8 @@ var fakeSystoolOutput = `Class = "fc_host" Device = "host1" Device path = "/sys/devices/css0/0.0.0001/0.0.a300/host1" uevent = "DEVTYPE=scsi_host" + + ` var _ = Describe("Test FC Initiator", func() { @@ -78,6 +81,7 @@ var _ = Describe("Test FC Initiator", func() { realFcSysPath string realScsiSysPath string realSysBlockPath string + cmdErr error = errors.New("command error") ) volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: 1} @@ -124,6 +128,30 @@ var _ = Describe("Test FC Initiator", func() { }) }) + Context("get HBAs from sys fc path", func() { + hbas := []string{"host0", "host1", "host2"} + + BeforeEach(func() { + for _, hba := range hbas { + fullPath := FAKE_FC_HOST_SYSFS_PATH + "/" + hba + err := os.MkdirAll(fullPath, os.ModePerm) + Ω(err).ShouldNot(HaveOccurred()) + } + }) + + It("should get from sys fc path if systool is not installed", func() { + fakeExec.IsExecutableReturns(cmdErr) + hbasRes := fcInitiator.GetHBAs() + Expect(hbasRes).To(Equal(hbas)) + }) + + It("should get from sys fc path if systool returns error", func() { + fakeExec.ExecuteReturns([]byte{}, cmdErr) + hbasRes := fcInitiator.GetHBAs() + Expect(hbasRes).To(Equal(hbas)) + }) + }) + }) Context("RescanHosts", func() { From 192c79a851ffbc0528e551e5c6c82b93a6b9a703 Mon Sep 17 00:00:00 2001 From: 27149chen <7991675+27149chen@users.noreply.github.com> Date: Wed, 27 Feb 2019 02:26:24 +0800 Subject: [PATCH 16/36] update after review Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> --- remote/mounter/block_device_utils/mpath.go | 2 + remote/mounter/block_device_utils/rescan.go | 2 + .../connectors/fibre_channel_test.go | 103 +++++++++++++++--- remote/mounter/initiator/linuxfc.go | 8 +- remote/mounter/scbe.go | 18 +-- resources/resources.go | 17 +++ 6 files changed, 117 insertions(+), 33 deletions(-) diff --git a/remote/mounter/block_device_utils/mpath.go b/remote/mounter/block_device_utils/mpath.go index beaa679a..51a0329c 100644 --- a/remote/mounter/block_device_utils/mpath.go +++ b/remote/mounter/block_device_utils/mpath.go @@ -54,6 +54,8 @@ func (b *blockDeviceUtils) ReloadMultipath() error { return nil } +// getMultipathOutputAndDeviceUid runs "multipath -ll" and analysises the output to find the device uid +// and then return both the output and the uid. func (b *blockDeviceUtils) getMultipathOutputAndDeviceUid(volumeWwn string) ([]byte, string, error) { if err := b.exec.IsExecutable(multipathCmd); err != nil { return []byte{}, "", b.logger.ErrorRet(&commandNotFoundError{multipathCmd, err}, "failed") diff --git a/remote/mounter/block_device_utils/rescan.go b/remote/mounter/block_device_utils/rescan.go index b023f7f0..d4ec08a9 100644 --- a/remote/mounter/block_device_utils/rescan.go +++ b/remote/mounter/block_device_utils/rescan.go @@ -80,6 +80,8 @@ func (b *blockDeviceUtils) RescanISCSI() error { } func (b *blockDeviceUtils) RescanSCSI(volumeMountProperties *resources.VolumeMountProperties) error { + defer b.logger.Trace(logs.DEBUG)() + var err error for i := 0; i < 6; i++ { if err = b.fcConnector.ConnectVolume(volumeMountProperties); err != nil { diff --git a/remote/mounter/initiator/connectors/fibre_channel_test.go b/remote/mounter/initiator/connectors/fibre_channel_test.go index b508d611..60d95af1 100644 --- a/remote/mounter/initiator/connectors/fibre_channel_test.go +++ b/remote/mounter/initiator/connectors/fibre_channel_test.go @@ -13,7 +13,7 @@ import ( "github.com/IBM/ubiquity/resources" ) -var fakeMpathOutput = ` +var fakeMpathOutputForLUN255 = ` |- 0:0:4:255 sda 8:0 active ready running |- 0:0:5:255 sdb 8:16 active ready running |- 0:0:6:255 sdc 8:32 active ready running @@ -23,6 +23,26 @@ var fakeMpathOutput = ` |- 1:0:6:255 sdg 8:96 active ready running ` + "`- 1:0:7:255 sdh 8:112 active ready running\n" +var fakeMpathOutputForLUN0 = ` + |- 0:0:4:0 sda 8:0 active ready running + |- 0:0:5:0 sdb 8:16 active ready running + |- 0:0:6:0 sdc 8:32 active ready running + |- 0:0:7:0 sdd 8:48 active ready running + |- 1:0:4:0 sde 8:64 active ready running + |- 1:0:5:0 sdf 8:80 active ready running + |- 1:0:6:0 sdg 8:96 active ready running + ` + "`- 1:0:7:0 sdh 8:112 active ready running\n" + +var fakeMpathOutputForLUNZlinux = ` + |- 0:0:4:1076248592 sda 8:0 active ready running + |- 0:0:5:1076248592 sdb 8:16 active ready running + |- 0:0:6:1076248592 sdc 8:32 active ready running + |- 0:0:7:1076248592 sdd 8:48 active ready running + |- 1:0:4:1076248592 sde 8:64 active ready running + |- 1:0:5:1076248592 sdf 8:80 active ready running + |- 1:0:6:1076248592 sdg 8:96 active ready running + ` + "`- 1:0:7:1076248592 sdh 8:112 active ready running\n" + var _ = Describe("Test Fibre Channel Connector", func() { var ( fakeExec *fakes.FakeExecutor @@ -52,24 +72,73 @@ var _ = Describe("Test Fibre Channel Connector", func() { Context("DisconnectVolume", func() { - BeforeEach(func() { - fakeExec.ExecuteReturns([]byte(fakeMpathOutput), nil) + Context("remove lun 255", func() { + + BeforeEach(func() { + fakeExec.ExecuteReturns([]byte(fakeMpathOutputForLUN255), nil) + }) + + It("should remove all the scsi devices", func() { + err := fcConnector.DisconnectVolume(volumeMountProperties) + Ω(err).ShouldNot(HaveOccurred()) + cmd, args := fakeExec.ExecuteArgsForCall(0) + Expect(cmd).To(Equal("multipath")) + Expect(args).To(Equal([]string{"-ll", "|", fmt.Sprintf(`egrep "[0-9]+:[0-9]+:[0-9]+:%d "`, volumeMountProperties.LunNumber)})) + + Expect(fakeInitiator.RemoveSCSIDeviceCallCount()).To(Equal(8)) + var a byte = 97 + for i := 0; i < 8; i++ { + expectDev := "/dev/sd" + string(a+byte(i)) + dev := fakeInitiator.RemoveSCSIDeviceArgsForCall(i) + Expect(dev).To(Equal(expectDev)) + } + }) }) - It("should remove all the scsi devices", func() { - err := fcConnector.DisconnectVolume(volumeMountProperties) - Ω(err).ShouldNot(HaveOccurred()) - cmd, args := fakeExec.ExecuteArgsForCall(0) - Expect(cmd).To(Equal("multipath")) - Expect(args).To(Equal([]string{"-ll", "|", fmt.Sprintf(`egrep "[0-9]+:[0-9]+:[0-9]+:%d "`, volumeMountProperties.LunNumber)})) - - Expect(fakeInitiator.RemoveSCSIDeviceCallCount()).To(Equal(8)) - var a byte = 97 - for i := 0; i < 8; i++ { - expectDev := "/dev/sd" + string(a+byte(i)) - dev := fakeInitiator.RemoveSCSIDeviceArgsForCall(i) - Expect(dev).To(Equal(expectDev)) - } + Context("remove lun 0", func() { + + BeforeEach(func() { + fakeExec.ExecuteReturns([]byte(fakeMpathOutputForLUN0), nil) + }) + + It("should remove all the scsi devices", func() { + err := fcConnector.DisconnectVolume(volumeMountProperties) + Ω(err).ShouldNot(HaveOccurred()) + cmd, args := fakeExec.ExecuteArgsForCall(0) + Expect(cmd).To(Equal("multipath")) + Expect(args).To(Equal([]string{"-ll", "|", fmt.Sprintf(`egrep "[0-9]+:[0-9]+:[0-9]+:%d "`, volumeMountProperties.LunNumber)})) + + Expect(fakeInitiator.RemoveSCSIDeviceCallCount()).To(Equal(8)) + var a byte = 97 + for i := 0; i < 8; i++ { + expectDev := "/dev/sd" + string(a+byte(i)) + dev := fakeInitiator.RemoveSCSIDeviceArgsForCall(i) + Expect(dev).To(Equal(expectDev)) + } + }) + }) + + Context("remove zlinux lun", func() { + + BeforeEach(func() { + fakeExec.ExecuteReturns([]byte(fakeMpathOutputForLUNZlinux), nil) + }) + + It("should remove all the scsi devices", func() { + err := fcConnector.DisconnectVolume(volumeMountProperties) + Ω(err).ShouldNot(HaveOccurred()) + cmd, args := fakeExec.ExecuteArgsForCall(0) + Expect(cmd).To(Equal("multipath")) + Expect(args).To(Equal([]string{"-ll", "|", fmt.Sprintf(`egrep "[0-9]+:[0-9]+:[0-9]+:%d "`, volumeMountProperties.LunNumber)})) + + Expect(fakeInitiator.RemoveSCSIDeviceCallCount()).To(Equal(8)) + var a byte = 97 + for i := 0; i < 8; i++ { + expectDev := "/dev/sd" + string(a+byte(i)) + dev := fakeInitiator.RemoveSCSIDeviceArgsForCall(i) + Expect(dev).To(Equal(expectDev)) + } + }) }) }) }) diff --git a/remote/mounter/initiator/linuxfc.go b/remote/mounter/initiator/linuxfc.go index 2b2c5a73..7ad2b561 100644 --- a/remote/mounter/initiator/linuxfc.go +++ b/remote/mounter/initiator/linuxfc.go @@ -11,6 +11,8 @@ import ( "github.com/IBM/ubiquity/utils/logs" ) +const SYSTOOL = "systool" + var FC_HOST_SYSFS_PATH = "/sys/class/fc_host" var SCSI_HOST_SYSFS_PATH = "/sys/class/scsi_host" @@ -61,13 +63,13 @@ func (lfc *linuxFibreChannel) GetHBAs() []string { return []string{} } - systool := "systool" - if err := lfc.exec.IsExecutable(systool); err != nil { + SYSTOOL := "systool" + if err := lfc.exec.IsExecutable(SYSTOOL); err != nil { lfc.logger.Warning(fmt.Sprintf("No systool installed, get from path %s instead.", FC_HOST_SYSFS_PATH)) return lfc.getFcHBAsByPath() } - out, err := lfc.exec.Execute(systool, []string{"-c", "fc_host", "-v"}) + out, err := lfc.exec.Execute(SYSTOOL, []string{"-c", "fc_host", "-v"}) if err != nil { lfc.logger.Warning(fmt.Sprintf("Executing systool failed with error: %v. Get from path %s instead.", err, FC_HOST_SYSFS_PATH)) return lfc.getFcHBAsByPath() diff --git a/remote/mounter/scbe.go b/remote/mounter/scbe.go index ae66841a..ed9e16d4 100644 --- a/remote/mounter/scbe.go +++ b/remote/mounter/scbe.go @@ -50,10 +50,11 @@ func NewScbeMounterWithExecuter(blockDeviceMounterUtils block_device_mounter_uti return newScbMounter(blockDeviceMounterUtils, executer) } -func (s *scbeMounter) prepareVolumeMountProperties(mountRequest resources.MountRequest) *resources.VolumeMountProperties { - volumeWWN := mountRequest.VolumeConfig["Wwn"].(string) +func (s *scbeMounter) prepareVolumeMountProperties(vcGetter resources.VolumeConfigGetter) *resources.VolumeMountProperties { + volumeConfig := vcGetter.GetVolumeConfig() + volumeWWN := volumeConfig["Wwn"].(string) volumeLunNumber := -1 - if volumeLunNumberInterface, exists := mountRequest.VolumeConfig[resources.ScbeKeyVolAttachLunNumToHost]; exists { + if volumeLunNumberInterface, exists := volumeConfig[resources.ScbeKeyVolAttachLunNumToHost]; exists { volumeLunNumber = volumeLunNumberInterface.(int) } return &resources.VolumeMountProperties{WWN: volumeWWN, LunNumber: volumeLunNumber} @@ -151,18 +152,9 @@ func (s *scbeMounter) Unmount(unmountRequest resources.UnmountRequest) error { } -func (s *scbeMounter) prepareVolumeActionAfterDetachProperties(request resources.AfterDetachRequest) *resources.VolumeMountProperties { - volumeWWN := request.VolumeConfig["Wwn"].(string) - volumeLunNumber := -1 - if volumeLunNumberInterface, exists := request.VolumeConfig[resources.ScbeKeyVolAttachLunNumToHost]; exists { - volumeLunNumber = volumeLunNumberInterface.(int) - } - return &resources.VolumeMountProperties{WWN: volumeWWN, LunNumber: volumeLunNumber} -} - func (s *scbeMounter) ActionAfterDetach(request resources.AfterDetachRequest) error { defer s.logger.Trace(logs.DEBUG)() - volumeMountProperties := s.prepareVolumeActionAfterDetachProperties(request) + volumeMountProperties := s.prepareVolumeMountProperties(request) // Disconnect volume if err := s.blockDeviceMounterUtils.DisconnectAll(volumeMountProperties); err != nil { diff --git a/resources/resources.go b/resources/resources.go index 8eb8ccd1..f6b55ff9 100644 --- a/resources/resources.go +++ b/resources/resources.go @@ -195,6 +195,10 @@ type Mounter interface { ActionAfterDetach(request AfterDetachRequest) error } +type VolumeConfigGetter interface { + GetVolumeConfig() map[string]interface{} +} + type ActivateRequest struct { CredentialInfo CredentialInfo Backends []string @@ -261,6 +265,12 @@ type MountRequest struct { Context RequestContext } +func (r *MountRequest) GetVolumeConfig() map[string]interface{} { + return r.VolumeConfig +} + +var _ VolumeConfigGetter = &MountRequest{} + type UnmountRequest struct { // TODO missing Mountpoint string VolumeConfig map[string]interface{} @@ -270,6 +280,13 @@ type AfterDetachRequest struct { VolumeConfig map[string]interface{} Context RequestContext } + +func (r *AfterDetachRequest) GetVolumeConfig() map[string]interface{} { + return r.VolumeConfig +} + +var _ VolumeConfigGetter = &AfterDetachRequest{} + type AttachResponse struct { Mountpoint string Err string From 5ed4bd7a788b00fba89e074907cadaceef43422e Mon Sep 17 00:00:00 2001 From: 27149chen <7991675+27149chen@users.noreply.github.com> Date: Wed, 27 Feb 2019 16:30:12 +0800 Subject: [PATCH 17/36] fixed a defect Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> --- remote/mounter/scbe.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/remote/mounter/scbe.go b/remote/mounter/scbe.go index ed9e16d4..a79cfb78 100644 --- a/remote/mounter/scbe.go +++ b/remote/mounter/scbe.go @@ -62,7 +62,7 @@ func (s *scbeMounter) prepareVolumeMountProperties(vcGetter resources.VolumeConf func (s *scbeMounter) Mount(mountRequest resources.MountRequest) (string, error) { defer s.logger.Trace(logs.DEBUG)() - volumeMountProperties := s.prepareVolumeMountProperties(mountRequest) + volumeMountProperties := s.prepareVolumeMountProperties(&mountRequest) // Rescan OS if err := s.blockDeviceMounterUtils.RescanAll(volumeMountProperties); err != nil { @@ -154,7 +154,7 @@ func (s *scbeMounter) Unmount(unmountRequest resources.UnmountRequest) error { func (s *scbeMounter) ActionAfterDetach(request resources.AfterDetachRequest) error { defer s.logger.Trace(logs.DEBUG)() - volumeMountProperties := s.prepareVolumeMountProperties(request) + volumeMountProperties := s.prepareVolumeMountProperties(&request) // Disconnect volume if err := s.blockDeviceMounterUtils.DisconnectAll(volumeMountProperties); err != nil { From b48a4a07ef26159d4301b9e7b061338292847995 Mon Sep 17 00:00:00 2001 From: 27149chen <7991675+27149chen@users.noreply.github.com> Date: Thu, 28 Feb 2019 21:42:03 +0800 Subject: [PATCH 18/36] change lunNumber from int to float64 Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> --- .../block_device_utils_mounter_test.go | 2 +- .../block_device_utils/block_device_utils_test.go | 2 +- remote/mounter/initiator/connectors/fibre_channel.go | 3 ++- .../initiator/connectors/fibre_channel_test.go | 8 ++++---- remote/mounter/initiator/linuxfc.go | 5 +++-- remote/mounter/initiator/linuxfc_test.go | 4 ++-- remote/mounter/scbe.go | 4 ++-- remote/mounter/scbe_test.go | 12 ++++++++---- resources/resources.go | 2 +- 9 files changed, 24 insertions(+), 18 deletions(-) diff --git a/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go b/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go index bcae89da..6285f8f0 100644 --- a/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go +++ b/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go @@ -37,7 +37,7 @@ var _ = Describe("block_device_mounter_utils_test", func() { err error callErr error = errors.New("error") ) - volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: 1} + volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: float64(1)} BeforeEach(func() { fakeBlockDeviceUtils = new(fakes.FakeBlockDeviceUtils) diff --git a/remote/mounter/block_device_utils/block_device_utils_test.go b/remote/mounter/block_device_utils/block_device_utils_test.go index afba946d..ed0d85c7 100644 --- a/remote/mounter/block_device_utils/block_device_utils_test.go +++ b/remote/mounter/block_device_utils/block_device_utils_test.go @@ -44,7 +44,7 @@ var _ = Describe("block_device_utils_test", func() { err error cmdErr error = errors.New("command error") ) - volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: 1} + volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: float64(1)} BeforeEach(func() { fakeExec = new(fakes.FakeExecutor) diff --git a/remote/mounter/initiator/connectors/fibre_channel.go b/remote/mounter/initiator/connectors/fibre_channel.go index eb2aa5a5..bd9a6364 100644 --- a/remote/mounter/initiator/connectors/fibre_channel.go +++ b/remote/mounter/initiator/connectors/fibre_channel.go @@ -84,7 +84,8 @@ func (c *fibreChannelConnector) findPathsFromMultipathOutpot(volumeMountProperti } lunNumber := volumeMountProperties.LunNumber - out, err := c.exec.Execute(multipath, []string{"-ll", "|", fmt.Sprintf(`egrep "[0-9]+:[0-9]+:[0-9]+:%d "`, lunNumber)}) + // use %g to print a float64 to int + out, err := c.exec.Execute(multipath, []string{"-ll", "|", fmt.Sprintf(`egrep "[0-9]+:[0-9]+:[0-9]+:%g "`, lunNumber)}) if err != nil { c.logger.Warning(fmt.Sprintf("Executing multipath failed with error: %v", err)) return []string{} diff --git a/remote/mounter/initiator/connectors/fibre_channel_test.go b/remote/mounter/initiator/connectors/fibre_channel_test.go index 60d95af1..bdd087c2 100644 --- a/remote/mounter/initiator/connectors/fibre_channel_test.go +++ b/remote/mounter/initiator/connectors/fibre_channel_test.go @@ -49,7 +49,7 @@ var _ = Describe("Test Fibre Channel Connector", func() { fakeInitiator *fakeinitiator.FakeInitiator fcConnector initiator.Connector ) - volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: 1} + volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: float64(1)} BeforeEach(func() { fakeExec = new(fakes.FakeExecutor) @@ -83,7 +83,7 @@ var _ = Describe("Test Fibre Channel Connector", func() { Ω(err).ShouldNot(HaveOccurred()) cmd, args := fakeExec.ExecuteArgsForCall(0) Expect(cmd).To(Equal("multipath")) - Expect(args).To(Equal([]string{"-ll", "|", fmt.Sprintf(`egrep "[0-9]+:[0-9]+:[0-9]+:%d "`, volumeMountProperties.LunNumber)})) + Expect(args).To(Equal([]string{"-ll", "|", fmt.Sprintf(`egrep "[0-9]+:[0-9]+:[0-9]+:%g "`, volumeMountProperties.LunNumber)})) Expect(fakeInitiator.RemoveSCSIDeviceCallCount()).To(Equal(8)) var a byte = 97 @@ -106,7 +106,7 @@ var _ = Describe("Test Fibre Channel Connector", func() { Ω(err).ShouldNot(HaveOccurred()) cmd, args := fakeExec.ExecuteArgsForCall(0) Expect(cmd).To(Equal("multipath")) - Expect(args).To(Equal([]string{"-ll", "|", fmt.Sprintf(`egrep "[0-9]+:[0-9]+:[0-9]+:%d "`, volumeMountProperties.LunNumber)})) + Expect(args).To(Equal([]string{"-ll", "|", fmt.Sprintf(`egrep "[0-9]+:[0-9]+:[0-9]+:%g "`, volumeMountProperties.LunNumber)})) Expect(fakeInitiator.RemoveSCSIDeviceCallCount()).To(Equal(8)) var a byte = 97 @@ -129,7 +129,7 @@ var _ = Describe("Test Fibre Channel Connector", func() { Ω(err).ShouldNot(HaveOccurred()) cmd, args := fakeExec.ExecuteArgsForCall(0) Expect(cmd).To(Equal("multipath")) - Expect(args).To(Equal([]string{"-ll", "|", fmt.Sprintf(`egrep "[0-9]+:[0-9]+:[0-9]+:%d "`, volumeMountProperties.LunNumber)})) + Expect(args).To(Equal([]string{"-ll", "|", fmt.Sprintf(`egrep "[0-9]+:[0-9]+:[0-9]+:%g "`, volumeMountProperties.LunNumber)})) Expect(fakeInitiator.RemoveSCSIDeviceCallCount()).To(Equal(8)) var a byte = 97 diff --git a/remote/mounter/initiator/linuxfc.go b/remote/mounter/initiator/linuxfc.go index 7ad2b561..17ad19ce 100644 --- a/remote/mounter/initiator/linuxfc.go +++ b/remote/mounter/initiator/linuxfc.go @@ -51,10 +51,11 @@ func (lfc *linuxFibreChannel) hasFCSupport() bool { // may be '-' wildcards if unable to determine them. func (lfc *linuxFibreChannel) getHBAChannelScsiTarget(volumeMountProperties *resources.VolumeMountProperties) string { //TODO: get channel and target - if volumeMountProperties.LunNumber == -1 { + if volumeMountProperties.LunNumber == float64(-1) { return "- - -" } - return fmt.Sprintf("- - %d", volumeMountProperties.LunNumber) + // use %g to print a float64 to int + return fmt.Sprintf("- - %g", volumeMountProperties.LunNumber) } // GetHBAs return all the FC HBAs in the system diff --git a/remote/mounter/initiator/linuxfc_test.go b/remote/mounter/initiator/linuxfc_test.go index d1ae4267..fc962094 100644 --- a/remote/mounter/initiator/linuxfc_test.go +++ b/remote/mounter/initiator/linuxfc_test.go @@ -83,7 +83,7 @@ var _ = Describe("Test FC Initiator", func() { realSysBlockPath string cmdErr error = errors.New("command error") ) - volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: 1} + volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: float64(1)} BeforeEach(func() { err := os.MkdirAll(FAKE_FC_HOST_SYSFS_PATH, os.ModePerm) @@ -171,7 +171,7 @@ var _ = Describe("Test FC Initiator", func() { Ω(err).ShouldNot(HaveOccurred()) data, err := ioutil.ReadFile(scanFile) Ω(err).ShouldNot(HaveOccurred()) - Expect(string(data)).To(Equal(fmt.Sprintf("- - %d", volumeMountProperties.LunNumber))) + Expect(string(data)).To(Equal(fmt.Sprintf("- - %g", volumeMountProperties.LunNumber))) }) }) diff --git a/remote/mounter/scbe.go b/remote/mounter/scbe.go index a79cfb78..ff822160 100644 --- a/remote/mounter/scbe.go +++ b/remote/mounter/scbe.go @@ -53,9 +53,9 @@ func NewScbeMounterWithExecuter(blockDeviceMounterUtils block_device_mounter_uti func (s *scbeMounter) prepareVolumeMountProperties(vcGetter resources.VolumeConfigGetter) *resources.VolumeMountProperties { volumeConfig := vcGetter.GetVolumeConfig() volumeWWN := volumeConfig["Wwn"].(string) - volumeLunNumber := -1 + volumeLunNumber := float64(-1) if volumeLunNumberInterface, exists := volumeConfig[resources.ScbeKeyVolAttachLunNumToHost]; exists { - volumeLunNumber = volumeLunNumberInterface.(int) + volumeLunNumber = volumeLunNumberInterface.(float64) } return &resources.VolumeMountProperties{WWN: volumeWWN, LunNumber: volumeLunNumber} } diff --git a/remote/mounter/scbe_test.go b/remote/mounter/scbe_test.go index 4f619917..5e833702 100644 --- a/remote/mounter/scbe_test.go +++ b/remote/mounter/scbe_test.go @@ -34,13 +34,13 @@ var _ = Describe("scbe_mounter_test", func() { mountRequestForDS8kLun1 = resources.MountRequest{Mountpoint: "test_mountpointDS8k", VolumeConfig: map[string]interface{}{"Name": "u_vol", "PhysicalCapacity": fakePhysicalCapacity, "Profile": fakeProfile, "StorageType": fakeDS8kStoragetType, "UsedCapacity": fakeUsedCapacity, "Wwn": "wwn", "attach-to": "node1", - "LogicalCapacity": fakeLogicalCapacity, "LunNumber": 1, "PoolName": "pool", "StorageName": "IBM.2107", "fstype": "ext4"}} + "LogicalCapacity": fakeLogicalCapacity, "LunNumber": float64(1), "PoolName": "pool", "StorageName": "IBM.2107", "fstype": "ext4"}} mountRequestForSVCLun1 = resources.MountRequest{Mountpoint: "test_mountpointSVC", VolumeConfig: map[string]interface{}{"Name": "u_vol", "PhysicalCapacity": fakePhysicalCapacity, "Profile": fakeProfile, "StorageType": fakeV7kStorageType, "UsedCapacity": fakeUsedCapacity, "Wwn": "wwn", "attach-to": "node1", - "LogicalCapacity": fakeLogicalCapacity, "LunNumber": 1, "PoolName": "pool", "StorageName": "IBM.2706", "fstype": "ext4"}} + "LogicalCapacity": fakeLogicalCapacity, "LunNumber": float64(1), "PoolName": "pool", "StorageName": "IBM.2706", "fstype": "ext4"}} mountRequestForDS8kLun2 = resources.MountRequest{Mountpoint: "test_mountpointDS8k", VolumeConfig: map[string]interface{}{"Name": "u_vol", "PhysicalCapacity": fakePhysicalCapacity, "Profile": fakeProfile, "UsedCapacity": fakeUsedCapacity, "Wwn": "wwn", "attach-to": "node1", - "LogicalCapacity": fakeLogicalCapacity, "LunNumber": 1, "PoolName": "pool", "StorageName": "IBM.2107", "fstype": "ext4"}} + "LogicalCapacity": fakeLogicalCapacity, "LunNumber": float64(1), "PoolName": "pool", "StorageName": "IBM.2107", "fstype": "ext4"}} mountRequestForDS8kLun3 = resources.MountRequest{Mountpoint: "test_mountpointDS8k", VolumeConfig: map[string]interface{}{"Name": "u_vol", "PhysicalCapacity": fakePhysicalCapacity, "Profile": fakeProfile, "StorageType": fakeDS8kStoragetType, "UsedCapacity": fakeUsedCapacity, "Wwn": "wwn", "attach-to": "node1", "LogicalCapacity": fakeLogicalCapacity, "PoolName": "pool", "StorageName": "IBM.2107", "fstype": "ext4"}} @@ -153,6 +153,10 @@ var _ = Describe("scbe_mounter_test", func() { }) }) Context("Mount", func() { + FIt("should be true to discover ", func() { + _, err := scbeMounter.Mount(mountRequestForDS8kLun1) + Expect(err).NotTo(HaveOccurred()) + }) It("should fail to discover ds8k with lun1 if failed to discover with '-r' ", func() { fakeBdUtils.DiscoverReturns("", callErr) fakeBdUtils.RescanAllReturns(nil) @@ -186,7 +190,7 @@ var _ = Describe("scbe_mounter_test", func() { }) Context("ActionAfterDetach", func() { It("should call DisconnectAll ", func() { - req := resources.AfterDetachRequest{VolumeConfig: map[string]interface{}{"Wwn": "wwn", "LunNumber": 1}} + req := resources.AfterDetachRequest{VolumeConfig: map[string]interface{}{"Wwn": "wwn", "LunNumber": float64(1)}} err := scbeMounter.ActionAfterDetach(req) Expect(err).NotTo(HaveOccurred()) Expect(fakeBdUtils.DisconnectAllCallCount()).To(Equal(1)) diff --git a/resources/resources.go b/resources/resources.go index f6b55ff9..24187e38 100644 --- a/resources/resources.go +++ b/resources/resources.go @@ -358,5 +358,5 @@ type RequestContext struct { type VolumeMountProperties struct { WWN string - LunNumber int + LunNumber float64 } From 857dcc40dca5e72fa8eaddb0a2ecb89f2ba14b3f Mon Sep 17 00:00:00 2001 From: 27149chen <7991675+27149chen@users.noreply.github.com> Date: Fri, 1 Mar 2019 20:46:30 +0800 Subject: [PATCH 19/36] rewrite the method of getting devices from multipath output Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> --- remote/mounter/block_device_utils/mpath.go | 30 +---- remote/mounter/block_device_utils/rescan.go | 3 +- .../initiator/connectors/fibre_channel.go | 69 +++------- .../connectors/fibre_channel_test.go | 125 ++++-------------- .../initiator/fakes/fake_base_initiator.go | 38 ++++++ .../mounter/initiator/fakes/fake_initiator.go | 38 ++++++ remote/mounter/initiator/linuxfc_test.go | 15 +++ remote/mounter/initiator/linuxscsi.go | 19 +++ remote/mounter/initiator/resources.go | 1 + utils/error.go | 9 ++ utils/mpath.go | 81 ++++++++++++ utils/mpath_test.go | 59 +++++++++ 12 files changed, 308 insertions(+), 179 deletions(-) create mode 100644 utils/mpath.go create mode 100644 utils/mpath_test.go diff --git a/remote/mounter/block_device_utils/mpath.go b/remote/mounter/block_device_utils/mpath.go index 51a0329c..381cd514 100644 --- a/remote/mounter/block_device_utils/mpath.go +++ b/remote/mounter/block_device_utils/mpath.go @@ -24,6 +24,7 @@ import ( "regexp" "strings" + "github.com/IBM/ubiquity/utils" "github.com/IBM/ubiquity/utils/logs" ) @@ -54,37 +55,10 @@ func (b *blockDeviceUtils) ReloadMultipath() error { return nil } -// getMultipathOutputAndDeviceUid runs "multipath -ll" and analysises the output to find the device uid -// and then return both the output and the uid. -func (b *blockDeviceUtils) getMultipathOutputAndDeviceUid(volumeWwn string) ([]byte, string, error) { - if err := b.exec.IsExecutable(multipathCmd); err != nil { - return []byte{}, "", b.logger.ErrorRet(&commandNotFoundError{multipathCmd, err}, "failed") - } - args := []string{"-ll"} - outputBytes, err := b.exec.ExecuteWithTimeout(DiscoverTimeout, multipathCmd, args) - if err != nil { - return []byte{}, "", b.logger.ErrorRet(&CommandExecuteError{multipathCmd, err}, "failed") - } - scanner := bufio.NewScanner(strings.NewReader(string(outputBytes[:]))) - pattern := "(?i)" + volumeWwn - regex, err := regexp.Compile(pattern) - if err != nil { - return []byte{}, "", b.logger.ErrorRet(err, "failed") - } - dev := "" - for scanner.Scan() { - if regex.MatchString(scanner.Text()) { - dev = strings.Split(scanner.Text(), " ")[0] - break - } - } - return outputBytes, dev, nil -} - func (b *blockDeviceUtils) Discover(volumeWwn string, deepDiscovery bool) (string, error) { defer b.logger.Trace(logs.DEBUG, logs.Args{{"volumeWwn", volumeWwn}, {"deepDiscovery", deepDiscovery}})() - outputBytes, dev, err := b.getMultipathOutputAndDeviceUid(volumeWwn) + outputBytes, dev, _, err := utils.GetMultipathOutputAndDeviceMapperAndDevice(volumeWwn, b.exec) if err != nil { return "", err } diff --git a/remote/mounter/block_device_utils/rescan.go b/remote/mounter/block_device_utils/rescan.go index d4ec08a9..85f00696 100644 --- a/remote/mounter/block_device_utils/rescan.go +++ b/remote/mounter/block_device_utils/rescan.go @@ -21,6 +21,7 @@ import ( "time" "github.com/IBM/ubiquity/resources" + "github.com/IBM/ubiquity/utils" "github.com/IBM/ubiquity/utils/logs" ) @@ -87,7 +88,7 @@ func (b *blockDeviceUtils) RescanSCSI(volumeMountProperties *resources.VolumeMou if err = b.fcConnector.ConnectVolume(volumeMountProperties); err != nil { return b.logger.ErrorRet(err, "RescanSCSI failed", logs.Args{{"volumeWWN", volumeMountProperties.WWN}}) } - if _, _, err = b.getMultipathOutputAndDeviceUid(volumeMountProperties.WWN); err == nil { + if _, _, _, err = utils.GetMultipathOutputAndDeviceMapperAndDevice(volumeMountProperties.WWN, b.exec); err == nil { return nil } b.logger.Warning("Can't find the new volume in multipath output after rescan, sleep one second and try again.") diff --git a/remote/mounter/initiator/connectors/fibre_channel.go b/remote/mounter/initiator/connectors/fibre_channel.go index bd9a6364..0c5449f9 100644 --- a/remote/mounter/initiator/connectors/fibre_channel.go +++ b/remote/mounter/initiator/connectors/fibre_channel.go @@ -2,7 +2,6 @@ package connectors import ( "fmt" - "strings" "github.com/IBM/ubiquity/remote/mounter/initiator" "github.com/IBM/ubiquity/resources" @@ -56,14 +55,26 @@ func (c *fibreChannelConnector) ConnectVolume(volumeMountProperties *resources.V // DisconnectVolume removes a volume from host by echo "1" to all scsi device's /delete func (c *fibreChannelConnector) DisconnectVolume(volumeMountProperties *resources.VolumeMountProperties) error { devices := []string{} - paths := c.findPathsFromMultipathOutpot(volumeMountProperties) - for _, path := range paths { - device := fmt.Sprintf("/dev/%s", path) + _, _, devNames, err := utils.GetMultipathOutputAndDeviceMapperAndDevice(volumeMountProperties.WWN, c.exec) + if err != nil { + return c.logger.ErrorRet(err, "Failed to get multipath output before disconnecting volume") + } + for _, devName := range devNames { + device := fmt.Sprintf("/dev/%s", devName) devices = append(devices, device) } c.logger.Debug("Remove devices", logs.Args{{"names", devices}}) - return c.removeDevices(devices) + err = c.removeDevices(devices) + if err != nil { + return c.logger.ErrorRet(err, "Failed to remove devices") + } + + if _, devMapper, _, _ := utils.GetMultipathOutputAndDeviceMapperAndDevice(volumeMountProperties.WWN, c.exec); devMapper != "" { + // flush multipath if device still exists after disconnection + c.linuxfc.FlushMultipath(devMapper) + } + return nil } func (c *fibreChannelConnector) removeDevices(devices []string) error { @@ -74,51 +85,3 @@ func (c *fibreChannelConnector) removeDevices(devices []string) error { } return err } - -// TODO: it is not a good idea to find device paths in this way, try to improve it. -func (c *fibreChannelConnector) findPathsFromMultipathOutpot(volumeMountProperties *resources.VolumeMountProperties) []string { - multipath := "multipath" - if err := c.exec.IsExecutable(multipath); err != nil { - c.logger.Warning("No multipath installed.") - return []string{} - } - - lunNumber := volumeMountProperties.LunNumber - // use %g to print a float64 to int - out, err := c.exec.Execute(multipath, []string{"-ll", "|", fmt.Sprintf(`egrep "[0-9]+:[0-9]+:[0-9]+:%g "`, lunNumber)}) - if err != nil { - c.logger.Warning(fmt.Sprintf("Executing multipath failed with error: %v", err)) - return []string{} - } - return generatePathsFromMultipathOutput(out) -} - -/* -generatePathsFromMultipathOutput analysises the output of command "multipath -ll | egrep '[0-9]+:[0-9]+:[0-9]+lunNumber '", -and generates a list of path. - -A sample output is: - |- 0:0:4:255 sda 8:0 active ready running - |- 0:0:5:255 sdb 8:16 active ready running - |- 0:0:6:255 sdc 8:32 active ready running - |- 0:0:7:255 sdd 8:48 active ready running - |- 1:0:4:255 sde 8:64 active ready running - |- 1:0:5:255 sdf 8:80 active ready running - |- 1:0:6:255 sdg 8:96 active ready running - `- 1:0:7:255 sdh 8:112 active ready running -*/ -func generatePathsFromMultipathOutput(out []byte) []string { - lines := strings.Split(string(out), "\n") - paths := []string{} - for _, line := range lines { - line = strings.TrimSpace(line) - if line == "" { - continue - } - path := strings.Split(line, " ")[2] - if strings.HasPrefix(path, "sd") { - paths = append(paths, path) - } - } - return paths -} diff --git a/remote/mounter/initiator/connectors/fibre_channel_test.go b/remote/mounter/initiator/connectors/fibre_channel_test.go index bdd087c2..aa74f0cb 100644 --- a/remote/mounter/initiator/connectors/fibre_channel_test.go +++ b/remote/mounter/initiator/connectors/fibre_channel_test.go @@ -1,8 +1,6 @@ package connectors_test import ( - "fmt" - . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -13,35 +11,21 @@ import ( "github.com/IBM/ubiquity/resources" ) -var fakeMpathOutputForLUN255 = ` - |- 0:0:4:255 sda 8:0 active ready running - |- 0:0:5:255 sdb 8:16 active ready running - |- 0:0:6:255 sdc 8:32 active ready running - |- 0:0:7:255 sdd 8:48 active ready running - |- 1:0:4:255 sde 8:64 active ready running - |- 1:0:5:255 sdf 8:80 active ready running - |- 1:0:6:255 sdg 8:96 active ready running - ` + "`- 1:0:7:255 sdh 8:112 active ready running\n" - -var fakeMpathOutputForLUN0 = ` - |- 0:0:4:0 sda 8:0 active ready running - |- 0:0:5:0 sdb 8:16 active ready running - |- 0:0:6:0 sdc 8:32 active ready running - |- 0:0:7:0 sdd 8:48 active ready running - |- 1:0:4:0 sde 8:64 active ready running - |- 1:0:5:0 sdf 8:80 active ready running - |- 1:0:6:0 sdg 8:96 active ready running - ` + "`- 1:0:7:0 sdh 8:112 active ready running\n" - -var fakeMpathOutputForLUNZlinux = ` - |- 0:0:4:1076248592 sda 8:0 active ready running - |- 0:0:5:1076248592 sdb 8:16 active ready running - |- 0:0:6:1076248592 sdc 8:32 active ready running - |- 0:0:7:1076248592 sdd 8:48 active ready running - |- 1:0:4:1076248592 sde 8:64 active ready running - |- 1:0:5:1076248592 sdf 8:80 active ready running - |- 1:0:6:1076248592 sdg 8:96 active ready running - ` + "`- 1:0:7:1076248592 sdh 8:112 active ready running\n" +var fakeWwn = "6005076306ffd69d0000000000001004" + +var fakeMultipathOutput = ` +mpathg (36005076306ffd69d0000000000001004) dm-14 IBM ,2107900 +size=1.0G features='1 queue_if_no_path' hwhandler='0' wp=rw +` + "`-+- policy='service-time 0' prio=1 status=active" + ` + |- 29:0:1:1 sda 8:64 active ready running + |- 29:0:6:1 sdb 8:80 active ready running + ` + "`- 29:0:7:1 sdc 8:96 active ready running" + ` +mpathf (36005076306ffd69d000000000000010a) dm-2 IBM ,2107900 +size=2.0G features='1 queue_if_no_path' hwhandler='0' wp=rw +` + "`-+- policy='service-time 0' prio=1 status=enabled" + ` + |- 29:0:1:0 sdb 8:16 active ready running + |- 29:0:6:0 sdc 8:32 active ready running + ` + "`- 29:0:7:0 sdd 8:48 active ready running\n" var _ = Describe("Test Fibre Channel Connector", func() { var ( @@ -49,7 +33,7 @@ var _ = Describe("Test Fibre Channel Connector", func() { fakeInitiator *fakeinitiator.FakeInitiator fcConnector initiator.Connector ) - volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: float64(1)} + volumeMountProperties := &resources.VolumeMountProperties{WWN: fakeWwn, LunNumber: float64(1)} BeforeEach(func() { fakeExec = new(fakes.FakeExecutor) @@ -72,73 +56,20 @@ var _ = Describe("Test Fibre Channel Connector", func() { Context("DisconnectVolume", func() { - Context("remove lun 255", func() { - - BeforeEach(func() { - fakeExec.ExecuteReturns([]byte(fakeMpathOutputForLUN255), nil) - }) - - It("should remove all the scsi devices", func() { - err := fcConnector.DisconnectVolume(volumeMountProperties) - Ω(err).ShouldNot(HaveOccurred()) - cmd, args := fakeExec.ExecuteArgsForCall(0) - Expect(cmd).To(Equal("multipath")) - Expect(args).To(Equal([]string{"-ll", "|", fmt.Sprintf(`egrep "[0-9]+:[0-9]+:[0-9]+:%g "`, volumeMountProperties.LunNumber)})) - - Expect(fakeInitiator.RemoveSCSIDeviceCallCount()).To(Equal(8)) - var a byte = 97 - for i := 0; i < 8; i++ { - expectDev := "/dev/sd" + string(a+byte(i)) - dev := fakeInitiator.RemoveSCSIDeviceArgsForCall(i) - Expect(dev).To(Equal(expectDev)) - } - }) - }) - - Context("remove lun 0", func() { - - BeforeEach(func() { - fakeExec.ExecuteReturns([]byte(fakeMpathOutputForLUN0), nil) - }) - - It("should remove all the scsi devices", func() { - err := fcConnector.DisconnectVolume(volumeMountProperties) - Ω(err).ShouldNot(HaveOccurred()) - cmd, args := fakeExec.ExecuteArgsForCall(0) - Expect(cmd).To(Equal("multipath")) - Expect(args).To(Equal([]string{"-ll", "|", fmt.Sprintf(`egrep "[0-9]+:[0-9]+:[0-9]+:%g "`, volumeMountProperties.LunNumber)})) - - Expect(fakeInitiator.RemoveSCSIDeviceCallCount()).To(Equal(8)) - var a byte = 97 - for i := 0; i < 8; i++ { - expectDev := "/dev/sd" + string(a+byte(i)) - dev := fakeInitiator.RemoveSCSIDeviceArgsForCall(i) - Expect(dev).To(Equal(expectDev)) - } - }) + BeforeEach(func() { + fakeExec.ExecuteWithTimeoutReturns([]byte(fakeMultipathOutput), nil) }) - Context("remove zlinux lun", func() { - - BeforeEach(func() { - fakeExec.ExecuteReturns([]byte(fakeMpathOutputForLUNZlinux), nil) - }) - - It("should remove all the scsi devices", func() { - err := fcConnector.DisconnectVolume(volumeMountProperties) - Ω(err).ShouldNot(HaveOccurred()) - cmd, args := fakeExec.ExecuteArgsForCall(0) - Expect(cmd).To(Equal("multipath")) - Expect(args).To(Equal([]string{"-ll", "|", fmt.Sprintf(`egrep "[0-9]+:[0-9]+:[0-9]+:%g "`, volumeMountProperties.LunNumber)})) - - Expect(fakeInitiator.RemoveSCSIDeviceCallCount()).To(Equal(8)) - var a byte = 97 - for i := 0; i < 8; i++ { - expectDev := "/dev/sd" + string(a+byte(i)) - dev := fakeInitiator.RemoveSCSIDeviceArgsForCall(i) - Expect(dev).To(Equal(expectDev)) - } - }) + It("should remove all the scsi devices", func() { + err := fcConnector.DisconnectVolume(volumeMountProperties) + Ω(err).ShouldNot(HaveOccurred()) + Expect(fakeInitiator.RemoveSCSIDeviceCallCount()).To(Equal(3)) + var a byte = 97 + for i := 0; i < 3; i++ { + expectDev := "/dev/sd" + string(a+byte(i)) + dev := fakeInitiator.RemoveSCSIDeviceArgsForCall(i) + Expect(dev).To(Equal(expectDev)) + } }) }) }) diff --git a/remote/mounter/initiator/fakes/fake_base_initiator.go b/remote/mounter/initiator/fakes/fake_base_initiator.go index 4ff0a578..e2fe9801 100644 --- a/remote/mounter/initiator/fakes/fake_base_initiator.go +++ b/remote/mounter/initiator/fakes/fake_base_initiator.go @@ -8,6 +8,11 @@ import ( ) type FakeBaseInitiator struct { + FlushMultipathStub func(string) + flushMultipathMutex sync.RWMutex + flushMultipathArgsForCall []struct { + arg1 string + } RemoveSCSIDeviceStub func(string) error removeSCSIDeviceMutex sync.RWMutex removeSCSIDeviceArgsForCall []struct { @@ -23,6 +28,37 @@ type FakeBaseInitiator struct { invocationsMutex sync.RWMutex } +func (fake *FakeBaseInitiator) FlushMultipath(arg1 string) { + fake.flushMultipathMutex.Lock() + fake.flushMultipathArgsForCall = append(fake.flushMultipathArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("FlushMultipath", []interface{}{arg1}) + fake.flushMultipathMutex.Unlock() + if fake.FlushMultipathStub != nil { + fake.FlushMultipathStub(arg1) + } +} + +func (fake *FakeBaseInitiator) FlushMultipathCallCount() int { + fake.flushMultipathMutex.RLock() + defer fake.flushMultipathMutex.RUnlock() + return len(fake.flushMultipathArgsForCall) +} + +func (fake *FakeBaseInitiator) FlushMultipathCalls(stub func(string)) { + fake.flushMultipathMutex.Lock() + defer fake.flushMultipathMutex.Unlock() + fake.FlushMultipathStub = stub +} + +func (fake *FakeBaseInitiator) FlushMultipathArgsForCall(i int) string { + fake.flushMultipathMutex.RLock() + defer fake.flushMultipathMutex.RUnlock() + argsForCall := fake.flushMultipathArgsForCall[i] + return argsForCall.arg1 +} + func (fake *FakeBaseInitiator) RemoveSCSIDevice(arg1 string) error { fake.removeSCSIDeviceMutex.Lock() ret, specificReturn := fake.removeSCSIDeviceReturnsOnCall[len(fake.removeSCSIDeviceArgsForCall)] @@ -86,6 +122,8 @@ func (fake *FakeBaseInitiator) RemoveSCSIDeviceReturnsOnCall(i int, result1 erro func (fake *FakeBaseInitiator) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() + fake.flushMultipathMutex.RLock() + defer fake.flushMultipathMutex.RUnlock() fake.removeSCSIDeviceMutex.RLock() defer fake.removeSCSIDeviceMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} diff --git a/remote/mounter/initiator/fakes/fake_initiator.go b/remote/mounter/initiator/fakes/fake_initiator.go index 227155ad..acf074ef 100644 --- a/remote/mounter/initiator/fakes/fake_initiator.go +++ b/remote/mounter/initiator/fakes/fake_initiator.go @@ -9,6 +9,11 @@ import ( ) type FakeInitiator struct { + FlushMultipathStub func(string) + flushMultipathMutex sync.RWMutex + flushMultipathArgsForCall []struct { + arg1 string + } GetHBAsStub func() []string getHBAsMutex sync.RWMutex getHBAsArgsForCall []struct { @@ -46,6 +51,37 @@ type FakeInitiator struct { invocationsMutex sync.RWMutex } +func (fake *FakeInitiator) FlushMultipath(arg1 string) { + fake.flushMultipathMutex.Lock() + fake.flushMultipathArgsForCall = append(fake.flushMultipathArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("FlushMultipath", []interface{}{arg1}) + fake.flushMultipathMutex.Unlock() + if fake.FlushMultipathStub != nil { + fake.FlushMultipathStub(arg1) + } +} + +func (fake *FakeInitiator) FlushMultipathCallCount() int { + fake.flushMultipathMutex.RLock() + defer fake.flushMultipathMutex.RUnlock() + return len(fake.flushMultipathArgsForCall) +} + +func (fake *FakeInitiator) FlushMultipathCalls(stub func(string)) { + fake.flushMultipathMutex.Lock() + defer fake.flushMultipathMutex.Unlock() + fake.FlushMultipathStub = stub +} + +func (fake *FakeInitiator) FlushMultipathArgsForCall(i int) string { + fake.flushMultipathMutex.RLock() + defer fake.flushMultipathMutex.RUnlock() + argsForCall := fake.flushMultipathArgsForCall[i] + return argsForCall.arg1 +} + func (fake *FakeInitiator) GetHBAs() []string { fake.getHBAsMutex.Lock() ret, specificReturn := fake.getHBAsReturnsOnCall[len(fake.getHBAsArgsForCall)] @@ -227,6 +263,8 @@ func (fake *FakeInitiator) RescanHostsReturnsOnCall(i int, result1 error) { func (fake *FakeInitiator) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() + fake.flushMultipathMutex.RLock() + defer fake.flushMultipathMutex.RUnlock() fake.getHBAsMutex.RLock() defer fake.getHBAsMutex.RUnlock() fake.removeSCSIDeviceMutex.RLock() diff --git a/remote/mounter/initiator/linuxfc_test.go b/remote/mounter/initiator/linuxfc_test.go index fc962094..f3b72e23 100644 --- a/remote/mounter/initiator/linuxfc_test.go +++ b/remote/mounter/initiator/linuxfc_test.go @@ -196,4 +196,19 @@ var _ = Describe("Test FC Initiator", func() { Expect(string(data)).To(Equal("1")) }) }) + + Context("FlushMultipath", func() { + + It("should flush once if succeeds", func() { + fakeExec.ExecuteWithTimeoutReturns([]byte{}, nil) + fcInitiator.FlushMultipath("fake") + Expect(fakeExec.ExecuteWithTimeoutCallCount()).To(Equal(1)) + }) + + It("should flush twice if fails", func() { + fakeExec.ExecuteWithTimeoutReturns([]byte{}, cmdErr) + fcInitiator.FlushMultipath("fake") + Expect(fakeExec.ExecuteWithTimeoutCallCount()).To(Equal(2)) + }) + }) }) diff --git a/remote/mounter/initiator/linuxscsi.go b/remote/mounter/initiator/linuxscsi.go index fc94f0fc..b335b41b 100644 --- a/remote/mounter/initiator/linuxscsi.go +++ b/remote/mounter/initiator/linuxscsi.go @@ -10,6 +10,9 @@ import ( "github.com/IBM/ubiquity/utils/logs" ) +const multipathCmd = "multipath" +const FlushTimeout = 10 * 1000 + var SYS_BLOCK_PATH = "/sys/block" type linuxSCSI struct { @@ -17,6 +20,22 @@ type linuxSCSI struct { logger logs.Logger } +// FlushMultipath flushes the device, if it is failed becasue of device in use, retry again. +func (ls *linuxSCSI) FlushMultipath(deviceMapName string) { + if err := ls.exec.IsExecutable(multipathCmd); err != nil { + return + } + + for i := 0; i < 2; i++ { + args := []string{"-f", deviceMapName} + ls.logger.Info(fmt.Sprintf("Flush multipath by running: multipath -f %s", deviceMapName)) + _, err := ls.exec.ExecuteWithTimeout(FlushTimeout, multipathCmd, args) + if err == nil { + return + } + } +} + // RemoveSCSIDevice removes a scsi device based upon /dev/sdX name. func (ls *linuxSCSI) RemoveSCSIDevice(device string) error { deviceName := strings.Replace(device, "/dev/", "", 1) diff --git a/remote/mounter/initiator/resources.go b/remote/mounter/initiator/resources.go index a4da4811..83f53a77 100644 --- a/remote/mounter/initiator/resources.go +++ b/remote/mounter/initiator/resources.go @@ -5,6 +5,7 @@ import "github.com/IBM/ubiquity/resources" //go:generate counterfeiter -o fakes/fake_base_initiator.go . BaseInitiator type BaseInitiator interface { RemoveSCSIDevice(device string) error + FlushMultipath(deviceMapName string) } //go:generate counterfeiter -o fakes/fake_initiator.go . Initiator diff --git a/utils/error.go b/utils/error.go index 0b5bfbd3..eb5a71e7 100644 --- a/utils/error.go +++ b/utils/error.go @@ -36,3 +36,12 @@ type CommandExecuteError struct { func (e *CommandExecuteError) Error() string { return fmt.Sprintf("command [%v] execution failure [%v]", e.Cmd, e.Err) } + +type CommandNotFoundError struct { + Cmd string + Err error +} + +func (e *CommandNotFoundError) Error() string { + return fmt.Sprintf("command [%v] is not found [%v]", e.Cmd, e.Err) +} diff --git a/utils/mpath.go b/utils/mpath.go new file mode 100644 index 00000000..7e8ee448 --- /dev/null +++ b/utils/mpath.go @@ -0,0 +1,81 @@ +package utils + +import ( + "bufio" + "regexp" + "strings" +) + +const multipathCmd = "multipath" +const MultipathTimeout = 10 * 1000 + +/* +GetMultipathOutputAndDeviceMapperAndDevice analysises the output of command "multipath -ll", +and find the device mapper and device names according to the given WWN. + +For example: +Input: +6005076306ffd69d0000000000001004 + +Multipath output: +mpathg (36005076306ffd69d0000000000001004) dm-14 IBM ,2107900 +size=1.0G features='1 queue_if_no_path' hwhandler='0' wp=rw +`-+- policy='service-time 0' prio=1 status=active + |- 29:0:1:1 sde 8:64 active ready running + |- 29:0:6:1 sdf 8:80 active ready running + `- 29:0:7:1 sdg 8:96 active ready running +mpathf (36005076306ffd69d000000000000010a) dm-2 IBM ,2107900 +size=2.0G features='1 queue_if_no_path' hwhandler='0' wp=rw +`-+- policy='service-time 0' prio=1 status=enabled + |- 29:0:1:0 sdb 8:16 active ready running + |- 29:0:6:0 sdc 8:32 active ready running + `- 29:0:7:0 sdd 8:48 active ready running + +Output: +fullOutput, mpathg, [sde, sdf, sdg], nil +*/ +func GetMultipathOutputAndDeviceMapperAndDevice(volumeWwn string, exec Executor) ([]byte, string, []string, error) { + if err := exec.IsExecutable(multipathCmd); err != nil { + return []byte{}, "", []string{}, &CommandNotFoundError{multipathCmd, err} + } + args := []string{"-ll"} + outputBytes, err := exec.ExecuteWithTimeout(MultipathTimeout, multipathCmd, args) + if err != nil { + return []byte{}, "", []string{}, &CommandExecuteError{multipathCmd, err} + } + scanner := bufio.NewScanner(strings.NewReader(string(outputBytes[:]))) + headerPattern := "(?i)" + volumeWwn + headerRegex, err := regexp.Compile(headerPattern) + if err != nil { + return []byte{}, "", []string{}, err + } + bodyPattern := "[0-9]+:[0-9]+:[0-9]+:[0-9]+ " + bodyRegex, err := regexp.Compile(bodyPattern) + if err != nil { + return []byte{}, "", []string{}, err + } + devMapper := "" + for scanner.Scan() { + if headerRegex.MatchString(scanner.Text()) { + devMapper = strings.Split(scanner.Text(), " ")[0] + break + } + } + deviceNames := []string{} + if devMapper != "" { + // skip next two lines + scanner.Scan() + scanner.Scan() + for scanner.Scan() { + text := scanner.Text() + text = strings.TrimSpace(text) + if bodyRegex.MatchString(text) { + deviceName := strings.Split(text, " ")[2] + deviceNames = append(deviceNames, deviceName) + } else { + break + } + } + } + return outputBytes, devMapper, deviceNames, nil +} diff --git a/utils/mpath_test.go b/utils/mpath_test.go new file mode 100644 index 00000000..2c8717c8 --- /dev/null +++ b/utils/mpath_test.go @@ -0,0 +1,59 @@ +package utils_test + +import ( + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + + "github.com/IBM/ubiquity/fakes" + "github.com/IBM/ubiquity/utils" +) + +const ( + fakePhysicalCapacity = 2040 + fakeLogicalCapacity = 2040 + fakeUsedCapacity = 2040 + fakeDS8kStoragetType = "2107" + fakeV7kStorageType = "2076" + fakeA9kStorageType = "2810" + fakeProfile = "gold" +) + +var fakeWwn = "6005076306ffd69d0000000000001004" + +var fakeMultipathOutput = ` +mpathg (36005076306ffd69d0000000000001004) dm-14 IBM ,2107900 +size=1.0G features='1 queue_if_no_path' hwhandler='0' wp=rw +` + "`-+- policy='service-time 0' prio=1 status=active" + ` + |- 29:0:1:1 sde 8:64 active ready running + |- 29:0:6:1 sdf 8:80 active ready running + ` + "`- 29:0:7:1 sdg 8:96 active ready running" + ` +mpathf (36005076306ffd69d000000000000010a) dm-2 IBM ,2107900 +size=2.0G features='1 queue_if_no_path' hwhandler='0' wp=rw +` + "`-+- policy='service-time 0' prio=1 status=enabled" + ` + |- 29:0:1:0 sdb 8:16 active ready running + |- 29:0:6:0 sdc 8:32 active ready running + ` + "`- 29:0:7:0 sdd 8:48 active ready running\n" + +var _ = Describe("scbe_mounter_test", func() { + var ( + fakeExec *fakes.FakeExecutor + ) + + BeforeEach(func() { + fakeExec = new(fakes.FakeExecutor) + }) + + Context("GetMultipathOutputAndDeviceMapperAndDevice", func() { + + BeforeEach(func() { + fakeExec.ExecuteWithTimeoutReturns([]byte(fakeMultipathOutput), nil) + }) + + It("should call DisconnectAll ", func() { + _, devMapper, devNames, err := utils.GetMultipathOutputAndDeviceMapperAndDevice(fakeWwn, fakeExec) + Ω(err).ShouldNot(HaveOccurred()) + Expect(devMapper).To(Equal("mpathg")) + Expect(devNames).To(Equal([]string{"sde", "sdf", "sdg"})) + }) + }) +}) From 8d1cddd97778346c14835e5e5a7541033fa5d7de Mon Sep 17 00:00:00 2001 From: 27149chen <7991675+27149chen@users.noreply.github.com> Date: Mon, 4 Mar 2019 18:02:27 +0800 Subject: [PATCH 20/36] update after review Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> --- fakes/fake_block_device_mounter_utils.go | 80 ++--- fakes/fake_block_device_utils.go | 80 ++--- fakes/fake_scbe_data_model_wrapper.go | 318 ------------------ .../block_device_mounter_utils.go | 6 +- .../block_device_utils_mounter_test.go | 40 +-- .../block_device_mounter_utils/resources.go | 2 +- .../block_device_utils_test.go | 10 +- remote/mounter/block_device_utils/rescan.go | 12 +- .../mounter/block_device_utils/resources.go | 2 +- remote/mounter/initiator/linuxfc.go | 4 +- remote/mounter/initiator/linuxfc_test.go | 4 +- remote/mounter/scbe.go | 6 +- remote/mounter/scbe_test.go | 6 +- 13 files changed, 126 insertions(+), 444 deletions(-) delete mode 100644 fakes/fake_scbe_data_model_wrapper.go diff --git a/fakes/fake_block_device_mounter_utils.go b/fakes/fake_block_device_mounter_utils.go index 19c6f4a6..0cb9c993 100644 --- a/fakes/fake_block_device_mounter_utils.go +++ b/fakes/fake_block_device_mounter_utils.go @@ -9,15 +9,15 @@ import ( ) type FakeBlockDeviceMounterUtils struct { - DisconnectAllStub func(*resources.VolumeMountProperties) error - disconnectAllMutex sync.RWMutex - disconnectAllArgsForCall []struct { + CleanupAllStub func(*resources.VolumeMountProperties) error + cleanupAllMutex sync.RWMutex + cleanupAllArgsForCall []struct { arg1 *resources.VolumeMountProperties } - disconnectAllReturns struct { + cleanupAllReturns struct { result1 error } - disconnectAllReturnsOnCall map[int]struct { + cleanupAllReturnsOnCall map[int]struct { result1 error } DiscoverStub func(string, bool) (string, error) @@ -74,62 +74,62 @@ type FakeBlockDeviceMounterUtils struct { invocationsMutex sync.RWMutex } -func (fake *FakeBlockDeviceMounterUtils) DisconnectAll(arg1 *resources.VolumeMountProperties) error { - fake.disconnectAllMutex.Lock() - ret, specificReturn := fake.disconnectAllReturnsOnCall[len(fake.disconnectAllArgsForCall)] - fake.disconnectAllArgsForCall = append(fake.disconnectAllArgsForCall, struct { +func (fake *FakeBlockDeviceMounterUtils) CleanupAll(arg1 *resources.VolumeMountProperties) error { + fake.cleanupAllMutex.Lock() + ret, specificReturn := fake.cleanupAllReturnsOnCall[len(fake.cleanupAllArgsForCall)] + fake.cleanupAllArgsForCall = append(fake.cleanupAllArgsForCall, struct { arg1 *resources.VolumeMountProperties }{arg1}) - fake.recordInvocation("DisconnectAll", []interface{}{arg1}) - fake.disconnectAllMutex.Unlock() - if fake.DisconnectAllStub != nil { - return fake.DisconnectAllStub(arg1) + fake.recordInvocation("CleanupAll", []interface{}{arg1}) + fake.cleanupAllMutex.Unlock() + if fake.CleanupAllStub != nil { + return fake.CleanupAllStub(arg1) } if specificReturn { return ret.result1 } - fakeReturns := fake.disconnectAllReturns + fakeReturns := fake.cleanupAllReturns return fakeReturns.result1 } -func (fake *FakeBlockDeviceMounterUtils) DisconnectAllCallCount() int { - fake.disconnectAllMutex.RLock() - defer fake.disconnectAllMutex.RUnlock() - return len(fake.disconnectAllArgsForCall) +func (fake *FakeBlockDeviceMounterUtils) CleanupAllCallCount() int { + fake.cleanupAllMutex.RLock() + defer fake.cleanupAllMutex.RUnlock() + return len(fake.cleanupAllArgsForCall) } -func (fake *FakeBlockDeviceMounterUtils) DisconnectAllCalls(stub func(*resources.VolumeMountProperties) error) { - fake.disconnectAllMutex.Lock() - defer fake.disconnectAllMutex.Unlock() - fake.DisconnectAllStub = stub +func (fake *FakeBlockDeviceMounterUtils) CleanupAllCalls(stub func(*resources.VolumeMountProperties) error) { + fake.cleanupAllMutex.Lock() + defer fake.cleanupAllMutex.Unlock() + fake.CleanupAllStub = stub } -func (fake *FakeBlockDeviceMounterUtils) DisconnectAllArgsForCall(i int) *resources.VolumeMountProperties { - fake.disconnectAllMutex.RLock() - defer fake.disconnectAllMutex.RUnlock() - argsForCall := fake.disconnectAllArgsForCall[i] +func (fake *FakeBlockDeviceMounterUtils) CleanupAllArgsForCall(i int) *resources.VolumeMountProperties { + fake.cleanupAllMutex.RLock() + defer fake.cleanupAllMutex.RUnlock() + argsForCall := fake.cleanupAllArgsForCall[i] return argsForCall.arg1 } -func (fake *FakeBlockDeviceMounterUtils) DisconnectAllReturns(result1 error) { - fake.disconnectAllMutex.Lock() - defer fake.disconnectAllMutex.Unlock() - fake.DisconnectAllStub = nil - fake.disconnectAllReturns = struct { +func (fake *FakeBlockDeviceMounterUtils) CleanupAllReturns(result1 error) { + fake.cleanupAllMutex.Lock() + defer fake.cleanupAllMutex.Unlock() + fake.CleanupAllStub = nil + fake.cleanupAllReturns = struct { result1 error }{result1} } -func (fake *FakeBlockDeviceMounterUtils) DisconnectAllReturnsOnCall(i int, result1 error) { - fake.disconnectAllMutex.Lock() - defer fake.disconnectAllMutex.Unlock() - fake.DisconnectAllStub = nil - if fake.disconnectAllReturnsOnCall == nil { - fake.disconnectAllReturnsOnCall = make(map[int]struct { +func (fake *FakeBlockDeviceMounterUtils) CleanupAllReturnsOnCall(i int, result1 error) { + fake.cleanupAllMutex.Lock() + defer fake.cleanupAllMutex.Unlock() + fake.CleanupAllStub = nil + if fake.cleanupAllReturnsOnCall == nil { + fake.cleanupAllReturnsOnCall = make(map[int]struct { result1 error }) } - fake.disconnectAllReturnsOnCall[i] = struct { + fake.cleanupAllReturnsOnCall[i] = struct { result1 error }{result1} } @@ -384,8 +384,8 @@ func (fake *FakeBlockDeviceMounterUtils) UnmountDeviceFlowReturnsOnCall(i int, r func (fake *FakeBlockDeviceMounterUtils) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() - fake.disconnectAllMutex.RLock() - defer fake.disconnectAllMutex.RUnlock() + fake.cleanupAllMutex.RLock() + defer fake.cleanupAllMutex.RUnlock() fake.discoverMutex.RLock() defer fake.discoverMutex.RUnlock() fake.mountDeviceFlowMutex.RLock() diff --git a/fakes/fake_block_device_utils.go b/fakes/fake_block_device_utils.go index 2d00c2da..76a1ee9b 100644 --- a/fakes/fake_block_device_utils.go +++ b/fakes/fake_block_device_utils.go @@ -33,16 +33,16 @@ type FakeBlockDeviceUtils struct { cleanupReturnsOnCall map[int]struct { result1 error } - DisconnectStub func(block_device_utils.Protocol, *resources.VolumeMountProperties) error - disconnectMutex sync.RWMutex - disconnectArgsForCall []struct { + CleanupDevicesStub func(block_device_utils.Protocol, *resources.VolumeMountProperties) error + cleanupDevicesMutex sync.RWMutex + cleanupDevicesArgsForCall []struct { arg1 block_device_utils.Protocol arg2 *resources.VolumeMountProperties } - disconnectReturns struct { + cleanupDevicesReturns struct { result1 error } - disconnectReturnsOnCall map[int]struct { + cleanupDevicesReturnsOnCall map[int]struct { result1 error } DiscoverStub func(string, bool) (string, error) @@ -313,63 +313,63 @@ func (fake *FakeBlockDeviceUtils) CleanupReturnsOnCall(i int, result1 error) { }{result1} } -func (fake *FakeBlockDeviceUtils) Disconnect(arg1 block_device_utils.Protocol, arg2 *resources.VolumeMountProperties) error { - fake.disconnectMutex.Lock() - ret, specificReturn := fake.disconnectReturnsOnCall[len(fake.disconnectArgsForCall)] - fake.disconnectArgsForCall = append(fake.disconnectArgsForCall, struct { +func (fake *FakeBlockDeviceUtils) CleanupDevices(arg1 block_device_utils.Protocol, arg2 *resources.VolumeMountProperties) error { + fake.cleanupDevicesMutex.Lock() + ret, specificReturn := fake.cleanupDevicesReturnsOnCall[len(fake.cleanupDevicesArgsForCall)] + fake.cleanupDevicesArgsForCall = append(fake.cleanupDevicesArgsForCall, struct { arg1 block_device_utils.Protocol arg2 *resources.VolumeMountProperties }{arg1, arg2}) - fake.recordInvocation("Disconnect", []interface{}{arg1, arg2}) - fake.disconnectMutex.Unlock() - if fake.DisconnectStub != nil { - return fake.DisconnectStub(arg1, arg2) + fake.recordInvocation("CleanupDevices", []interface{}{arg1, arg2}) + fake.cleanupDevicesMutex.Unlock() + if fake.CleanupDevicesStub != nil { + return fake.CleanupDevicesStub(arg1, arg2) } if specificReturn { return ret.result1 } - fakeReturns := fake.disconnectReturns + fakeReturns := fake.cleanupDevicesReturns return fakeReturns.result1 } -func (fake *FakeBlockDeviceUtils) DisconnectCallCount() int { - fake.disconnectMutex.RLock() - defer fake.disconnectMutex.RUnlock() - return len(fake.disconnectArgsForCall) +func (fake *FakeBlockDeviceUtils) CleanupDevicesCallCount() int { + fake.cleanupDevicesMutex.RLock() + defer fake.cleanupDevicesMutex.RUnlock() + return len(fake.cleanupDevicesArgsForCall) } -func (fake *FakeBlockDeviceUtils) DisconnectCalls(stub func(block_device_utils.Protocol, *resources.VolumeMountProperties) error) { - fake.disconnectMutex.Lock() - defer fake.disconnectMutex.Unlock() - fake.DisconnectStub = stub +func (fake *FakeBlockDeviceUtils) CleanupDevicesCalls(stub func(block_device_utils.Protocol, *resources.VolumeMountProperties) error) { + fake.cleanupDevicesMutex.Lock() + defer fake.cleanupDevicesMutex.Unlock() + fake.CleanupDevicesStub = stub } -func (fake *FakeBlockDeviceUtils) DisconnectArgsForCall(i int) (block_device_utils.Protocol, *resources.VolumeMountProperties) { - fake.disconnectMutex.RLock() - defer fake.disconnectMutex.RUnlock() - argsForCall := fake.disconnectArgsForCall[i] +func (fake *FakeBlockDeviceUtils) CleanupDevicesArgsForCall(i int) (block_device_utils.Protocol, *resources.VolumeMountProperties) { + fake.cleanupDevicesMutex.RLock() + defer fake.cleanupDevicesMutex.RUnlock() + argsForCall := fake.cleanupDevicesArgsForCall[i] return argsForCall.arg1, argsForCall.arg2 } -func (fake *FakeBlockDeviceUtils) DisconnectReturns(result1 error) { - fake.disconnectMutex.Lock() - defer fake.disconnectMutex.Unlock() - fake.DisconnectStub = nil - fake.disconnectReturns = struct { +func (fake *FakeBlockDeviceUtils) CleanupDevicesReturns(result1 error) { + fake.cleanupDevicesMutex.Lock() + defer fake.cleanupDevicesMutex.Unlock() + fake.CleanupDevicesStub = nil + fake.cleanupDevicesReturns = struct { result1 error }{result1} } -func (fake *FakeBlockDeviceUtils) DisconnectReturnsOnCall(i int, result1 error) { - fake.disconnectMutex.Lock() - defer fake.disconnectMutex.Unlock() - fake.DisconnectStub = nil - if fake.disconnectReturnsOnCall == nil { - fake.disconnectReturnsOnCall = make(map[int]struct { +func (fake *FakeBlockDeviceUtils) CleanupDevicesReturnsOnCall(i int, result1 error) { + fake.cleanupDevicesMutex.Lock() + defer fake.cleanupDevicesMutex.Unlock() + fake.CleanupDevicesStub = nil + if fake.cleanupDevicesReturnsOnCall == nil { + fake.cleanupDevicesReturnsOnCall = make(map[int]struct { result1 error }) } - fake.disconnectReturnsOnCall[i] = struct { + fake.cleanupDevicesReturnsOnCall[i] = struct { result1 error }{result1} } @@ -1061,8 +1061,8 @@ func (fake *FakeBlockDeviceUtils) Invocations() map[string][][]interface{} { defer fake.checkFsMutex.RUnlock() fake.cleanupMutex.RLock() defer fake.cleanupMutex.RUnlock() - fake.disconnectMutex.RLock() - defer fake.disconnectMutex.RUnlock() + fake.cleanupDevicesMutex.RLock() + defer fake.cleanupDevicesMutex.RUnlock() fake.discoverMutex.RLock() defer fake.discoverMutex.RUnlock() fake.discoverBySgInqMutex.RLock() diff --git a/fakes/fake_scbe_data_model_wrapper.go b/fakes/fake_scbe_data_model_wrapper.go deleted file mode 100644 index e45cb58f..00000000 --- a/fakes/fake_scbe_data_model_wrapper.go +++ /dev/null @@ -1,318 +0,0 @@ -// Code generated by counterfeiter. DO NOT EDIT. -package fakes - -import ( - "sync" - - "github.com/IBM/ubiquity/local/scbe" -) - -type FakeScbeDataModelWrapper struct { - GetVolumeStub func(name string, mustExist bool) (scbe.ScbeVolume, error) - getVolumeMutex sync.RWMutex - getVolumeArgsForCall []struct { - name string - mustExist bool - } - getVolumeReturns struct { - result1 scbe.ScbeVolume - result2 error - } - getVolumeReturnsOnCall map[int]struct { - result1 scbe.ScbeVolume - result2 error - } - DeleteVolumeStub func(name string) error - deleteVolumeMutex sync.RWMutex - deleteVolumeArgsForCall []struct { - name string - } - deleteVolumeReturns struct { - result1 error - } - deleteVolumeReturnsOnCall map[int]struct { - result1 error - } - InsertVolumeStub func(volumeName string, wwn string, fstype string) error - insertVolumeMutex sync.RWMutex - insertVolumeArgsForCall []struct { - volumeName string - wwn string - fstype string - } - insertVolumeReturns struct { - result1 error - } - insertVolumeReturnsOnCall map[int]struct { - result1 error - } - ListVolumesStub func() ([]scbe.ScbeVolume, error) - listVolumesMutex sync.RWMutex - listVolumesArgsForCall []struct{} - listVolumesReturns struct { - result1 []scbe.ScbeVolume - result2 error - } - listVolumesReturnsOnCall map[int]struct { - result1 []scbe.ScbeVolume - result2 error - } - UpdateDatabaseVolumeStub func(newVolume *scbe.ScbeVolume) - updateDatabaseVolumeMutex sync.RWMutex - updateDatabaseVolumeArgsForCall []struct { - newVolume *scbe.ScbeVolume - } - invocations map[string][][]interface{} - invocationsMutex sync.RWMutex -} - -func (fake *FakeScbeDataModelWrapper) GetVolume(name string, mustExist bool) (scbe.ScbeVolume, error) { - fake.getVolumeMutex.Lock() - ret, specificReturn := fake.getVolumeReturnsOnCall[len(fake.getVolumeArgsForCall)] - fake.getVolumeArgsForCall = append(fake.getVolumeArgsForCall, struct { - name string - mustExist bool - }{name, mustExist}) - fake.recordInvocation("GetVolume", []interface{}{name, mustExist}) - fake.getVolumeMutex.Unlock() - if fake.GetVolumeStub != nil { - return fake.GetVolumeStub(name, mustExist) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fake.getVolumeReturns.result1, fake.getVolumeReturns.result2 -} - -func (fake *FakeScbeDataModelWrapper) GetVolumeCallCount() int { - fake.getVolumeMutex.RLock() - defer fake.getVolumeMutex.RUnlock() - return len(fake.getVolumeArgsForCall) -} - -func (fake *FakeScbeDataModelWrapper) GetVolumeArgsForCall(i int) (string, bool) { - fake.getVolumeMutex.RLock() - defer fake.getVolumeMutex.RUnlock() - return fake.getVolumeArgsForCall[i].name, fake.getVolumeArgsForCall[i].mustExist -} - -func (fake *FakeScbeDataModelWrapper) GetVolumeReturns(result1 scbe.ScbeVolume, result2 error) { - fake.GetVolumeStub = nil - fake.getVolumeReturns = struct { - result1 scbe.ScbeVolume - result2 error - }{result1, result2} -} - -func (fake *FakeScbeDataModelWrapper) GetVolumeReturnsOnCall(i int, result1 scbe.ScbeVolume, result2 error) { - fake.GetVolumeStub = nil - if fake.getVolumeReturnsOnCall == nil { - fake.getVolumeReturnsOnCall = make(map[int]struct { - result1 scbe.ScbeVolume - result2 error - }) - } - fake.getVolumeReturnsOnCall[i] = struct { - result1 scbe.ScbeVolume - result2 error - }{result1, result2} -} - -func (fake *FakeScbeDataModelWrapper) DeleteVolume(name string) error { - fake.deleteVolumeMutex.Lock() - ret, specificReturn := fake.deleteVolumeReturnsOnCall[len(fake.deleteVolumeArgsForCall)] - fake.deleteVolumeArgsForCall = append(fake.deleteVolumeArgsForCall, struct { - name string - }{name}) - fake.recordInvocation("DeleteVolume", []interface{}{name}) - fake.deleteVolumeMutex.Unlock() - if fake.DeleteVolumeStub != nil { - return fake.DeleteVolumeStub(name) - } - if specificReturn { - return ret.result1 - } - return fake.deleteVolumeReturns.result1 -} - -func (fake *FakeScbeDataModelWrapper) DeleteVolumeCallCount() int { - fake.deleteVolumeMutex.RLock() - defer fake.deleteVolumeMutex.RUnlock() - return len(fake.deleteVolumeArgsForCall) -} - -func (fake *FakeScbeDataModelWrapper) DeleteVolumeArgsForCall(i int) string { - fake.deleteVolumeMutex.RLock() - defer fake.deleteVolumeMutex.RUnlock() - return fake.deleteVolumeArgsForCall[i].name -} - -func (fake *FakeScbeDataModelWrapper) DeleteVolumeReturns(result1 error) { - fake.DeleteVolumeStub = nil - fake.deleteVolumeReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeScbeDataModelWrapper) DeleteVolumeReturnsOnCall(i int, result1 error) { - fake.DeleteVolumeStub = nil - if fake.deleteVolumeReturnsOnCall == nil { - fake.deleteVolumeReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.deleteVolumeReturnsOnCall[i] = struct { - result1 error - }{result1} -} - -func (fake *FakeScbeDataModelWrapper) InsertVolume(volumeName string, wwn string, fstype string) error { - fake.insertVolumeMutex.Lock() - ret, specificReturn := fake.insertVolumeReturnsOnCall[len(fake.insertVolumeArgsForCall)] - fake.insertVolumeArgsForCall = append(fake.insertVolumeArgsForCall, struct { - volumeName string - wwn string - fstype string - }{volumeName, wwn, fstype}) - fake.recordInvocation("InsertVolume", []interface{}{volumeName, wwn, fstype}) - fake.insertVolumeMutex.Unlock() - if fake.InsertVolumeStub != nil { - return fake.InsertVolumeStub(volumeName, wwn, fstype) - } - if specificReturn { - return ret.result1 - } - return fake.insertVolumeReturns.result1 -} - -func (fake *FakeScbeDataModelWrapper) InsertVolumeCallCount() int { - fake.insertVolumeMutex.RLock() - defer fake.insertVolumeMutex.RUnlock() - return len(fake.insertVolumeArgsForCall) -} - -func (fake *FakeScbeDataModelWrapper) InsertVolumeArgsForCall(i int) (string, string, string) { - fake.insertVolumeMutex.RLock() - defer fake.insertVolumeMutex.RUnlock() - return fake.insertVolumeArgsForCall[i].volumeName, fake.insertVolumeArgsForCall[i].wwn, fake.insertVolumeArgsForCall[i].fstype -} - -func (fake *FakeScbeDataModelWrapper) InsertVolumeReturns(result1 error) { - fake.InsertVolumeStub = nil - fake.insertVolumeReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeScbeDataModelWrapper) InsertVolumeReturnsOnCall(i int, result1 error) { - fake.InsertVolumeStub = nil - if fake.insertVolumeReturnsOnCall == nil { - fake.insertVolumeReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.insertVolumeReturnsOnCall[i] = struct { - result1 error - }{result1} -} - -func (fake *FakeScbeDataModelWrapper) ListVolumes() ([]scbe.ScbeVolume, error) { - fake.listVolumesMutex.Lock() - ret, specificReturn := fake.listVolumesReturnsOnCall[len(fake.listVolumesArgsForCall)] - fake.listVolumesArgsForCall = append(fake.listVolumesArgsForCall, struct{}{}) - fake.recordInvocation("ListVolumes", []interface{}{}) - fake.listVolumesMutex.Unlock() - if fake.ListVolumesStub != nil { - return fake.ListVolumesStub() - } - if specificReturn { - return ret.result1, ret.result2 - } - return fake.listVolumesReturns.result1, fake.listVolumesReturns.result2 -} - -func (fake *FakeScbeDataModelWrapper) ListVolumesCallCount() int { - fake.listVolumesMutex.RLock() - defer fake.listVolumesMutex.RUnlock() - return len(fake.listVolumesArgsForCall) -} - -func (fake *FakeScbeDataModelWrapper) ListVolumesReturns(result1 []scbe.ScbeVolume, result2 error) { - fake.ListVolumesStub = nil - fake.listVolumesReturns = struct { - result1 []scbe.ScbeVolume - result2 error - }{result1, result2} -} - -func (fake *FakeScbeDataModelWrapper) ListVolumesReturnsOnCall(i int, result1 []scbe.ScbeVolume, result2 error) { - fake.ListVolumesStub = nil - if fake.listVolumesReturnsOnCall == nil { - fake.listVolumesReturnsOnCall = make(map[int]struct { - result1 []scbe.ScbeVolume - result2 error - }) - } - fake.listVolumesReturnsOnCall[i] = struct { - result1 []scbe.ScbeVolume - result2 error - }{result1, result2} -} - -func (fake *FakeScbeDataModelWrapper) UpdateDatabaseVolume(newVolume *scbe.ScbeVolume) { - fake.updateDatabaseVolumeMutex.Lock() - fake.updateDatabaseVolumeArgsForCall = append(fake.updateDatabaseVolumeArgsForCall, struct { - newVolume *scbe.ScbeVolume - }{newVolume}) - fake.recordInvocation("UpdateDatabaseVolume", []interface{}{newVolume}) - fake.updateDatabaseVolumeMutex.Unlock() - if fake.UpdateDatabaseVolumeStub != nil { - fake.UpdateDatabaseVolumeStub(newVolume) - } -} - -func (fake *FakeScbeDataModelWrapper) UpdateDatabaseVolumeCallCount() int { - fake.updateDatabaseVolumeMutex.RLock() - defer fake.updateDatabaseVolumeMutex.RUnlock() - return len(fake.updateDatabaseVolumeArgsForCall) -} - -func (fake *FakeScbeDataModelWrapper) UpdateDatabaseVolumeArgsForCall(i int) *scbe.ScbeVolume { - fake.updateDatabaseVolumeMutex.RLock() - defer fake.updateDatabaseVolumeMutex.RUnlock() - return fake.updateDatabaseVolumeArgsForCall[i].newVolume -} - -func (fake *FakeScbeDataModelWrapper) Invocations() map[string][][]interface{} { - fake.invocationsMutex.RLock() - defer fake.invocationsMutex.RUnlock() - fake.getVolumeMutex.RLock() - defer fake.getVolumeMutex.RUnlock() - fake.deleteVolumeMutex.RLock() - defer fake.deleteVolumeMutex.RUnlock() - fake.insertVolumeMutex.RLock() - defer fake.insertVolumeMutex.RUnlock() - fake.listVolumesMutex.RLock() - defer fake.listVolumesMutex.RUnlock() - fake.updateDatabaseVolumeMutex.RLock() - defer fake.updateDatabaseVolumeMutex.RUnlock() - copiedInvocations := map[string][][]interface{}{} - for key, value := range fake.invocations { - copiedInvocations[key] = value - } - return copiedInvocations -} - -func (fake *FakeScbeDataModelWrapper) recordInvocation(key string, args []interface{}) { - fake.invocationsMutex.Lock() - defer fake.invocationsMutex.Unlock() - if fake.invocations == nil { - fake.invocations = map[string][][]interface{}{} - } - if fake.invocations[key] == nil { - fake.invocations[key] = [][]interface{}{} - } - fake.invocations[key] = append(fake.invocations[key], args) -} - -var _ scbe.ScbeDataModelWrapper = new(FakeScbeDataModelWrapper) diff --git a/remote/mounter/block_device_mounter_utils/block_device_mounter_utils.go b/remote/mounter/block_device_mounter_utils/block_device_mounter_utils.go index 04d5fcd2..691987c4 100644 --- a/remote/mounter/block_device_mounter_utils/block_device_mounter_utils.go +++ b/remote/mounter/block_device_mounter_utils/block_device_mounter_utils.go @@ -200,13 +200,13 @@ func (b *blockDeviceMounterUtils) RescanAll(volumeMountProperties *resources.Vol } // DisconnectAll remove the device from host after the volume is unmapped. -func (b *blockDeviceMounterUtils) DisconnectAll(volumeMountProperties *resources.VolumeMountProperties) error { +func (b *blockDeviceMounterUtils) CleanupAll(volumeMountProperties *resources.VolumeMountProperties) error { // in case of FC : if no iscsiadm on the machine or no session login - this will log a warning not fail! - if err := b.blockDeviceUtils.Disconnect(block_device_utils.ISCSI, volumeMountProperties); err != nil { + if err := b.blockDeviceUtils.CleanupDevices(block_device_utils.ISCSI, volumeMountProperties); err != nil { return b.logger.ErrorRet(err, "ISCSI Disconnect failed", logs.Args{{"protocol", block_device_utils.ISCSI}}) } - if err := b.blockDeviceUtils.Disconnect(block_device_utils.SCSI, volumeMountProperties); err != nil { + if err := b.blockDeviceUtils.CleanupDevices(block_device_utils.SCSI, volumeMountProperties); err != nil { return b.logger.ErrorRet(err, "OS Disconnect failed", logs.Args{{"protocol", block_device_utils.SCSI}}) } return nil diff --git a/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go b/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go index 6285f8f0..2c220d7e 100644 --- a/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go +++ b/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go @@ -285,37 +285,37 @@ var _ = Describe("block_device_mounter_utils_test", func() { Expect(fakeBlockDeviceUtils.CleanupCallCount()).To(Equal(1)) }) }) - Context(".DisconnectAll", func() { - It("should fail if iscsi disconnect fail", func() { - fakeBlockDeviceUtils.DisconnectReturnsOnCall(0, callErr) - err = blockDeviceMounterUtils.DisconnectAll(volumeMountProperties) + Context(".CleanupAll", func() { + It("should fail if iscsi cleanup fail", func() { + fakeBlockDeviceUtils.CleanupDevicesReturnsOnCall(0, callErr) + err = blockDeviceMounterUtils.CleanupAll(volumeMountProperties) Expect(err).To(HaveOccurred()) Expect(err).To(MatchError(callErr)) - Expect(fakeBlockDeviceUtils.DisconnectCallCount()).To(Equal(1)) - protocol, _ := fakeBlockDeviceUtils.DisconnectArgsForCall(0) + Expect(fakeBlockDeviceUtils.CleanupDevicesCallCount()).To(Equal(1)) + protocol, _ := fakeBlockDeviceUtils.CleanupDevicesArgsForCall(0) Expect(protocol).To(Equal(block_device_utils.ISCSI)) }) - It("should fail if scsi disconnect fail", func() { - fakeBlockDeviceUtils.DisconnectReturnsOnCall(0, nil) - fakeBlockDeviceUtils.DisconnectReturnsOnCall(1, callErr) - err = blockDeviceMounterUtils.DisconnectAll(volumeMountProperties) + It("should fail if scsi cleanup fail", func() { + fakeBlockDeviceUtils.CleanupDevicesReturnsOnCall(0, nil) + fakeBlockDeviceUtils.CleanupDevicesReturnsOnCall(1, callErr) + err = blockDeviceMounterUtils.CleanupAll(volumeMountProperties) Expect(err).To(HaveOccurred()) Expect(err).To(MatchError(callErr)) - Expect(fakeBlockDeviceUtils.DisconnectCallCount()).To(Equal(2)) - protocol, _ := fakeBlockDeviceUtils.DisconnectArgsForCall(0) + Expect(fakeBlockDeviceUtils.CleanupDevicesCallCount()).To(Equal(2)) + protocol, _ := fakeBlockDeviceUtils.CleanupDevicesArgsForCall(0) Expect(protocol).To(Equal(block_device_utils.ISCSI)) - protocol, _ = fakeBlockDeviceUtils.DisconnectArgsForCall(1) + protocol, _ = fakeBlockDeviceUtils.CleanupDevicesArgsForCall(1) Expect(protocol).To(Equal(block_device_utils.SCSI)) }) - It("should succeed to disconnect all", func() { - fakeBlockDeviceUtils.DisconnectReturnsOnCall(0, nil) - fakeBlockDeviceUtils.DisconnectReturnsOnCall(1, nil) - err = blockDeviceMounterUtils.DisconnectAll(volumeMountProperties) + It("should succeed to cleanup all", func() { + fakeBlockDeviceUtils.CleanupDevicesReturnsOnCall(0, nil) + fakeBlockDeviceUtils.CleanupDevicesReturnsOnCall(1, nil) + err = blockDeviceMounterUtils.CleanupAll(volumeMountProperties) Expect(err).NotTo(HaveOccurred()) - Expect(fakeBlockDeviceUtils.DisconnectCallCount()).To(Equal(2)) - protocol, _ := fakeBlockDeviceUtils.DisconnectArgsForCall(0) + Expect(fakeBlockDeviceUtils.CleanupDevicesCallCount()).To(Equal(2)) + protocol, _ := fakeBlockDeviceUtils.CleanupDevicesArgsForCall(0) Expect(protocol).To(Equal(block_device_utils.ISCSI)) - protocol, _ = fakeBlockDeviceUtils.DisconnectArgsForCall(1) + protocol, _ = fakeBlockDeviceUtils.CleanupDevicesArgsForCall(1) Expect(protocol).To(Equal(block_device_utils.SCSI)) }) }) diff --git a/remote/mounter/block_device_mounter_utils/resources.go b/remote/mounter/block_device_mounter_utils/resources.go index 339c0902..9e8008f5 100644 --- a/remote/mounter/block_device_mounter_utils/resources.go +++ b/remote/mounter/block_device_mounter_utils/resources.go @@ -21,7 +21,7 @@ import "github.com/IBM/ubiquity/resources" //go:generate counterfeiter -o ../../../fakes/fake_block_device_mounter_utils.go . BlockDeviceMounterUtils type BlockDeviceMounterUtils interface { RescanAll(volumeMountProperties *resources.VolumeMountProperties) error - DisconnectAll(volumeMountProperties *resources.VolumeMountProperties) error + CleanupAll(volumeMountProperties *resources.VolumeMountProperties) error MountDeviceFlow(devicePath string, fsType string, mountPoint string) error Discover(volumeWwn string, deepDiscovery bool) (string, error) UnmountDeviceFlow(devicePath string, volumeWwn string) error diff --git a/remote/mounter/block_device_utils/block_device_utils_test.go b/remote/mounter/block_device_utils/block_device_utils_test.go index ed0d85c7..098f12b3 100644 --- a/remote/mounter/block_device_utils/block_device_utils_test.go +++ b/remote/mounter/block_device_utils/block_device_utils_test.go @@ -90,17 +90,17 @@ var _ = Describe("block_device_utils_test", func() { Expect(err).To(HaveOccurred()) }) }) - Context(".Disconnect", func() { - It("Disconnect ISCSI calls 'sudo iscsiadm -m session --rescan'", func() { - err = bdUtils.Disconnect(block_device_utils.ISCSI, volumeMountProperties) + Context(".CleanupDevices", func() { + It("Cleanup ISCSI calls 'sudo iscsiadm -m session --rescan'", func() { + err = bdUtils.CleanupDevices(block_device_utils.ISCSI, volumeMountProperties) Expect(err).ToNot(HaveOccurred()) Expect(fakeExec.ExecuteWithTimeoutCallCount()).To(Equal(1)) _, cmd, args := fakeExec.ExecuteWithTimeoutArgsForCall(0) Expect(cmd).To(Equal("iscsiadm")) Expect(args).To(Equal([]string{"-m", "session", "--rescan"})) }) - It(`Disconnect SCSI calls fcConnector.DisconnectVolume`, func() { - err = bdUtils.Disconnect(block_device_utils.SCSI, volumeMountProperties) + It(`Cleanup SCSI calls fcConnector.DisconnectVolume`, func() { + err = bdUtils.CleanupDevices(block_device_utils.SCSI, volumeMountProperties) Expect(err).ToNot(HaveOccurred()) Expect(fakeFcConnector.DisconnectVolumeCallCount()).To(Equal(1)) }) diff --git a/remote/mounter/block_device_utils/rescan.go b/remote/mounter/block_device_utils/rescan.go index 85f00696..58b4bb65 100644 --- a/remote/mounter/block_device_utils/rescan.go +++ b/remote/mounter/block_device_utils/rescan.go @@ -44,14 +44,14 @@ func (b *blockDeviceUtils) Rescan(protocol Protocol, volumeMountProperties *reso } } -func (b *blockDeviceUtils) Disconnect(protocol Protocol, volumeMountProperties *resources.VolumeMountProperties) error { +func (b *blockDeviceUtils) CleanupDevices(protocol Protocol, volumeMountProperties *resources.VolumeMountProperties) error { defer b.logger.Trace(logs.DEBUG)() switch protocol { case SCSI: - return b.DisconnectSCSI(volumeMountProperties) + return b.CleanupSCSIDevices(volumeMountProperties) case ISCSI: - return b.DisconnectISCSI() + return b.CleanupISCSIDevices() default: return b.logger.ErrorRet(&unsupportedProtocolError{protocol}, "failed") } @@ -97,11 +97,11 @@ func (b *blockDeviceUtils) RescanSCSI(volumeMountProperties *resources.VolumeMou return b.logger.ErrorRet(err, "RescanSCSI failed", logs.Args{{"volumeWWN", volumeMountProperties.WWN}}) } -// TODO: improve it to make it faster -func (b *blockDeviceUtils) DisconnectISCSI() error { +// TODO: improve it to make it faster, for more details, see os_brick project. +func (b *blockDeviceUtils) CleanupISCSIDevices() error { return b.RescanISCSI() } -func (b *blockDeviceUtils) DisconnectSCSI(volumeMountProperties *resources.VolumeMountProperties) error { +func (b *blockDeviceUtils) CleanupSCSIDevices(volumeMountProperties *resources.VolumeMountProperties) error { return b.fcConnector.DisconnectVolume(volumeMountProperties) } diff --git a/remote/mounter/block_device_utils/resources.go b/remote/mounter/block_device_utils/resources.go index e2e947dd..f8a8bfb4 100644 --- a/remote/mounter/block_device_utils/resources.go +++ b/remote/mounter/block_device_utils/resources.go @@ -30,7 +30,7 @@ const ( //go:generate counterfeiter -o ../../../fakes/fake_block_device_utils.go . BlockDeviceUtils type BlockDeviceUtils interface { Rescan(protocol Protocol, volumes *resources.VolumeMountProperties) error - Disconnect(protocol Protocol, volumes *resources.VolumeMountProperties) error + CleanupDevices(protocol Protocol, volumes *resources.VolumeMountProperties) error ReloadMultipath() error Discover(volumeWwn string, deepDiscovery bool) (string, error) GetWwnByScsiInq(mpathOutput string, dev string) (string, error) diff --git a/remote/mounter/initiator/linuxfc.go b/remote/mounter/initiator/linuxfc.go index 17ad19ce..c7346d8c 100644 --- a/remote/mounter/initiator/linuxfc.go +++ b/remote/mounter/initiator/linuxfc.go @@ -12,6 +12,7 @@ import ( ) const SYSTOOL = "systool" +const SYSTOOL_TIMEOUT = 5 * 1000 var FC_HOST_SYSFS_PATH = "/sys/class/fc_host" var SCSI_HOST_SYSFS_PATH = "/sys/class/scsi_host" @@ -64,13 +65,12 @@ func (lfc *linuxFibreChannel) GetHBAs() []string { return []string{} } - SYSTOOL := "systool" if err := lfc.exec.IsExecutable(SYSTOOL); err != nil { lfc.logger.Warning(fmt.Sprintf("No systool installed, get from path %s instead.", FC_HOST_SYSFS_PATH)) return lfc.getFcHBAsByPath() } - out, err := lfc.exec.Execute(SYSTOOL, []string{"-c", "fc_host", "-v"}) + out, err := lfc.exec.ExecuteWithTimeout(SYSTOOL_TIMEOUT, SYSTOOL, []string{"-c", "fc_host", "-v"}) if err != nil { lfc.logger.Warning(fmt.Sprintf("Executing systool failed with error: %v. Get from path %s instead.", err, FC_HOST_SYSFS_PATH)) return lfc.getFcHBAsByPath() diff --git a/remote/mounter/initiator/linuxfc_test.go b/remote/mounter/initiator/linuxfc_test.go index f3b72e23..703eb1b7 100644 --- a/remote/mounter/initiator/linuxfc_test.go +++ b/remote/mounter/initiator/linuxfc_test.go @@ -119,7 +119,7 @@ var _ = Describe("Test FC Initiator", func() { Context("get HBAs from systool", func() { BeforeEach(func() { - fakeExec.ExecuteReturns([]byte(fakeSystoolOutput), nil) + fakeExec.ExecuteWithTimeoutReturns([]byte(fakeSystoolOutput), nil) }) It("should get from systool if it is installed", func() { @@ -146,7 +146,7 @@ var _ = Describe("Test FC Initiator", func() { }) It("should get from sys fc path if systool returns error", func() { - fakeExec.ExecuteReturns([]byte{}, cmdErr) + fakeExec.ExecuteWithTimeoutReturns([]byte{}, cmdErr) hbasRes := fcInitiator.GetHBAs() Expect(hbasRes).To(Equal(hbas)) }) diff --git a/remote/mounter/scbe.go b/remote/mounter/scbe.go index ff822160..19b5f2a2 100644 --- a/remote/mounter/scbe.go +++ b/remote/mounter/scbe.go @@ -156,9 +156,9 @@ func (s *scbeMounter) ActionAfterDetach(request resources.AfterDetachRequest) er defer s.logger.Trace(logs.DEBUG)() volumeMountProperties := s.prepareVolumeMountProperties(&request) - // Disconnect volume - if err := s.blockDeviceMounterUtils.DisconnectAll(volumeMountProperties); err != nil { - return s.logger.ErrorRet(err, "DisconnectAll failed") + // Cleanup volume + if err := s.blockDeviceMounterUtils.CleanupAll(volumeMountProperties); err != nil { + return s.logger.ErrorRet(err, "CleanupAll failed") } return nil } diff --git a/remote/mounter/scbe_test.go b/remote/mounter/scbe_test.go index 5e833702..bc839e2f 100644 --- a/remote/mounter/scbe_test.go +++ b/remote/mounter/scbe_test.go @@ -153,7 +153,7 @@ var _ = Describe("scbe_mounter_test", func() { }) }) Context("Mount", func() { - FIt("should be true to discover ", func() { + It("should be true to discover ", func() { _, err := scbeMounter.Mount(mountRequestForDS8kLun1) Expect(err).NotTo(HaveOccurred()) }) @@ -189,11 +189,11 @@ var _ = Describe("scbe_mounter_test", func() { }) }) Context("ActionAfterDetach", func() { - It("should call DisconnectAll ", func() { + It("should call CleanupAll ", func() { req := resources.AfterDetachRequest{VolumeConfig: map[string]interface{}{"Wwn": "wwn", "LunNumber": float64(1)}} err := scbeMounter.ActionAfterDetach(req) Expect(err).NotTo(HaveOccurred()) - Expect(fakeBdUtils.DisconnectAllCallCount()).To(Equal(1)) + Expect(fakeBdUtils.CleanupAllCallCount()).To(Equal(1)) }) }) }) From 2cf3f186690d800b5908f8a93eb49e908244ca4f Mon Sep 17 00:00:00 2001 From: Shay Berman Date: Wed, 6 Mar 2019 13:14:51 +0200 Subject: [PATCH 21/36] set PV mountpoint chmod to 775 --- .../block_device_utils/block_device_utils_test.go | 15 ++++++++++++++- remote/mounter/block_device_utils/fs.go | 10 ++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/remote/mounter/block_device_utils/block_device_utils_test.go b/remote/mounter/block_device_utils/block_device_utils_test.go index 0115ceca..92818131 100644 --- a/remote/mounter/block_device_utils/block_device_utils_test.go +++ b/remote/mounter/block_device_utils/block_device_utils_test.go @@ -615,10 +615,14 @@ mpathhb (36001738cfc9035eb0000000000cea###) dm-3 ##,## mpoint := "mpoint" err = bdUtils.MountFs(mpath, mpoint) Expect(err).To(Not(HaveOccurred())) - Expect(fakeExec.ExecuteWithTimeoutCallCount()).To(Equal(1)) + Expect(fakeExec.ExecuteWithTimeoutCallCount()).To(Equal(2)) _, cmd, args := fakeExec.ExecuteWithTimeoutArgsForCall(0) Expect(cmd).To(Equal("mount")) Expect(args).To(Equal([]string{mpath, mpoint})) + + _, cmd, args = fakeExec.ExecuteWithTimeoutArgsForCall(1) + Expect(cmd).To(Equal("chmod")) + Expect(args).To(Equal([]string{"775", mpoint})) }) It("MountFs fails if mount command missing", func() { mpath := "mpath" @@ -636,6 +640,15 @@ mpathhb (36001738cfc9035eb0000000000cea###) dm-3 ##,## Expect(err).To(HaveOccurred()) Expect(err.Error()).To(MatchRegexp(cmdErr.Error())) }) + It("MountFs fails if chmod command fails", func() { + mpath := "mpath" + mpoint := "mpoint" + fakeExec.ExecuteWithTimeoutReturnsOnCall(0, []byte{}, nil) + fakeExec.ExecuteWithTimeoutReturnsOnCall(1, []byte{}, cmdErr) + err = bdUtils.MountFs(mpath, mpoint) + Expect(err).To(HaveOccurred()) + Expect(err.Error()).To(MatchRegexp(cmdErr.Error())) + }) }) Context(".IsDeviceMounted", func() { It("should fail if mount command missing", func() { diff --git a/remote/mounter/block_device_utils/fs.go b/remote/mounter/block_device_utils/fs.go index f2af2273..a836a68c 100644 --- a/remote/mounter/block_device_utils/fs.go +++ b/remote/mounter/block_device_utils/fs.go @@ -32,6 +32,7 @@ const ( TimeoutMilisecondMountCmdIsDeviceMounted = 20 * 1000 // max to wait for mount command TimeoutMilisecondMountCmdMountFs = 120 * 1000 // max to wait for mounting device TimeoutMilisecondUmountCmdUmountFs = 30 * 1000 // max wait timeout for umount command + TimeoutMilisecondChmodCmd = 3 * 1000 ) func (b *blockDeviceUtils) CheckFs(mpath string) (bool, error) { @@ -73,6 +74,8 @@ func (b *blockDeviceUtils) MakeFs(mpath string, fsType string) error { func (b *blockDeviceUtils) MountFs(mpath string, mpoint string) error { defer b.logger.Trace(logs.DEBUG)() mountCmd := "mount" + chmodCmd := "chmod" + if err := b.exec.IsExecutable(mountCmd); err != nil { return b.logger.ErrorRet(&commandNotFoundError{mountCmd, err}, "failed") } @@ -80,6 +83,13 @@ func (b *blockDeviceUtils) MountFs(mpath string, mpoint string) error { if _, err := b.exec.ExecuteWithTimeout(TimeoutMilisecondMountCmdMountFs, mountCmd, args); err != nil { return b.logger.ErrorRet(&CommandExecuteError{mountCmd, err}, "failed") } + + // Set explicitly the PV mountpoint permission to 775 + args = []string{"775", mpoint} + if _, err := b.exec.ExecuteWithTimeout(TimeoutMilisecondChmodCmd, chmodCmd, args); err != nil { + return b.logger.ErrorRet(&CommandExecuteError{chmodCmd, err}, "failed") + } + b.logger.Info("mounted", logs.Args{{"mpoint", mpoint}}) return nil } From b01dc272482f1f7a2137c0d1257dd4ed38346172 Mon Sep 17 00:00:00 2001 From: 27149chen <7991675+27149chen@users.noreply.github.com> Date: Thu, 7 Mar 2019 19:24:40 +0800 Subject: [PATCH 22/36] add lip reset Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> --- remote/mounter/initiator/linuxfc.go | 17 ++++++- remote/mounter/initiator/linuxfc_test.go | 57 +++++++++++++++++++++--- 2 files changed, 68 insertions(+), 6 deletions(-) diff --git a/remote/mounter/initiator/linuxfc.go b/remote/mounter/initiator/linuxfc.go index c7346d8c..44d5a9c5 100644 --- a/remote/mounter/initiator/linuxfc.go +++ b/remote/mounter/initiator/linuxfc.go @@ -14,6 +14,8 @@ import ( const SYSTOOL = "systool" const SYSTOOL_TIMEOUT = 5 * 1000 +var RESET_LIP = true + var FC_HOST_SYSFS_PATH = "/sys/class/fc_host" var SCSI_HOST_SYSFS_PATH = "/sys/class/scsi_host" @@ -113,16 +115,29 @@ func (lfc *linuxFibreChannel) RescanHosts(hbas []string, volumeMountProperties * ctl := lfc.getHBAChannelScsiTarget(volumeMountProperties) for _, hba := range hbas { + + if RESET_LIP { + lfc.lipReset(hba) + } + hbaPath := SCSI_HOST_SYSFS_PATH + "/" + hba + "/scan" lfc.logger.Debug(fmt.Sprintf(`Scanning HBA with command: echo "%s" > %s`, ctl, hbaPath)) if err := ioutil.WriteFile(hbaPath, []byte(ctl), 0666); err != nil { - lfc.logger.Debug("Failed to scan HBA", logs.Args{{"name", hba}, {"err", err}}) + lfc.logger.Warning("Failed to scan HBA", logs.Args{{"name", hba}, {"err", err}}) continue } } return nil } +func (lfc *linuxFibreChannel) lipReset(hba string) { + path := FC_HOST_SYSFS_PATH + "/" + hba + "/issue_lip" + lfc.logger.Debug(fmt.Sprintf(`Resetting LIP with command: echo "1" > %s`, path)) + if err := ioutil.WriteFile(path, []byte("1"), 0666); err != nil { + lfc.logger.Warning("Failed to reset LIP", logs.Args{{"name", hba}, {"err", err}}) + } +} + /* generateHBAsInfoFromSystoolOutput analysises the output of command "systool -c fc_host -v", and generates a list of HBA info. diff --git a/remote/mounter/initiator/linuxfc_test.go b/remote/mounter/initiator/linuxfc_test.go index 703eb1b7..432a7474 100644 --- a/remote/mounter/initiator/linuxfc_test.go +++ b/remote/mounter/initiator/linuxfc_test.go @@ -158,21 +158,68 @@ var _ = Describe("Test FC Initiator", func() { var hbas = []string{"host0"} var scanPath = FAKE_SCSI_HOST_SYSFS_PATH + "/" + hbas[0] var scanFile = scanPath + "/scan" + var lipPath = FAKE_FC_HOST_SYSFS_PATH + "/" + hbas[0] + var lipFile = lipPath + "/issue_lip" + var realLipResetBool bool BeforeEach(func() { err := os.MkdirAll(scanPath, os.ModePerm) Ω(err).ShouldNot(HaveOccurred()) _, err = os.Create(scanFile) Ω(err).ShouldNot(HaveOccurred()) - }) - It("should write '- - lunid' to the hba scan file", func() { - err := fcInitiator.RescanHosts(hbas, volumeMountProperties) + err = os.MkdirAll(lipPath, os.ModePerm) Ω(err).ShouldNot(HaveOccurred()) - data, err := ioutil.ReadFile(scanFile) + _, err = os.Create(lipFile) Ω(err).ShouldNot(HaveOccurred()) - Expect(string(data)).To(Equal(fmt.Sprintf("- - %g", volumeMountProperties.LunNumber))) }) + + Context("RESET_LIP is true", func() { + BeforeEach(func() { + realLipResetBool = initiator.RESET_LIP + initiator.RESET_LIP = true + }) + + AfterEach(func() { + initiator.RESET_LIP = realLipResetBool + }) + + It("should write '- - lunid' to the hba scan file", func() { + err := fcInitiator.RescanHosts(hbas, volumeMountProperties) + Ω(err).ShouldNot(HaveOccurred()) + data, err := ioutil.ReadFile(scanFile) + Ω(err).ShouldNot(HaveOccurred()) + Expect(string(data)).To(Equal(fmt.Sprintf("- - %g", volumeMountProperties.LunNumber))) + }) + + It("should write '1' to the hba lip file", func() { + err := fcInitiator.RescanHosts(hbas, volumeMountProperties) + Ω(err).ShouldNot(HaveOccurred()) + data, err := ioutil.ReadFile(lipFile) + Ω(err).ShouldNot(HaveOccurred()) + Expect(string(data)).To(Equal("1")) + }) + }) + + Context("RESET_LIP is false", func() { + BeforeEach(func() { + realLipResetBool = initiator.RESET_LIP + initiator.RESET_LIP = false + }) + + AfterEach(func() { + initiator.RESET_LIP = realLipResetBool + }) + + It("should write nothing to the hba lip file", func() { + err := fcInitiator.RescanHosts(hbas, volumeMountProperties) + Ω(err).ShouldNot(HaveOccurred()) + data, err := ioutil.ReadFile(lipFile) + Ω(err).ShouldNot(HaveOccurred()) + Expect(string(data)).To(Equal("")) + }) + }) + }) Context("RemoveSCSIDevice", func() { From 71e61722df3bb6f8fa3993a2807b9c13a4c87db2 Mon Sep 17 00:00:00 2001 From: 27149chen <7991675+27149chen@users.noreply.github.com> Date: Fri, 8 Mar 2019 16:16:12 +0800 Subject: [PATCH 23/36] Revert "set PV mountpoint chmod to 775" This reverts commit 2cf3f186690d800b5908f8a93eb49e908244ca4f. --- .../block_device_utils/block_device_utils_test.go | 15 +-------------- remote/mounter/block_device_utils/fs.go | 10 ---------- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/remote/mounter/block_device_utils/block_device_utils_test.go b/remote/mounter/block_device_utils/block_device_utils_test.go index 67d38441..098f12b3 100644 --- a/remote/mounter/block_device_utils/block_device_utils_test.go +++ b/remote/mounter/block_device_utils/block_device_utils_test.go @@ -611,14 +611,10 @@ mpathhb (36001738cfc9035eb0000000000cea###) dm-3 ##,## mpoint := "mpoint" err = bdUtils.MountFs(mpath, mpoint) Expect(err).To(Not(HaveOccurred())) - Expect(fakeExec.ExecuteWithTimeoutCallCount()).To(Equal(2)) + Expect(fakeExec.ExecuteWithTimeoutCallCount()).To(Equal(1)) _, cmd, args := fakeExec.ExecuteWithTimeoutArgsForCall(0) Expect(cmd).To(Equal("mount")) Expect(args).To(Equal([]string{mpath, mpoint})) - - _, cmd, args = fakeExec.ExecuteWithTimeoutArgsForCall(1) - Expect(cmd).To(Equal("chmod")) - Expect(args).To(Equal([]string{"775", mpoint})) }) It("MountFs fails if mount command missing", func() { mpath := "mpath" @@ -636,15 +632,6 @@ mpathhb (36001738cfc9035eb0000000000cea###) dm-3 ##,## Expect(err).To(HaveOccurred()) Expect(err.Error()).To(MatchRegexp(cmdErr.Error())) }) - It("MountFs fails if chmod command fails", func() { - mpath := "mpath" - mpoint := "mpoint" - fakeExec.ExecuteWithTimeoutReturnsOnCall(0, []byte{}, nil) - fakeExec.ExecuteWithTimeoutReturnsOnCall(1, []byte{}, cmdErr) - err = bdUtils.MountFs(mpath, mpoint) - Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(MatchRegexp(cmdErr.Error())) - }) }) Context(".IsDeviceMounted", func() { It("should fail if mount command missing", func() { diff --git a/remote/mounter/block_device_utils/fs.go b/remote/mounter/block_device_utils/fs.go index a836a68c..f2af2273 100644 --- a/remote/mounter/block_device_utils/fs.go +++ b/remote/mounter/block_device_utils/fs.go @@ -32,7 +32,6 @@ const ( TimeoutMilisecondMountCmdIsDeviceMounted = 20 * 1000 // max to wait for mount command TimeoutMilisecondMountCmdMountFs = 120 * 1000 // max to wait for mounting device TimeoutMilisecondUmountCmdUmountFs = 30 * 1000 // max wait timeout for umount command - TimeoutMilisecondChmodCmd = 3 * 1000 ) func (b *blockDeviceUtils) CheckFs(mpath string) (bool, error) { @@ -74,8 +73,6 @@ func (b *blockDeviceUtils) MakeFs(mpath string, fsType string) error { func (b *blockDeviceUtils) MountFs(mpath string, mpoint string) error { defer b.logger.Trace(logs.DEBUG)() mountCmd := "mount" - chmodCmd := "chmod" - if err := b.exec.IsExecutable(mountCmd); err != nil { return b.logger.ErrorRet(&commandNotFoundError{mountCmd, err}, "failed") } @@ -83,13 +80,6 @@ func (b *blockDeviceUtils) MountFs(mpath string, mpoint string) error { if _, err := b.exec.ExecuteWithTimeout(TimeoutMilisecondMountCmdMountFs, mountCmd, args); err != nil { return b.logger.ErrorRet(&CommandExecuteError{mountCmd, err}, "failed") } - - // Set explicitly the PV mountpoint permission to 775 - args = []string{"775", mpoint} - if _, err := b.exec.ExecuteWithTimeout(TimeoutMilisecondChmodCmd, chmodCmd, args); err != nil { - return b.logger.ErrorRet(&CommandExecuteError{chmodCmd, err}, "failed") - } - b.logger.Info("mounted", logs.Args{{"mpoint", mpoint}}) return nil } From ae27edce341844389ceadc68c3d25d7501c3378c Mon Sep 17 00:00:00 2001 From: 27149chen <7991675+27149chen@users.noreply.github.com> Date: Fri, 8 Mar 2019 16:33:32 +0800 Subject: [PATCH 24/36] set RESET_LIP as env Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> --- remote/mounter/initiator/linuxfc.go | 7 ++++--- remote/mounter/initiator/linuxfc_test.go | 14 ++------------ 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/remote/mounter/initiator/linuxfc.go b/remote/mounter/initiator/linuxfc.go index 44d5a9c5..dd57ca05 100644 --- a/remote/mounter/initiator/linuxfc.go +++ b/remote/mounter/initiator/linuxfc.go @@ -13,8 +13,7 @@ import ( const SYSTOOL = "systool" const SYSTOOL_TIMEOUT = 5 * 1000 - -var RESET_LIP = true +const KeyResetLIP = "RESET_LIP" var FC_HOST_SYSFS_PATH = "/sys/class/fc_host" var SCSI_HOST_SYSFS_PATH = "/sys/class/scsi_host" @@ -112,11 +111,13 @@ func (lfc *linuxFibreChannel) getFcHBAsByPath() []string { func (lfc *linuxFibreChannel) RescanHosts(hbas []string, volumeMountProperties *resources.VolumeMountProperties) error { defer lfc.logger.Trace(logs.DEBUG)() + resetLIP := os.Getenv(KeyResetLIP) + ctl := lfc.getHBAChannelScsiTarget(volumeMountProperties) for _, hba := range hbas { - if RESET_LIP { + if resetLIP != "" { lfc.lipReset(hba) } diff --git a/remote/mounter/initiator/linuxfc_test.go b/remote/mounter/initiator/linuxfc_test.go index 432a7474..9b468ea0 100644 --- a/remote/mounter/initiator/linuxfc_test.go +++ b/remote/mounter/initiator/linuxfc_test.go @@ -160,7 +160,6 @@ var _ = Describe("Test FC Initiator", func() { var scanFile = scanPath + "/scan" var lipPath = FAKE_FC_HOST_SYSFS_PATH + "/" + hbas[0] var lipFile = lipPath + "/issue_lip" - var realLipResetBool bool BeforeEach(func() { err := os.MkdirAll(scanPath, os.ModePerm) @@ -176,12 +175,11 @@ var _ = Describe("Test FC Initiator", func() { Context("RESET_LIP is true", func() { BeforeEach(func() { - realLipResetBool = initiator.RESET_LIP - initiator.RESET_LIP = true + os.Setenv("RESET_LIP", "true") }) AfterEach(func() { - initiator.RESET_LIP = realLipResetBool + os.Setenv("RESET_LIP", "") }) It("should write '- - lunid' to the hba scan file", func() { @@ -202,14 +200,6 @@ var _ = Describe("Test FC Initiator", func() { }) Context("RESET_LIP is false", func() { - BeforeEach(func() { - realLipResetBool = initiator.RESET_LIP - initiator.RESET_LIP = false - }) - - AfterEach(func() { - initiator.RESET_LIP = realLipResetBool - }) It("should write nothing to the hba lip file", func() { err := fcInitiator.RescanHosts(hbas, volumeMountProperties) From 56e2f793fe8fae4a712f9c1eef9d412bd88b6af8 Mon Sep 17 00:00:00 2001 From: 27149chen <7991675+27149chen@users.noreply.github.com> Date: Fri, 8 Mar 2019 10:36:04 +0200 Subject: [PATCH 25/36] UB-1835 new rescan and delete method (#294) * UB-1835 new rescan and delete method Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> * update comments Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> * add more ut Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> * added ut for fc connector Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> * add ut for fc initiator Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> * added ut for fc initiator Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> * update after review Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> * fixed a defect Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> * change lunNumber from int to float64 Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> * rewrite the method of getting devices from multipath output Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> * update after review Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> * set PV mountpoint chmod to 775 * add lip reset Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> --- fakes/fake_ScbeDataModel.go | 223 ++- fakes/fake_SpectrumDataModel.go | 477 ++--- fakes/fake_block_device_mounter_utils.go | 344 ++-- fakes/fake_block_device_utils.go | 1106 ++++++----- fakes/fake_executor.go | 1609 ++++++++++------- fakes/fake_mounter.go | 206 ++- fakes/fake_mounter_factory.go | 42 +- fakes/fake_scbe_data_model_wrapper.go | 318 ---- fakes/fake_scbe_rest_client.go | 607 ++++--- fakes/fake_simple_rest_client.go | 349 ++-- fakes/fake_spectrum.go | 1352 +++++++------- fakes/fake_storage_client.go | 544 +++--- local/scbe/datamodel_wrapper.go | 2 - local/scbe/scbe_rest_client.go | 2 +- local/scbe/simple_rest_client.go | 9 +- .../block_device_mounter_utils.go | 56 +- .../block_device_utils_mounter_test.go | 73 +- .../block_device_mounter_utils/resources.go | 7 +- .../block_device_utils/block_device_utils.go | 21 +- .../block_device_utils_test.go | 87 +- remote/mounter/block_device_utils/fs.go | 10 + remote/mounter/block_device_utils/mpath.go | 24 +- remote/mounter/block_device_utils/rescan.go | 80 +- .../mounter/block_device_utils/resources.go | 10 +- .../connectors/connectors_suite_test.go | 16 + .../initiator/connectors/fibre_channel.go | 87 + .../connectors/fibre_channel_test.go | 75 + .../initiator/fakes/fake_base_initiator.go | 148 ++ .../mounter/initiator/fakes/fake_connector.go | 184 ++ .../mounter/initiator/fakes/fake_initiator.go | 293 +++ .../mounter/initiator/initiator_suite_test.go | 16 + remote/mounter/initiator/linuxfc.go | 225 +++ remote/mounter/initiator/linuxfc_test.go | 261 +++ remote/mounter/initiator/linuxscsi.go | 51 + remote/mounter/initiator/resources.go | 22 + remote/mounter/mounter_factory.go | 5 +- remote/mounter/scbe.go | 53 +- remote/mounter/scbe_test.go | 32 +- resources/resources.go | 22 + utils/error.go | 19 +- utils/mpath.go | 81 + utils/mpath_test.go | 59 + 42 files changed, 5669 insertions(+), 3538 deletions(-) delete mode 100644 fakes/fake_scbe_data_model_wrapper.go create mode 100644 remote/mounter/initiator/connectors/connectors_suite_test.go create mode 100644 remote/mounter/initiator/connectors/fibre_channel.go create mode 100644 remote/mounter/initiator/connectors/fibre_channel_test.go create mode 100644 remote/mounter/initiator/fakes/fake_base_initiator.go create mode 100644 remote/mounter/initiator/fakes/fake_connector.go create mode 100644 remote/mounter/initiator/fakes/fake_initiator.go create mode 100644 remote/mounter/initiator/initiator_suite_test.go create mode 100644 remote/mounter/initiator/linuxfc.go create mode 100644 remote/mounter/initiator/linuxfc_test.go create mode 100644 remote/mounter/initiator/linuxscsi.go create mode 100644 remote/mounter/initiator/resources.go create mode 100644 utils/mpath.go create mode 100644 utils/mpath_test.go diff --git a/fakes/fake_ScbeDataModel.go b/fakes/fake_ScbeDataModel.go index 8f695867..1a56bae8 100644 --- a/fakes/fake_ScbeDataModel.go +++ b/fakes/fake_ScbeDataModel.go @@ -8,10 +8,10 @@ import ( ) type FakeScbeDataModel struct { - DeleteVolumeStub func(name string) error + DeleteVolumeStub func(string) error deleteVolumeMutex sync.RWMutex deleteVolumeArgsForCall []struct { - name string + arg1 string } deleteVolumeReturns struct { result1 error @@ -19,23 +19,10 @@ type FakeScbeDataModel struct { deleteVolumeReturnsOnCall map[int]struct { result1 error } - InsertVolumeStub func(volumeName string, wwn string, fstype string) error - insertVolumeMutex sync.RWMutex - insertVolumeArgsForCall []struct { - volumeName string - wwn string - fstype string - } - insertVolumeReturns struct { - result1 error - } - insertVolumeReturnsOnCall map[int]struct { - result1 error - } - GetVolumeStub func(name string) (scbe.ScbeVolume, bool, error) + GetVolumeStub func(string) (scbe.ScbeVolume, bool, error) getVolumeMutex sync.RWMutex getVolumeArgsForCall []struct { - name string + arg1 string } getVolumeReturns struct { result1 scbe.ScbeVolume @@ -47,10 +34,24 @@ type FakeScbeDataModel struct { result2 bool result3 error } + InsertVolumeStub func(string, string, string) error + insertVolumeMutex sync.RWMutex + insertVolumeArgsForCall []struct { + arg1 string + arg2 string + arg3 string + } + insertVolumeReturns struct { + result1 error + } + insertVolumeReturnsOnCall map[int]struct { + result1 error + } ListVolumesStub func() ([]scbe.ScbeVolume, error) listVolumesMutex sync.RWMutex - listVolumesArgsForCall []struct{} - listVolumesReturns struct { + listVolumesArgsForCall []struct { + } + listVolumesReturns struct { result1 []scbe.ScbeVolume result2 error } @@ -62,21 +63,22 @@ type FakeScbeDataModel struct { invocationsMutex sync.RWMutex } -func (fake *FakeScbeDataModel) DeleteVolume(name string) error { +func (fake *FakeScbeDataModel) DeleteVolume(arg1 string) error { fake.deleteVolumeMutex.Lock() ret, specificReturn := fake.deleteVolumeReturnsOnCall[len(fake.deleteVolumeArgsForCall)] fake.deleteVolumeArgsForCall = append(fake.deleteVolumeArgsForCall, struct { - name string - }{name}) - fake.recordInvocation("DeleteVolume", []interface{}{name}) + arg1 string + }{arg1}) + fake.recordInvocation("DeleteVolume", []interface{}{arg1}) fake.deleteVolumeMutex.Unlock() if fake.DeleteVolumeStub != nil { - return fake.DeleteVolumeStub(name) + return fake.DeleteVolumeStub(arg1) } if specificReturn { return ret.result1 } - return fake.deleteVolumeReturns.result1 + fakeReturns := fake.deleteVolumeReturns + return fakeReturns.result1 } func (fake *FakeScbeDataModel) DeleteVolumeCallCount() int { @@ -85,13 +87,22 @@ func (fake *FakeScbeDataModel) DeleteVolumeCallCount() int { return len(fake.deleteVolumeArgsForCall) } +func (fake *FakeScbeDataModel) DeleteVolumeCalls(stub func(string) error) { + fake.deleteVolumeMutex.Lock() + defer fake.deleteVolumeMutex.Unlock() + fake.DeleteVolumeStub = stub +} + func (fake *FakeScbeDataModel) DeleteVolumeArgsForCall(i int) string { fake.deleteVolumeMutex.RLock() defer fake.deleteVolumeMutex.RUnlock() - return fake.deleteVolumeArgsForCall[i].name + argsForCall := fake.deleteVolumeArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeScbeDataModel) DeleteVolumeReturns(result1 error) { + fake.deleteVolumeMutex.Lock() + defer fake.deleteVolumeMutex.Unlock() fake.DeleteVolumeStub = nil fake.deleteVolumeReturns = struct { result1 error @@ -99,6 +110,8 @@ func (fake *FakeScbeDataModel) DeleteVolumeReturns(result1 error) { } func (fake *FakeScbeDataModel) DeleteVolumeReturnsOnCall(i int, result1 error) { + fake.deleteVolumeMutex.Lock() + defer fake.deleteVolumeMutex.Unlock() fake.DeleteVolumeStub = nil if fake.deleteVolumeReturnsOnCall == nil { fake.deleteVolumeReturnsOnCall = make(map[int]struct { @@ -110,71 +123,22 @@ func (fake *FakeScbeDataModel) DeleteVolumeReturnsOnCall(i int, result1 error) { }{result1} } -func (fake *FakeScbeDataModel) InsertVolume(volumeName string, wwn string, fstype string) error { - fake.insertVolumeMutex.Lock() - ret, specificReturn := fake.insertVolumeReturnsOnCall[len(fake.insertVolumeArgsForCall)] - fake.insertVolumeArgsForCall = append(fake.insertVolumeArgsForCall, struct { - volumeName string - wwn string - fstype string - }{volumeName, wwn, fstype}) - fake.recordInvocation("InsertVolume", []interface{}{volumeName, wwn, fstype}) - fake.insertVolumeMutex.Unlock() - if fake.InsertVolumeStub != nil { - return fake.InsertVolumeStub(volumeName, wwn, fstype) - } - if specificReturn { - return ret.result1 - } - return fake.insertVolumeReturns.result1 -} - -func (fake *FakeScbeDataModel) InsertVolumeCallCount() int { - fake.insertVolumeMutex.RLock() - defer fake.insertVolumeMutex.RUnlock() - return len(fake.insertVolumeArgsForCall) -} - -func (fake *FakeScbeDataModel) InsertVolumeArgsForCall(i int) (string, string, string) { - fake.insertVolumeMutex.RLock() - defer fake.insertVolumeMutex.RUnlock() - return fake.insertVolumeArgsForCall[i].volumeName, fake.insertVolumeArgsForCall[i].wwn, fake.insertVolumeArgsForCall[i].fstype -} - -func (fake *FakeScbeDataModel) InsertVolumeReturns(result1 error) { - fake.InsertVolumeStub = nil - fake.insertVolumeReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeScbeDataModel) InsertVolumeReturnsOnCall(i int, result1 error) { - fake.InsertVolumeStub = nil - if fake.insertVolumeReturnsOnCall == nil { - fake.insertVolumeReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.insertVolumeReturnsOnCall[i] = struct { - result1 error - }{result1} -} - -func (fake *FakeScbeDataModel) GetVolume(name string) (scbe.ScbeVolume, bool, error) { +func (fake *FakeScbeDataModel) GetVolume(arg1 string) (scbe.ScbeVolume, bool, error) { fake.getVolumeMutex.Lock() ret, specificReturn := fake.getVolumeReturnsOnCall[len(fake.getVolumeArgsForCall)] fake.getVolumeArgsForCall = append(fake.getVolumeArgsForCall, struct { - name string - }{name}) - fake.recordInvocation("GetVolume", []interface{}{name}) + arg1 string + }{arg1}) + fake.recordInvocation("GetVolume", []interface{}{arg1}) fake.getVolumeMutex.Unlock() if fake.GetVolumeStub != nil { - return fake.GetVolumeStub(name) + return fake.GetVolumeStub(arg1) } if specificReturn { return ret.result1, ret.result2, ret.result3 } - return fake.getVolumeReturns.result1, fake.getVolumeReturns.result2, fake.getVolumeReturns.result3 + fakeReturns := fake.getVolumeReturns + return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } func (fake *FakeScbeDataModel) GetVolumeCallCount() int { @@ -183,13 +147,22 @@ func (fake *FakeScbeDataModel) GetVolumeCallCount() int { return len(fake.getVolumeArgsForCall) } +func (fake *FakeScbeDataModel) GetVolumeCalls(stub func(string) (scbe.ScbeVolume, bool, error)) { + fake.getVolumeMutex.Lock() + defer fake.getVolumeMutex.Unlock() + fake.GetVolumeStub = stub +} + func (fake *FakeScbeDataModel) GetVolumeArgsForCall(i int) string { fake.getVolumeMutex.RLock() defer fake.getVolumeMutex.RUnlock() - return fake.getVolumeArgsForCall[i].name + argsForCall := fake.getVolumeArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeScbeDataModel) GetVolumeReturns(result1 scbe.ScbeVolume, result2 bool, result3 error) { + fake.getVolumeMutex.Lock() + defer fake.getVolumeMutex.Unlock() fake.GetVolumeStub = nil fake.getVolumeReturns = struct { result1 scbe.ScbeVolume @@ -199,6 +172,8 @@ func (fake *FakeScbeDataModel) GetVolumeReturns(result1 scbe.ScbeVolume, result2 } func (fake *FakeScbeDataModel) GetVolumeReturnsOnCall(i int, result1 scbe.ScbeVolume, result2 bool, result3 error) { + fake.getVolumeMutex.Lock() + defer fake.getVolumeMutex.Unlock() fake.GetVolumeStub = nil if fake.getVolumeReturnsOnCall == nil { fake.getVolumeReturnsOnCall = make(map[int]struct { @@ -214,10 +189,73 @@ func (fake *FakeScbeDataModel) GetVolumeReturnsOnCall(i int, result1 scbe.ScbeVo }{result1, result2, result3} } +func (fake *FakeScbeDataModel) InsertVolume(arg1 string, arg2 string, arg3 string) error { + fake.insertVolumeMutex.Lock() + ret, specificReturn := fake.insertVolumeReturnsOnCall[len(fake.insertVolumeArgsForCall)] + fake.insertVolumeArgsForCall = append(fake.insertVolumeArgsForCall, struct { + arg1 string + arg2 string + arg3 string + }{arg1, arg2, arg3}) + fake.recordInvocation("InsertVolume", []interface{}{arg1, arg2, arg3}) + fake.insertVolumeMutex.Unlock() + if fake.InsertVolumeStub != nil { + return fake.InsertVolumeStub(arg1, arg2, arg3) + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.insertVolumeReturns + return fakeReturns.result1 +} + +func (fake *FakeScbeDataModel) InsertVolumeCallCount() int { + fake.insertVolumeMutex.RLock() + defer fake.insertVolumeMutex.RUnlock() + return len(fake.insertVolumeArgsForCall) +} + +func (fake *FakeScbeDataModel) InsertVolumeCalls(stub func(string, string, string) error) { + fake.insertVolumeMutex.Lock() + defer fake.insertVolumeMutex.Unlock() + fake.InsertVolumeStub = stub +} + +func (fake *FakeScbeDataModel) InsertVolumeArgsForCall(i int) (string, string, string) { + fake.insertVolumeMutex.RLock() + defer fake.insertVolumeMutex.RUnlock() + argsForCall := fake.insertVolumeArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 +} + +func (fake *FakeScbeDataModel) InsertVolumeReturns(result1 error) { + fake.insertVolumeMutex.Lock() + defer fake.insertVolumeMutex.Unlock() + fake.InsertVolumeStub = nil + fake.insertVolumeReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeScbeDataModel) InsertVolumeReturnsOnCall(i int, result1 error) { + fake.insertVolumeMutex.Lock() + defer fake.insertVolumeMutex.Unlock() + fake.InsertVolumeStub = nil + if fake.insertVolumeReturnsOnCall == nil { + fake.insertVolumeReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.insertVolumeReturnsOnCall[i] = struct { + result1 error + }{result1} +} + func (fake *FakeScbeDataModel) ListVolumes() ([]scbe.ScbeVolume, error) { fake.listVolumesMutex.Lock() ret, specificReturn := fake.listVolumesReturnsOnCall[len(fake.listVolumesArgsForCall)] - fake.listVolumesArgsForCall = append(fake.listVolumesArgsForCall, struct{}{}) + fake.listVolumesArgsForCall = append(fake.listVolumesArgsForCall, struct { + }{}) fake.recordInvocation("ListVolumes", []interface{}{}) fake.listVolumesMutex.Unlock() if fake.ListVolumesStub != nil { @@ -226,7 +264,8 @@ func (fake *FakeScbeDataModel) ListVolumes() ([]scbe.ScbeVolume, error) { if specificReturn { return ret.result1, ret.result2 } - return fake.listVolumesReturns.result1, fake.listVolumesReturns.result2 + fakeReturns := fake.listVolumesReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeScbeDataModel) ListVolumesCallCount() int { @@ -235,7 +274,15 @@ func (fake *FakeScbeDataModel) ListVolumesCallCount() int { return len(fake.listVolumesArgsForCall) } +func (fake *FakeScbeDataModel) ListVolumesCalls(stub func() ([]scbe.ScbeVolume, error)) { + fake.listVolumesMutex.Lock() + defer fake.listVolumesMutex.Unlock() + fake.ListVolumesStub = stub +} + func (fake *FakeScbeDataModel) ListVolumesReturns(result1 []scbe.ScbeVolume, result2 error) { + fake.listVolumesMutex.Lock() + defer fake.listVolumesMutex.Unlock() fake.ListVolumesStub = nil fake.listVolumesReturns = struct { result1 []scbe.ScbeVolume @@ -244,6 +291,8 @@ func (fake *FakeScbeDataModel) ListVolumesReturns(result1 []scbe.ScbeVolume, res } func (fake *FakeScbeDataModel) ListVolumesReturnsOnCall(i int, result1 []scbe.ScbeVolume, result2 error) { + fake.listVolumesMutex.Lock() + defer fake.listVolumesMutex.Unlock() fake.ListVolumesStub = nil if fake.listVolumesReturnsOnCall == nil { fake.listVolumesReturnsOnCall = make(map[int]struct { @@ -262,10 +311,10 @@ func (fake *FakeScbeDataModel) Invocations() map[string][][]interface{} { defer fake.invocationsMutex.RUnlock() fake.deleteVolumeMutex.RLock() defer fake.deleteVolumeMutex.RUnlock() - fake.insertVolumeMutex.RLock() - defer fake.insertVolumeMutex.RUnlock() fake.getVolumeMutex.RLock() defer fake.getVolumeMutex.RUnlock() + fake.insertVolumeMutex.RLock() + defer fake.insertVolumeMutex.RUnlock() fake.listVolumesMutex.RLock() defer fake.listVolumesMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} diff --git a/fakes/fake_SpectrumDataModel.go b/fakes/fake_SpectrumDataModel.go index 9eff3fbe..a9547b36 100644 --- a/fakes/fake_SpectrumDataModel.go +++ b/fakes/fake_SpectrumDataModel.go @@ -1,19 +1,3 @@ -/** - * Copyright 2017 IBM Corp. - * - * 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. - */ - // Code generated by counterfeiter. DO NOT EDIT. package fakes @@ -27,17 +11,18 @@ import ( type FakeSpectrumDataModel struct { CreateVolumeTableStub func() error createVolumeTableMutex sync.RWMutex - createVolumeTableArgsForCall []struct{} - createVolumeTableReturns struct { + createVolumeTableArgsForCall []struct { + } + createVolumeTableReturns struct { result1 error } createVolumeTableReturnsOnCall map[int]struct { result1 error } - DeleteVolumeStub func(name string) error + DeleteVolumeStub func(string) error deleteVolumeMutex sync.RWMutex deleteVolumeArgsForCall []struct { - name string + arg1 string } deleteVolumeReturns struct { result1 error @@ -45,46 +30,30 @@ type FakeSpectrumDataModel struct { deleteVolumeReturnsOnCall map[int]struct { result1 error } - InsertFilesetVolumeStub func(fileset, volumeName string, filesystem string, isPreexisting bool, opts map[string]interface{}) error - insertFilesetVolumeMutex sync.RWMutex - insertFilesetVolumeArgsForCall []struct { - fileset string - volumeName string - filesystem string - isPreexisting bool - opts map[string]interface{} - } - insertFilesetVolumeReturns struct { - result1 error - } - insertFilesetVolumeReturnsOnCall map[int]struct { - result1 error + GetVolumeStub func(string) (spectrumscale.SpectrumScaleVolume, bool, error) + getVolumeMutex sync.RWMutex + getVolumeArgsForCall []struct { + arg1 string } - InsertLightweightVolumeStub func(fileset, directory, volumeName string, filesystem string, isPreexisting bool, opts map[string]interface{}) error - insertLightweightVolumeMutex sync.RWMutex - insertLightweightVolumeArgsForCall []struct { - fileset string - directory string - volumeName string - filesystem string - isPreexisting bool - opts map[string]interface{} - } - insertLightweightVolumeReturns struct { - result1 error + getVolumeReturns struct { + result1 spectrumscale.SpectrumScaleVolume + result2 bool + result3 error } - insertLightweightVolumeReturnsOnCall map[int]struct { - result1 error + getVolumeReturnsOnCall map[int]struct { + result1 spectrumscale.SpectrumScaleVolume + result2 bool + result3 error } - InsertFilesetQuotaVolumeStub func(fileset, quota, volumeName string, filesystem string, isPreexisting bool, opts map[string]interface{}) error + InsertFilesetQuotaVolumeStub func(string, string, string, string, bool, map[string]interface{}) error insertFilesetQuotaVolumeMutex sync.RWMutex insertFilesetQuotaVolumeArgsForCall []struct { - fileset string - quota string - volumeName string - filesystem string - isPreexisting bool - opts map[string]interface{} + arg1 string + arg2 string + arg3 string + arg4 string + arg5 bool + arg6 map[string]interface{} } insertFilesetQuotaVolumeReturns struct { result1 error @@ -92,25 +61,26 @@ type FakeSpectrumDataModel struct { insertFilesetQuotaVolumeReturnsOnCall map[int]struct { result1 error } - GetVolumeStub func(name string) (spectrumscale.SpectrumScaleVolume, bool, error) - getVolumeMutex sync.RWMutex - getVolumeArgsForCall []struct { - name string + InsertFilesetVolumeStub func(string, string, string, bool, map[string]interface{}) error + insertFilesetVolumeMutex sync.RWMutex + insertFilesetVolumeArgsForCall []struct { + arg1 string + arg2 string + arg3 string + arg4 bool + arg5 map[string]interface{} } - getVolumeReturns struct { - result1 spectrumscale.SpectrumScaleVolume - result2 bool - result3 error + insertFilesetVolumeReturns struct { + result1 error } - getVolumeReturnsOnCall map[int]struct { - result1 spectrumscale.SpectrumScaleVolume - result2 bool - result3 error + insertFilesetVolumeReturnsOnCall map[int]struct { + result1 error } ListVolumesStub func() ([]resources.Volume, error) listVolumesMutex sync.RWMutex - listVolumesArgsForCall []struct{} - listVolumesReturns struct { + listVolumesArgsForCall []struct { + } + listVolumesReturns struct { result1 []resources.Volume result2 error } @@ -118,11 +88,11 @@ type FakeSpectrumDataModel struct { result1 []resources.Volume result2 error } - UpdateVolumeMountpointStub func(name string, mountpoint string) error + UpdateVolumeMountpointStub func(string, string) error updateVolumeMountpointMutex sync.RWMutex updateVolumeMountpointArgsForCall []struct { - name string - mountpoint string + arg1 string + arg2 string } updateVolumeMountpointReturns struct { result1 error @@ -137,7 +107,8 @@ type FakeSpectrumDataModel struct { func (fake *FakeSpectrumDataModel) CreateVolumeTable() error { fake.createVolumeTableMutex.Lock() ret, specificReturn := fake.createVolumeTableReturnsOnCall[len(fake.createVolumeTableArgsForCall)] - fake.createVolumeTableArgsForCall = append(fake.createVolumeTableArgsForCall, struct{}{}) + fake.createVolumeTableArgsForCall = append(fake.createVolumeTableArgsForCall, struct { + }{}) fake.recordInvocation("CreateVolumeTable", []interface{}{}) fake.createVolumeTableMutex.Unlock() if fake.CreateVolumeTableStub != nil { @@ -146,7 +117,8 @@ func (fake *FakeSpectrumDataModel) CreateVolumeTable() error { if specificReturn { return ret.result1 } - return fake.createVolumeTableReturns.result1 + fakeReturns := fake.createVolumeTableReturns + return fakeReturns.result1 } func (fake *FakeSpectrumDataModel) CreateVolumeTableCallCount() int { @@ -155,7 +127,15 @@ func (fake *FakeSpectrumDataModel) CreateVolumeTableCallCount() int { return len(fake.createVolumeTableArgsForCall) } +func (fake *FakeSpectrumDataModel) CreateVolumeTableCalls(stub func() error) { + fake.createVolumeTableMutex.Lock() + defer fake.createVolumeTableMutex.Unlock() + fake.CreateVolumeTableStub = stub +} + func (fake *FakeSpectrumDataModel) CreateVolumeTableReturns(result1 error) { + fake.createVolumeTableMutex.Lock() + defer fake.createVolumeTableMutex.Unlock() fake.CreateVolumeTableStub = nil fake.createVolumeTableReturns = struct { result1 error @@ -163,6 +143,8 @@ func (fake *FakeSpectrumDataModel) CreateVolumeTableReturns(result1 error) { } func (fake *FakeSpectrumDataModel) CreateVolumeTableReturnsOnCall(i int, result1 error) { + fake.createVolumeTableMutex.Lock() + defer fake.createVolumeTableMutex.Unlock() fake.CreateVolumeTableStub = nil if fake.createVolumeTableReturnsOnCall == nil { fake.createVolumeTableReturnsOnCall = make(map[int]struct { @@ -174,21 +156,22 @@ func (fake *FakeSpectrumDataModel) CreateVolumeTableReturnsOnCall(i int, result1 }{result1} } -func (fake *FakeSpectrumDataModel) DeleteVolume(name string) error { +func (fake *FakeSpectrumDataModel) DeleteVolume(arg1 string) error { fake.deleteVolumeMutex.Lock() ret, specificReturn := fake.deleteVolumeReturnsOnCall[len(fake.deleteVolumeArgsForCall)] fake.deleteVolumeArgsForCall = append(fake.deleteVolumeArgsForCall, struct { - name string - }{name}) - fake.recordInvocation("DeleteVolume", []interface{}{name}) + arg1 string + }{arg1}) + fake.recordInvocation("DeleteVolume", []interface{}{arg1}) fake.deleteVolumeMutex.Unlock() if fake.DeleteVolumeStub != nil { - return fake.DeleteVolumeStub(name) + return fake.DeleteVolumeStub(arg1) } if specificReturn { return ret.result1 } - return fake.deleteVolumeReturns.result1 + fakeReturns := fake.deleteVolumeReturns + return fakeReturns.result1 } func (fake *FakeSpectrumDataModel) DeleteVolumeCallCount() int { @@ -197,13 +180,22 @@ func (fake *FakeSpectrumDataModel) DeleteVolumeCallCount() int { return len(fake.deleteVolumeArgsForCall) } +func (fake *FakeSpectrumDataModel) DeleteVolumeCalls(stub func(string) error) { + fake.deleteVolumeMutex.Lock() + defer fake.deleteVolumeMutex.Unlock() + fake.DeleteVolumeStub = stub +} + func (fake *FakeSpectrumDataModel) DeleteVolumeArgsForCall(i int) string { fake.deleteVolumeMutex.RLock() defer fake.deleteVolumeMutex.RUnlock() - return fake.deleteVolumeArgsForCall[i].name + argsForCall := fake.deleteVolumeArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeSpectrumDataModel) DeleteVolumeReturns(result1 error) { + fake.deleteVolumeMutex.Lock() + defer fake.deleteVolumeMutex.Unlock() fake.DeleteVolumeStub = nil fake.deleteVolumeReturns = struct { result1 error @@ -211,6 +203,8 @@ func (fake *FakeSpectrumDataModel) DeleteVolumeReturns(result1 error) { } func (fake *FakeSpectrumDataModel) DeleteVolumeReturnsOnCall(i int, result1 error) { + fake.deleteVolumeMutex.Lock() + defer fake.deleteVolumeMutex.Unlock() fake.DeleteVolumeStub = nil if fake.deleteVolumeReturnsOnCall == nil { fake.deleteVolumeReturnsOnCall = make(map[int]struct { @@ -222,131 +216,93 @@ func (fake *FakeSpectrumDataModel) DeleteVolumeReturnsOnCall(i int, result1 erro }{result1} } -func (fake *FakeSpectrumDataModel) InsertFilesetVolume(fileset string, volumeName string, filesystem string, isPreexisting bool, opts map[string]interface{}) error { - fake.insertFilesetVolumeMutex.Lock() - ret, specificReturn := fake.insertFilesetVolumeReturnsOnCall[len(fake.insertFilesetVolumeArgsForCall)] - fake.insertFilesetVolumeArgsForCall = append(fake.insertFilesetVolumeArgsForCall, struct { - fileset string - volumeName string - filesystem string - isPreexisting bool - opts map[string]interface{} - }{fileset, volumeName, filesystem, isPreexisting, opts}) - fake.recordInvocation("InsertFilesetVolume", []interface{}{fileset, volumeName, filesystem, isPreexisting, opts}) - fake.insertFilesetVolumeMutex.Unlock() - if fake.InsertFilesetVolumeStub != nil { - return fake.InsertFilesetVolumeStub(fileset, volumeName, filesystem, isPreexisting, opts) +func (fake *FakeSpectrumDataModel) GetVolume(arg1 string) (spectrumscale.SpectrumScaleVolume, bool, error) { + fake.getVolumeMutex.Lock() + ret, specificReturn := fake.getVolumeReturnsOnCall[len(fake.getVolumeArgsForCall)] + fake.getVolumeArgsForCall = append(fake.getVolumeArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("GetVolume", []interface{}{arg1}) + fake.getVolumeMutex.Unlock() + if fake.GetVolumeStub != nil { + return fake.GetVolumeStub(arg1) } if specificReturn { - return ret.result1 - } - return fake.insertFilesetVolumeReturns.result1 -} - -func (fake *FakeSpectrumDataModel) InsertFilesetVolumeCallCount() int { - fake.insertFilesetVolumeMutex.RLock() - defer fake.insertFilesetVolumeMutex.RUnlock() - return len(fake.insertFilesetVolumeArgsForCall) -} - -func (fake *FakeSpectrumDataModel) InsertFilesetVolumeArgsForCall(i int) (string, string, string, bool, map[string]interface{}) { - fake.insertFilesetVolumeMutex.RLock() - defer fake.insertFilesetVolumeMutex.RUnlock() - return fake.insertFilesetVolumeArgsForCall[i].fileset, fake.insertFilesetVolumeArgsForCall[i].volumeName, fake.insertFilesetVolumeArgsForCall[i].filesystem, fake.insertFilesetVolumeArgsForCall[i].isPreexisting, fake.insertFilesetVolumeArgsForCall[i].opts -} - -func (fake *FakeSpectrumDataModel) InsertFilesetVolumeReturns(result1 error) { - fake.InsertFilesetVolumeStub = nil - fake.insertFilesetVolumeReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeSpectrumDataModel) InsertFilesetVolumeReturnsOnCall(i int, result1 error) { - fake.InsertFilesetVolumeStub = nil - if fake.insertFilesetVolumeReturnsOnCall == nil { - fake.insertFilesetVolumeReturnsOnCall = make(map[int]struct { - result1 error - }) + return ret.result1, ret.result2, ret.result3 } - fake.insertFilesetVolumeReturnsOnCall[i] = struct { - result1 error - }{result1} + fakeReturns := fake.getVolumeReturns + return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } -func (fake *FakeSpectrumDataModel) InsertLightweightVolume(fileset string, directory string, volumeName string, filesystem string, isPreexisting bool, opts map[string]interface{}) error { - fake.insertLightweightVolumeMutex.Lock() - ret, specificReturn := fake.insertLightweightVolumeReturnsOnCall[len(fake.insertLightweightVolumeArgsForCall)] - fake.insertLightweightVolumeArgsForCall = append(fake.insertLightweightVolumeArgsForCall, struct { - fileset string - directory string - volumeName string - filesystem string - isPreexisting bool - opts map[string]interface{} - }{fileset, directory, volumeName, filesystem, isPreexisting, opts}) - fake.recordInvocation("InsertLightweightVolume", []interface{}{fileset, directory, volumeName, filesystem, isPreexisting, opts}) - fake.insertLightweightVolumeMutex.Unlock() - if fake.InsertLightweightVolumeStub != nil { - return fake.InsertLightweightVolumeStub(fileset, directory, volumeName, filesystem, isPreexisting, opts) - } - if specificReturn { - return ret.result1 - } - return fake.insertLightweightVolumeReturns.result1 +func (fake *FakeSpectrumDataModel) GetVolumeCallCount() int { + fake.getVolumeMutex.RLock() + defer fake.getVolumeMutex.RUnlock() + return len(fake.getVolumeArgsForCall) } -func (fake *FakeSpectrumDataModel) InsertLightweightVolumeCallCount() int { - fake.insertLightweightVolumeMutex.RLock() - defer fake.insertLightweightVolumeMutex.RUnlock() - return len(fake.insertLightweightVolumeArgsForCall) +func (fake *FakeSpectrumDataModel) GetVolumeCalls(stub func(string) (spectrumscale.SpectrumScaleVolume, bool, error)) { + fake.getVolumeMutex.Lock() + defer fake.getVolumeMutex.Unlock() + fake.GetVolumeStub = stub } -func (fake *FakeSpectrumDataModel) InsertLightweightVolumeArgsForCall(i int) (string, string, string, string, bool, map[string]interface{}) { - fake.insertLightweightVolumeMutex.RLock() - defer fake.insertLightweightVolumeMutex.RUnlock() - return fake.insertLightweightVolumeArgsForCall[i].fileset, fake.insertLightweightVolumeArgsForCall[i].directory, fake.insertLightweightVolumeArgsForCall[i].volumeName, fake.insertLightweightVolumeArgsForCall[i].filesystem, fake.insertLightweightVolumeArgsForCall[i].isPreexisting, fake.insertLightweightVolumeArgsForCall[i].opts +func (fake *FakeSpectrumDataModel) GetVolumeArgsForCall(i int) string { + fake.getVolumeMutex.RLock() + defer fake.getVolumeMutex.RUnlock() + argsForCall := fake.getVolumeArgsForCall[i] + return argsForCall.arg1 } -func (fake *FakeSpectrumDataModel) InsertLightweightVolumeReturns(result1 error) { - fake.InsertLightweightVolumeStub = nil - fake.insertLightweightVolumeReturns = struct { - result1 error - }{result1} +func (fake *FakeSpectrumDataModel) GetVolumeReturns(result1 spectrumscale.SpectrumScaleVolume, result2 bool, result3 error) { + fake.getVolumeMutex.Lock() + defer fake.getVolumeMutex.Unlock() + fake.GetVolumeStub = nil + fake.getVolumeReturns = struct { + result1 spectrumscale.SpectrumScaleVolume + result2 bool + result3 error + }{result1, result2, result3} } -func (fake *FakeSpectrumDataModel) InsertLightweightVolumeReturnsOnCall(i int, result1 error) { - fake.InsertLightweightVolumeStub = nil - if fake.insertLightweightVolumeReturnsOnCall == nil { - fake.insertLightweightVolumeReturnsOnCall = make(map[int]struct { - result1 error +func (fake *FakeSpectrumDataModel) GetVolumeReturnsOnCall(i int, result1 spectrumscale.SpectrumScaleVolume, result2 bool, result3 error) { + fake.getVolumeMutex.Lock() + defer fake.getVolumeMutex.Unlock() + fake.GetVolumeStub = nil + if fake.getVolumeReturnsOnCall == nil { + fake.getVolumeReturnsOnCall = make(map[int]struct { + result1 spectrumscale.SpectrumScaleVolume + result2 bool + result3 error }) } - fake.insertLightweightVolumeReturnsOnCall[i] = struct { - result1 error - }{result1} + fake.getVolumeReturnsOnCall[i] = struct { + result1 spectrumscale.SpectrumScaleVolume + result2 bool + result3 error + }{result1, result2, result3} } -func (fake *FakeSpectrumDataModel) InsertFilesetQuotaVolume(fileset string, quota string, volumeName string, filesystem string, isPreexisting bool, opts map[string]interface{}) error { +func (fake *FakeSpectrumDataModel) InsertFilesetQuotaVolume(arg1 string, arg2 string, arg3 string, arg4 string, arg5 bool, arg6 map[string]interface{}) error { fake.insertFilesetQuotaVolumeMutex.Lock() ret, specificReturn := fake.insertFilesetQuotaVolumeReturnsOnCall[len(fake.insertFilesetQuotaVolumeArgsForCall)] fake.insertFilesetQuotaVolumeArgsForCall = append(fake.insertFilesetQuotaVolumeArgsForCall, struct { - fileset string - quota string - volumeName string - filesystem string - isPreexisting bool - opts map[string]interface{} - }{fileset, quota, volumeName, filesystem, isPreexisting, opts}) - fake.recordInvocation("InsertFilesetQuotaVolume", []interface{}{fileset, quota, volumeName, filesystem, isPreexisting, opts}) + arg1 string + arg2 string + arg3 string + arg4 string + arg5 bool + arg6 map[string]interface{} + }{arg1, arg2, arg3, arg4, arg5, arg6}) + fake.recordInvocation("InsertFilesetQuotaVolume", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6}) fake.insertFilesetQuotaVolumeMutex.Unlock() if fake.InsertFilesetQuotaVolumeStub != nil { - return fake.InsertFilesetQuotaVolumeStub(fileset, quota, volumeName, filesystem, isPreexisting, opts) + return fake.InsertFilesetQuotaVolumeStub(arg1, arg2, arg3, arg4, arg5, arg6) } if specificReturn { return ret.result1 } - return fake.insertFilesetQuotaVolumeReturns.result1 + fakeReturns := fake.insertFilesetQuotaVolumeReturns + return fakeReturns.result1 } func (fake *FakeSpectrumDataModel) InsertFilesetQuotaVolumeCallCount() int { @@ -355,13 +311,22 @@ func (fake *FakeSpectrumDataModel) InsertFilesetQuotaVolumeCallCount() int { return len(fake.insertFilesetQuotaVolumeArgsForCall) } +func (fake *FakeSpectrumDataModel) InsertFilesetQuotaVolumeCalls(stub func(string, string, string, string, bool, map[string]interface{}) error) { + fake.insertFilesetQuotaVolumeMutex.Lock() + defer fake.insertFilesetQuotaVolumeMutex.Unlock() + fake.InsertFilesetQuotaVolumeStub = stub +} + func (fake *FakeSpectrumDataModel) InsertFilesetQuotaVolumeArgsForCall(i int) (string, string, string, string, bool, map[string]interface{}) { fake.insertFilesetQuotaVolumeMutex.RLock() defer fake.insertFilesetQuotaVolumeMutex.RUnlock() - return fake.insertFilesetQuotaVolumeArgsForCall[i].fileset, fake.insertFilesetQuotaVolumeArgsForCall[i].quota, fake.insertFilesetQuotaVolumeArgsForCall[i].volumeName, fake.insertFilesetQuotaVolumeArgsForCall[i].filesystem, fake.insertFilesetQuotaVolumeArgsForCall[i].isPreexisting, fake.insertFilesetQuotaVolumeArgsForCall[i].opts + argsForCall := fake.insertFilesetQuotaVolumeArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5, argsForCall.arg6 } func (fake *FakeSpectrumDataModel) InsertFilesetQuotaVolumeReturns(result1 error) { + fake.insertFilesetQuotaVolumeMutex.Lock() + defer fake.insertFilesetQuotaVolumeMutex.Unlock() fake.InsertFilesetQuotaVolumeStub = nil fake.insertFilesetQuotaVolumeReturns = struct { result1 error @@ -369,6 +334,8 @@ func (fake *FakeSpectrumDataModel) InsertFilesetQuotaVolumeReturns(result1 error } func (fake *FakeSpectrumDataModel) InsertFilesetQuotaVolumeReturnsOnCall(i int, result1 error) { + fake.insertFilesetQuotaVolumeMutex.Lock() + defer fake.insertFilesetQuotaVolumeMutex.Unlock() fake.InsertFilesetQuotaVolumeStub = nil if fake.insertFilesetQuotaVolumeReturnsOnCall == nil { fake.insertFilesetQuotaVolumeReturnsOnCall = make(map[int]struct { @@ -380,64 +347,75 @@ func (fake *FakeSpectrumDataModel) InsertFilesetQuotaVolumeReturnsOnCall(i int, }{result1} } -func (fake *FakeSpectrumDataModel) GetVolume(name string) (spectrumscale.SpectrumScaleVolume, bool, error) { - fake.getVolumeMutex.Lock() - ret, specificReturn := fake.getVolumeReturnsOnCall[len(fake.getVolumeArgsForCall)] - fake.getVolumeArgsForCall = append(fake.getVolumeArgsForCall, struct { - name string - }{name}) - fake.recordInvocation("GetVolume", []interface{}{name}) - fake.getVolumeMutex.Unlock() - if fake.GetVolumeStub != nil { - return fake.GetVolumeStub(name) +func (fake *FakeSpectrumDataModel) InsertFilesetVolume(arg1 string, arg2 string, arg3 string, arg4 bool, arg5 map[string]interface{}) error { + fake.insertFilesetVolumeMutex.Lock() + ret, specificReturn := fake.insertFilesetVolumeReturnsOnCall[len(fake.insertFilesetVolumeArgsForCall)] + fake.insertFilesetVolumeArgsForCall = append(fake.insertFilesetVolumeArgsForCall, struct { + arg1 string + arg2 string + arg3 string + arg4 bool + arg5 map[string]interface{} + }{arg1, arg2, arg3, arg4, arg5}) + fake.recordInvocation("InsertFilesetVolume", []interface{}{arg1, arg2, arg3, arg4, arg5}) + fake.insertFilesetVolumeMutex.Unlock() + if fake.InsertFilesetVolumeStub != nil { + return fake.InsertFilesetVolumeStub(arg1, arg2, arg3, arg4, arg5) } if specificReturn { - return ret.result1, ret.result2, ret.result3 + return ret.result1 } - return fake.getVolumeReturns.result1, fake.getVolumeReturns.result2, fake.getVolumeReturns.result3 + fakeReturns := fake.insertFilesetVolumeReturns + return fakeReturns.result1 } -func (fake *FakeSpectrumDataModel) GetVolumeCallCount() int { - fake.getVolumeMutex.RLock() - defer fake.getVolumeMutex.RUnlock() - return len(fake.getVolumeArgsForCall) +func (fake *FakeSpectrumDataModel) InsertFilesetVolumeCallCount() int { + fake.insertFilesetVolumeMutex.RLock() + defer fake.insertFilesetVolumeMutex.RUnlock() + return len(fake.insertFilesetVolumeArgsForCall) } -func (fake *FakeSpectrumDataModel) GetVolumeArgsForCall(i int) string { - fake.getVolumeMutex.RLock() - defer fake.getVolumeMutex.RUnlock() - return fake.getVolumeArgsForCall[i].name +func (fake *FakeSpectrumDataModel) InsertFilesetVolumeCalls(stub func(string, string, string, bool, map[string]interface{}) error) { + fake.insertFilesetVolumeMutex.Lock() + defer fake.insertFilesetVolumeMutex.Unlock() + fake.InsertFilesetVolumeStub = stub } -func (fake *FakeSpectrumDataModel) GetVolumeReturns(result1 spectrumscale.SpectrumScaleVolume, result2 bool, result3 error) { - fake.GetVolumeStub = nil - fake.getVolumeReturns = struct { - result1 spectrumscale.SpectrumScaleVolume - result2 bool - result3 error - }{result1, result2, result3} +func (fake *FakeSpectrumDataModel) InsertFilesetVolumeArgsForCall(i int) (string, string, string, bool, map[string]interface{}) { + fake.insertFilesetVolumeMutex.RLock() + defer fake.insertFilesetVolumeMutex.RUnlock() + argsForCall := fake.insertFilesetVolumeArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5 } -func (fake *FakeSpectrumDataModel) GetVolumeReturnsOnCall(i int, result1 spectrumscale.SpectrumScaleVolume, result2 bool, result3 error) { - fake.GetVolumeStub = nil - if fake.getVolumeReturnsOnCall == nil { - fake.getVolumeReturnsOnCall = make(map[int]struct { - result1 spectrumscale.SpectrumScaleVolume - result2 bool - result3 error +func (fake *FakeSpectrumDataModel) InsertFilesetVolumeReturns(result1 error) { + fake.insertFilesetVolumeMutex.Lock() + defer fake.insertFilesetVolumeMutex.Unlock() + fake.InsertFilesetVolumeStub = nil + fake.insertFilesetVolumeReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeSpectrumDataModel) InsertFilesetVolumeReturnsOnCall(i int, result1 error) { + fake.insertFilesetVolumeMutex.Lock() + defer fake.insertFilesetVolumeMutex.Unlock() + fake.InsertFilesetVolumeStub = nil + if fake.insertFilesetVolumeReturnsOnCall == nil { + fake.insertFilesetVolumeReturnsOnCall = make(map[int]struct { + result1 error }) } - fake.getVolumeReturnsOnCall[i] = struct { - result1 spectrumscale.SpectrumScaleVolume - result2 bool - result3 error - }{result1, result2, result3} + fake.insertFilesetVolumeReturnsOnCall[i] = struct { + result1 error + }{result1} } func (fake *FakeSpectrumDataModel) ListVolumes() ([]resources.Volume, error) { fake.listVolumesMutex.Lock() ret, specificReturn := fake.listVolumesReturnsOnCall[len(fake.listVolumesArgsForCall)] - fake.listVolumesArgsForCall = append(fake.listVolumesArgsForCall, struct{}{}) + fake.listVolumesArgsForCall = append(fake.listVolumesArgsForCall, struct { + }{}) fake.recordInvocation("ListVolumes", []interface{}{}) fake.listVolumesMutex.Unlock() if fake.ListVolumesStub != nil { @@ -446,7 +424,8 @@ func (fake *FakeSpectrumDataModel) ListVolumes() ([]resources.Volume, error) { if specificReturn { return ret.result1, ret.result2 } - return fake.listVolumesReturns.result1, fake.listVolumesReturns.result2 + fakeReturns := fake.listVolumesReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeSpectrumDataModel) ListVolumesCallCount() int { @@ -455,7 +434,15 @@ func (fake *FakeSpectrumDataModel) ListVolumesCallCount() int { return len(fake.listVolumesArgsForCall) } +func (fake *FakeSpectrumDataModel) ListVolumesCalls(stub func() ([]resources.Volume, error)) { + fake.listVolumesMutex.Lock() + defer fake.listVolumesMutex.Unlock() + fake.ListVolumesStub = stub +} + func (fake *FakeSpectrumDataModel) ListVolumesReturns(result1 []resources.Volume, result2 error) { + fake.listVolumesMutex.Lock() + defer fake.listVolumesMutex.Unlock() fake.ListVolumesStub = nil fake.listVolumesReturns = struct { result1 []resources.Volume @@ -464,6 +451,8 @@ func (fake *FakeSpectrumDataModel) ListVolumesReturns(result1 []resources.Volume } func (fake *FakeSpectrumDataModel) ListVolumesReturnsOnCall(i int, result1 []resources.Volume, result2 error) { + fake.listVolumesMutex.Lock() + defer fake.listVolumesMutex.Unlock() fake.ListVolumesStub = nil if fake.listVolumesReturnsOnCall == nil { fake.listVolumesReturnsOnCall = make(map[int]struct { @@ -477,22 +466,23 @@ func (fake *FakeSpectrumDataModel) ListVolumesReturnsOnCall(i int, result1 []res }{result1, result2} } -func (fake *FakeSpectrumDataModel) UpdateVolumeMountpoint(name string, mountpoint string) error { +func (fake *FakeSpectrumDataModel) UpdateVolumeMountpoint(arg1 string, arg2 string) error { fake.updateVolumeMountpointMutex.Lock() ret, specificReturn := fake.updateVolumeMountpointReturnsOnCall[len(fake.updateVolumeMountpointArgsForCall)] fake.updateVolumeMountpointArgsForCall = append(fake.updateVolumeMountpointArgsForCall, struct { - name string - mountpoint string - }{name, mountpoint}) - fake.recordInvocation("UpdateVolumeMountpoint", []interface{}{name, mountpoint}) + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("UpdateVolumeMountpoint", []interface{}{arg1, arg2}) fake.updateVolumeMountpointMutex.Unlock() if fake.UpdateVolumeMountpointStub != nil { - return fake.UpdateVolumeMountpointStub(name, mountpoint) + return fake.UpdateVolumeMountpointStub(arg1, arg2) } if specificReturn { return ret.result1 } - return fake.updateVolumeMountpointReturns.result1 + fakeReturns := fake.updateVolumeMountpointReturns + return fakeReturns.result1 } func (fake *FakeSpectrumDataModel) UpdateVolumeMountpointCallCount() int { @@ -501,13 +491,22 @@ func (fake *FakeSpectrumDataModel) UpdateVolumeMountpointCallCount() int { return len(fake.updateVolumeMountpointArgsForCall) } +func (fake *FakeSpectrumDataModel) UpdateVolumeMountpointCalls(stub func(string, string) error) { + fake.updateVolumeMountpointMutex.Lock() + defer fake.updateVolumeMountpointMutex.Unlock() + fake.UpdateVolumeMountpointStub = stub +} + func (fake *FakeSpectrumDataModel) UpdateVolumeMountpointArgsForCall(i int) (string, string) { fake.updateVolumeMountpointMutex.RLock() defer fake.updateVolumeMountpointMutex.RUnlock() - return fake.updateVolumeMountpointArgsForCall[i].name, fake.updateVolumeMountpointArgsForCall[i].mountpoint + argsForCall := fake.updateVolumeMountpointArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } func (fake *FakeSpectrumDataModel) UpdateVolumeMountpointReturns(result1 error) { + fake.updateVolumeMountpointMutex.Lock() + defer fake.updateVolumeMountpointMutex.Unlock() fake.UpdateVolumeMountpointStub = nil fake.updateVolumeMountpointReturns = struct { result1 error @@ -515,6 +514,8 @@ func (fake *FakeSpectrumDataModel) UpdateVolumeMountpointReturns(result1 error) } func (fake *FakeSpectrumDataModel) UpdateVolumeMountpointReturnsOnCall(i int, result1 error) { + fake.updateVolumeMountpointMutex.Lock() + defer fake.updateVolumeMountpointMutex.Unlock() fake.UpdateVolumeMountpointStub = nil if fake.updateVolumeMountpointReturnsOnCall == nil { fake.updateVolumeMountpointReturnsOnCall = make(map[int]struct { @@ -533,19 +534,21 @@ func (fake *FakeSpectrumDataModel) Invocations() map[string][][]interface{} { defer fake.createVolumeTableMutex.RUnlock() fake.deleteVolumeMutex.RLock() defer fake.deleteVolumeMutex.RUnlock() - fake.insertFilesetVolumeMutex.RLock() - defer fake.insertFilesetVolumeMutex.RUnlock() - fake.insertLightweightVolumeMutex.RLock() - defer fake.insertLightweightVolumeMutex.RUnlock() - fake.insertFilesetQuotaVolumeMutex.RLock() - defer fake.insertFilesetQuotaVolumeMutex.RUnlock() fake.getVolumeMutex.RLock() defer fake.getVolumeMutex.RUnlock() + fake.insertFilesetQuotaVolumeMutex.RLock() + defer fake.insertFilesetQuotaVolumeMutex.RUnlock() + fake.insertFilesetVolumeMutex.RLock() + defer fake.insertFilesetVolumeMutex.RUnlock() fake.listVolumesMutex.RLock() defer fake.listVolumesMutex.RUnlock() fake.updateVolumeMountpointMutex.RLock() defer fake.updateVolumeMountpointMutex.RUnlock() - return fake.invocations + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations } func (fake *FakeSpectrumDataModel) recordInvocation(key string, args []interface{}) { diff --git a/fakes/fake_block_device_mounter_utils.go b/fakes/fake_block_device_mounter_utils.go index abc68d0c..0cb9c993 100644 --- a/fakes/fake_block_device_mounter_utils.go +++ b/fakes/fake_block_device_mounter_utils.go @@ -5,28 +5,41 @@ import ( "sync" "github.com/IBM/ubiquity/remote/mounter/block_device_mounter_utils" + "github.com/IBM/ubiquity/resources" ) type FakeBlockDeviceMounterUtils struct { - RescanAllStub func(wwn string, rescanForCleanUp bool, extraLunZeroScanning bool) error - rescanAllMutex sync.RWMutex - rescanAllArgsForCall []struct { - wwn string - rescanForCleanUp bool - extraLunZeroScanning bool + CleanupAllStub func(*resources.VolumeMountProperties) error + cleanupAllMutex sync.RWMutex + cleanupAllArgsForCall []struct { + arg1 *resources.VolumeMountProperties } - rescanAllReturns struct { + cleanupAllReturns struct { result1 error } - rescanAllReturnsOnCall map[int]struct { + cleanupAllReturnsOnCall map[int]struct { result1 error } - MountDeviceFlowStub func(devicePath string, fsType string, mountPoint string) error + DiscoverStub func(string, bool) (string, error) + discoverMutex sync.RWMutex + discoverArgsForCall []struct { + arg1 string + arg2 bool + } + discoverReturns struct { + result1 string + result2 error + } + discoverReturnsOnCall map[int]struct { + result1 string + result2 error + } + MountDeviceFlowStub func(string, string, string) error mountDeviceFlowMutex sync.RWMutex mountDeviceFlowArgsForCall []struct { - devicePath string - fsType string - mountPoint string + arg1 string + arg2 string + arg3 string } mountDeviceFlowReturns struct { result1 error @@ -34,25 +47,22 @@ type FakeBlockDeviceMounterUtils struct { mountDeviceFlowReturnsOnCall map[int]struct { result1 error } - DiscoverStub func(volumeWwn string, deepDiscovery bool) (string, error) - discoverMutex sync.RWMutex - discoverArgsForCall []struct { - volumeWwn string - deepDiscovery bool + RescanAllStub func(*resources.VolumeMountProperties) error + rescanAllMutex sync.RWMutex + rescanAllArgsForCall []struct { + arg1 *resources.VolumeMountProperties } - discoverReturns struct { - result1 string - result2 error + rescanAllReturns struct { + result1 error } - discoverReturnsOnCall map[int]struct { - result1 string - result2 error + rescanAllReturnsOnCall map[int]struct { + result1 error } - UnmountDeviceFlowStub func(devicePath string, volumeWwn string) error + UnmountDeviceFlowStub func(string, string) error unmountDeviceFlowMutex sync.RWMutex unmountDeviceFlowArgsForCall []struct { - devicePath string - volumeWwn string + arg1 string + arg2 string } unmountDeviceFlowReturns struct { result1 error @@ -64,73 +74,148 @@ type FakeBlockDeviceMounterUtils struct { invocationsMutex sync.RWMutex } -func (fake *FakeBlockDeviceMounterUtils) RescanAll(wwn string, rescanForCleanUp bool, extraLunZeroScanning bool) error { - fake.rescanAllMutex.Lock() - ret, specificReturn := fake.rescanAllReturnsOnCall[len(fake.rescanAllArgsForCall)] - fake.rescanAllArgsForCall = append(fake.rescanAllArgsForCall, struct { - wwn string - rescanForCleanUp bool - extraLunZeroScanning bool - }{wwn, rescanForCleanUp, extraLunZeroScanning}) - fake.recordInvocation("RescanAll", []interface{}{wwn, rescanForCleanUp, extraLunZeroScanning}) - fake.rescanAllMutex.Unlock() - if fake.RescanAllStub != nil { - return fake.RescanAllStub(wwn, rescanForCleanUp, extraLunZeroScanning) +func (fake *FakeBlockDeviceMounterUtils) CleanupAll(arg1 *resources.VolumeMountProperties) error { + fake.cleanupAllMutex.Lock() + ret, specificReturn := fake.cleanupAllReturnsOnCall[len(fake.cleanupAllArgsForCall)] + fake.cleanupAllArgsForCall = append(fake.cleanupAllArgsForCall, struct { + arg1 *resources.VolumeMountProperties + }{arg1}) + fake.recordInvocation("CleanupAll", []interface{}{arg1}) + fake.cleanupAllMutex.Unlock() + if fake.CleanupAllStub != nil { + return fake.CleanupAllStub(arg1) } if specificReturn { return ret.result1 } - return fake.rescanAllReturns.result1 + fakeReturns := fake.cleanupAllReturns + return fakeReturns.result1 } -func (fake *FakeBlockDeviceMounterUtils) RescanAllCallCount() int { - fake.rescanAllMutex.RLock() - defer fake.rescanAllMutex.RUnlock() - return len(fake.rescanAllArgsForCall) +func (fake *FakeBlockDeviceMounterUtils) CleanupAllCallCount() int { + fake.cleanupAllMutex.RLock() + defer fake.cleanupAllMutex.RUnlock() + return len(fake.cleanupAllArgsForCall) } -func (fake *FakeBlockDeviceMounterUtils) RescanAllArgsForCall(i int) (string, bool, bool) { - fake.rescanAllMutex.RLock() - defer fake.rescanAllMutex.RUnlock() - return fake.rescanAllArgsForCall[i].wwn, fake.rescanAllArgsForCall[i].rescanForCleanUp, fake.rescanAllArgsForCall[i].extraLunZeroScanning +func (fake *FakeBlockDeviceMounterUtils) CleanupAllCalls(stub func(*resources.VolumeMountProperties) error) { + fake.cleanupAllMutex.Lock() + defer fake.cleanupAllMutex.Unlock() + fake.CleanupAllStub = stub } -func (fake *FakeBlockDeviceMounterUtils) RescanAllReturns(result1 error) { - fake.RescanAllStub = nil - fake.rescanAllReturns = struct { +func (fake *FakeBlockDeviceMounterUtils) CleanupAllArgsForCall(i int) *resources.VolumeMountProperties { + fake.cleanupAllMutex.RLock() + defer fake.cleanupAllMutex.RUnlock() + argsForCall := fake.cleanupAllArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeBlockDeviceMounterUtils) CleanupAllReturns(result1 error) { + fake.cleanupAllMutex.Lock() + defer fake.cleanupAllMutex.Unlock() + fake.CleanupAllStub = nil + fake.cleanupAllReturns = struct { result1 error }{result1} } -func (fake *FakeBlockDeviceMounterUtils) RescanAllReturnsOnCall(i int, result1 error) { - fake.RescanAllStub = nil - if fake.rescanAllReturnsOnCall == nil { - fake.rescanAllReturnsOnCall = make(map[int]struct { +func (fake *FakeBlockDeviceMounterUtils) CleanupAllReturnsOnCall(i int, result1 error) { + fake.cleanupAllMutex.Lock() + defer fake.cleanupAllMutex.Unlock() + fake.CleanupAllStub = nil + if fake.cleanupAllReturnsOnCall == nil { + fake.cleanupAllReturnsOnCall = make(map[int]struct { result1 error }) } - fake.rescanAllReturnsOnCall[i] = struct { + fake.cleanupAllReturnsOnCall[i] = struct { result1 error }{result1} } -func (fake *FakeBlockDeviceMounterUtils) MountDeviceFlow(devicePath string, fsType string, mountPoint string) error { +func (fake *FakeBlockDeviceMounterUtils) Discover(arg1 string, arg2 bool) (string, error) { + fake.discoverMutex.Lock() + ret, specificReturn := fake.discoverReturnsOnCall[len(fake.discoverArgsForCall)] + fake.discoverArgsForCall = append(fake.discoverArgsForCall, struct { + arg1 string + arg2 bool + }{arg1, arg2}) + fake.recordInvocation("Discover", []interface{}{arg1, arg2}) + fake.discoverMutex.Unlock() + if fake.DiscoverStub != nil { + return fake.DiscoverStub(arg1, arg2) + } + if specificReturn { + return ret.result1, ret.result2 + } + fakeReturns := fake.discoverReturns + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeBlockDeviceMounterUtils) DiscoverCallCount() int { + fake.discoverMutex.RLock() + defer fake.discoverMutex.RUnlock() + return len(fake.discoverArgsForCall) +} + +func (fake *FakeBlockDeviceMounterUtils) DiscoverCalls(stub func(string, bool) (string, error)) { + fake.discoverMutex.Lock() + defer fake.discoverMutex.Unlock() + fake.DiscoverStub = stub +} + +func (fake *FakeBlockDeviceMounterUtils) DiscoverArgsForCall(i int) (string, bool) { + fake.discoverMutex.RLock() + defer fake.discoverMutex.RUnlock() + argsForCall := fake.discoverArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeBlockDeviceMounterUtils) DiscoverReturns(result1 string, result2 error) { + fake.discoverMutex.Lock() + defer fake.discoverMutex.Unlock() + fake.DiscoverStub = nil + fake.discoverReturns = struct { + result1 string + result2 error + }{result1, result2} +} + +func (fake *FakeBlockDeviceMounterUtils) DiscoverReturnsOnCall(i int, result1 string, result2 error) { + fake.discoverMutex.Lock() + defer fake.discoverMutex.Unlock() + fake.DiscoverStub = nil + if fake.discoverReturnsOnCall == nil { + fake.discoverReturnsOnCall = make(map[int]struct { + result1 string + result2 error + }) + } + fake.discoverReturnsOnCall[i] = struct { + result1 string + result2 error + }{result1, result2} +} + +func (fake *FakeBlockDeviceMounterUtils) MountDeviceFlow(arg1 string, arg2 string, arg3 string) error { fake.mountDeviceFlowMutex.Lock() ret, specificReturn := fake.mountDeviceFlowReturnsOnCall[len(fake.mountDeviceFlowArgsForCall)] fake.mountDeviceFlowArgsForCall = append(fake.mountDeviceFlowArgsForCall, struct { - devicePath string - fsType string - mountPoint string - }{devicePath, fsType, mountPoint}) - fake.recordInvocation("MountDeviceFlow", []interface{}{devicePath, fsType, mountPoint}) + arg1 string + arg2 string + arg3 string + }{arg1, arg2, arg3}) + fake.recordInvocation("MountDeviceFlow", []interface{}{arg1, arg2, arg3}) fake.mountDeviceFlowMutex.Unlock() if fake.MountDeviceFlowStub != nil { - return fake.MountDeviceFlowStub(devicePath, fsType, mountPoint) + return fake.MountDeviceFlowStub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - return fake.mountDeviceFlowReturns.result1 + fakeReturns := fake.mountDeviceFlowReturns + return fakeReturns.result1 } func (fake *FakeBlockDeviceMounterUtils) MountDeviceFlowCallCount() int { @@ -139,13 +224,22 @@ func (fake *FakeBlockDeviceMounterUtils) MountDeviceFlowCallCount() int { return len(fake.mountDeviceFlowArgsForCall) } +func (fake *FakeBlockDeviceMounterUtils) MountDeviceFlowCalls(stub func(string, string, string) error) { + fake.mountDeviceFlowMutex.Lock() + defer fake.mountDeviceFlowMutex.Unlock() + fake.MountDeviceFlowStub = stub +} + func (fake *FakeBlockDeviceMounterUtils) MountDeviceFlowArgsForCall(i int) (string, string, string) { fake.mountDeviceFlowMutex.RLock() defer fake.mountDeviceFlowMutex.RUnlock() - return fake.mountDeviceFlowArgsForCall[i].devicePath, fake.mountDeviceFlowArgsForCall[i].fsType, fake.mountDeviceFlowArgsForCall[i].mountPoint + argsForCall := fake.mountDeviceFlowArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 } func (fake *FakeBlockDeviceMounterUtils) MountDeviceFlowReturns(result1 error) { + fake.mountDeviceFlowMutex.Lock() + defer fake.mountDeviceFlowMutex.Unlock() fake.MountDeviceFlowStub = nil fake.mountDeviceFlowReturns = struct { result1 error @@ -153,6 +247,8 @@ func (fake *FakeBlockDeviceMounterUtils) MountDeviceFlowReturns(result1 error) { } func (fake *FakeBlockDeviceMounterUtils) MountDeviceFlowReturnsOnCall(i int, result1 error) { + fake.mountDeviceFlowMutex.Lock() + defer fake.mountDeviceFlowMutex.Unlock() fake.MountDeviceFlowStub = nil if fake.mountDeviceFlowReturnsOnCall == nil { fake.mountDeviceFlowReturnsOnCall = make(map[int]struct { @@ -164,74 +260,83 @@ func (fake *FakeBlockDeviceMounterUtils) MountDeviceFlowReturnsOnCall(i int, res }{result1} } -func (fake *FakeBlockDeviceMounterUtils) Discover(volumeWwn string, deepDiscovery bool) (string, error) { - fake.discoverMutex.Lock() - ret, specificReturn := fake.discoverReturnsOnCall[len(fake.discoverArgsForCall)] - fake.discoverArgsForCall = append(fake.discoverArgsForCall, struct { - volumeWwn string - deepDiscovery bool - }{volumeWwn, deepDiscovery}) - fake.recordInvocation("Discover", []interface{}{volumeWwn, deepDiscovery}) - fake.discoverMutex.Unlock() - if fake.DiscoverStub != nil { - return fake.DiscoverStub(volumeWwn, deepDiscovery) +func (fake *FakeBlockDeviceMounterUtils) RescanAll(arg1 *resources.VolumeMountProperties) error { + fake.rescanAllMutex.Lock() + ret, specificReturn := fake.rescanAllReturnsOnCall[len(fake.rescanAllArgsForCall)] + fake.rescanAllArgsForCall = append(fake.rescanAllArgsForCall, struct { + arg1 *resources.VolumeMountProperties + }{arg1}) + fake.recordInvocation("RescanAll", []interface{}{arg1}) + fake.rescanAllMutex.Unlock() + if fake.RescanAllStub != nil { + return fake.RescanAllStub(arg1) } if specificReturn { - return ret.result1, ret.result2 + return ret.result1 } - return fake.discoverReturns.result1, fake.discoverReturns.result2 + fakeReturns := fake.rescanAllReturns + return fakeReturns.result1 } -func (fake *FakeBlockDeviceMounterUtils) DiscoverCallCount() int { - fake.discoverMutex.RLock() - defer fake.discoverMutex.RUnlock() - return len(fake.discoverArgsForCall) +func (fake *FakeBlockDeviceMounterUtils) RescanAllCallCount() int { + fake.rescanAllMutex.RLock() + defer fake.rescanAllMutex.RUnlock() + return len(fake.rescanAllArgsForCall) } -func (fake *FakeBlockDeviceMounterUtils) DiscoverArgsForCall(i int) (string, bool) { - fake.discoverMutex.RLock() - defer fake.discoverMutex.RUnlock() - return fake.discoverArgsForCall[i].volumeWwn, fake.discoverArgsForCall[i].deepDiscovery +func (fake *FakeBlockDeviceMounterUtils) RescanAllCalls(stub func(*resources.VolumeMountProperties) error) { + fake.rescanAllMutex.Lock() + defer fake.rescanAllMutex.Unlock() + fake.RescanAllStub = stub } -func (fake *FakeBlockDeviceMounterUtils) DiscoverReturns(result1 string, result2 error) { - fake.DiscoverStub = nil - fake.discoverReturns = struct { - result1 string - result2 error - }{result1, result2} +func (fake *FakeBlockDeviceMounterUtils) RescanAllArgsForCall(i int) *resources.VolumeMountProperties { + fake.rescanAllMutex.RLock() + defer fake.rescanAllMutex.RUnlock() + argsForCall := fake.rescanAllArgsForCall[i] + return argsForCall.arg1 } -func (fake *FakeBlockDeviceMounterUtils) DiscoverReturnsOnCall(i int, result1 string, result2 error) { - fake.DiscoverStub = nil - if fake.discoverReturnsOnCall == nil { - fake.discoverReturnsOnCall = make(map[int]struct { - result1 string - result2 error +func (fake *FakeBlockDeviceMounterUtils) RescanAllReturns(result1 error) { + fake.rescanAllMutex.Lock() + defer fake.rescanAllMutex.Unlock() + fake.RescanAllStub = nil + fake.rescanAllReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeBlockDeviceMounterUtils) RescanAllReturnsOnCall(i int, result1 error) { + fake.rescanAllMutex.Lock() + defer fake.rescanAllMutex.Unlock() + fake.RescanAllStub = nil + if fake.rescanAllReturnsOnCall == nil { + fake.rescanAllReturnsOnCall = make(map[int]struct { + result1 error }) } - fake.discoverReturnsOnCall[i] = struct { - result1 string - result2 error - }{result1, result2} + fake.rescanAllReturnsOnCall[i] = struct { + result1 error + }{result1} } -func (fake *FakeBlockDeviceMounterUtils) UnmountDeviceFlow(devicePath string, volumeWwn string) error { +func (fake *FakeBlockDeviceMounterUtils) UnmountDeviceFlow(arg1 string, arg2 string) error { fake.unmountDeviceFlowMutex.Lock() ret, specificReturn := fake.unmountDeviceFlowReturnsOnCall[len(fake.unmountDeviceFlowArgsForCall)] fake.unmountDeviceFlowArgsForCall = append(fake.unmountDeviceFlowArgsForCall, struct { - devicePath string - volumeWwn string - }{devicePath, volumeWwn}) - fake.recordInvocation("UnmountDeviceFlow", []interface{}{devicePath, volumeWwn}) + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("UnmountDeviceFlow", []interface{}{arg1, arg2}) fake.unmountDeviceFlowMutex.Unlock() if fake.UnmountDeviceFlowStub != nil { - return fake.UnmountDeviceFlowStub(devicePath, volumeWwn) + return fake.UnmountDeviceFlowStub(arg1, arg2) } if specificReturn { return ret.result1 } - return fake.unmountDeviceFlowReturns.result1 + fakeReturns := fake.unmountDeviceFlowReturns + return fakeReturns.result1 } func (fake *FakeBlockDeviceMounterUtils) UnmountDeviceFlowCallCount() int { @@ -240,13 +345,22 @@ func (fake *FakeBlockDeviceMounterUtils) UnmountDeviceFlowCallCount() int { return len(fake.unmountDeviceFlowArgsForCall) } +func (fake *FakeBlockDeviceMounterUtils) UnmountDeviceFlowCalls(stub func(string, string) error) { + fake.unmountDeviceFlowMutex.Lock() + defer fake.unmountDeviceFlowMutex.Unlock() + fake.UnmountDeviceFlowStub = stub +} + func (fake *FakeBlockDeviceMounterUtils) UnmountDeviceFlowArgsForCall(i int) (string, string) { fake.unmountDeviceFlowMutex.RLock() defer fake.unmountDeviceFlowMutex.RUnlock() - return fake.unmountDeviceFlowArgsForCall[i].devicePath, fake.unmountDeviceFlowArgsForCall[i].volumeWwn + argsForCall := fake.unmountDeviceFlowArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } func (fake *FakeBlockDeviceMounterUtils) UnmountDeviceFlowReturns(result1 error) { + fake.unmountDeviceFlowMutex.Lock() + defer fake.unmountDeviceFlowMutex.Unlock() fake.UnmountDeviceFlowStub = nil fake.unmountDeviceFlowReturns = struct { result1 error @@ -254,6 +368,8 @@ func (fake *FakeBlockDeviceMounterUtils) UnmountDeviceFlowReturns(result1 error) } func (fake *FakeBlockDeviceMounterUtils) UnmountDeviceFlowReturnsOnCall(i int, result1 error) { + fake.unmountDeviceFlowMutex.Lock() + defer fake.unmountDeviceFlowMutex.Unlock() fake.UnmountDeviceFlowStub = nil if fake.unmountDeviceFlowReturnsOnCall == nil { fake.unmountDeviceFlowReturnsOnCall = make(map[int]struct { @@ -268,12 +384,14 @@ func (fake *FakeBlockDeviceMounterUtils) UnmountDeviceFlowReturnsOnCall(i int, r func (fake *FakeBlockDeviceMounterUtils) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() - fake.rescanAllMutex.RLock() - defer fake.rescanAllMutex.RUnlock() - fake.mountDeviceFlowMutex.RLock() - defer fake.mountDeviceFlowMutex.RUnlock() + fake.cleanupAllMutex.RLock() + defer fake.cleanupAllMutex.RUnlock() fake.discoverMutex.RLock() defer fake.discoverMutex.RUnlock() + fake.mountDeviceFlowMutex.RLock() + defer fake.mountDeviceFlowMutex.RUnlock() + fake.rescanAllMutex.RLock() + defer fake.rescanAllMutex.RUnlock() fake.unmountDeviceFlowMutex.RLock() defer fake.unmountDeviceFlowMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} diff --git a/fakes/fake_block_device_utils.go b/fakes/fake_block_device_utils.go index 850d50e0..76a1ee9b 100644 --- a/fakes/fake_block_device_utils.go +++ b/fakes/fake_block_device_utils.go @@ -5,43 +5,51 @@ import ( "sync" "github.com/IBM/ubiquity/remote/mounter/block_device_utils" + "github.com/IBM/ubiquity/resources" ) type FakeBlockDeviceUtils struct { - RescanStub func(protocol block_device_utils.Protocol) error - rescanMutex sync.RWMutex - rescanArgsForCall []struct { - protocol block_device_utils.Protocol + CheckFsStub func(string) (bool, error) + checkFsMutex sync.RWMutex + checkFsArgsForCall []struct { + arg1 string } - rescanReturns struct { - result1 error + checkFsReturns struct { + result1 bool + result2 error } - rescanReturnsOnCall map[int]struct { - result1 error + checkFsReturnsOnCall map[int]struct { + result1 bool + result2 error + } + CleanupStub func(string) error + cleanupMutex sync.RWMutex + cleanupArgsForCall []struct { + arg1 string } - RescanSCSILun0Stub func() error - rescanSCSILun0Mutex sync.RWMutex - rescanSCSILun0ArgsForCall []struct{} - rescanSCSILun0Returns struct { + cleanupReturns struct { result1 error } - rescanSCSILun0ReturnsOnCall map[int]struct { + cleanupReturnsOnCall map[int]struct { result1 error } - ReloadMultipathStub func() error - reloadMultipathMutex sync.RWMutex - reloadMultipathArgsForCall []struct{} - reloadMultipathReturns struct { + CleanupDevicesStub func(block_device_utils.Protocol, *resources.VolumeMountProperties) error + cleanupDevicesMutex sync.RWMutex + cleanupDevicesArgsForCall []struct { + arg1 block_device_utils.Protocol + arg2 *resources.VolumeMountProperties + } + cleanupDevicesReturns struct { result1 error } - reloadMultipathReturnsOnCall map[int]struct { + cleanupDevicesReturnsOnCall map[int]struct { result1 error } - DiscoverStub func(volumeWwn string, deepDiscovery bool) (string, error) + DiscoverStub func(string, bool) (string, error) discoverMutex sync.RWMutex discoverArgsForCall []struct { - volumeWwn string - deepDiscovery bool + arg1 string + arg2 bool } discoverReturns struct { result1 string @@ -51,63 +59,69 @@ type FakeBlockDeviceUtils struct { result1 string result2 error } - GetWwnByScsiInqStub func(mpathOutput string, dev string) (string, error) - getWwnByScsiInqMutex sync.RWMutex - getWwnByScsiInqArgsForCall []struct { - mpathOutput string - dev string + DiscoverBySgInqStub func(string, string) (string, error) + discoverBySgInqMutex sync.RWMutex + discoverBySgInqArgsForCall []struct { + arg1 string + arg2 string } - getWwnByScsiInqReturns struct { + discoverBySgInqReturns struct { result1 string result2 error } - getWwnByScsiInqReturnsOnCall map[int]struct { + discoverBySgInqReturnsOnCall map[int]struct { result1 string result2 error } - DiscoverBySgInqStub func(mpathOutput string, volumeWwn string) (string, error) - discoverBySgInqMutex sync.RWMutex - discoverBySgInqArgsForCall []struct { - mpathOutput string - volumeWwn string + GetWwnByScsiInqStub func(string, string) (string, error) + getWwnByScsiInqMutex sync.RWMutex + getWwnByScsiInqArgsForCall []struct { + arg1 string + arg2 string } - discoverBySgInqReturns struct { + getWwnByScsiInqReturns struct { result1 string result2 error } - discoverBySgInqReturnsOnCall map[int]struct { + getWwnByScsiInqReturnsOnCall map[int]struct { result1 string result2 error } - CleanupStub func(mpath string) error - cleanupMutex sync.RWMutex - cleanupArgsForCall []struct { - mpath string + IsDeviceMountedStub func(string) (bool, []string, error) + isDeviceMountedMutex sync.RWMutex + isDeviceMountedArgsForCall []struct { + arg1 string } - cleanupReturns struct { - result1 error + isDeviceMountedReturns struct { + result1 bool + result2 []string + result3 error } - cleanupReturnsOnCall map[int]struct { - result1 error + isDeviceMountedReturnsOnCall map[int]struct { + result1 bool + result2 []string + result3 error } - CheckFsStub func(mpath string) (bool, error) - checkFsMutex sync.RWMutex - checkFsArgsForCall []struct { - mpath string + IsDirAMountPointStub func(string) (bool, []string, error) + isDirAMountPointMutex sync.RWMutex + isDirAMountPointArgsForCall []struct { + arg1 string } - checkFsReturns struct { + isDirAMountPointReturns struct { result1 bool - result2 error + result2 []string + result3 error } - checkFsReturnsOnCall map[int]struct { + isDirAMountPointReturnsOnCall map[int]struct { result1 bool - result2 error + result2 []string + result3 error } - MakeFsStub func(mpath string, fsType string) error + MakeFsStub func(string, string) error makeFsMutex sync.RWMutex makeFsArgsForCall []struct { - mpath string - fsType string + arg1 string + arg2 string } makeFsReturns struct { result1 error @@ -115,11 +129,11 @@ type FakeBlockDeviceUtils struct { makeFsReturnsOnCall map[int]struct { result1 error } - MountFsStub func(mpath string, mpoint string) error + MountFsStub func(string, string) error mountFsMutex sync.RWMutex mountFsArgsForCall []struct { - mpath string - mpoint string + arg1 string + arg2 string } mountFsReturns struct { result1 error @@ -127,52 +141,32 @@ type FakeBlockDeviceUtils struct { mountFsReturnsOnCall map[int]struct { result1 error } - UmountFsStub func(mpoint string, volumeWwn string) error - umountFsMutex sync.RWMutex - umountFsArgsForCall []struct { - mpoint string - volumeWwn string + ReloadMultipathStub func() error + reloadMultipathMutex sync.RWMutex + reloadMultipathArgsForCall []struct { } - umountFsReturns struct { + reloadMultipathReturns struct { result1 error } - umountFsReturnsOnCall map[int]struct { + reloadMultipathReturnsOnCall map[int]struct { result1 error } - IsDeviceMountedStub func(devPath string) (bool, []string, error) - isDeviceMountedMutex sync.RWMutex - isDeviceMountedArgsForCall []struct { - devPath string - } - isDeviceMountedReturns struct { - result1 bool - result2 []string - result3 error - } - isDeviceMountedReturnsOnCall map[int]struct { - result1 bool - result2 []string - result3 error - } - IsDirAMountPointStub func(dirPath string) (bool, []string, error) - isDirAMountPointMutex sync.RWMutex - isDirAMountPointArgsForCall []struct { - dirPath string + RescanStub func(block_device_utils.Protocol, *resources.VolumeMountProperties) error + rescanMutex sync.RWMutex + rescanArgsForCall []struct { + arg1 block_device_utils.Protocol + arg2 *resources.VolumeMountProperties } - isDirAMountPointReturns struct { - result1 bool - result2 []string - result3 error + rescanReturns struct { + result1 error } - isDirAMountPointReturnsOnCall map[int]struct { - result1 bool - result2 []string - result3 error + rescanReturnsOnCall map[int]struct { + result1 error } - SetDmsetupStub func(mpath string) error + SetDmsetupStub func(string) error setDmsetupMutex sync.RWMutex setDmsetupArgsForCall []struct { - mpath string + arg1 string } setDmsetupReturns struct { result1 error @@ -180,154 +174,223 @@ type FakeBlockDeviceUtils struct { setDmsetupReturnsOnCall map[int]struct { result1 error } + UmountFsStub func(string, string) error + umountFsMutex sync.RWMutex + umountFsArgsForCall []struct { + arg1 string + arg2 string + } + umountFsReturns struct { + result1 error + } + umountFsReturnsOnCall map[int]struct { + result1 error + } invocations map[string][][]interface{} invocationsMutex sync.RWMutex } -func (fake *FakeBlockDeviceUtils) Rescan(protocol block_device_utils.Protocol) error { - fake.rescanMutex.Lock() - ret, specificReturn := fake.rescanReturnsOnCall[len(fake.rescanArgsForCall)] - fake.rescanArgsForCall = append(fake.rescanArgsForCall, struct { - protocol block_device_utils.Protocol - }{protocol}) - fake.recordInvocation("Rescan", []interface{}{protocol}) - fake.rescanMutex.Unlock() - if fake.RescanStub != nil { - return fake.RescanStub(protocol) +func (fake *FakeBlockDeviceUtils) CheckFs(arg1 string) (bool, error) { + fake.checkFsMutex.Lock() + ret, specificReturn := fake.checkFsReturnsOnCall[len(fake.checkFsArgsForCall)] + fake.checkFsArgsForCall = append(fake.checkFsArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("CheckFs", []interface{}{arg1}) + fake.checkFsMutex.Unlock() + if fake.CheckFsStub != nil { + return fake.CheckFsStub(arg1) } if specificReturn { - return ret.result1 + return ret.result1, ret.result2 } - return fake.rescanReturns.result1 + fakeReturns := fake.checkFsReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeBlockDeviceUtils) RescanCallCount() int { - fake.rescanMutex.RLock() - defer fake.rescanMutex.RUnlock() - return len(fake.rescanArgsForCall) +func (fake *FakeBlockDeviceUtils) CheckFsCallCount() int { + fake.checkFsMutex.RLock() + defer fake.checkFsMutex.RUnlock() + return len(fake.checkFsArgsForCall) } -func (fake *FakeBlockDeviceUtils) RescanArgsForCall(i int) block_device_utils.Protocol { - fake.rescanMutex.RLock() - defer fake.rescanMutex.RUnlock() - return fake.rescanArgsForCall[i].protocol +func (fake *FakeBlockDeviceUtils) CheckFsCalls(stub func(string) (bool, error)) { + fake.checkFsMutex.Lock() + defer fake.checkFsMutex.Unlock() + fake.CheckFsStub = stub } -func (fake *FakeBlockDeviceUtils) RescanReturns(result1 error) { - fake.RescanStub = nil - fake.rescanReturns = struct { - result1 error - }{result1} +func (fake *FakeBlockDeviceUtils) CheckFsArgsForCall(i int) string { + fake.checkFsMutex.RLock() + defer fake.checkFsMutex.RUnlock() + argsForCall := fake.checkFsArgsForCall[i] + return argsForCall.arg1 } -func (fake *FakeBlockDeviceUtils) RescanReturnsOnCall(i int, result1 error) { - fake.RescanStub = nil - if fake.rescanReturnsOnCall == nil { - fake.rescanReturnsOnCall = make(map[int]struct { - result1 error +func (fake *FakeBlockDeviceUtils) CheckFsReturns(result1 bool, result2 error) { + fake.checkFsMutex.Lock() + defer fake.checkFsMutex.Unlock() + fake.CheckFsStub = nil + fake.checkFsReturns = struct { + result1 bool + result2 error + }{result1, result2} +} + +func (fake *FakeBlockDeviceUtils) CheckFsReturnsOnCall(i int, result1 bool, result2 error) { + fake.checkFsMutex.Lock() + defer fake.checkFsMutex.Unlock() + fake.CheckFsStub = nil + if fake.checkFsReturnsOnCall == nil { + fake.checkFsReturnsOnCall = make(map[int]struct { + result1 bool + result2 error }) } - fake.rescanReturnsOnCall[i] = struct { - result1 error - }{result1} + fake.checkFsReturnsOnCall[i] = struct { + result1 bool + result2 error + }{result1, result2} } -func (fake *FakeBlockDeviceUtils) RescanSCSILun0() error { - fake.rescanSCSILun0Mutex.Lock() - ret, specificReturn := fake.rescanSCSILun0ReturnsOnCall[len(fake.rescanSCSILun0ArgsForCall)] - fake.rescanSCSILun0ArgsForCall = append(fake.rescanSCSILun0ArgsForCall, struct{}{}) - fake.recordInvocation("RescanSCSILun0", []interface{}{}) - fake.rescanSCSILun0Mutex.Unlock() - if fake.RescanSCSILun0Stub != nil { - return fake.RescanSCSILun0Stub() +func (fake *FakeBlockDeviceUtils) Cleanup(arg1 string) error { + fake.cleanupMutex.Lock() + ret, specificReturn := fake.cleanupReturnsOnCall[len(fake.cleanupArgsForCall)] + fake.cleanupArgsForCall = append(fake.cleanupArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("Cleanup", []interface{}{arg1}) + fake.cleanupMutex.Unlock() + if fake.CleanupStub != nil { + return fake.CleanupStub(arg1) } if specificReturn { return ret.result1 } - return fake.rescanSCSILun0Returns.result1 + fakeReturns := fake.cleanupReturns + return fakeReturns.result1 +} + +func (fake *FakeBlockDeviceUtils) CleanupCallCount() int { + fake.cleanupMutex.RLock() + defer fake.cleanupMutex.RUnlock() + return len(fake.cleanupArgsForCall) } -func (fake *FakeBlockDeviceUtils) RescanSCSILun0CallCount() int { - fake.rescanSCSILun0Mutex.RLock() - defer fake.rescanSCSILun0Mutex.RUnlock() - return len(fake.rescanSCSILun0ArgsForCall) +func (fake *FakeBlockDeviceUtils) CleanupCalls(stub func(string) error) { + fake.cleanupMutex.Lock() + defer fake.cleanupMutex.Unlock() + fake.CleanupStub = stub +} + +func (fake *FakeBlockDeviceUtils) CleanupArgsForCall(i int) string { + fake.cleanupMutex.RLock() + defer fake.cleanupMutex.RUnlock() + argsForCall := fake.cleanupArgsForCall[i] + return argsForCall.arg1 } -func (fake *FakeBlockDeviceUtils) RescanSCSILun0Returns(result1 error) { - fake.RescanSCSILun0Stub = nil - fake.rescanSCSILun0Returns = struct { +func (fake *FakeBlockDeviceUtils) CleanupReturns(result1 error) { + fake.cleanupMutex.Lock() + defer fake.cleanupMutex.Unlock() + fake.CleanupStub = nil + fake.cleanupReturns = struct { result1 error }{result1} } -func (fake *FakeBlockDeviceUtils) RescanSCSILun0ReturnsOnCall(i int, result1 error) { - fake.RescanSCSILun0Stub = nil - if fake.rescanSCSILun0ReturnsOnCall == nil { - fake.rescanSCSILun0ReturnsOnCall = make(map[int]struct { +func (fake *FakeBlockDeviceUtils) CleanupReturnsOnCall(i int, result1 error) { + fake.cleanupMutex.Lock() + defer fake.cleanupMutex.Unlock() + fake.CleanupStub = nil + if fake.cleanupReturnsOnCall == nil { + fake.cleanupReturnsOnCall = make(map[int]struct { result1 error }) } - fake.rescanSCSILun0ReturnsOnCall[i] = struct { + fake.cleanupReturnsOnCall[i] = struct { result1 error }{result1} } -func (fake *FakeBlockDeviceUtils) ReloadMultipath() error { - fake.reloadMultipathMutex.Lock() - ret, specificReturn := fake.reloadMultipathReturnsOnCall[len(fake.reloadMultipathArgsForCall)] - fake.reloadMultipathArgsForCall = append(fake.reloadMultipathArgsForCall, struct{}{}) - fake.recordInvocation("ReloadMultipath", []interface{}{}) - fake.reloadMultipathMutex.Unlock() - if fake.ReloadMultipathStub != nil { - return fake.ReloadMultipathStub() +func (fake *FakeBlockDeviceUtils) CleanupDevices(arg1 block_device_utils.Protocol, arg2 *resources.VolumeMountProperties) error { + fake.cleanupDevicesMutex.Lock() + ret, specificReturn := fake.cleanupDevicesReturnsOnCall[len(fake.cleanupDevicesArgsForCall)] + fake.cleanupDevicesArgsForCall = append(fake.cleanupDevicesArgsForCall, struct { + arg1 block_device_utils.Protocol + arg2 *resources.VolumeMountProperties + }{arg1, arg2}) + fake.recordInvocation("CleanupDevices", []interface{}{arg1, arg2}) + fake.cleanupDevicesMutex.Unlock() + if fake.CleanupDevicesStub != nil { + return fake.CleanupDevicesStub(arg1, arg2) } if specificReturn { return ret.result1 } - return fake.reloadMultipathReturns.result1 + fakeReturns := fake.cleanupDevicesReturns + return fakeReturns.result1 } -func (fake *FakeBlockDeviceUtils) ReloadMultipathCallCount() int { - fake.reloadMultipathMutex.RLock() - defer fake.reloadMultipathMutex.RUnlock() - return len(fake.reloadMultipathArgsForCall) +func (fake *FakeBlockDeviceUtils) CleanupDevicesCallCount() int { + fake.cleanupDevicesMutex.RLock() + defer fake.cleanupDevicesMutex.RUnlock() + return len(fake.cleanupDevicesArgsForCall) } -func (fake *FakeBlockDeviceUtils) ReloadMultipathReturns(result1 error) { - fake.ReloadMultipathStub = nil - fake.reloadMultipathReturns = struct { +func (fake *FakeBlockDeviceUtils) CleanupDevicesCalls(stub func(block_device_utils.Protocol, *resources.VolumeMountProperties) error) { + fake.cleanupDevicesMutex.Lock() + defer fake.cleanupDevicesMutex.Unlock() + fake.CleanupDevicesStub = stub +} + +func (fake *FakeBlockDeviceUtils) CleanupDevicesArgsForCall(i int) (block_device_utils.Protocol, *resources.VolumeMountProperties) { + fake.cleanupDevicesMutex.RLock() + defer fake.cleanupDevicesMutex.RUnlock() + argsForCall := fake.cleanupDevicesArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeBlockDeviceUtils) CleanupDevicesReturns(result1 error) { + fake.cleanupDevicesMutex.Lock() + defer fake.cleanupDevicesMutex.Unlock() + fake.CleanupDevicesStub = nil + fake.cleanupDevicesReturns = struct { result1 error }{result1} } -func (fake *FakeBlockDeviceUtils) ReloadMultipathReturnsOnCall(i int, result1 error) { - fake.ReloadMultipathStub = nil - if fake.reloadMultipathReturnsOnCall == nil { - fake.reloadMultipathReturnsOnCall = make(map[int]struct { +func (fake *FakeBlockDeviceUtils) CleanupDevicesReturnsOnCall(i int, result1 error) { + fake.cleanupDevicesMutex.Lock() + defer fake.cleanupDevicesMutex.Unlock() + fake.CleanupDevicesStub = nil + if fake.cleanupDevicesReturnsOnCall == nil { + fake.cleanupDevicesReturnsOnCall = make(map[int]struct { result1 error }) } - fake.reloadMultipathReturnsOnCall[i] = struct { + fake.cleanupDevicesReturnsOnCall[i] = struct { result1 error }{result1} } -func (fake *FakeBlockDeviceUtils) Discover(volumeWwn string, deepDiscovery bool) (string, error) { +func (fake *FakeBlockDeviceUtils) Discover(arg1 string, arg2 bool) (string, error) { fake.discoverMutex.Lock() ret, specificReturn := fake.discoverReturnsOnCall[len(fake.discoverArgsForCall)] fake.discoverArgsForCall = append(fake.discoverArgsForCall, struct { - volumeWwn string - deepDiscovery bool - }{volumeWwn, deepDiscovery}) - fake.recordInvocation("Discover", []interface{}{volumeWwn, deepDiscovery}) + arg1 string + arg2 bool + }{arg1, arg2}) + fake.recordInvocation("Discover", []interface{}{arg1, arg2}) fake.discoverMutex.Unlock() if fake.DiscoverStub != nil { - return fake.DiscoverStub(volumeWwn, deepDiscovery) + return fake.DiscoverStub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - return fake.discoverReturns.result1, fake.discoverReturns.result2 + fakeReturns := fake.discoverReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeBlockDeviceUtils) DiscoverCallCount() int { @@ -336,13 +399,22 @@ func (fake *FakeBlockDeviceUtils) DiscoverCallCount() int { return len(fake.discoverArgsForCall) } +func (fake *FakeBlockDeviceUtils) DiscoverCalls(stub func(string, bool) (string, error)) { + fake.discoverMutex.Lock() + defer fake.discoverMutex.Unlock() + fake.DiscoverStub = stub +} + func (fake *FakeBlockDeviceUtils) DiscoverArgsForCall(i int) (string, bool) { fake.discoverMutex.RLock() defer fake.discoverMutex.RUnlock() - return fake.discoverArgsForCall[i].volumeWwn, fake.discoverArgsForCall[i].deepDiscovery + argsForCall := fake.discoverArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } func (fake *FakeBlockDeviceUtils) DiscoverReturns(result1 string, result2 error) { + fake.discoverMutex.Lock() + defer fake.discoverMutex.Unlock() fake.DiscoverStub = nil fake.discoverReturns = struct { result1 string @@ -351,6 +423,8 @@ func (fake *FakeBlockDeviceUtils) DiscoverReturns(result1 string, result2 error) } func (fake *FakeBlockDeviceUtils) DiscoverReturnsOnCall(i int, result1 string, result2 error) { + fake.discoverMutex.Lock() + defer fake.discoverMutex.Unlock() fake.DiscoverStub = nil if fake.discoverReturnsOnCall == nil { fake.discoverReturnsOnCall = make(map[int]struct { @@ -364,225 +438,283 @@ func (fake *FakeBlockDeviceUtils) DiscoverReturnsOnCall(i int, result1 string, r }{result1, result2} } -func (fake *FakeBlockDeviceUtils) GetWwnByScsiInq(mpathOutput string, dev string) (string, error) { - fake.getWwnByScsiInqMutex.Lock() - ret, specificReturn := fake.getWwnByScsiInqReturnsOnCall[len(fake.getWwnByScsiInqArgsForCall)] - fake.getWwnByScsiInqArgsForCall = append(fake.getWwnByScsiInqArgsForCall, struct { - mpathOutput string - dev string - }{mpathOutput, dev}) - fake.recordInvocation("GetWwnByScsiInq", []interface{}{mpathOutput, dev}) - fake.getWwnByScsiInqMutex.Unlock() - if fake.GetWwnByScsiInqStub != nil { - return fake.GetWwnByScsiInqStub(mpathOutput, dev) +func (fake *FakeBlockDeviceUtils) DiscoverBySgInq(arg1 string, arg2 string) (string, error) { + fake.discoverBySgInqMutex.Lock() + ret, specificReturn := fake.discoverBySgInqReturnsOnCall[len(fake.discoverBySgInqArgsForCall)] + fake.discoverBySgInqArgsForCall = append(fake.discoverBySgInqArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("DiscoverBySgInq", []interface{}{arg1, arg2}) + fake.discoverBySgInqMutex.Unlock() + if fake.DiscoverBySgInqStub != nil { + return fake.DiscoverBySgInqStub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - return fake.getWwnByScsiInqReturns.result1, fake.getWwnByScsiInqReturns.result2 + fakeReturns := fake.discoverBySgInqReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeBlockDeviceUtils) GetWwnByScsiInqCallCount() int { - fake.getWwnByScsiInqMutex.RLock() - defer fake.getWwnByScsiInqMutex.RUnlock() - return len(fake.getWwnByScsiInqArgsForCall) +func (fake *FakeBlockDeviceUtils) DiscoverBySgInqCallCount() int { + fake.discoverBySgInqMutex.RLock() + defer fake.discoverBySgInqMutex.RUnlock() + return len(fake.discoverBySgInqArgsForCall) } -func (fake *FakeBlockDeviceUtils) GetWwnByScsiInqArgsForCall(i int) (string, string) { - fake.getWwnByScsiInqMutex.RLock() - defer fake.getWwnByScsiInqMutex.RUnlock() - return fake.getWwnByScsiInqArgsForCall[i].mpathOutput, fake.getWwnByScsiInqArgsForCall[i].dev +func (fake *FakeBlockDeviceUtils) DiscoverBySgInqCalls(stub func(string, string) (string, error)) { + fake.discoverBySgInqMutex.Lock() + defer fake.discoverBySgInqMutex.Unlock() + fake.DiscoverBySgInqStub = stub } -func (fake *FakeBlockDeviceUtils) GetWwnByScsiInqReturns(result1 string, result2 error) { - fake.GetWwnByScsiInqStub = nil - fake.getWwnByScsiInqReturns = struct { - result1 string - result2 error - }{result1, result2} +func (fake *FakeBlockDeviceUtils) DiscoverBySgInqArgsForCall(i int) (string, string) { + fake.discoverBySgInqMutex.RLock() + defer fake.discoverBySgInqMutex.RUnlock() + argsForCall := fake.discoverBySgInqArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } -func (fake *FakeBlockDeviceUtils) GetWwnByScsiInqReturnsOnCall(i int, result1 string, result2 error) { - fake.GetWwnByScsiInqStub = nil - if fake.getWwnByScsiInqReturnsOnCall == nil { - fake.getWwnByScsiInqReturnsOnCall = make(map[int]struct { +func (fake *FakeBlockDeviceUtils) DiscoverBySgInqReturns(result1 string, result2 error) { + fake.discoverBySgInqMutex.Lock() + defer fake.discoverBySgInqMutex.Unlock() + fake.DiscoverBySgInqStub = nil + fake.discoverBySgInqReturns = struct { + result1 string + result2 error + }{result1, result2} +} + +func (fake *FakeBlockDeviceUtils) DiscoverBySgInqReturnsOnCall(i int, result1 string, result2 error) { + fake.discoverBySgInqMutex.Lock() + defer fake.discoverBySgInqMutex.Unlock() + fake.DiscoverBySgInqStub = nil + if fake.discoverBySgInqReturnsOnCall == nil { + fake.discoverBySgInqReturnsOnCall = make(map[int]struct { result1 string result2 error }) } - fake.getWwnByScsiInqReturnsOnCall[i] = struct { + fake.discoverBySgInqReturnsOnCall[i] = struct { result1 string result2 error }{result1, result2} } -func (fake *FakeBlockDeviceUtils) DiscoverBySgInq(mpathOutput string, volumeWwn string) (string, error) { - fake.discoverBySgInqMutex.Lock() - ret, specificReturn := fake.discoverBySgInqReturnsOnCall[len(fake.discoverBySgInqArgsForCall)] - fake.discoverBySgInqArgsForCall = append(fake.discoverBySgInqArgsForCall, struct { - mpathOutput string - volumeWwn string - }{mpathOutput, volumeWwn}) - fake.recordInvocation("DiscoverBySgInq", []interface{}{mpathOutput, volumeWwn}) - fake.discoverBySgInqMutex.Unlock() - if fake.DiscoverBySgInqStub != nil { - return fake.DiscoverBySgInqStub(mpathOutput, volumeWwn) +func (fake *FakeBlockDeviceUtils) GetWwnByScsiInq(arg1 string, arg2 string) (string, error) { + fake.getWwnByScsiInqMutex.Lock() + ret, specificReturn := fake.getWwnByScsiInqReturnsOnCall[len(fake.getWwnByScsiInqArgsForCall)] + fake.getWwnByScsiInqArgsForCall = append(fake.getWwnByScsiInqArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("GetWwnByScsiInq", []interface{}{arg1, arg2}) + fake.getWwnByScsiInqMutex.Unlock() + if fake.GetWwnByScsiInqStub != nil { + return fake.GetWwnByScsiInqStub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - return fake.discoverBySgInqReturns.result1, fake.discoverBySgInqReturns.result2 + fakeReturns := fake.getWwnByScsiInqReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeBlockDeviceUtils) DiscoverBySgInqCallCount() int { - fake.discoverBySgInqMutex.RLock() - defer fake.discoverBySgInqMutex.RUnlock() - return len(fake.discoverBySgInqArgsForCall) +func (fake *FakeBlockDeviceUtils) GetWwnByScsiInqCallCount() int { + fake.getWwnByScsiInqMutex.RLock() + defer fake.getWwnByScsiInqMutex.RUnlock() + return len(fake.getWwnByScsiInqArgsForCall) } -func (fake *FakeBlockDeviceUtils) DiscoverBySgInqArgsForCall(i int) (string, string) { - fake.discoverBySgInqMutex.RLock() - defer fake.discoverBySgInqMutex.RUnlock() - return fake.discoverBySgInqArgsForCall[i].mpathOutput, fake.discoverBySgInqArgsForCall[i].volumeWwn +func (fake *FakeBlockDeviceUtils) GetWwnByScsiInqCalls(stub func(string, string) (string, error)) { + fake.getWwnByScsiInqMutex.Lock() + defer fake.getWwnByScsiInqMutex.Unlock() + fake.GetWwnByScsiInqStub = stub } -func (fake *FakeBlockDeviceUtils) DiscoverBySgInqReturns(result1 string, result2 error) { - fake.DiscoverBySgInqStub = nil - fake.discoverBySgInqReturns = struct { +func (fake *FakeBlockDeviceUtils) GetWwnByScsiInqArgsForCall(i int) (string, string) { + fake.getWwnByScsiInqMutex.RLock() + defer fake.getWwnByScsiInqMutex.RUnlock() + argsForCall := fake.getWwnByScsiInqArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeBlockDeviceUtils) GetWwnByScsiInqReturns(result1 string, result2 error) { + fake.getWwnByScsiInqMutex.Lock() + defer fake.getWwnByScsiInqMutex.Unlock() + fake.GetWwnByScsiInqStub = nil + fake.getWwnByScsiInqReturns = struct { result1 string result2 error }{result1, result2} } -func (fake *FakeBlockDeviceUtils) DiscoverBySgInqReturnsOnCall(i int, result1 string, result2 error) { - fake.DiscoverBySgInqStub = nil - if fake.discoverBySgInqReturnsOnCall == nil { - fake.discoverBySgInqReturnsOnCall = make(map[int]struct { +func (fake *FakeBlockDeviceUtils) GetWwnByScsiInqReturnsOnCall(i int, result1 string, result2 error) { + fake.getWwnByScsiInqMutex.Lock() + defer fake.getWwnByScsiInqMutex.Unlock() + fake.GetWwnByScsiInqStub = nil + if fake.getWwnByScsiInqReturnsOnCall == nil { + fake.getWwnByScsiInqReturnsOnCall = make(map[int]struct { result1 string result2 error }) } - fake.discoverBySgInqReturnsOnCall[i] = struct { + fake.getWwnByScsiInqReturnsOnCall[i] = struct { result1 string result2 error }{result1, result2} } -func (fake *FakeBlockDeviceUtils) Cleanup(mpath string) error { - fake.cleanupMutex.Lock() - ret, specificReturn := fake.cleanupReturnsOnCall[len(fake.cleanupArgsForCall)] - fake.cleanupArgsForCall = append(fake.cleanupArgsForCall, struct { - mpath string - }{mpath}) - fake.recordInvocation("Cleanup", []interface{}{mpath}) - fake.cleanupMutex.Unlock() - if fake.CleanupStub != nil { - return fake.CleanupStub(mpath) +func (fake *FakeBlockDeviceUtils) IsDeviceMounted(arg1 string) (bool, []string, error) { + fake.isDeviceMountedMutex.Lock() + ret, specificReturn := fake.isDeviceMountedReturnsOnCall[len(fake.isDeviceMountedArgsForCall)] + fake.isDeviceMountedArgsForCall = append(fake.isDeviceMountedArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("IsDeviceMounted", []interface{}{arg1}) + fake.isDeviceMountedMutex.Unlock() + if fake.IsDeviceMountedStub != nil { + return fake.IsDeviceMountedStub(arg1) } if specificReturn { - return ret.result1 + return ret.result1, ret.result2, ret.result3 } - return fake.cleanupReturns.result1 + fakeReturns := fake.isDeviceMountedReturns + return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } -func (fake *FakeBlockDeviceUtils) CleanupCallCount() int { - fake.cleanupMutex.RLock() - defer fake.cleanupMutex.RUnlock() - return len(fake.cleanupArgsForCall) +func (fake *FakeBlockDeviceUtils) IsDeviceMountedCallCount() int { + fake.isDeviceMountedMutex.RLock() + defer fake.isDeviceMountedMutex.RUnlock() + return len(fake.isDeviceMountedArgsForCall) } -func (fake *FakeBlockDeviceUtils) CleanupArgsForCall(i int) string { - fake.cleanupMutex.RLock() - defer fake.cleanupMutex.RUnlock() - return fake.cleanupArgsForCall[i].mpath +func (fake *FakeBlockDeviceUtils) IsDeviceMountedCalls(stub func(string) (bool, []string, error)) { + fake.isDeviceMountedMutex.Lock() + defer fake.isDeviceMountedMutex.Unlock() + fake.IsDeviceMountedStub = stub } -func (fake *FakeBlockDeviceUtils) CleanupReturns(result1 error) { - fake.CleanupStub = nil - fake.cleanupReturns = struct { - result1 error - }{result1} +func (fake *FakeBlockDeviceUtils) IsDeviceMountedArgsForCall(i int) string { + fake.isDeviceMountedMutex.RLock() + defer fake.isDeviceMountedMutex.RUnlock() + argsForCall := fake.isDeviceMountedArgsForCall[i] + return argsForCall.arg1 } -func (fake *FakeBlockDeviceUtils) CleanupReturnsOnCall(i int, result1 error) { - fake.CleanupStub = nil - if fake.cleanupReturnsOnCall == nil { - fake.cleanupReturnsOnCall = make(map[int]struct { - result1 error +func (fake *FakeBlockDeviceUtils) IsDeviceMountedReturns(result1 bool, result2 []string, result3 error) { + fake.isDeviceMountedMutex.Lock() + defer fake.isDeviceMountedMutex.Unlock() + fake.IsDeviceMountedStub = nil + fake.isDeviceMountedReturns = struct { + result1 bool + result2 []string + result3 error + }{result1, result2, result3} +} + +func (fake *FakeBlockDeviceUtils) IsDeviceMountedReturnsOnCall(i int, result1 bool, result2 []string, result3 error) { + fake.isDeviceMountedMutex.Lock() + defer fake.isDeviceMountedMutex.Unlock() + fake.IsDeviceMountedStub = nil + if fake.isDeviceMountedReturnsOnCall == nil { + fake.isDeviceMountedReturnsOnCall = make(map[int]struct { + result1 bool + result2 []string + result3 error }) } - fake.cleanupReturnsOnCall[i] = struct { - result1 error - }{result1} + fake.isDeviceMountedReturnsOnCall[i] = struct { + result1 bool + result2 []string + result3 error + }{result1, result2, result3} } -func (fake *FakeBlockDeviceUtils) CheckFs(mpath string) (bool, error) { - fake.checkFsMutex.Lock() - ret, specificReturn := fake.checkFsReturnsOnCall[len(fake.checkFsArgsForCall)] - fake.checkFsArgsForCall = append(fake.checkFsArgsForCall, struct { - mpath string - }{mpath}) - fake.recordInvocation("CheckFs", []interface{}{mpath}) - fake.checkFsMutex.Unlock() - if fake.CheckFsStub != nil { - return fake.CheckFsStub(mpath) +func (fake *FakeBlockDeviceUtils) IsDirAMountPoint(arg1 string) (bool, []string, error) { + fake.isDirAMountPointMutex.Lock() + ret, specificReturn := fake.isDirAMountPointReturnsOnCall[len(fake.isDirAMountPointArgsForCall)] + fake.isDirAMountPointArgsForCall = append(fake.isDirAMountPointArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("IsDirAMountPoint", []interface{}{arg1}) + fake.isDirAMountPointMutex.Unlock() + if fake.IsDirAMountPointStub != nil { + return fake.IsDirAMountPointStub(arg1) } if specificReturn { - return ret.result1, ret.result2 + return ret.result1, ret.result2, ret.result3 } - return fake.checkFsReturns.result1, fake.checkFsReturns.result2 + fakeReturns := fake.isDirAMountPointReturns + return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 } -func (fake *FakeBlockDeviceUtils) CheckFsCallCount() int { - fake.checkFsMutex.RLock() - defer fake.checkFsMutex.RUnlock() - return len(fake.checkFsArgsForCall) +func (fake *FakeBlockDeviceUtils) IsDirAMountPointCallCount() int { + fake.isDirAMountPointMutex.RLock() + defer fake.isDirAMountPointMutex.RUnlock() + return len(fake.isDirAMountPointArgsForCall) } -func (fake *FakeBlockDeviceUtils) CheckFsArgsForCall(i int) string { - fake.checkFsMutex.RLock() - defer fake.checkFsMutex.RUnlock() - return fake.checkFsArgsForCall[i].mpath +func (fake *FakeBlockDeviceUtils) IsDirAMountPointCalls(stub func(string) (bool, []string, error)) { + fake.isDirAMountPointMutex.Lock() + defer fake.isDirAMountPointMutex.Unlock() + fake.IsDirAMountPointStub = stub } -func (fake *FakeBlockDeviceUtils) CheckFsReturns(result1 bool, result2 error) { - fake.CheckFsStub = nil - fake.checkFsReturns = struct { +func (fake *FakeBlockDeviceUtils) IsDirAMountPointArgsForCall(i int) string { + fake.isDirAMountPointMutex.RLock() + defer fake.isDirAMountPointMutex.RUnlock() + argsForCall := fake.isDirAMountPointArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeBlockDeviceUtils) IsDirAMountPointReturns(result1 bool, result2 []string, result3 error) { + fake.isDirAMountPointMutex.Lock() + defer fake.isDirAMountPointMutex.Unlock() + fake.IsDirAMountPointStub = nil + fake.isDirAMountPointReturns = struct { result1 bool - result2 error - }{result1, result2} + result2 []string + result3 error + }{result1, result2, result3} } -func (fake *FakeBlockDeviceUtils) CheckFsReturnsOnCall(i int, result1 bool, result2 error) { - fake.CheckFsStub = nil - if fake.checkFsReturnsOnCall == nil { - fake.checkFsReturnsOnCall = make(map[int]struct { +func (fake *FakeBlockDeviceUtils) IsDirAMountPointReturnsOnCall(i int, result1 bool, result2 []string, result3 error) { + fake.isDirAMountPointMutex.Lock() + defer fake.isDirAMountPointMutex.Unlock() + fake.IsDirAMountPointStub = nil + if fake.isDirAMountPointReturnsOnCall == nil { + fake.isDirAMountPointReturnsOnCall = make(map[int]struct { result1 bool - result2 error + result2 []string + result3 error }) } - fake.checkFsReturnsOnCall[i] = struct { + fake.isDirAMountPointReturnsOnCall[i] = struct { result1 bool - result2 error - }{result1, result2} + result2 []string + result3 error + }{result1, result2, result3} } -func (fake *FakeBlockDeviceUtils) MakeFs(mpath string, fsType string) error { +func (fake *FakeBlockDeviceUtils) MakeFs(arg1 string, arg2 string) error { fake.makeFsMutex.Lock() ret, specificReturn := fake.makeFsReturnsOnCall[len(fake.makeFsArgsForCall)] fake.makeFsArgsForCall = append(fake.makeFsArgsForCall, struct { - mpath string - fsType string - }{mpath, fsType}) - fake.recordInvocation("MakeFs", []interface{}{mpath, fsType}) + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("MakeFs", []interface{}{arg1, arg2}) fake.makeFsMutex.Unlock() if fake.MakeFsStub != nil { - return fake.MakeFsStub(mpath, fsType) + return fake.MakeFsStub(arg1, arg2) } if specificReturn { return ret.result1 } - return fake.makeFsReturns.result1 + fakeReturns := fake.makeFsReturns + return fakeReturns.result1 } func (fake *FakeBlockDeviceUtils) MakeFsCallCount() int { @@ -591,13 +723,22 @@ func (fake *FakeBlockDeviceUtils) MakeFsCallCount() int { return len(fake.makeFsArgsForCall) } +func (fake *FakeBlockDeviceUtils) MakeFsCalls(stub func(string, string) error) { + fake.makeFsMutex.Lock() + defer fake.makeFsMutex.Unlock() + fake.MakeFsStub = stub +} + func (fake *FakeBlockDeviceUtils) MakeFsArgsForCall(i int) (string, string) { fake.makeFsMutex.RLock() defer fake.makeFsMutex.RUnlock() - return fake.makeFsArgsForCall[i].mpath, fake.makeFsArgsForCall[i].fsType + argsForCall := fake.makeFsArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } func (fake *FakeBlockDeviceUtils) MakeFsReturns(result1 error) { + fake.makeFsMutex.Lock() + defer fake.makeFsMutex.Unlock() fake.MakeFsStub = nil fake.makeFsReturns = struct { result1 error @@ -605,6 +746,8 @@ func (fake *FakeBlockDeviceUtils) MakeFsReturns(result1 error) { } func (fake *FakeBlockDeviceUtils) MakeFsReturnsOnCall(i int, result1 error) { + fake.makeFsMutex.Lock() + defer fake.makeFsMutex.Unlock() fake.MakeFsStub = nil if fake.makeFsReturnsOnCall == nil { fake.makeFsReturnsOnCall = make(map[int]struct { @@ -616,22 +759,23 @@ func (fake *FakeBlockDeviceUtils) MakeFsReturnsOnCall(i int, result1 error) { }{result1} } -func (fake *FakeBlockDeviceUtils) MountFs(mpath string, mpoint string) error { +func (fake *FakeBlockDeviceUtils) MountFs(arg1 string, arg2 string) error { fake.mountFsMutex.Lock() ret, specificReturn := fake.mountFsReturnsOnCall[len(fake.mountFsArgsForCall)] fake.mountFsArgsForCall = append(fake.mountFsArgsForCall, struct { - mpath string - mpoint string - }{mpath, mpoint}) - fake.recordInvocation("MountFs", []interface{}{mpath, mpoint}) + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("MountFs", []interface{}{arg1, arg2}) fake.mountFsMutex.Unlock() if fake.MountFsStub != nil { - return fake.MountFsStub(mpath, mpoint) + return fake.MountFsStub(arg1, arg2) } if specificReturn { return ret.result1 } - return fake.mountFsReturns.result1 + fakeReturns := fake.mountFsReturns + return fakeReturns.result1 } func (fake *FakeBlockDeviceUtils) MountFsCallCount() int { @@ -640,13 +784,22 @@ func (fake *FakeBlockDeviceUtils) MountFsCallCount() int { return len(fake.mountFsArgsForCall) } +func (fake *FakeBlockDeviceUtils) MountFsCalls(stub func(string, string) error) { + fake.mountFsMutex.Lock() + defer fake.mountFsMutex.Unlock() + fake.MountFsStub = stub +} + func (fake *FakeBlockDeviceUtils) MountFsArgsForCall(i int) (string, string) { fake.mountFsMutex.RLock() defer fake.mountFsMutex.RUnlock() - return fake.mountFsArgsForCall[i].mpath, fake.mountFsArgsForCall[i].mpoint + argsForCall := fake.mountFsArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } func (fake *FakeBlockDeviceUtils) MountFsReturns(result1 error) { + fake.mountFsMutex.Lock() + defer fake.mountFsMutex.Unlock() fake.MountFsStub = nil fake.mountFsReturns = struct { result1 error @@ -654,6 +807,8 @@ func (fake *FakeBlockDeviceUtils) MountFsReturns(result1 error) { } func (fake *FakeBlockDeviceUtils) MountFsReturnsOnCall(i int, result1 error) { + fake.mountFsMutex.Lock() + defer fake.mountFsMutex.Unlock() fake.MountFsStub = nil if fake.mountFsReturnsOnCall == nil { fake.mountFsReturnsOnCall = make(map[int]struct { @@ -665,178 +820,135 @@ func (fake *FakeBlockDeviceUtils) MountFsReturnsOnCall(i int, result1 error) { }{result1} } -func (fake *FakeBlockDeviceUtils) UmountFs(mpoint string, volumeWwn string) error { - fake.umountFsMutex.Lock() - ret, specificReturn := fake.umountFsReturnsOnCall[len(fake.umountFsArgsForCall)] - fake.umountFsArgsForCall = append(fake.umountFsArgsForCall, struct { - mpoint string - volumeWwn string - }{mpoint, volumeWwn}) - fake.recordInvocation("UmountFs", []interface{}{mpoint, volumeWwn}) - fake.umountFsMutex.Unlock() - if fake.UmountFsStub != nil { - return fake.UmountFsStub(mpoint, volumeWwn) +func (fake *FakeBlockDeviceUtils) ReloadMultipath() error { + fake.reloadMultipathMutex.Lock() + ret, specificReturn := fake.reloadMultipathReturnsOnCall[len(fake.reloadMultipathArgsForCall)] + fake.reloadMultipathArgsForCall = append(fake.reloadMultipathArgsForCall, struct { + }{}) + fake.recordInvocation("ReloadMultipath", []interface{}{}) + fake.reloadMultipathMutex.Unlock() + if fake.ReloadMultipathStub != nil { + return fake.ReloadMultipathStub() } if specificReturn { return ret.result1 } - return fake.umountFsReturns.result1 + fakeReturns := fake.reloadMultipathReturns + return fakeReturns.result1 } -func (fake *FakeBlockDeviceUtils) UmountFsCallCount() int { - fake.umountFsMutex.RLock() - defer fake.umountFsMutex.RUnlock() - return len(fake.umountFsArgsForCall) +func (fake *FakeBlockDeviceUtils) ReloadMultipathCallCount() int { + fake.reloadMultipathMutex.RLock() + defer fake.reloadMultipathMutex.RUnlock() + return len(fake.reloadMultipathArgsForCall) } -func (fake *FakeBlockDeviceUtils) UmountFsArgsForCall(i int) (string, string) { - fake.umountFsMutex.RLock() - defer fake.umountFsMutex.RUnlock() - return fake.umountFsArgsForCall[i].mpoint, fake.umountFsArgsForCall[i].volumeWwn +func (fake *FakeBlockDeviceUtils) ReloadMultipathCalls(stub func() error) { + fake.reloadMultipathMutex.Lock() + defer fake.reloadMultipathMutex.Unlock() + fake.ReloadMultipathStub = stub } -func (fake *FakeBlockDeviceUtils) UmountFsReturns(result1 error) { - fake.UmountFsStub = nil - fake.umountFsReturns = struct { +func (fake *FakeBlockDeviceUtils) ReloadMultipathReturns(result1 error) { + fake.reloadMultipathMutex.Lock() + defer fake.reloadMultipathMutex.Unlock() + fake.ReloadMultipathStub = nil + fake.reloadMultipathReturns = struct { result1 error }{result1} } -func (fake *FakeBlockDeviceUtils) UmountFsReturnsOnCall(i int, result1 error) { - fake.UmountFsStub = nil - if fake.umountFsReturnsOnCall == nil { - fake.umountFsReturnsOnCall = make(map[int]struct { +func (fake *FakeBlockDeviceUtils) ReloadMultipathReturnsOnCall(i int, result1 error) { + fake.reloadMultipathMutex.Lock() + defer fake.reloadMultipathMutex.Unlock() + fake.ReloadMultipathStub = nil + if fake.reloadMultipathReturnsOnCall == nil { + fake.reloadMultipathReturnsOnCall = make(map[int]struct { result1 error }) } - fake.umountFsReturnsOnCall[i] = struct { + fake.reloadMultipathReturnsOnCall[i] = struct { result1 error }{result1} } -func (fake *FakeBlockDeviceUtils) IsDeviceMounted(devPath string) (bool, []string, error) { - fake.isDeviceMountedMutex.Lock() - ret, specificReturn := fake.isDeviceMountedReturnsOnCall[len(fake.isDeviceMountedArgsForCall)] - fake.isDeviceMountedArgsForCall = append(fake.isDeviceMountedArgsForCall, struct { - devPath string - }{devPath}) - fake.recordInvocation("IsDeviceMounted", []interface{}{devPath}) - fake.isDeviceMountedMutex.Unlock() - if fake.IsDeviceMountedStub != nil { - return fake.IsDeviceMountedStub(devPath) +func (fake *FakeBlockDeviceUtils) Rescan(arg1 block_device_utils.Protocol, arg2 *resources.VolumeMountProperties) error { + fake.rescanMutex.Lock() + ret, specificReturn := fake.rescanReturnsOnCall[len(fake.rescanArgsForCall)] + fake.rescanArgsForCall = append(fake.rescanArgsForCall, struct { + arg1 block_device_utils.Protocol + arg2 *resources.VolumeMountProperties + }{arg1, arg2}) + fake.recordInvocation("Rescan", []interface{}{arg1, arg2}) + fake.rescanMutex.Unlock() + if fake.RescanStub != nil { + return fake.RescanStub(arg1, arg2) } if specificReturn { - return ret.result1, ret.result2, ret.result3 - } - return fake.isDeviceMountedReturns.result1, fake.isDeviceMountedReturns.result2, fake.isDeviceMountedReturns.result3 -} - -func (fake *FakeBlockDeviceUtils) IsDeviceMountedCallCount() int { - fake.isDeviceMountedMutex.RLock() - defer fake.isDeviceMountedMutex.RUnlock() - return len(fake.isDeviceMountedArgsForCall) -} - -func (fake *FakeBlockDeviceUtils) IsDeviceMountedArgsForCall(i int) string { - fake.isDeviceMountedMutex.RLock() - defer fake.isDeviceMountedMutex.RUnlock() - return fake.isDeviceMountedArgsForCall[i].devPath -} - -func (fake *FakeBlockDeviceUtils) IsDeviceMountedReturns(result1 bool, result2 []string, result3 error) { - fake.IsDeviceMountedStub = nil - fake.isDeviceMountedReturns = struct { - result1 bool - result2 []string - result3 error - }{result1, result2, result3} -} - -func (fake *FakeBlockDeviceUtils) IsDeviceMountedReturnsOnCall(i int, result1 bool, result2 []string, result3 error) { - fake.IsDeviceMountedStub = nil - if fake.isDeviceMountedReturnsOnCall == nil { - fake.isDeviceMountedReturnsOnCall = make(map[int]struct { - result1 bool - result2 []string - result3 error - }) + return ret.result1 } - fake.isDeviceMountedReturnsOnCall[i] = struct { - result1 bool - result2 []string - result3 error - }{result1, result2, result3} + fakeReturns := fake.rescanReturns + return fakeReturns.result1 } -func (fake *FakeBlockDeviceUtils) IsDirAMountPoint(dirPath string) (bool, []string, error) { - fake.isDirAMountPointMutex.Lock() - ret, specificReturn := fake.isDirAMountPointReturnsOnCall[len(fake.isDirAMountPointArgsForCall)] - fake.isDirAMountPointArgsForCall = append(fake.isDirAMountPointArgsForCall, struct { - dirPath string - }{dirPath}) - fake.recordInvocation("IsDirAMountPoint", []interface{}{dirPath}) - fake.isDirAMountPointMutex.Unlock() - if fake.IsDirAMountPointStub != nil { - return fake.IsDirAMountPointStub(dirPath) - } - if specificReturn { - return ret.result1, ret.result2, ret.result3 - } - return fake.isDirAMountPointReturns.result1, fake.isDirAMountPointReturns.result2, fake.isDirAMountPointReturns.result3 +func (fake *FakeBlockDeviceUtils) RescanCallCount() int { + fake.rescanMutex.RLock() + defer fake.rescanMutex.RUnlock() + return len(fake.rescanArgsForCall) } -func (fake *FakeBlockDeviceUtils) IsDirAMountPointCallCount() int { - fake.isDirAMountPointMutex.RLock() - defer fake.isDirAMountPointMutex.RUnlock() - return len(fake.isDirAMountPointArgsForCall) +func (fake *FakeBlockDeviceUtils) RescanCalls(stub func(block_device_utils.Protocol, *resources.VolumeMountProperties) error) { + fake.rescanMutex.Lock() + defer fake.rescanMutex.Unlock() + fake.RescanStub = stub } -func (fake *FakeBlockDeviceUtils) IsDirAMountPointArgsForCall(i int) string { - fake.isDirAMountPointMutex.RLock() - defer fake.isDirAMountPointMutex.RUnlock() - return fake.isDirAMountPointArgsForCall[i].dirPath +func (fake *FakeBlockDeviceUtils) RescanArgsForCall(i int) (block_device_utils.Protocol, *resources.VolumeMountProperties) { + fake.rescanMutex.RLock() + defer fake.rescanMutex.RUnlock() + argsForCall := fake.rescanArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } -func (fake *FakeBlockDeviceUtils) IsDirAMountPointReturns(result1 bool, result2 []string, result3 error) { - fake.IsDirAMountPointStub = nil - fake.isDirAMountPointReturns = struct { - result1 bool - result2 []string - result3 error - }{result1, result2, result3} +func (fake *FakeBlockDeviceUtils) RescanReturns(result1 error) { + fake.rescanMutex.Lock() + defer fake.rescanMutex.Unlock() + fake.RescanStub = nil + fake.rescanReturns = struct { + result1 error + }{result1} } -func (fake *FakeBlockDeviceUtils) IsDirAMountPointReturnsOnCall(i int, result1 bool, result2 []string, result3 error) { - fake.IsDirAMountPointStub = nil - if fake.isDirAMountPointReturnsOnCall == nil { - fake.isDirAMountPointReturnsOnCall = make(map[int]struct { - result1 bool - result2 []string - result3 error +func (fake *FakeBlockDeviceUtils) RescanReturnsOnCall(i int, result1 error) { + fake.rescanMutex.Lock() + defer fake.rescanMutex.Unlock() + fake.RescanStub = nil + if fake.rescanReturnsOnCall == nil { + fake.rescanReturnsOnCall = make(map[int]struct { + result1 error }) } - fake.isDirAMountPointReturnsOnCall[i] = struct { - result1 bool - result2 []string - result3 error - }{result1, result2, result3} + fake.rescanReturnsOnCall[i] = struct { + result1 error + }{result1} } -func (fake *FakeBlockDeviceUtils) SetDmsetup(mpath string) error { +func (fake *FakeBlockDeviceUtils) SetDmsetup(arg1 string) error { fake.setDmsetupMutex.Lock() ret, specificReturn := fake.setDmsetupReturnsOnCall[len(fake.setDmsetupArgsForCall)] fake.setDmsetupArgsForCall = append(fake.setDmsetupArgsForCall, struct { - mpath string - }{mpath}) - fake.recordInvocation("SetDmsetup", []interface{}{mpath}) + arg1 string + }{arg1}) + fake.recordInvocation("SetDmsetup", []interface{}{arg1}) fake.setDmsetupMutex.Unlock() if fake.SetDmsetupStub != nil { - return fake.SetDmsetupStub(mpath) + return fake.SetDmsetupStub(arg1) } if specificReturn { return ret.result1 } - return fake.setDmsetupReturns.result1 + fakeReturns := fake.setDmsetupReturns + return fakeReturns.result1 } func (fake *FakeBlockDeviceUtils) SetDmsetupCallCount() int { @@ -845,13 +957,22 @@ func (fake *FakeBlockDeviceUtils) SetDmsetupCallCount() int { return len(fake.setDmsetupArgsForCall) } +func (fake *FakeBlockDeviceUtils) SetDmsetupCalls(stub func(string) error) { + fake.setDmsetupMutex.Lock() + defer fake.setDmsetupMutex.Unlock() + fake.SetDmsetupStub = stub +} + func (fake *FakeBlockDeviceUtils) SetDmsetupArgsForCall(i int) string { fake.setDmsetupMutex.RLock() defer fake.setDmsetupMutex.RUnlock() - return fake.setDmsetupArgsForCall[i].mpath + argsForCall := fake.setDmsetupArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeBlockDeviceUtils) SetDmsetupReturns(result1 error) { + fake.setDmsetupMutex.Lock() + defer fake.setDmsetupMutex.Unlock() fake.SetDmsetupStub = nil fake.setDmsetupReturns = struct { result1 error @@ -859,6 +980,8 @@ func (fake *FakeBlockDeviceUtils) SetDmsetupReturns(result1 error) { } func (fake *FakeBlockDeviceUtils) SetDmsetupReturnsOnCall(i int, result1 error) { + fake.setDmsetupMutex.Lock() + defer fake.setDmsetupMutex.Unlock() fake.SetDmsetupStub = nil if fake.setDmsetupReturnsOnCall == nil { fake.setDmsetupReturnsOnCall = make(map[int]struct { @@ -870,37 +993,98 @@ func (fake *FakeBlockDeviceUtils) SetDmsetupReturnsOnCall(i int, result1 error) }{result1} } +func (fake *FakeBlockDeviceUtils) UmountFs(arg1 string, arg2 string) error { + fake.umountFsMutex.Lock() + ret, specificReturn := fake.umountFsReturnsOnCall[len(fake.umountFsArgsForCall)] + fake.umountFsArgsForCall = append(fake.umountFsArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("UmountFs", []interface{}{arg1, arg2}) + fake.umountFsMutex.Unlock() + if fake.UmountFsStub != nil { + return fake.UmountFsStub(arg1, arg2) + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.umountFsReturns + return fakeReturns.result1 +} + +func (fake *FakeBlockDeviceUtils) UmountFsCallCount() int { + fake.umountFsMutex.RLock() + defer fake.umountFsMutex.RUnlock() + return len(fake.umountFsArgsForCall) +} + +func (fake *FakeBlockDeviceUtils) UmountFsCalls(stub func(string, string) error) { + fake.umountFsMutex.Lock() + defer fake.umountFsMutex.Unlock() + fake.UmountFsStub = stub +} + +func (fake *FakeBlockDeviceUtils) UmountFsArgsForCall(i int) (string, string) { + fake.umountFsMutex.RLock() + defer fake.umountFsMutex.RUnlock() + argsForCall := fake.umountFsArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeBlockDeviceUtils) UmountFsReturns(result1 error) { + fake.umountFsMutex.Lock() + defer fake.umountFsMutex.Unlock() + fake.UmountFsStub = nil + fake.umountFsReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeBlockDeviceUtils) UmountFsReturnsOnCall(i int, result1 error) { + fake.umountFsMutex.Lock() + defer fake.umountFsMutex.Unlock() + fake.UmountFsStub = nil + if fake.umountFsReturnsOnCall == nil { + fake.umountFsReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.umountFsReturnsOnCall[i] = struct { + result1 error + }{result1} +} + func (fake *FakeBlockDeviceUtils) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() - fake.rescanMutex.RLock() - defer fake.rescanMutex.RUnlock() - fake.rescanSCSILun0Mutex.RLock() - defer fake.rescanSCSILun0Mutex.RUnlock() - fake.reloadMultipathMutex.RLock() - defer fake.reloadMultipathMutex.RUnlock() + fake.checkFsMutex.RLock() + defer fake.checkFsMutex.RUnlock() + fake.cleanupMutex.RLock() + defer fake.cleanupMutex.RUnlock() + fake.cleanupDevicesMutex.RLock() + defer fake.cleanupDevicesMutex.RUnlock() fake.discoverMutex.RLock() defer fake.discoverMutex.RUnlock() - fake.getWwnByScsiInqMutex.RLock() - defer fake.getWwnByScsiInqMutex.RUnlock() fake.discoverBySgInqMutex.RLock() defer fake.discoverBySgInqMutex.RUnlock() - fake.cleanupMutex.RLock() - defer fake.cleanupMutex.RUnlock() - fake.checkFsMutex.RLock() - defer fake.checkFsMutex.RUnlock() - fake.makeFsMutex.RLock() - defer fake.makeFsMutex.RUnlock() - fake.mountFsMutex.RLock() - defer fake.mountFsMutex.RUnlock() - fake.umountFsMutex.RLock() - defer fake.umountFsMutex.RUnlock() + fake.getWwnByScsiInqMutex.RLock() + defer fake.getWwnByScsiInqMutex.RUnlock() fake.isDeviceMountedMutex.RLock() defer fake.isDeviceMountedMutex.RUnlock() fake.isDirAMountPointMutex.RLock() defer fake.isDirAMountPointMutex.RUnlock() + fake.makeFsMutex.RLock() + defer fake.makeFsMutex.RUnlock() + fake.mountFsMutex.RLock() + defer fake.mountFsMutex.RUnlock() + fake.reloadMultipathMutex.RLock() + defer fake.reloadMultipathMutex.RUnlock() + fake.rescanMutex.RLock() + defer fake.rescanMutex.RUnlock() fake.setDmsetupMutex.RLock() defer fake.setDmsetupMutex.RUnlock() + fake.umountFsMutex.RLock() + defer fake.umountFsMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} for key, value := range fake.invocations { copiedInvocations[key] = value diff --git a/fakes/fake_executor.go b/fakes/fake_executor.go index a2da0012..931a575c 100644 --- a/fakes/fake_executor.go +++ b/fakes/fake_executor.go @@ -9,11 +9,24 @@ import ( ) type FakeExecutor struct { - ExecuteStub func(command string, args []string) ([]byte, error) + EvalSymlinksStub func(string) (string, error) + evalSymlinksMutex sync.RWMutex + evalSymlinksArgsForCall []struct { + arg1 string + } + evalSymlinksReturns struct { + result1 string + result2 error + } + evalSymlinksReturnsOnCall map[int]struct { + result1 string + result2 error + } + ExecuteStub func(string, []string) ([]byte, error) executeMutex sync.RWMutex executeArgsForCall []struct { - command string - args []string + arg1 string + arg2 []string } executeReturns struct { result1 []byte @@ -23,74 +36,79 @@ type FakeExecutor struct { result1 []byte result2 error } - StatStub func(string) (os.FileInfo, error) - statMutex sync.RWMutex - statArgsForCall []struct { - arg1 string + ExecuteWithTimeoutStub func(int, string, []string) ([]byte, error) + executeWithTimeoutMutex sync.RWMutex + executeWithTimeoutArgsForCall []struct { + arg1 int + arg2 string + arg3 []string } - statReturns struct { - result1 os.FileInfo + executeWithTimeoutReturns struct { + result1 []byte result2 error } - statReturnsOnCall map[int]struct { - result1 os.FileInfo + executeWithTimeoutReturnsOnCall map[int]struct { + result1 []byte result2 error } - MkdirStub func(string, os.FileMode) error - mkdirMutex sync.RWMutex - mkdirArgsForCall []struct { - arg1 string - arg2 os.FileMode + GetDeviceForFileStatStub func(os.FileInfo) uint64 + getDeviceForFileStatMutex sync.RWMutex + getDeviceForFileStatArgsForCall []struct { + arg1 os.FileInfo } - mkdirReturns struct { - result1 error + getDeviceForFileStatReturns struct { + result1 uint64 } - mkdirReturnsOnCall map[int]struct { - result1 error + getDeviceForFileStatReturnsOnCall map[int]struct { + result1 uint64 } - MkdirAllStub func(string, os.FileMode) error - mkdirAllMutex sync.RWMutex - mkdirAllArgsForCall []struct { + GetGlobFilesStub func(string) ([]string, error) + getGlobFilesMutex sync.RWMutex + getGlobFilesArgsForCall []struct { arg1 string - arg2 os.FileMode } - mkdirAllReturns struct { - result1 error + getGlobFilesReturns struct { + result1 []string + result2 error } - mkdirAllReturnsOnCall map[int]struct { - result1 error + getGlobFilesReturnsOnCall map[int]struct { + result1 []string + result2 error } - RemoveAllStub func(string) error - removeAllMutex sync.RWMutex - removeAllArgsForCall []struct { - arg1 string + HostnameStub func() (string, error) + hostnameMutex sync.RWMutex + hostnameArgsForCall []struct { } - removeAllReturns struct { - result1 error + hostnameReturns struct { + result1 string + result2 error } - removeAllReturnsOnCall map[int]struct { - result1 error + hostnameReturnsOnCall map[int]struct { + result1 string + result2 error } - RemoveStub func(string) error - removeMutex sync.RWMutex - removeArgsForCall []struct { - arg1 string + IsDirStub func(os.FileInfo) bool + isDirMutex sync.RWMutex + isDirArgsForCall []struct { + arg1 os.FileInfo } - removeReturns struct { - result1 error + isDirReturns struct { + result1 bool } - removeReturnsOnCall map[int]struct { - result1 error + isDirReturnsOnCall map[int]struct { + result1 bool } - HostnameStub func() (string, error) - hostnameMutex sync.RWMutex - hostnameArgsForCall []struct{} - hostnameReturns struct { - result1 string + IsDirEmptyStub func(string) (bool, error) + isDirEmptyMutex sync.RWMutex + isDirEmptyArgsForCall []struct { + arg1 string + } + isDirEmptyReturns struct { + result1 bool result2 error } - hostnameReturnsOnCall map[int]struct { - result1 string + isDirEmptyReturnsOnCall map[int]struct { + result1 bool result2 error } IsExecutableStub func(string) error @@ -115,38 +133,33 @@ type FakeExecutor struct { isNotExistReturnsOnCall map[int]struct { result1 bool } - EvalSymlinksStub func(path string) (string, error) - evalSymlinksMutex sync.RWMutex - evalSymlinksArgsForCall []struct { - path string + IsSameFileStub func(os.FileInfo, os.FileInfo) bool + isSameFileMutex sync.RWMutex + isSameFileArgsForCall []struct { + arg1 os.FileInfo + arg2 os.FileInfo } - evalSymlinksReturns struct { - result1 string - result2 error + isSameFileReturns struct { + result1 bool } - evalSymlinksReturnsOnCall map[int]struct { - result1 string - result2 error + isSameFileReturnsOnCall map[int]struct { + result1 bool } - ExecuteWithTimeoutStub func(mSeconds int, command string, args []string) ([]byte, error) - executeWithTimeoutMutex sync.RWMutex - executeWithTimeoutArgsForCall []struct { - mSeconds int - command string - args []string + IsSlinkStub func(os.FileInfo) bool + isSlinkMutex sync.RWMutex + isSlinkArgsForCall []struct { + arg1 os.FileInfo } - executeWithTimeoutReturns struct { - result1 []byte - result2 error + isSlinkReturns struct { + result1 bool } - executeWithTimeoutReturnsOnCall map[int]struct { - result1 []byte - result2 error + isSlinkReturnsOnCall map[int]struct { + result1 bool } - LstatStub func(path string) (os.FileInfo, error) + LstatStub func(string) (os.FileInfo, error) lstatMutex sync.RWMutex lstatArgsForCall []struct { - path string + arg1 string } lstatReturns struct { result1 os.FileInfo @@ -156,399 +169,411 @@ type FakeExecutor struct { result1 os.FileInfo result2 error } - IsDirStub func(fInfo os.FileInfo) bool - isDirMutex sync.RWMutex - isDirArgsForCall []struct { - fInfo os.FileInfo - } - isDirReturns struct { - result1 bool - } - isDirReturnsOnCall map[int]struct { - result1 bool - } - SymlinkStub func(target string, slink string) error - symlinkMutex sync.RWMutex - symlinkArgsForCall []struct { - target string - slink string + MkdirStub func(string, os.FileMode) error + mkdirMutex sync.RWMutex + mkdirArgsForCall []struct { + arg1 string + arg2 os.FileMode } - symlinkReturns struct { + mkdirReturns struct { result1 error } - symlinkReturnsOnCall map[int]struct { + mkdirReturnsOnCall map[int]struct { result1 error } - IsSlinkStub func(fInfo os.FileInfo) bool - isSlinkMutex sync.RWMutex - isSlinkArgsForCall []struct { - fInfo os.FileInfo + MkdirAllStub func(string, os.FileMode) error + mkdirAllMutex sync.RWMutex + mkdirAllArgsForCall []struct { + arg1 string + arg2 os.FileMode } - isSlinkReturns struct { - result1 bool + mkdirAllReturns struct { + result1 error } - isSlinkReturnsOnCall map[int]struct { - result1 bool + mkdirAllReturnsOnCall map[int]struct { + result1 error } - GetGlobFilesStub func(file_pattern string) (matches []string, err error) - getGlobFilesMutex sync.RWMutex - getGlobFilesArgsForCall []struct { - file_pattern string + RemoveStub func(string) error + removeMutex sync.RWMutex + removeArgsForCall []struct { + arg1 string } - getGlobFilesReturns struct { - result1 []string - result2 error + removeReturns struct { + result1 error } - getGlobFilesReturnsOnCall map[int]struct { - result1 []string - result2 error + removeReturnsOnCall map[int]struct { + result1 error } - IsSameFileStub func(file1 os.FileInfo, file2 os.FileInfo) bool - isSameFileMutex sync.RWMutex - isSameFileArgsForCall []struct { - file1 os.FileInfo - file2 os.FileInfo + RemoveAllStub func(string) error + removeAllMutex sync.RWMutex + removeAllArgsForCall []struct { + arg1 string } - isSameFileReturns struct { - result1 bool + removeAllReturns struct { + result1 error } - isSameFileReturnsOnCall map[int]struct { - result1 bool + removeAllReturnsOnCall map[int]struct { + result1 error } - IsDirEmptyStub func(dir string) (bool, error) - isDirEmptyMutex sync.RWMutex - isDirEmptyArgsForCall []struct { - dir string + StatStub func(string) (os.FileInfo, error) + statMutex sync.RWMutex + statArgsForCall []struct { + arg1 string } - isDirEmptyReturns struct { - result1 bool + statReturns struct { + result1 os.FileInfo result2 error } - isDirEmptyReturnsOnCall map[int]struct { - result1 bool + statReturnsOnCall map[int]struct { + result1 os.FileInfo result2 error } - GetDeviceForFileStatStub func(os.FileInfo) uint64 - getDeviceForFileStatMutex sync.RWMutex - getDeviceForFileStatArgsForCall []struct { - arg1 os.FileInfo + SymlinkStub func(string, string) error + symlinkMutex sync.RWMutex + symlinkArgsForCall []struct { + arg1 string + arg2 string } - getDeviceForFileStatReturns struct { - result1 uint64 + symlinkReturns struct { + result1 error } - getDeviceForFileStatReturnsOnCall map[int]struct { - result1 uint64 + symlinkReturnsOnCall map[int]struct { + result1 error } invocations map[string][][]interface{} invocationsMutex sync.RWMutex } -func (fake *FakeExecutor) Execute(command string, args []string) ([]byte, error) { - var argsCopy []string - if args != nil { - argsCopy = make([]string, len(args)) - copy(argsCopy, args) - } - fake.executeMutex.Lock() - ret, specificReturn := fake.executeReturnsOnCall[len(fake.executeArgsForCall)] - fake.executeArgsForCall = append(fake.executeArgsForCall, struct { - command string - args []string - }{command, argsCopy}) - fake.recordInvocation("Execute", []interface{}{command, argsCopy}) - fake.executeMutex.Unlock() - if fake.ExecuteStub != nil { - return fake.ExecuteStub(command, args) +func (fake *FakeExecutor) EvalSymlinks(arg1 string) (string, error) { + fake.evalSymlinksMutex.Lock() + ret, specificReturn := fake.evalSymlinksReturnsOnCall[len(fake.evalSymlinksArgsForCall)] + fake.evalSymlinksArgsForCall = append(fake.evalSymlinksArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("EvalSymlinks", []interface{}{arg1}) + fake.evalSymlinksMutex.Unlock() + if fake.EvalSymlinksStub != nil { + return fake.EvalSymlinksStub(arg1) } if specificReturn { return ret.result1, ret.result2 } - return fake.executeReturns.result1, fake.executeReturns.result2 + fakeReturns := fake.evalSymlinksReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeExecutor) ExecuteCallCount() int { - fake.executeMutex.RLock() - defer fake.executeMutex.RUnlock() - return len(fake.executeArgsForCall) +func (fake *FakeExecutor) EvalSymlinksCallCount() int { + fake.evalSymlinksMutex.RLock() + defer fake.evalSymlinksMutex.RUnlock() + return len(fake.evalSymlinksArgsForCall) } -func (fake *FakeExecutor) ExecuteArgsForCall(i int) (string, []string) { - fake.executeMutex.RLock() - defer fake.executeMutex.RUnlock() - return fake.executeArgsForCall[i].command, fake.executeArgsForCall[i].args +func (fake *FakeExecutor) EvalSymlinksCalls(stub func(string) (string, error)) { + fake.evalSymlinksMutex.Lock() + defer fake.evalSymlinksMutex.Unlock() + fake.EvalSymlinksStub = stub } -func (fake *FakeExecutor) ExecuteReturns(result1 []byte, result2 error) { - fake.ExecuteStub = nil - fake.executeReturns = struct { - result1 []byte +func (fake *FakeExecutor) EvalSymlinksArgsForCall(i int) string { + fake.evalSymlinksMutex.RLock() + defer fake.evalSymlinksMutex.RUnlock() + argsForCall := fake.evalSymlinksArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeExecutor) EvalSymlinksReturns(result1 string, result2 error) { + fake.evalSymlinksMutex.Lock() + defer fake.evalSymlinksMutex.Unlock() + fake.EvalSymlinksStub = nil + fake.evalSymlinksReturns = struct { + result1 string result2 error }{result1, result2} } -func (fake *FakeExecutor) ExecuteReturnsOnCall(i int, result1 []byte, result2 error) { - fake.ExecuteStub = nil - if fake.executeReturnsOnCall == nil { - fake.executeReturnsOnCall = make(map[int]struct { - result1 []byte +func (fake *FakeExecutor) EvalSymlinksReturnsOnCall(i int, result1 string, result2 error) { + fake.evalSymlinksMutex.Lock() + defer fake.evalSymlinksMutex.Unlock() + fake.EvalSymlinksStub = nil + if fake.evalSymlinksReturnsOnCall == nil { + fake.evalSymlinksReturnsOnCall = make(map[int]struct { + result1 string result2 error }) } - fake.executeReturnsOnCall[i] = struct { - result1 []byte + fake.evalSymlinksReturnsOnCall[i] = struct { + result1 string result2 error }{result1, result2} } -func (fake *FakeExecutor) Stat(arg1 string) (os.FileInfo, error) { - fake.statMutex.Lock() - ret, specificReturn := fake.statReturnsOnCall[len(fake.statArgsForCall)] - fake.statArgsForCall = append(fake.statArgsForCall, struct { +func (fake *FakeExecutor) Execute(arg1 string, arg2 []string) ([]byte, error) { + var arg2Copy []string + if arg2 != nil { + arg2Copy = make([]string, len(arg2)) + copy(arg2Copy, arg2) + } + fake.executeMutex.Lock() + ret, specificReturn := fake.executeReturnsOnCall[len(fake.executeArgsForCall)] + fake.executeArgsForCall = append(fake.executeArgsForCall, struct { arg1 string - }{arg1}) - fake.recordInvocation("Stat", []interface{}{arg1}) - fake.statMutex.Unlock() - if fake.StatStub != nil { - return fake.StatStub(arg1) + arg2 []string + }{arg1, arg2Copy}) + fake.recordInvocation("Execute", []interface{}{arg1, arg2Copy}) + fake.executeMutex.Unlock() + if fake.ExecuteStub != nil { + return fake.ExecuteStub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - return fake.statReturns.result1, fake.statReturns.result2 + fakeReturns := fake.executeReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeExecutor) StatCallCount() int { - fake.statMutex.RLock() - defer fake.statMutex.RUnlock() - return len(fake.statArgsForCall) +func (fake *FakeExecutor) ExecuteCallCount() int { + fake.executeMutex.RLock() + defer fake.executeMutex.RUnlock() + return len(fake.executeArgsForCall) } -func (fake *FakeExecutor) StatArgsForCall(i int) string { - fake.statMutex.RLock() - defer fake.statMutex.RUnlock() - return fake.statArgsForCall[i].arg1 +func (fake *FakeExecutor) ExecuteCalls(stub func(string, []string) ([]byte, error)) { + fake.executeMutex.Lock() + defer fake.executeMutex.Unlock() + fake.ExecuteStub = stub } -func (fake *FakeExecutor) StatReturns(result1 os.FileInfo, result2 error) { - fake.StatStub = nil - fake.statReturns = struct { - result1 os.FileInfo +func (fake *FakeExecutor) ExecuteArgsForCall(i int) (string, []string) { + fake.executeMutex.RLock() + defer fake.executeMutex.RUnlock() + argsForCall := fake.executeArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeExecutor) ExecuteReturns(result1 []byte, result2 error) { + fake.executeMutex.Lock() + defer fake.executeMutex.Unlock() + fake.ExecuteStub = nil + fake.executeReturns = struct { + result1 []byte result2 error }{result1, result2} } -func (fake *FakeExecutor) StatReturnsOnCall(i int, result1 os.FileInfo, result2 error) { - fake.StatStub = nil - if fake.statReturnsOnCall == nil { - fake.statReturnsOnCall = make(map[int]struct { - result1 os.FileInfo +func (fake *FakeExecutor) ExecuteReturnsOnCall(i int, result1 []byte, result2 error) { + fake.executeMutex.Lock() + defer fake.executeMutex.Unlock() + fake.ExecuteStub = nil + if fake.executeReturnsOnCall == nil { + fake.executeReturnsOnCall = make(map[int]struct { + result1 []byte result2 error }) } - fake.statReturnsOnCall[i] = struct { - result1 os.FileInfo + fake.executeReturnsOnCall[i] = struct { + result1 []byte result2 error }{result1, result2} } -func (fake *FakeExecutor) Mkdir(arg1 string, arg2 os.FileMode) error { - fake.mkdirMutex.Lock() - ret, specificReturn := fake.mkdirReturnsOnCall[len(fake.mkdirArgsForCall)] - fake.mkdirArgsForCall = append(fake.mkdirArgsForCall, struct { - arg1 string - arg2 os.FileMode - }{arg1, arg2}) - fake.recordInvocation("Mkdir", []interface{}{arg1, arg2}) - fake.mkdirMutex.Unlock() - if fake.MkdirStub != nil { - return fake.MkdirStub(arg1, arg2) +func (fake *FakeExecutor) ExecuteWithTimeout(arg1 int, arg2 string, arg3 []string) ([]byte, error) { + var arg3Copy []string + if arg3 != nil { + arg3Copy = make([]string, len(arg3)) + copy(arg3Copy, arg3) } - if specificReturn { - return ret.result1 + fake.executeWithTimeoutMutex.Lock() + ret, specificReturn := fake.executeWithTimeoutReturnsOnCall[len(fake.executeWithTimeoutArgsForCall)] + fake.executeWithTimeoutArgsForCall = append(fake.executeWithTimeoutArgsForCall, struct { + arg1 int + arg2 string + arg3 []string + }{arg1, arg2, arg3Copy}) + fake.recordInvocation("ExecuteWithTimeout", []interface{}{arg1, arg2, arg3Copy}) + fake.executeWithTimeoutMutex.Unlock() + if fake.ExecuteWithTimeoutStub != nil { + return fake.ExecuteWithTimeoutStub(arg1, arg2, arg3) } - return fake.mkdirReturns.result1 -} - -func (fake *FakeExecutor) MkdirCallCount() int { - fake.mkdirMutex.RLock() - defer fake.mkdirMutex.RUnlock() - return len(fake.mkdirArgsForCall) -} - -func (fake *FakeExecutor) MkdirArgsForCall(i int) (string, os.FileMode) { - fake.mkdirMutex.RLock() - defer fake.mkdirMutex.RUnlock() - return fake.mkdirArgsForCall[i].arg1, fake.mkdirArgsForCall[i].arg2 -} - -func (fake *FakeExecutor) MkdirReturns(result1 error) { - fake.MkdirStub = nil - fake.mkdirReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeExecutor) MkdirReturnsOnCall(i int, result1 error) { - fake.MkdirStub = nil - if fake.mkdirReturnsOnCall == nil { - fake.mkdirReturnsOnCall = make(map[int]struct { - result1 error - }) + if specificReturn { + return ret.result1, ret.result2 } - fake.mkdirReturnsOnCall[i] = struct { - result1 error - }{result1} + fakeReturns := fake.executeWithTimeoutReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeExecutor) MkdirAll(arg1 string, arg2 os.FileMode) error { - fake.mkdirAllMutex.Lock() - ret, specificReturn := fake.mkdirAllReturnsOnCall[len(fake.mkdirAllArgsForCall)] - fake.mkdirAllArgsForCall = append(fake.mkdirAllArgsForCall, struct { - arg1 string - arg2 os.FileMode - }{arg1, arg2}) - fake.recordInvocation("MkdirAll", []interface{}{arg1, arg2}) - fake.mkdirAllMutex.Unlock() - if fake.MkdirAllStub != nil { - return fake.MkdirAllStub(arg1, arg2) - } - if specificReturn { - return ret.result1 - } - return fake.mkdirAllReturns.result1 +func (fake *FakeExecutor) ExecuteWithTimeoutCallCount() int { + fake.executeWithTimeoutMutex.RLock() + defer fake.executeWithTimeoutMutex.RUnlock() + return len(fake.executeWithTimeoutArgsForCall) } -func (fake *FakeExecutor) MkdirAllCallCount() int { - fake.mkdirAllMutex.RLock() - defer fake.mkdirAllMutex.RUnlock() - return len(fake.mkdirAllArgsForCall) +func (fake *FakeExecutor) ExecuteWithTimeoutCalls(stub func(int, string, []string) ([]byte, error)) { + fake.executeWithTimeoutMutex.Lock() + defer fake.executeWithTimeoutMutex.Unlock() + fake.ExecuteWithTimeoutStub = stub } -func (fake *FakeExecutor) MkdirAllArgsForCall(i int) (string, os.FileMode) { - fake.mkdirAllMutex.RLock() - defer fake.mkdirAllMutex.RUnlock() - return fake.mkdirAllArgsForCall[i].arg1, fake.mkdirAllArgsForCall[i].arg2 +func (fake *FakeExecutor) ExecuteWithTimeoutArgsForCall(i int) (int, string, []string) { + fake.executeWithTimeoutMutex.RLock() + defer fake.executeWithTimeoutMutex.RUnlock() + argsForCall := fake.executeWithTimeoutArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 } -func (fake *FakeExecutor) MkdirAllReturns(result1 error) { - fake.MkdirAllStub = nil - fake.mkdirAllReturns = struct { - result1 error - }{result1} +func (fake *FakeExecutor) ExecuteWithTimeoutReturns(result1 []byte, result2 error) { + fake.executeWithTimeoutMutex.Lock() + defer fake.executeWithTimeoutMutex.Unlock() + fake.ExecuteWithTimeoutStub = nil + fake.executeWithTimeoutReturns = struct { + result1 []byte + result2 error + }{result1, result2} } -func (fake *FakeExecutor) MkdirAllReturnsOnCall(i int, result1 error) { - fake.MkdirAllStub = nil - if fake.mkdirAllReturnsOnCall == nil { - fake.mkdirAllReturnsOnCall = make(map[int]struct { - result1 error +func (fake *FakeExecutor) ExecuteWithTimeoutReturnsOnCall(i int, result1 []byte, result2 error) { + fake.executeWithTimeoutMutex.Lock() + defer fake.executeWithTimeoutMutex.Unlock() + fake.ExecuteWithTimeoutStub = nil + if fake.executeWithTimeoutReturnsOnCall == nil { + fake.executeWithTimeoutReturnsOnCall = make(map[int]struct { + result1 []byte + result2 error }) } - fake.mkdirAllReturnsOnCall[i] = struct { - result1 error - }{result1} + fake.executeWithTimeoutReturnsOnCall[i] = struct { + result1 []byte + result2 error + }{result1, result2} } -func (fake *FakeExecutor) RemoveAll(arg1 string) error { - fake.removeAllMutex.Lock() - ret, specificReturn := fake.removeAllReturnsOnCall[len(fake.removeAllArgsForCall)] - fake.removeAllArgsForCall = append(fake.removeAllArgsForCall, struct { - arg1 string +func (fake *FakeExecutor) GetDeviceForFileStat(arg1 os.FileInfo) uint64 { + fake.getDeviceForFileStatMutex.Lock() + ret, specificReturn := fake.getDeviceForFileStatReturnsOnCall[len(fake.getDeviceForFileStatArgsForCall)] + fake.getDeviceForFileStatArgsForCall = append(fake.getDeviceForFileStatArgsForCall, struct { + arg1 os.FileInfo }{arg1}) - fake.recordInvocation("RemoveAll", []interface{}{arg1}) - fake.removeAllMutex.Unlock() - if fake.RemoveAllStub != nil { - return fake.RemoveAllStub(arg1) + fake.recordInvocation("GetDeviceForFileStat", []interface{}{arg1}) + fake.getDeviceForFileStatMutex.Unlock() + if fake.GetDeviceForFileStatStub != nil { + return fake.GetDeviceForFileStatStub(arg1) } if specificReturn { return ret.result1 } - return fake.removeAllReturns.result1 + fakeReturns := fake.getDeviceForFileStatReturns + return fakeReturns.result1 } -func (fake *FakeExecutor) RemoveAllCallCount() int { - fake.removeAllMutex.RLock() - defer fake.removeAllMutex.RUnlock() - return len(fake.removeAllArgsForCall) +func (fake *FakeExecutor) GetDeviceForFileStatCallCount() int { + fake.getDeviceForFileStatMutex.RLock() + defer fake.getDeviceForFileStatMutex.RUnlock() + return len(fake.getDeviceForFileStatArgsForCall) } -func (fake *FakeExecutor) RemoveAllArgsForCall(i int) string { - fake.removeAllMutex.RLock() - defer fake.removeAllMutex.RUnlock() - return fake.removeAllArgsForCall[i].arg1 +func (fake *FakeExecutor) GetDeviceForFileStatCalls(stub func(os.FileInfo) uint64) { + fake.getDeviceForFileStatMutex.Lock() + defer fake.getDeviceForFileStatMutex.Unlock() + fake.GetDeviceForFileStatStub = stub } -func (fake *FakeExecutor) RemoveAllReturns(result1 error) { - fake.RemoveAllStub = nil - fake.removeAllReturns = struct { - result1 error +func (fake *FakeExecutor) GetDeviceForFileStatArgsForCall(i int) os.FileInfo { + fake.getDeviceForFileStatMutex.RLock() + defer fake.getDeviceForFileStatMutex.RUnlock() + argsForCall := fake.getDeviceForFileStatArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeExecutor) GetDeviceForFileStatReturns(result1 uint64) { + fake.getDeviceForFileStatMutex.Lock() + defer fake.getDeviceForFileStatMutex.Unlock() + fake.GetDeviceForFileStatStub = nil + fake.getDeviceForFileStatReturns = struct { + result1 uint64 }{result1} } -func (fake *FakeExecutor) RemoveAllReturnsOnCall(i int, result1 error) { - fake.RemoveAllStub = nil - if fake.removeAllReturnsOnCall == nil { - fake.removeAllReturnsOnCall = make(map[int]struct { - result1 error +func (fake *FakeExecutor) GetDeviceForFileStatReturnsOnCall(i int, result1 uint64) { + fake.getDeviceForFileStatMutex.Lock() + defer fake.getDeviceForFileStatMutex.Unlock() + fake.GetDeviceForFileStatStub = nil + if fake.getDeviceForFileStatReturnsOnCall == nil { + fake.getDeviceForFileStatReturnsOnCall = make(map[int]struct { + result1 uint64 }) } - fake.removeAllReturnsOnCall[i] = struct { - result1 error + fake.getDeviceForFileStatReturnsOnCall[i] = struct { + result1 uint64 }{result1} } -func (fake *FakeExecutor) Remove(arg1 string) error { - fake.removeMutex.Lock() - ret, specificReturn := fake.removeReturnsOnCall[len(fake.removeArgsForCall)] - fake.removeArgsForCall = append(fake.removeArgsForCall, struct { +func (fake *FakeExecutor) GetGlobFiles(arg1 string) ([]string, error) { + fake.getGlobFilesMutex.Lock() + ret, specificReturn := fake.getGlobFilesReturnsOnCall[len(fake.getGlobFilesArgsForCall)] + fake.getGlobFilesArgsForCall = append(fake.getGlobFilesArgsForCall, struct { arg1 string }{arg1}) - fake.recordInvocation("Remove", []interface{}{arg1}) - fake.removeMutex.Unlock() - if fake.RemoveStub != nil { - return fake.RemoveStub(arg1) + fake.recordInvocation("GetGlobFiles", []interface{}{arg1}) + fake.getGlobFilesMutex.Unlock() + if fake.GetGlobFilesStub != nil { + return fake.GetGlobFilesStub(arg1) } if specificReturn { - return ret.result1 + return ret.result1, ret.result2 } - return fake.removeReturns.result1 + fakeReturns := fake.getGlobFilesReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeExecutor) RemoveCallCount() int { - fake.removeMutex.RLock() - defer fake.removeMutex.RUnlock() - return len(fake.removeArgsForCall) +func (fake *FakeExecutor) GetGlobFilesCallCount() int { + fake.getGlobFilesMutex.RLock() + defer fake.getGlobFilesMutex.RUnlock() + return len(fake.getGlobFilesArgsForCall) } -func (fake *FakeExecutor) RemoveArgsForCall(i int) string { - fake.removeMutex.RLock() - defer fake.removeMutex.RUnlock() - return fake.removeArgsForCall[i].arg1 +func (fake *FakeExecutor) GetGlobFilesCalls(stub func(string) ([]string, error)) { + fake.getGlobFilesMutex.Lock() + defer fake.getGlobFilesMutex.Unlock() + fake.GetGlobFilesStub = stub } -func (fake *FakeExecutor) RemoveReturns(result1 error) { - fake.RemoveStub = nil - fake.removeReturns = struct { - result1 error - }{result1} +func (fake *FakeExecutor) GetGlobFilesArgsForCall(i int) string { + fake.getGlobFilesMutex.RLock() + defer fake.getGlobFilesMutex.RUnlock() + argsForCall := fake.getGlobFilesArgsForCall[i] + return argsForCall.arg1 } -func (fake *FakeExecutor) RemoveReturnsOnCall(i int, result1 error) { - fake.RemoveStub = nil - if fake.removeReturnsOnCall == nil { - fake.removeReturnsOnCall = make(map[int]struct { - result1 error +func (fake *FakeExecutor) GetGlobFilesReturns(result1 []string, result2 error) { + fake.getGlobFilesMutex.Lock() + defer fake.getGlobFilesMutex.Unlock() + fake.GetGlobFilesStub = nil + fake.getGlobFilesReturns = struct { + result1 []string + result2 error + }{result1, result2} +} + +func (fake *FakeExecutor) GetGlobFilesReturnsOnCall(i int, result1 []string, result2 error) { + fake.getGlobFilesMutex.Lock() + defer fake.getGlobFilesMutex.Unlock() + fake.GetGlobFilesStub = nil + if fake.getGlobFilesReturnsOnCall == nil { + fake.getGlobFilesReturnsOnCall = make(map[int]struct { + result1 []string + result2 error }) } - fake.removeReturnsOnCall[i] = struct { - result1 error - }{result1} + fake.getGlobFilesReturnsOnCall[i] = struct { + result1 []string + result2 error + }{result1, result2} } func (fake *FakeExecutor) Hostname() (string, error) { fake.hostnameMutex.Lock() ret, specificReturn := fake.hostnameReturnsOnCall[len(fake.hostnameArgsForCall)] - fake.hostnameArgsForCall = append(fake.hostnameArgsForCall, struct{}{}) + fake.hostnameArgsForCall = append(fake.hostnameArgsForCall, struct { + }{}) fake.recordInvocation("Hostname", []interface{}{}) fake.hostnameMutex.Unlock() if fake.HostnameStub != nil { @@ -557,7 +582,8 @@ func (fake *FakeExecutor) Hostname() (string, error) { if specificReturn { return ret.result1, ret.result2 } - return fake.hostnameReturns.result1, fake.hostnameReturns.result2 + fakeReturns := fake.hostnameReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeExecutor) HostnameCallCount() int { @@ -566,7 +592,15 @@ func (fake *FakeExecutor) HostnameCallCount() int { return len(fake.hostnameArgsForCall) } +func (fake *FakeExecutor) HostnameCalls(stub func() (string, error)) { + fake.hostnameMutex.Lock() + defer fake.hostnameMutex.Unlock() + fake.HostnameStub = stub +} + func (fake *FakeExecutor) HostnameReturns(result1 string, result2 error) { + fake.hostnameMutex.Lock() + defer fake.hostnameMutex.Unlock() fake.HostnameStub = nil fake.hostnameReturns = struct { result1 string @@ -575,6 +609,8 @@ func (fake *FakeExecutor) HostnameReturns(result1 string, result2 error) { } func (fake *FakeExecutor) HostnameReturnsOnCall(i int, result1 string, result2 error) { + fake.hostnameMutex.Lock() + defer fake.hostnameMutex.Unlock() fake.HostnameStub = nil if fake.hostnameReturnsOnCall == nil { fake.hostnameReturnsOnCall = make(map[int]struct { @@ -588,6 +624,129 @@ func (fake *FakeExecutor) HostnameReturnsOnCall(i int, result1 string, result2 e }{result1, result2} } +func (fake *FakeExecutor) IsDir(arg1 os.FileInfo) bool { + fake.isDirMutex.Lock() + ret, specificReturn := fake.isDirReturnsOnCall[len(fake.isDirArgsForCall)] + fake.isDirArgsForCall = append(fake.isDirArgsForCall, struct { + arg1 os.FileInfo + }{arg1}) + fake.recordInvocation("IsDir", []interface{}{arg1}) + fake.isDirMutex.Unlock() + if fake.IsDirStub != nil { + return fake.IsDirStub(arg1) + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.isDirReturns + return fakeReturns.result1 +} + +func (fake *FakeExecutor) IsDirCallCount() int { + fake.isDirMutex.RLock() + defer fake.isDirMutex.RUnlock() + return len(fake.isDirArgsForCall) +} + +func (fake *FakeExecutor) IsDirCalls(stub func(os.FileInfo) bool) { + fake.isDirMutex.Lock() + defer fake.isDirMutex.Unlock() + fake.IsDirStub = stub +} + +func (fake *FakeExecutor) IsDirArgsForCall(i int) os.FileInfo { + fake.isDirMutex.RLock() + defer fake.isDirMutex.RUnlock() + argsForCall := fake.isDirArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeExecutor) IsDirReturns(result1 bool) { + fake.isDirMutex.Lock() + defer fake.isDirMutex.Unlock() + fake.IsDirStub = nil + fake.isDirReturns = struct { + result1 bool + }{result1} +} + +func (fake *FakeExecutor) IsDirReturnsOnCall(i int, result1 bool) { + fake.isDirMutex.Lock() + defer fake.isDirMutex.Unlock() + fake.IsDirStub = nil + if fake.isDirReturnsOnCall == nil { + fake.isDirReturnsOnCall = make(map[int]struct { + result1 bool + }) + } + fake.isDirReturnsOnCall[i] = struct { + result1 bool + }{result1} +} + +func (fake *FakeExecutor) IsDirEmpty(arg1 string) (bool, error) { + fake.isDirEmptyMutex.Lock() + ret, specificReturn := fake.isDirEmptyReturnsOnCall[len(fake.isDirEmptyArgsForCall)] + fake.isDirEmptyArgsForCall = append(fake.isDirEmptyArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("IsDirEmpty", []interface{}{arg1}) + fake.isDirEmptyMutex.Unlock() + if fake.IsDirEmptyStub != nil { + return fake.IsDirEmptyStub(arg1) + } + if specificReturn { + return ret.result1, ret.result2 + } + fakeReturns := fake.isDirEmptyReturns + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeExecutor) IsDirEmptyCallCount() int { + fake.isDirEmptyMutex.RLock() + defer fake.isDirEmptyMutex.RUnlock() + return len(fake.isDirEmptyArgsForCall) +} + +func (fake *FakeExecutor) IsDirEmptyCalls(stub func(string) (bool, error)) { + fake.isDirEmptyMutex.Lock() + defer fake.isDirEmptyMutex.Unlock() + fake.IsDirEmptyStub = stub +} + +func (fake *FakeExecutor) IsDirEmptyArgsForCall(i int) string { + fake.isDirEmptyMutex.RLock() + defer fake.isDirEmptyMutex.RUnlock() + argsForCall := fake.isDirEmptyArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeExecutor) IsDirEmptyReturns(result1 bool, result2 error) { + fake.isDirEmptyMutex.Lock() + defer fake.isDirEmptyMutex.Unlock() + fake.IsDirEmptyStub = nil + fake.isDirEmptyReturns = struct { + result1 bool + result2 error + }{result1, result2} +} + +func (fake *FakeExecutor) IsDirEmptyReturnsOnCall(i int, result1 bool, result2 error) { + fake.isDirEmptyMutex.Lock() + defer fake.isDirEmptyMutex.Unlock() + fake.IsDirEmptyStub = nil + if fake.isDirEmptyReturnsOnCall == nil { + fake.isDirEmptyReturnsOnCall = make(map[int]struct { + result1 bool + result2 error + }) + } + fake.isDirEmptyReturnsOnCall[i] = struct { + result1 bool + result2 error + }{result1, result2} +} + func (fake *FakeExecutor) IsExecutable(arg1 string) error { fake.isExecutableMutex.Lock() ret, specificReturn := fake.isExecutableReturnsOnCall[len(fake.isExecutableArgsForCall)] @@ -602,7 +761,8 @@ func (fake *FakeExecutor) IsExecutable(arg1 string) error { if specificReturn { return ret.result1 } - return fake.isExecutableReturns.result1 + fakeReturns := fake.isExecutableReturns + return fakeReturns.result1 } func (fake *FakeExecutor) IsExecutableCallCount() int { @@ -611,13 +771,22 @@ func (fake *FakeExecutor) IsExecutableCallCount() int { return len(fake.isExecutableArgsForCall) } +func (fake *FakeExecutor) IsExecutableCalls(stub func(string) error) { + fake.isExecutableMutex.Lock() + defer fake.isExecutableMutex.Unlock() + fake.IsExecutableStub = stub +} + func (fake *FakeExecutor) IsExecutableArgsForCall(i int) string { fake.isExecutableMutex.RLock() defer fake.isExecutableMutex.RUnlock() - return fake.isExecutableArgsForCall[i].arg1 + argsForCall := fake.isExecutableArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeExecutor) IsExecutableReturns(result1 error) { + fake.isExecutableMutex.Lock() + defer fake.isExecutableMutex.Unlock() fake.IsExecutableStub = nil fake.isExecutableReturns = struct { result1 error @@ -625,6 +794,8 @@ func (fake *FakeExecutor) IsExecutableReturns(result1 error) { } func (fake *FakeExecutor) IsExecutableReturnsOnCall(i int, result1 error) { + fake.isExecutableMutex.Lock() + defer fake.isExecutableMutex.Unlock() fake.IsExecutableStub = nil if fake.isExecutableReturnsOnCall == nil { fake.isExecutableReturnsOnCall = make(map[int]struct { @@ -650,7 +821,8 @@ func (fake *FakeExecutor) IsNotExist(arg1 error) bool { if specificReturn { return ret.result1 } - return fake.isNotExistReturns.result1 + fakeReturns := fake.isNotExistReturns + return fakeReturns.result1 } func (fake *FakeExecutor) IsNotExistCallCount() int { @@ -659,13 +831,22 @@ func (fake *FakeExecutor) IsNotExistCallCount() int { return len(fake.isNotExistArgsForCall) } +func (fake *FakeExecutor) IsNotExistCalls(stub func(error) bool) { + fake.isNotExistMutex.Lock() + defer fake.isNotExistMutex.Unlock() + fake.IsNotExistStub = stub +} + func (fake *FakeExecutor) IsNotExistArgsForCall(i int) error { fake.isNotExistMutex.RLock() defer fake.isNotExistMutex.RUnlock() - return fake.isNotExistArgsForCall[i].arg1 + argsForCall := fake.isNotExistArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeExecutor) IsNotExistReturns(result1 bool) { + fake.isNotExistMutex.Lock() + defer fake.isNotExistMutex.Unlock() fake.IsNotExistStub = nil fake.isNotExistReturns = struct { result1 bool @@ -673,6 +854,8 @@ func (fake *FakeExecutor) IsNotExistReturns(result1 bool) { } func (fake *FakeExecutor) IsNotExistReturnsOnCall(i int, result1 bool) { + fake.isNotExistMutex.Lock() + defer fake.isNotExistMutex.Unlock() fake.IsNotExistStub = nil if fake.isNotExistReturnsOnCall == nil { fake.isNotExistReturnsOnCall = make(map[int]struct { @@ -684,130 +867,143 @@ func (fake *FakeExecutor) IsNotExistReturnsOnCall(i int, result1 bool) { }{result1} } -func (fake *FakeExecutor) EvalSymlinks(path string) (string, error) { - fake.evalSymlinksMutex.Lock() - ret, specificReturn := fake.evalSymlinksReturnsOnCall[len(fake.evalSymlinksArgsForCall)] - fake.evalSymlinksArgsForCall = append(fake.evalSymlinksArgsForCall, struct { - path string - }{path}) - fake.recordInvocation("EvalSymlinks", []interface{}{path}) - fake.evalSymlinksMutex.Unlock() - if fake.EvalSymlinksStub != nil { - return fake.EvalSymlinksStub(path) +func (fake *FakeExecutor) IsSameFile(arg1 os.FileInfo, arg2 os.FileInfo) bool { + fake.isSameFileMutex.Lock() + ret, specificReturn := fake.isSameFileReturnsOnCall[len(fake.isSameFileArgsForCall)] + fake.isSameFileArgsForCall = append(fake.isSameFileArgsForCall, struct { + arg1 os.FileInfo + arg2 os.FileInfo + }{arg1, arg2}) + fake.recordInvocation("IsSameFile", []interface{}{arg1, arg2}) + fake.isSameFileMutex.Unlock() + if fake.IsSameFileStub != nil { + return fake.IsSameFileStub(arg1, arg2) } if specificReturn { - return ret.result1, ret.result2 + return ret.result1 } - return fake.evalSymlinksReturns.result1, fake.evalSymlinksReturns.result2 + fakeReturns := fake.isSameFileReturns + return fakeReturns.result1 } -func (fake *FakeExecutor) EvalSymlinksCallCount() int { - fake.evalSymlinksMutex.RLock() - defer fake.evalSymlinksMutex.RUnlock() - return len(fake.evalSymlinksArgsForCall) +func (fake *FakeExecutor) IsSameFileCallCount() int { + fake.isSameFileMutex.RLock() + defer fake.isSameFileMutex.RUnlock() + return len(fake.isSameFileArgsForCall) } -func (fake *FakeExecutor) EvalSymlinksArgsForCall(i int) string { - fake.evalSymlinksMutex.RLock() - defer fake.evalSymlinksMutex.RUnlock() - return fake.evalSymlinksArgsForCall[i].path +func (fake *FakeExecutor) IsSameFileCalls(stub func(os.FileInfo, os.FileInfo) bool) { + fake.isSameFileMutex.Lock() + defer fake.isSameFileMutex.Unlock() + fake.IsSameFileStub = stub } -func (fake *FakeExecutor) EvalSymlinksReturns(result1 string, result2 error) { - fake.EvalSymlinksStub = nil - fake.evalSymlinksReturns = struct { - result1 string - result2 error - }{result1, result2} +func (fake *FakeExecutor) IsSameFileArgsForCall(i int) (os.FileInfo, os.FileInfo) { + fake.isSameFileMutex.RLock() + defer fake.isSameFileMutex.RUnlock() + argsForCall := fake.isSameFileArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } -func (fake *FakeExecutor) EvalSymlinksReturnsOnCall(i int, result1 string, result2 error) { - fake.EvalSymlinksStub = nil - if fake.evalSymlinksReturnsOnCall == nil { - fake.evalSymlinksReturnsOnCall = make(map[int]struct { - result1 string - result2 error +func (fake *FakeExecutor) IsSameFileReturns(result1 bool) { + fake.isSameFileMutex.Lock() + defer fake.isSameFileMutex.Unlock() + fake.IsSameFileStub = nil + fake.isSameFileReturns = struct { + result1 bool + }{result1} +} + +func (fake *FakeExecutor) IsSameFileReturnsOnCall(i int, result1 bool) { + fake.isSameFileMutex.Lock() + defer fake.isSameFileMutex.Unlock() + fake.IsSameFileStub = nil + if fake.isSameFileReturnsOnCall == nil { + fake.isSameFileReturnsOnCall = make(map[int]struct { + result1 bool }) } - fake.evalSymlinksReturnsOnCall[i] = struct { - result1 string - result2 error - }{result1, result2} + fake.isSameFileReturnsOnCall[i] = struct { + result1 bool + }{result1} } -func (fake *FakeExecutor) ExecuteWithTimeout(mSeconds int, command string, args []string) ([]byte, error) { - var argsCopy []string - if args != nil { - argsCopy = make([]string, len(args)) - copy(argsCopy, args) - } - fake.executeWithTimeoutMutex.Lock() - ret, specificReturn := fake.executeWithTimeoutReturnsOnCall[len(fake.executeWithTimeoutArgsForCall)] - fake.executeWithTimeoutArgsForCall = append(fake.executeWithTimeoutArgsForCall, struct { - mSeconds int - command string - args []string - }{mSeconds, command, argsCopy}) - fake.recordInvocation("ExecuteWithTimeout", []interface{}{mSeconds, command, argsCopy}) - fake.executeWithTimeoutMutex.Unlock() - if fake.ExecuteWithTimeoutStub != nil { - return fake.ExecuteWithTimeoutStub(mSeconds, command, args) +func (fake *FakeExecutor) IsSlink(arg1 os.FileInfo) bool { + fake.isSlinkMutex.Lock() + ret, specificReturn := fake.isSlinkReturnsOnCall[len(fake.isSlinkArgsForCall)] + fake.isSlinkArgsForCall = append(fake.isSlinkArgsForCall, struct { + arg1 os.FileInfo + }{arg1}) + fake.recordInvocation("IsSlink", []interface{}{arg1}) + fake.isSlinkMutex.Unlock() + if fake.IsSlinkStub != nil { + return fake.IsSlinkStub(arg1) } if specificReturn { - return ret.result1, ret.result2 + return ret.result1 } - return fake.executeWithTimeoutReturns.result1, fake.executeWithTimeoutReturns.result2 + fakeReturns := fake.isSlinkReturns + return fakeReturns.result1 } -func (fake *FakeExecutor) ExecuteWithTimeoutCallCount() int { - fake.executeWithTimeoutMutex.RLock() - defer fake.executeWithTimeoutMutex.RUnlock() - return len(fake.executeWithTimeoutArgsForCall) +func (fake *FakeExecutor) IsSlinkCallCount() int { + fake.isSlinkMutex.RLock() + defer fake.isSlinkMutex.RUnlock() + return len(fake.isSlinkArgsForCall) } -func (fake *FakeExecutor) ExecuteWithTimeoutArgsForCall(i int) (int, string, []string) { - fake.executeWithTimeoutMutex.RLock() - defer fake.executeWithTimeoutMutex.RUnlock() - return fake.executeWithTimeoutArgsForCall[i].mSeconds, fake.executeWithTimeoutArgsForCall[i].command, fake.executeWithTimeoutArgsForCall[i].args +func (fake *FakeExecutor) IsSlinkCalls(stub func(os.FileInfo) bool) { + fake.isSlinkMutex.Lock() + defer fake.isSlinkMutex.Unlock() + fake.IsSlinkStub = stub } -func (fake *FakeExecutor) ExecuteWithTimeoutReturns(result1 []byte, result2 error) { - fake.ExecuteWithTimeoutStub = nil - fake.executeWithTimeoutReturns = struct { - result1 []byte - result2 error - }{result1, result2} +func (fake *FakeExecutor) IsSlinkArgsForCall(i int) os.FileInfo { + fake.isSlinkMutex.RLock() + defer fake.isSlinkMutex.RUnlock() + argsForCall := fake.isSlinkArgsForCall[i] + return argsForCall.arg1 } -func (fake *FakeExecutor) ExecuteWithTimeoutReturnsOnCall(i int, result1 []byte, result2 error) { - fake.ExecuteWithTimeoutStub = nil - if fake.executeWithTimeoutReturnsOnCall == nil { - fake.executeWithTimeoutReturnsOnCall = make(map[int]struct { - result1 []byte - result2 error +func (fake *FakeExecutor) IsSlinkReturns(result1 bool) { + fake.isSlinkMutex.Lock() + defer fake.isSlinkMutex.Unlock() + fake.IsSlinkStub = nil + fake.isSlinkReturns = struct { + result1 bool + }{result1} +} + +func (fake *FakeExecutor) IsSlinkReturnsOnCall(i int, result1 bool) { + fake.isSlinkMutex.Lock() + defer fake.isSlinkMutex.Unlock() + fake.IsSlinkStub = nil + if fake.isSlinkReturnsOnCall == nil { + fake.isSlinkReturnsOnCall = make(map[int]struct { + result1 bool }) } - fake.executeWithTimeoutReturnsOnCall[i] = struct { - result1 []byte - result2 error - }{result1, result2} + fake.isSlinkReturnsOnCall[i] = struct { + result1 bool + }{result1} } -func (fake *FakeExecutor) Lstat(path string) (os.FileInfo, error) { +func (fake *FakeExecutor) Lstat(arg1 string) (os.FileInfo, error) { fake.lstatMutex.Lock() ret, specificReturn := fake.lstatReturnsOnCall[len(fake.lstatArgsForCall)] fake.lstatArgsForCall = append(fake.lstatArgsForCall, struct { - path string - }{path}) - fake.recordInvocation("Lstat", []interface{}{path}) + arg1 string + }{arg1}) + fake.recordInvocation("Lstat", []interface{}{arg1}) fake.lstatMutex.Unlock() if fake.LstatStub != nil { - return fake.LstatStub(path) + return fake.LstatStub(arg1) } if specificReturn { return ret.result1, ret.result2 } - return fake.lstatReturns.result1, fake.lstatReturns.result2 + fakeReturns := fake.lstatReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeExecutor) LstatCallCount() int { @@ -816,13 +1012,22 @@ func (fake *FakeExecutor) LstatCallCount() int { return len(fake.lstatArgsForCall) } +func (fake *FakeExecutor) LstatCalls(stub func(string) (os.FileInfo, error)) { + fake.lstatMutex.Lock() + defer fake.lstatMutex.Unlock() + fake.LstatStub = stub +} + func (fake *FakeExecutor) LstatArgsForCall(i int) string { fake.lstatMutex.RLock() defer fake.lstatMutex.RUnlock() - return fake.lstatArgsForCall[i].path + argsForCall := fake.lstatArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeExecutor) LstatReturns(result1 os.FileInfo, result2 error) { + fake.lstatMutex.Lock() + defer fake.lstatMutex.Unlock() fake.LstatStub = nil fake.lstatReturns = struct { result1 os.FileInfo @@ -831,6 +1036,8 @@ func (fake *FakeExecutor) LstatReturns(result1 os.FileInfo, result2 error) { } func (fake *FakeExecutor) LstatReturnsOnCall(i int, result1 os.FileInfo, result2 error) { + fake.lstatMutex.Lock() + defer fake.lstatMutex.Unlock() fake.LstatStub = nil if fake.lstatReturnsOnCall == nil { fake.lstatReturnsOnCall = make(map[int]struct { @@ -844,391 +1051,413 @@ func (fake *FakeExecutor) LstatReturnsOnCall(i int, result1 os.FileInfo, result2 }{result1, result2} } -func (fake *FakeExecutor) IsDir(fInfo os.FileInfo) bool { - fake.isDirMutex.Lock() - ret, specificReturn := fake.isDirReturnsOnCall[len(fake.isDirArgsForCall)] - fake.isDirArgsForCall = append(fake.isDirArgsForCall, struct { - fInfo os.FileInfo - }{fInfo}) - fake.recordInvocation("IsDir", []interface{}{fInfo}) - fake.isDirMutex.Unlock() - if fake.IsDirStub != nil { - return fake.IsDirStub(fInfo) +func (fake *FakeExecutor) Mkdir(arg1 string, arg2 os.FileMode) error { + fake.mkdirMutex.Lock() + ret, specificReturn := fake.mkdirReturnsOnCall[len(fake.mkdirArgsForCall)] + fake.mkdirArgsForCall = append(fake.mkdirArgsForCall, struct { + arg1 string + arg2 os.FileMode + }{arg1, arg2}) + fake.recordInvocation("Mkdir", []interface{}{arg1, arg2}) + fake.mkdirMutex.Unlock() + if fake.MkdirStub != nil { + return fake.MkdirStub(arg1, arg2) } if specificReturn { return ret.result1 } - return fake.isDirReturns.result1 + fakeReturns := fake.mkdirReturns + return fakeReturns.result1 } -func (fake *FakeExecutor) IsDirCallCount() int { - fake.isDirMutex.RLock() - defer fake.isDirMutex.RUnlock() - return len(fake.isDirArgsForCall) +func (fake *FakeExecutor) MkdirCallCount() int { + fake.mkdirMutex.RLock() + defer fake.mkdirMutex.RUnlock() + return len(fake.mkdirArgsForCall) } -func (fake *FakeExecutor) IsDirArgsForCall(i int) os.FileInfo { - fake.isDirMutex.RLock() - defer fake.isDirMutex.RUnlock() - return fake.isDirArgsForCall[i].fInfo +func (fake *FakeExecutor) MkdirCalls(stub func(string, os.FileMode) error) { + fake.mkdirMutex.Lock() + defer fake.mkdirMutex.Unlock() + fake.MkdirStub = stub } -func (fake *FakeExecutor) IsDirReturns(result1 bool) { - fake.IsDirStub = nil - fake.isDirReturns = struct { - result1 bool +func (fake *FakeExecutor) MkdirArgsForCall(i int) (string, os.FileMode) { + fake.mkdirMutex.RLock() + defer fake.mkdirMutex.RUnlock() + argsForCall := fake.mkdirArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeExecutor) MkdirReturns(result1 error) { + fake.mkdirMutex.Lock() + defer fake.mkdirMutex.Unlock() + fake.MkdirStub = nil + fake.mkdirReturns = struct { + result1 error }{result1} } -func (fake *FakeExecutor) IsDirReturnsOnCall(i int, result1 bool) { - fake.IsDirStub = nil - if fake.isDirReturnsOnCall == nil { - fake.isDirReturnsOnCall = make(map[int]struct { - result1 bool +func (fake *FakeExecutor) MkdirReturnsOnCall(i int, result1 error) { + fake.mkdirMutex.Lock() + defer fake.mkdirMutex.Unlock() + fake.MkdirStub = nil + if fake.mkdirReturnsOnCall == nil { + fake.mkdirReturnsOnCall = make(map[int]struct { + result1 error }) } - fake.isDirReturnsOnCall[i] = struct { - result1 bool + fake.mkdirReturnsOnCall[i] = struct { + result1 error }{result1} } -func (fake *FakeExecutor) Symlink(target string, slink string) error { - fake.symlinkMutex.Lock() - ret, specificReturn := fake.symlinkReturnsOnCall[len(fake.symlinkArgsForCall)] - fake.symlinkArgsForCall = append(fake.symlinkArgsForCall, struct { - target string - slink string - }{target, slink}) - fake.recordInvocation("Symlink", []interface{}{target, slink}) - fake.symlinkMutex.Unlock() - if fake.SymlinkStub != nil { - return fake.SymlinkStub(target, slink) +func (fake *FakeExecutor) MkdirAll(arg1 string, arg2 os.FileMode) error { + fake.mkdirAllMutex.Lock() + ret, specificReturn := fake.mkdirAllReturnsOnCall[len(fake.mkdirAllArgsForCall)] + fake.mkdirAllArgsForCall = append(fake.mkdirAllArgsForCall, struct { + arg1 string + arg2 os.FileMode + }{arg1, arg2}) + fake.recordInvocation("MkdirAll", []interface{}{arg1, arg2}) + fake.mkdirAllMutex.Unlock() + if fake.MkdirAllStub != nil { + return fake.MkdirAllStub(arg1, arg2) } if specificReturn { return ret.result1 } - return fake.symlinkReturns.result1 + fakeReturns := fake.mkdirAllReturns + return fakeReturns.result1 } -func (fake *FakeExecutor) SymlinkCallCount() int { - fake.symlinkMutex.RLock() - defer fake.symlinkMutex.RUnlock() - return len(fake.symlinkArgsForCall) +func (fake *FakeExecutor) MkdirAllCallCount() int { + fake.mkdirAllMutex.RLock() + defer fake.mkdirAllMutex.RUnlock() + return len(fake.mkdirAllArgsForCall) } -func (fake *FakeExecutor) SymlinkArgsForCall(i int) (string, string) { - fake.symlinkMutex.RLock() - defer fake.symlinkMutex.RUnlock() - return fake.symlinkArgsForCall[i].target, fake.symlinkArgsForCall[i].slink +func (fake *FakeExecutor) MkdirAllCalls(stub func(string, os.FileMode) error) { + fake.mkdirAllMutex.Lock() + defer fake.mkdirAllMutex.Unlock() + fake.MkdirAllStub = stub } -func (fake *FakeExecutor) SymlinkReturns(result1 error) { - fake.SymlinkStub = nil - fake.symlinkReturns = struct { +func (fake *FakeExecutor) MkdirAllArgsForCall(i int) (string, os.FileMode) { + fake.mkdirAllMutex.RLock() + defer fake.mkdirAllMutex.RUnlock() + argsForCall := fake.mkdirAllArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeExecutor) MkdirAllReturns(result1 error) { + fake.mkdirAllMutex.Lock() + defer fake.mkdirAllMutex.Unlock() + fake.MkdirAllStub = nil + fake.mkdirAllReturns = struct { result1 error }{result1} } -func (fake *FakeExecutor) SymlinkReturnsOnCall(i int, result1 error) { - fake.SymlinkStub = nil - if fake.symlinkReturnsOnCall == nil { - fake.symlinkReturnsOnCall = make(map[int]struct { +func (fake *FakeExecutor) MkdirAllReturnsOnCall(i int, result1 error) { + fake.mkdirAllMutex.Lock() + defer fake.mkdirAllMutex.Unlock() + fake.MkdirAllStub = nil + if fake.mkdirAllReturnsOnCall == nil { + fake.mkdirAllReturnsOnCall = make(map[int]struct { result1 error }) } - fake.symlinkReturnsOnCall[i] = struct { + fake.mkdirAllReturnsOnCall[i] = struct { result1 error }{result1} } -func (fake *FakeExecutor) IsSlink(fInfo os.FileInfo) bool { - fake.isSlinkMutex.Lock() - ret, specificReturn := fake.isSlinkReturnsOnCall[len(fake.isSlinkArgsForCall)] - fake.isSlinkArgsForCall = append(fake.isSlinkArgsForCall, struct { - fInfo os.FileInfo - }{fInfo}) - fake.recordInvocation("IsSlink", []interface{}{fInfo}) - fake.isSlinkMutex.Unlock() - if fake.IsSlinkStub != nil { - return fake.IsSlinkStub(fInfo) +func (fake *FakeExecutor) Remove(arg1 string) error { + fake.removeMutex.Lock() + ret, specificReturn := fake.removeReturnsOnCall[len(fake.removeArgsForCall)] + fake.removeArgsForCall = append(fake.removeArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("Remove", []interface{}{arg1}) + fake.removeMutex.Unlock() + if fake.RemoveStub != nil { + return fake.RemoveStub(arg1) } if specificReturn { return ret.result1 } - return fake.isSlinkReturns.result1 -} - -func (fake *FakeExecutor) IsSlinkCallCount() int { - fake.isSlinkMutex.RLock() - defer fake.isSlinkMutex.RUnlock() - return len(fake.isSlinkArgsForCall) -} - -func (fake *FakeExecutor) IsSlinkArgsForCall(i int) os.FileInfo { - fake.isSlinkMutex.RLock() - defer fake.isSlinkMutex.RUnlock() - return fake.isSlinkArgsForCall[i].fInfo -} - -func (fake *FakeExecutor) IsSlinkReturns(result1 bool) { - fake.IsSlinkStub = nil - fake.isSlinkReturns = struct { - result1 bool - }{result1} -} - -func (fake *FakeExecutor) IsSlinkReturnsOnCall(i int, result1 bool) { - fake.IsSlinkStub = nil - if fake.isSlinkReturnsOnCall == nil { - fake.isSlinkReturnsOnCall = make(map[int]struct { - result1 bool - }) - } - fake.isSlinkReturnsOnCall[i] = struct { - result1 bool - }{result1} + fakeReturns := fake.removeReturns + return fakeReturns.result1 } -func (fake *FakeExecutor) GetGlobFiles(file_pattern string) (matches []string, err error) { - fake.getGlobFilesMutex.Lock() - ret, specificReturn := fake.getGlobFilesReturnsOnCall[len(fake.getGlobFilesArgsForCall)] - fake.getGlobFilesArgsForCall = append(fake.getGlobFilesArgsForCall, struct { - file_pattern string - }{file_pattern}) - fake.recordInvocation("GetGlobFiles", []interface{}{file_pattern}) - fake.getGlobFilesMutex.Unlock() - if fake.GetGlobFilesStub != nil { - return fake.GetGlobFilesStub(file_pattern) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fake.getGlobFilesReturns.result1, fake.getGlobFilesReturns.result2 +func (fake *FakeExecutor) RemoveCallCount() int { + fake.removeMutex.RLock() + defer fake.removeMutex.RUnlock() + return len(fake.removeArgsForCall) } -func (fake *FakeExecutor) GetGlobFilesCallCount() int { - fake.getGlobFilesMutex.RLock() - defer fake.getGlobFilesMutex.RUnlock() - return len(fake.getGlobFilesArgsForCall) +func (fake *FakeExecutor) RemoveCalls(stub func(string) error) { + fake.removeMutex.Lock() + defer fake.removeMutex.Unlock() + fake.RemoveStub = stub } -func (fake *FakeExecutor) GetGlobFilesArgsForCall(i int) string { - fake.getGlobFilesMutex.RLock() - defer fake.getGlobFilesMutex.RUnlock() - return fake.getGlobFilesArgsForCall[i].file_pattern +func (fake *FakeExecutor) RemoveArgsForCall(i int) string { + fake.removeMutex.RLock() + defer fake.removeMutex.RUnlock() + argsForCall := fake.removeArgsForCall[i] + return argsForCall.arg1 } -func (fake *FakeExecutor) GetGlobFilesReturns(result1 []string, result2 error) { - fake.GetGlobFilesStub = nil - fake.getGlobFilesReturns = struct { - result1 []string - result2 error - }{result1, result2} +func (fake *FakeExecutor) RemoveReturns(result1 error) { + fake.removeMutex.Lock() + defer fake.removeMutex.Unlock() + fake.RemoveStub = nil + fake.removeReturns = struct { + result1 error + }{result1} } -func (fake *FakeExecutor) GetGlobFilesReturnsOnCall(i int, result1 []string, result2 error) { - fake.GetGlobFilesStub = nil - if fake.getGlobFilesReturnsOnCall == nil { - fake.getGlobFilesReturnsOnCall = make(map[int]struct { - result1 []string - result2 error +func (fake *FakeExecutor) RemoveReturnsOnCall(i int, result1 error) { + fake.removeMutex.Lock() + defer fake.removeMutex.Unlock() + fake.RemoveStub = nil + if fake.removeReturnsOnCall == nil { + fake.removeReturnsOnCall = make(map[int]struct { + result1 error }) } - fake.getGlobFilesReturnsOnCall[i] = struct { - result1 []string - result2 error - }{result1, result2} + fake.removeReturnsOnCall[i] = struct { + result1 error + }{result1} } -func (fake *FakeExecutor) IsSameFile(file1 os.FileInfo, file2 os.FileInfo) bool { - fake.isSameFileMutex.Lock() - ret, specificReturn := fake.isSameFileReturnsOnCall[len(fake.isSameFileArgsForCall)] - fake.isSameFileArgsForCall = append(fake.isSameFileArgsForCall, struct { - file1 os.FileInfo - file2 os.FileInfo - }{file1, file2}) - fake.recordInvocation("IsSameFile", []interface{}{file1, file2}) - fake.isSameFileMutex.Unlock() - if fake.IsSameFileStub != nil { - return fake.IsSameFileStub(file1, file2) +func (fake *FakeExecutor) RemoveAll(arg1 string) error { + fake.removeAllMutex.Lock() + ret, specificReturn := fake.removeAllReturnsOnCall[len(fake.removeAllArgsForCall)] + fake.removeAllArgsForCall = append(fake.removeAllArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("RemoveAll", []interface{}{arg1}) + fake.removeAllMutex.Unlock() + if fake.RemoveAllStub != nil { + return fake.RemoveAllStub(arg1) } if specificReturn { return ret.result1 } - return fake.isSameFileReturns.result1 + fakeReturns := fake.removeAllReturns + return fakeReturns.result1 } -func (fake *FakeExecutor) IsSameFileCallCount() int { - fake.isSameFileMutex.RLock() - defer fake.isSameFileMutex.RUnlock() - return len(fake.isSameFileArgsForCall) +func (fake *FakeExecutor) RemoveAllCallCount() int { + fake.removeAllMutex.RLock() + defer fake.removeAllMutex.RUnlock() + return len(fake.removeAllArgsForCall) } -func (fake *FakeExecutor) IsSameFileArgsForCall(i int) (os.FileInfo, os.FileInfo) { - fake.isSameFileMutex.RLock() - defer fake.isSameFileMutex.RUnlock() - return fake.isSameFileArgsForCall[i].file1, fake.isSameFileArgsForCall[i].file2 +func (fake *FakeExecutor) RemoveAllCalls(stub func(string) error) { + fake.removeAllMutex.Lock() + defer fake.removeAllMutex.Unlock() + fake.RemoveAllStub = stub } -func (fake *FakeExecutor) IsSameFileReturns(result1 bool) { - fake.IsSameFileStub = nil - fake.isSameFileReturns = struct { - result1 bool +func (fake *FakeExecutor) RemoveAllArgsForCall(i int) string { + fake.removeAllMutex.RLock() + defer fake.removeAllMutex.RUnlock() + argsForCall := fake.removeAllArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeExecutor) RemoveAllReturns(result1 error) { + fake.removeAllMutex.Lock() + defer fake.removeAllMutex.Unlock() + fake.RemoveAllStub = nil + fake.removeAllReturns = struct { + result1 error }{result1} } -func (fake *FakeExecutor) IsSameFileReturnsOnCall(i int, result1 bool) { - fake.IsSameFileStub = nil - if fake.isSameFileReturnsOnCall == nil { - fake.isSameFileReturnsOnCall = make(map[int]struct { - result1 bool +func (fake *FakeExecutor) RemoveAllReturnsOnCall(i int, result1 error) { + fake.removeAllMutex.Lock() + defer fake.removeAllMutex.Unlock() + fake.RemoveAllStub = nil + if fake.removeAllReturnsOnCall == nil { + fake.removeAllReturnsOnCall = make(map[int]struct { + result1 error }) } - fake.isSameFileReturnsOnCall[i] = struct { - result1 bool + fake.removeAllReturnsOnCall[i] = struct { + result1 error }{result1} } -func (fake *FakeExecutor) IsDirEmpty(dir string) (bool, error) { - fake.isDirEmptyMutex.Lock() - ret, specificReturn := fake.isDirEmptyReturnsOnCall[len(fake.isDirEmptyArgsForCall)] - fake.isDirEmptyArgsForCall = append(fake.isDirEmptyArgsForCall, struct { - dir string - }{dir}) - fake.recordInvocation("IsDirEmpty", []interface{}{dir}) - fake.isDirEmptyMutex.Unlock() - if fake.IsDirEmptyStub != nil { - return fake.IsDirEmptyStub(dir) +func (fake *FakeExecutor) Stat(arg1 string) (os.FileInfo, error) { + fake.statMutex.Lock() + ret, specificReturn := fake.statReturnsOnCall[len(fake.statArgsForCall)] + fake.statArgsForCall = append(fake.statArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("Stat", []interface{}{arg1}) + fake.statMutex.Unlock() + if fake.StatStub != nil { + return fake.StatStub(arg1) } if specificReturn { return ret.result1, ret.result2 } - return fake.isDirEmptyReturns.result1, fake.isDirEmptyReturns.result2 + fakeReturns := fake.statReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeExecutor) IsDirEmptyCallCount() int { - fake.isDirEmptyMutex.RLock() - defer fake.isDirEmptyMutex.RUnlock() - return len(fake.isDirEmptyArgsForCall) +func (fake *FakeExecutor) StatCallCount() int { + fake.statMutex.RLock() + defer fake.statMutex.RUnlock() + return len(fake.statArgsForCall) } -func (fake *FakeExecutor) IsDirEmptyArgsForCall(i int) string { - fake.isDirEmptyMutex.RLock() - defer fake.isDirEmptyMutex.RUnlock() - return fake.isDirEmptyArgsForCall[i].dir +func (fake *FakeExecutor) StatCalls(stub func(string) (os.FileInfo, error)) { + fake.statMutex.Lock() + defer fake.statMutex.Unlock() + fake.StatStub = stub } -func (fake *FakeExecutor) IsDirEmptyReturns(result1 bool, result2 error) { - fake.IsDirEmptyStub = nil - fake.isDirEmptyReturns = struct { - result1 bool +func (fake *FakeExecutor) StatArgsForCall(i int) string { + fake.statMutex.RLock() + defer fake.statMutex.RUnlock() + argsForCall := fake.statArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeExecutor) StatReturns(result1 os.FileInfo, result2 error) { + fake.statMutex.Lock() + defer fake.statMutex.Unlock() + fake.StatStub = nil + fake.statReturns = struct { + result1 os.FileInfo result2 error }{result1, result2} } -func (fake *FakeExecutor) IsDirEmptyReturnsOnCall(i int, result1 bool, result2 error) { - fake.IsDirEmptyStub = nil - if fake.isDirEmptyReturnsOnCall == nil { - fake.isDirEmptyReturnsOnCall = make(map[int]struct { - result1 bool +func (fake *FakeExecutor) StatReturnsOnCall(i int, result1 os.FileInfo, result2 error) { + fake.statMutex.Lock() + defer fake.statMutex.Unlock() + fake.StatStub = nil + if fake.statReturnsOnCall == nil { + fake.statReturnsOnCall = make(map[int]struct { + result1 os.FileInfo result2 error }) } - fake.isDirEmptyReturnsOnCall[i] = struct { - result1 bool + fake.statReturnsOnCall[i] = struct { + result1 os.FileInfo result2 error }{result1, result2} } -func (fake *FakeExecutor) GetDeviceForFileStat(arg1 os.FileInfo) uint64 { - fake.getDeviceForFileStatMutex.Lock() - ret, specificReturn := fake.getDeviceForFileStatReturnsOnCall[len(fake.getDeviceForFileStatArgsForCall)] - fake.getDeviceForFileStatArgsForCall = append(fake.getDeviceForFileStatArgsForCall, struct { - arg1 os.FileInfo - }{arg1}) - fake.recordInvocation("GetDeviceForFileStat", []interface{}{arg1}) - fake.getDeviceForFileStatMutex.Unlock() - if fake.GetDeviceForFileStatStub != nil { - return fake.GetDeviceForFileStatStub(arg1) +func (fake *FakeExecutor) Symlink(arg1 string, arg2 string) error { + fake.symlinkMutex.Lock() + ret, specificReturn := fake.symlinkReturnsOnCall[len(fake.symlinkArgsForCall)] + fake.symlinkArgsForCall = append(fake.symlinkArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("Symlink", []interface{}{arg1, arg2}) + fake.symlinkMutex.Unlock() + if fake.SymlinkStub != nil { + return fake.SymlinkStub(arg1, arg2) } if specificReturn { return ret.result1 } - return fake.getDeviceForFileStatReturns.result1 + fakeReturns := fake.symlinkReturns + return fakeReturns.result1 } -func (fake *FakeExecutor) GetDeviceForFileStatCallCount() int { - fake.getDeviceForFileStatMutex.RLock() - defer fake.getDeviceForFileStatMutex.RUnlock() - return len(fake.getDeviceForFileStatArgsForCall) +func (fake *FakeExecutor) SymlinkCallCount() int { + fake.symlinkMutex.RLock() + defer fake.symlinkMutex.RUnlock() + return len(fake.symlinkArgsForCall) } -func (fake *FakeExecutor) GetDeviceForFileStatArgsForCall(i int) os.FileInfo { - fake.getDeviceForFileStatMutex.RLock() - defer fake.getDeviceForFileStatMutex.RUnlock() - return fake.getDeviceForFileStatArgsForCall[i].arg1 +func (fake *FakeExecutor) SymlinkCalls(stub func(string, string) error) { + fake.symlinkMutex.Lock() + defer fake.symlinkMutex.Unlock() + fake.SymlinkStub = stub } -func (fake *FakeExecutor) GetDeviceForFileStatReturns(result1 uint64) { - fake.GetDeviceForFileStatStub = nil - fake.getDeviceForFileStatReturns = struct { - result1 uint64 +func (fake *FakeExecutor) SymlinkArgsForCall(i int) (string, string) { + fake.symlinkMutex.RLock() + defer fake.symlinkMutex.RUnlock() + argsForCall := fake.symlinkArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeExecutor) SymlinkReturns(result1 error) { + fake.symlinkMutex.Lock() + defer fake.symlinkMutex.Unlock() + fake.SymlinkStub = nil + fake.symlinkReturns = struct { + result1 error }{result1} } -func (fake *FakeExecutor) GetDeviceForFileStatReturnsOnCall(i int, result1 uint64) { - fake.GetDeviceForFileStatStub = nil - if fake.getDeviceForFileStatReturnsOnCall == nil { - fake.getDeviceForFileStatReturnsOnCall = make(map[int]struct { - result1 uint64 +func (fake *FakeExecutor) SymlinkReturnsOnCall(i int, result1 error) { + fake.symlinkMutex.Lock() + defer fake.symlinkMutex.Unlock() + fake.SymlinkStub = nil + if fake.symlinkReturnsOnCall == nil { + fake.symlinkReturnsOnCall = make(map[int]struct { + result1 error }) } - fake.getDeviceForFileStatReturnsOnCall[i] = struct { - result1 uint64 + fake.symlinkReturnsOnCall[i] = struct { + result1 error }{result1} } func (fake *FakeExecutor) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() + fake.evalSymlinksMutex.RLock() + defer fake.evalSymlinksMutex.RUnlock() fake.executeMutex.RLock() defer fake.executeMutex.RUnlock() - fake.statMutex.RLock() - defer fake.statMutex.RUnlock() - fake.mkdirMutex.RLock() - defer fake.mkdirMutex.RUnlock() - fake.mkdirAllMutex.RLock() - defer fake.mkdirAllMutex.RUnlock() - fake.removeAllMutex.RLock() - defer fake.removeAllMutex.RUnlock() - fake.removeMutex.RLock() - defer fake.removeMutex.RUnlock() + fake.executeWithTimeoutMutex.RLock() + defer fake.executeWithTimeoutMutex.RUnlock() + fake.getDeviceForFileStatMutex.RLock() + defer fake.getDeviceForFileStatMutex.RUnlock() + fake.getGlobFilesMutex.RLock() + defer fake.getGlobFilesMutex.RUnlock() fake.hostnameMutex.RLock() defer fake.hostnameMutex.RUnlock() + fake.isDirMutex.RLock() + defer fake.isDirMutex.RUnlock() + fake.isDirEmptyMutex.RLock() + defer fake.isDirEmptyMutex.RUnlock() fake.isExecutableMutex.RLock() defer fake.isExecutableMutex.RUnlock() fake.isNotExistMutex.RLock() defer fake.isNotExistMutex.RUnlock() - fake.evalSymlinksMutex.RLock() - defer fake.evalSymlinksMutex.RUnlock() - fake.executeWithTimeoutMutex.RLock() - defer fake.executeWithTimeoutMutex.RUnlock() + fake.isSameFileMutex.RLock() + defer fake.isSameFileMutex.RUnlock() + fake.isSlinkMutex.RLock() + defer fake.isSlinkMutex.RUnlock() fake.lstatMutex.RLock() defer fake.lstatMutex.RUnlock() - fake.isDirMutex.RLock() - defer fake.isDirMutex.RUnlock() + fake.mkdirMutex.RLock() + defer fake.mkdirMutex.RUnlock() + fake.mkdirAllMutex.RLock() + defer fake.mkdirAllMutex.RUnlock() + fake.removeMutex.RLock() + defer fake.removeMutex.RUnlock() + fake.removeAllMutex.RLock() + defer fake.removeAllMutex.RUnlock() + fake.statMutex.RLock() + defer fake.statMutex.RUnlock() fake.symlinkMutex.RLock() defer fake.symlinkMutex.RUnlock() - fake.isSlinkMutex.RLock() - defer fake.isSlinkMutex.RUnlock() - fake.getGlobFilesMutex.RLock() - defer fake.getGlobFilesMutex.RUnlock() - fake.isSameFileMutex.RLock() - defer fake.isSameFileMutex.RUnlock() - fake.isDirEmptyMutex.RLock() - defer fake.isDirEmptyMutex.RUnlock() - fake.getDeviceForFileStatMutex.RLock() - defer fake.getDeviceForFileStatMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} for key, value := range fake.invocations { copiedInvocations[key] = value diff --git a/fakes/fake_mounter.go b/fakes/fake_mounter.go index 482dc368..44248463 100644 --- a/fakes/fake_mounter.go +++ b/fakes/fake_mounter.go @@ -1,19 +1,3 @@ -/** - * Copyright 2017 IBM Corp. - * - * 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. - */ - // Code generated by counterfeiter. DO NOT EDIT. package fakes @@ -24,10 +8,21 @@ import ( ) type FakeMounter struct { - MountStub func(mountRequest resources.MountRequest) (string, error) + ActionAfterDetachStub func(resources.AfterDetachRequest) error + actionAfterDetachMutex sync.RWMutex + actionAfterDetachArgsForCall []struct { + arg1 resources.AfterDetachRequest + } + actionAfterDetachReturns struct { + result1 error + } + actionAfterDetachReturnsOnCall map[int]struct { + result1 error + } + MountStub func(resources.MountRequest) (string, error) mountMutex sync.RWMutex mountArgsForCall []struct { - mountRequest resources.MountRequest + arg1 resources.MountRequest } mountReturns struct { result1 string @@ -37,10 +32,10 @@ type FakeMounter struct { result1 string result2 error } - UnmountStub func(unmountRequest resources.UnmountRequest) error + UnmountStub func(resources.UnmountRequest) error unmountMutex sync.RWMutex unmountArgsForCall []struct { - unmountRequest resources.UnmountRequest + arg1 resources.UnmountRequest } unmountReturns struct { result1 error @@ -48,36 +43,86 @@ type FakeMounter struct { unmountReturnsOnCall map[int]struct { result1 error } - ActionAfterDetachStub func(request resources.AfterDetachRequest) error - actionAfterDetachMutex sync.RWMutex - actionAfterDetachArgsForCall []struct { - request resources.AfterDetachRequest + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakeMounter) ActionAfterDetach(arg1 resources.AfterDetachRequest) error { + fake.actionAfterDetachMutex.Lock() + ret, specificReturn := fake.actionAfterDetachReturnsOnCall[len(fake.actionAfterDetachArgsForCall)] + fake.actionAfterDetachArgsForCall = append(fake.actionAfterDetachArgsForCall, struct { + arg1 resources.AfterDetachRequest + }{arg1}) + fake.recordInvocation("ActionAfterDetach", []interface{}{arg1}) + fake.actionAfterDetachMutex.Unlock() + if fake.ActionAfterDetachStub != nil { + return fake.ActionAfterDetachStub(arg1) } - actionAfterDetachReturns struct { - result1 error + if specificReturn { + return ret.result1 } - actionAfterDetachReturnsOnCall map[int]struct { + fakeReturns := fake.actionAfterDetachReturns + return fakeReturns.result1 +} + +func (fake *FakeMounter) ActionAfterDetachCallCount() int { + fake.actionAfterDetachMutex.RLock() + defer fake.actionAfterDetachMutex.RUnlock() + return len(fake.actionAfterDetachArgsForCall) +} + +func (fake *FakeMounter) ActionAfterDetachCalls(stub func(resources.AfterDetachRequest) error) { + fake.actionAfterDetachMutex.Lock() + defer fake.actionAfterDetachMutex.Unlock() + fake.ActionAfterDetachStub = stub +} + +func (fake *FakeMounter) ActionAfterDetachArgsForCall(i int) resources.AfterDetachRequest { + fake.actionAfterDetachMutex.RLock() + defer fake.actionAfterDetachMutex.RUnlock() + argsForCall := fake.actionAfterDetachArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeMounter) ActionAfterDetachReturns(result1 error) { + fake.actionAfterDetachMutex.Lock() + defer fake.actionAfterDetachMutex.Unlock() + fake.ActionAfterDetachStub = nil + fake.actionAfterDetachReturns = struct { result1 error + }{result1} +} + +func (fake *FakeMounter) ActionAfterDetachReturnsOnCall(i int, result1 error) { + fake.actionAfterDetachMutex.Lock() + defer fake.actionAfterDetachMutex.Unlock() + fake.ActionAfterDetachStub = nil + if fake.actionAfterDetachReturnsOnCall == nil { + fake.actionAfterDetachReturnsOnCall = make(map[int]struct { + result1 error + }) } - invocations map[string][][]interface{} - invocationsMutex sync.RWMutex + fake.actionAfterDetachReturnsOnCall[i] = struct { + result1 error + }{result1} } -func (fake *FakeMounter) Mount(mountRequest resources.MountRequest) (string, error) { +func (fake *FakeMounter) Mount(arg1 resources.MountRequest) (string, error) { fake.mountMutex.Lock() ret, specificReturn := fake.mountReturnsOnCall[len(fake.mountArgsForCall)] fake.mountArgsForCall = append(fake.mountArgsForCall, struct { - mountRequest resources.MountRequest - }{mountRequest}) - fake.recordInvocation("Mount", []interface{}{mountRequest}) + arg1 resources.MountRequest + }{arg1}) + fake.recordInvocation("Mount", []interface{}{arg1}) fake.mountMutex.Unlock() if fake.MountStub != nil { - return fake.MountStub(mountRequest) + return fake.MountStub(arg1) } if specificReturn { return ret.result1, ret.result2 } - return fake.mountReturns.result1, fake.mountReturns.result2 + fakeReturns := fake.mountReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeMounter) MountCallCount() int { @@ -86,13 +131,22 @@ func (fake *FakeMounter) MountCallCount() int { return len(fake.mountArgsForCall) } +func (fake *FakeMounter) MountCalls(stub func(resources.MountRequest) (string, error)) { + fake.mountMutex.Lock() + defer fake.mountMutex.Unlock() + fake.MountStub = stub +} + func (fake *FakeMounter) MountArgsForCall(i int) resources.MountRequest { fake.mountMutex.RLock() defer fake.mountMutex.RUnlock() - return fake.mountArgsForCall[i].mountRequest + argsForCall := fake.mountArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeMounter) MountReturns(result1 string, result2 error) { + fake.mountMutex.Lock() + defer fake.mountMutex.Unlock() fake.MountStub = nil fake.mountReturns = struct { result1 string @@ -101,6 +155,8 @@ func (fake *FakeMounter) MountReturns(result1 string, result2 error) { } func (fake *FakeMounter) MountReturnsOnCall(i int, result1 string, result2 error) { + fake.mountMutex.Lock() + defer fake.mountMutex.Unlock() fake.MountStub = nil if fake.mountReturnsOnCall == nil { fake.mountReturnsOnCall = make(map[int]struct { @@ -114,21 +170,22 @@ func (fake *FakeMounter) MountReturnsOnCall(i int, result1 string, result2 error }{result1, result2} } -func (fake *FakeMounter) Unmount(unmountRequest resources.UnmountRequest) error { +func (fake *FakeMounter) Unmount(arg1 resources.UnmountRequest) error { fake.unmountMutex.Lock() ret, specificReturn := fake.unmountReturnsOnCall[len(fake.unmountArgsForCall)] fake.unmountArgsForCall = append(fake.unmountArgsForCall, struct { - unmountRequest resources.UnmountRequest - }{unmountRequest}) - fake.recordInvocation("Unmount", []interface{}{unmountRequest}) + arg1 resources.UnmountRequest + }{arg1}) + fake.recordInvocation("Unmount", []interface{}{arg1}) fake.unmountMutex.Unlock() if fake.UnmountStub != nil { - return fake.UnmountStub(unmountRequest) + return fake.UnmountStub(arg1) } if specificReturn { return ret.result1 } - return fake.unmountReturns.result1 + fakeReturns := fake.unmountReturns + return fakeReturns.result1 } func (fake *FakeMounter) UnmountCallCount() int { @@ -137,13 +194,22 @@ func (fake *FakeMounter) UnmountCallCount() int { return len(fake.unmountArgsForCall) } +func (fake *FakeMounter) UnmountCalls(stub func(resources.UnmountRequest) error) { + fake.unmountMutex.Lock() + defer fake.unmountMutex.Unlock() + fake.UnmountStub = stub +} + func (fake *FakeMounter) UnmountArgsForCall(i int) resources.UnmountRequest { fake.unmountMutex.RLock() defer fake.unmountMutex.RUnlock() - return fake.unmountArgsForCall[i].unmountRequest + argsForCall := fake.unmountArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeMounter) UnmountReturns(result1 error) { + fake.unmountMutex.Lock() + defer fake.unmountMutex.Unlock() fake.UnmountStub = nil fake.unmountReturns = struct { result1 error @@ -151,6 +217,8 @@ func (fake *FakeMounter) UnmountReturns(result1 error) { } func (fake *FakeMounter) UnmountReturnsOnCall(i int, result1 error) { + fake.unmountMutex.Lock() + defer fake.unmountMutex.Unlock() fake.UnmountStub = nil if fake.unmountReturnsOnCall == nil { fake.unmountReturnsOnCall = make(map[int]struct { @@ -162,63 +230,15 @@ func (fake *FakeMounter) UnmountReturnsOnCall(i int, result1 error) { }{result1} } -func (fake *FakeMounter) ActionAfterDetach(request resources.AfterDetachRequest) error { - fake.actionAfterDetachMutex.Lock() - ret, specificReturn := fake.actionAfterDetachReturnsOnCall[len(fake.actionAfterDetachArgsForCall)] - fake.actionAfterDetachArgsForCall = append(fake.actionAfterDetachArgsForCall, struct { - request resources.AfterDetachRequest - }{request}) - fake.recordInvocation("ActionAfterDetach", []interface{}{request}) - fake.actionAfterDetachMutex.Unlock() - if fake.ActionAfterDetachStub != nil { - return fake.ActionAfterDetachStub(request) - } - if specificReturn { - return ret.result1 - } - return fake.actionAfterDetachReturns.result1 -} - -func (fake *FakeMounter) ActionAfterDetachCallCount() int { - fake.actionAfterDetachMutex.RLock() - defer fake.actionAfterDetachMutex.RUnlock() - return len(fake.actionAfterDetachArgsForCall) -} - -func (fake *FakeMounter) ActionAfterDetachArgsForCall(i int) resources.AfterDetachRequest { - fake.actionAfterDetachMutex.RLock() - defer fake.actionAfterDetachMutex.RUnlock() - return fake.actionAfterDetachArgsForCall[i].request -} - -func (fake *FakeMounter) ActionAfterDetachReturns(result1 error) { - fake.ActionAfterDetachStub = nil - fake.actionAfterDetachReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeMounter) ActionAfterDetachReturnsOnCall(i int, result1 error) { - fake.ActionAfterDetachStub = nil - if fake.actionAfterDetachReturnsOnCall == nil { - fake.actionAfterDetachReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.actionAfterDetachReturnsOnCall[i] = struct { - result1 error - }{result1} -} - func (fake *FakeMounter) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() + fake.actionAfterDetachMutex.RLock() + defer fake.actionAfterDetachMutex.RUnlock() fake.mountMutex.RLock() defer fake.mountMutex.RUnlock() fake.unmountMutex.RLock() defer fake.unmountMutex.RUnlock() - fake.actionAfterDetachMutex.RLock() - defer fake.actionAfterDetachMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} for key, value := range fake.invocations { copiedInvocations[key] = value diff --git a/fakes/fake_mounter_factory.go b/fakes/fake_mounter_factory.go index 1760d5b0..0576c79b 100644 --- a/fakes/fake_mounter_factory.go +++ b/fakes/fake_mounter_factory.go @@ -10,13 +10,13 @@ import ( ) type FakeMounterFactory struct { - GetMounterPerBackendStub func(backend string, legacyLogger *log.Logger, pluginConfig resources.UbiquityPluginConfig, requestContext resources.RequestContext) (resources.Mounter, error) + GetMounterPerBackendStub func(string, *log.Logger, resources.UbiquityPluginConfig, resources.RequestContext) (resources.Mounter, error) getMounterPerBackendMutex sync.RWMutex getMounterPerBackendArgsForCall []struct { - backend string - legacyLogger *log.Logger - pluginConfig resources.UbiquityPluginConfig - requestContext resources.RequestContext + arg1 string + arg2 *log.Logger + arg3 resources.UbiquityPluginConfig + arg4 resources.RequestContext } getMounterPerBackendReturns struct { result1 resources.Mounter @@ -30,24 +30,25 @@ type FakeMounterFactory struct { invocationsMutex sync.RWMutex } -func (fake *FakeMounterFactory) GetMounterPerBackend(backend string, legacyLogger *log.Logger, pluginConfig resources.UbiquityPluginConfig, requestContext resources.RequestContext) (resources.Mounter, error) { +func (fake *FakeMounterFactory) GetMounterPerBackend(arg1 string, arg2 *log.Logger, arg3 resources.UbiquityPluginConfig, arg4 resources.RequestContext) (resources.Mounter, error) { fake.getMounterPerBackendMutex.Lock() ret, specificReturn := fake.getMounterPerBackendReturnsOnCall[len(fake.getMounterPerBackendArgsForCall)] fake.getMounterPerBackendArgsForCall = append(fake.getMounterPerBackendArgsForCall, struct { - backend string - legacyLogger *log.Logger - pluginConfig resources.UbiquityPluginConfig - requestContext resources.RequestContext - }{backend, legacyLogger, pluginConfig, requestContext}) - fake.recordInvocation("GetMounterPerBackend", []interface{}{backend, legacyLogger, pluginConfig, requestContext}) + arg1 string + arg2 *log.Logger + arg3 resources.UbiquityPluginConfig + arg4 resources.RequestContext + }{arg1, arg2, arg3, arg4}) + fake.recordInvocation("GetMounterPerBackend", []interface{}{arg1, arg2, arg3, arg4}) fake.getMounterPerBackendMutex.Unlock() if fake.GetMounterPerBackendStub != nil { - return fake.GetMounterPerBackendStub(backend, legacyLogger, pluginConfig, requestContext) + return fake.GetMounterPerBackendStub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1, ret.result2 } - return fake.getMounterPerBackendReturns.result1, fake.getMounterPerBackendReturns.result2 + fakeReturns := fake.getMounterPerBackendReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeMounterFactory) GetMounterPerBackendCallCount() int { @@ -56,13 +57,22 @@ func (fake *FakeMounterFactory) GetMounterPerBackendCallCount() int { return len(fake.getMounterPerBackendArgsForCall) } +func (fake *FakeMounterFactory) GetMounterPerBackendCalls(stub func(string, *log.Logger, resources.UbiquityPluginConfig, resources.RequestContext) (resources.Mounter, error)) { + fake.getMounterPerBackendMutex.Lock() + defer fake.getMounterPerBackendMutex.Unlock() + fake.GetMounterPerBackendStub = stub +} + func (fake *FakeMounterFactory) GetMounterPerBackendArgsForCall(i int) (string, *log.Logger, resources.UbiquityPluginConfig, resources.RequestContext) { fake.getMounterPerBackendMutex.RLock() defer fake.getMounterPerBackendMutex.RUnlock() - return fake.getMounterPerBackendArgsForCall[i].backend, fake.getMounterPerBackendArgsForCall[i].legacyLogger, fake.getMounterPerBackendArgsForCall[i].pluginConfig, fake.getMounterPerBackendArgsForCall[i].requestContext + argsForCall := fake.getMounterPerBackendArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4 } func (fake *FakeMounterFactory) GetMounterPerBackendReturns(result1 resources.Mounter, result2 error) { + fake.getMounterPerBackendMutex.Lock() + defer fake.getMounterPerBackendMutex.Unlock() fake.GetMounterPerBackendStub = nil fake.getMounterPerBackendReturns = struct { result1 resources.Mounter @@ -71,6 +81,8 @@ func (fake *FakeMounterFactory) GetMounterPerBackendReturns(result1 resources.Mo } func (fake *FakeMounterFactory) GetMounterPerBackendReturnsOnCall(i int, result1 resources.Mounter, result2 error) { + fake.getMounterPerBackendMutex.Lock() + defer fake.getMounterPerBackendMutex.Unlock() fake.GetMounterPerBackendStub = nil if fake.getMounterPerBackendReturnsOnCall == nil { fake.getMounterPerBackendReturnsOnCall = make(map[int]struct { diff --git a/fakes/fake_scbe_data_model_wrapper.go b/fakes/fake_scbe_data_model_wrapper.go deleted file mode 100644 index e45cb58f..00000000 --- a/fakes/fake_scbe_data_model_wrapper.go +++ /dev/null @@ -1,318 +0,0 @@ -// Code generated by counterfeiter. DO NOT EDIT. -package fakes - -import ( - "sync" - - "github.com/IBM/ubiquity/local/scbe" -) - -type FakeScbeDataModelWrapper struct { - GetVolumeStub func(name string, mustExist bool) (scbe.ScbeVolume, error) - getVolumeMutex sync.RWMutex - getVolumeArgsForCall []struct { - name string - mustExist bool - } - getVolumeReturns struct { - result1 scbe.ScbeVolume - result2 error - } - getVolumeReturnsOnCall map[int]struct { - result1 scbe.ScbeVolume - result2 error - } - DeleteVolumeStub func(name string) error - deleteVolumeMutex sync.RWMutex - deleteVolumeArgsForCall []struct { - name string - } - deleteVolumeReturns struct { - result1 error - } - deleteVolumeReturnsOnCall map[int]struct { - result1 error - } - InsertVolumeStub func(volumeName string, wwn string, fstype string) error - insertVolumeMutex sync.RWMutex - insertVolumeArgsForCall []struct { - volumeName string - wwn string - fstype string - } - insertVolumeReturns struct { - result1 error - } - insertVolumeReturnsOnCall map[int]struct { - result1 error - } - ListVolumesStub func() ([]scbe.ScbeVolume, error) - listVolumesMutex sync.RWMutex - listVolumesArgsForCall []struct{} - listVolumesReturns struct { - result1 []scbe.ScbeVolume - result2 error - } - listVolumesReturnsOnCall map[int]struct { - result1 []scbe.ScbeVolume - result2 error - } - UpdateDatabaseVolumeStub func(newVolume *scbe.ScbeVolume) - updateDatabaseVolumeMutex sync.RWMutex - updateDatabaseVolumeArgsForCall []struct { - newVolume *scbe.ScbeVolume - } - invocations map[string][][]interface{} - invocationsMutex sync.RWMutex -} - -func (fake *FakeScbeDataModelWrapper) GetVolume(name string, mustExist bool) (scbe.ScbeVolume, error) { - fake.getVolumeMutex.Lock() - ret, specificReturn := fake.getVolumeReturnsOnCall[len(fake.getVolumeArgsForCall)] - fake.getVolumeArgsForCall = append(fake.getVolumeArgsForCall, struct { - name string - mustExist bool - }{name, mustExist}) - fake.recordInvocation("GetVolume", []interface{}{name, mustExist}) - fake.getVolumeMutex.Unlock() - if fake.GetVolumeStub != nil { - return fake.GetVolumeStub(name, mustExist) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fake.getVolumeReturns.result1, fake.getVolumeReturns.result2 -} - -func (fake *FakeScbeDataModelWrapper) GetVolumeCallCount() int { - fake.getVolumeMutex.RLock() - defer fake.getVolumeMutex.RUnlock() - return len(fake.getVolumeArgsForCall) -} - -func (fake *FakeScbeDataModelWrapper) GetVolumeArgsForCall(i int) (string, bool) { - fake.getVolumeMutex.RLock() - defer fake.getVolumeMutex.RUnlock() - return fake.getVolumeArgsForCall[i].name, fake.getVolumeArgsForCall[i].mustExist -} - -func (fake *FakeScbeDataModelWrapper) GetVolumeReturns(result1 scbe.ScbeVolume, result2 error) { - fake.GetVolumeStub = nil - fake.getVolumeReturns = struct { - result1 scbe.ScbeVolume - result2 error - }{result1, result2} -} - -func (fake *FakeScbeDataModelWrapper) GetVolumeReturnsOnCall(i int, result1 scbe.ScbeVolume, result2 error) { - fake.GetVolumeStub = nil - if fake.getVolumeReturnsOnCall == nil { - fake.getVolumeReturnsOnCall = make(map[int]struct { - result1 scbe.ScbeVolume - result2 error - }) - } - fake.getVolumeReturnsOnCall[i] = struct { - result1 scbe.ScbeVolume - result2 error - }{result1, result2} -} - -func (fake *FakeScbeDataModelWrapper) DeleteVolume(name string) error { - fake.deleteVolumeMutex.Lock() - ret, specificReturn := fake.deleteVolumeReturnsOnCall[len(fake.deleteVolumeArgsForCall)] - fake.deleteVolumeArgsForCall = append(fake.deleteVolumeArgsForCall, struct { - name string - }{name}) - fake.recordInvocation("DeleteVolume", []interface{}{name}) - fake.deleteVolumeMutex.Unlock() - if fake.DeleteVolumeStub != nil { - return fake.DeleteVolumeStub(name) - } - if specificReturn { - return ret.result1 - } - return fake.deleteVolumeReturns.result1 -} - -func (fake *FakeScbeDataModelWrapper) DeleteVolumeCallCount() int { - fake.deleteVolumeMutex.RLock() - defer fake.deleteVolumeMutex.RUnlock() - return len(fake.deleteVolumeArgsForCall) -} - -func (fake *FakeScbeDataModelWrapper) DeleteVolumeArgsForCall(i int) string { - fake.deleteVolumeMutex.RLock() - defer fake.deleteVolumeMutex.RUnlock() - return fake.deleteVolumeArgsForCall[i].name -} - -func (fake *FakeScbeDataModelWrapper) DeleteVolumeReturns(result1 error) { - fake.DeleteVolumeStub = nil - fake.deleteVolumeReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeScbeDataModelWrapper) DeleteVolumeReturnsOnCall(i int, result1 error) { - fake.DeleteVolumeStub = nil - if fake.deleteVolumeReturnsOnCall == nil { - fake.deleteVolumeReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.deleteVolumeReturnsOnCall[i] = struct { - result1 error - }{result1} -} - -func (fake *FakeScbeDataModelWrapper) InsertVolume(volumeName string, wwn string, fstype string) error { - fake.insertVolumeMutex.Lock() - ret, specificReturn := fake.insertVolumeReturnsOnCall[len(fake.insertVolumeArgsForCall)] - fake.insertVolumeArgsForCall = append(fake.insertVolumeArgsForCall, struct { - volumeName string - wwn string - fstype string - }{volumeName, wwn, fstype}) - fake.recordInvocation("InsertVolume", []interface{}{volumeName, wwn, fstype}) - fake.insertVolumeMutex.Unlock() - if fake.InsertVolumeStub != nil { - return fake.InsertVolumeStub(volumeName, wwn, fstype) - } - if specificReturn { - return ret.result1 - } - return fake.insertVolumeReturns.result1 -} - -func (fake *FakeScbeDataModelWrapper) InsertVolumeCallCount() int { - fake.insertVolumeMutex.RLock() - defer fake.insertVolumeMutex.RUnlock() - return len(fake.insertVolumeArgsForCall) -} - -func (fake *FakeScbeDataModelWrapper) InsertVolumeArgsForCall(i int) (string, string, string) { - fake.insertVolumeMutex.RLock() - defer fake.insertVolumeMutex.RUnlock() - return fake.insertVolumeArgsForCall[i].volumeName, fake.insertVolumeArgsForCall[i].wwn, fake.insertVolumeArgsForCall[i].fstype -} - -func (fake *FakeScbeDataModelWrapper) InsertVolumeReturns(result1 error) { - fake.InsertVolumeStub = nil - fake.insertVolumeReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeScbeDataModelWrapper) InsertVolumeReturnsOnCall(i int, result1 error) { - fake.InsertVolumeStub = nil - if fake.insertVolumeReturnsOnCall == nil { - fake.insertVolumeReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.insertVolumeReturnsOnCall[i] = struct { - result1 error - }{result1} -} - -func (fake *FakeScbeDataModelWrapper) ListVolumes() ([]scbe.ScbeVolume, error) { - fake.listVolumesMutex.Lock() - ret, specificReturn := fake.listVolumesReturnsOnCall[len(fake.listVolumesArgsForCall)] - fake.listVolumesArgsForCall = append(fake.listVolumesArgsForCall, struct{}{}) - fake.recordInvocation("ListVolumes", []interface{}{}) - fake.listVolumesMutex.Unlock() - if fake.ListVolumesStub != nil { - return fake.ListVolumesStub() - } - if specificReturn { - return ret.result1, ret.result2 - } - return fake.listVolumesReturns.result1, fake.listVolumesReturns.result2 -} - -func (fake *FakeScbeDataModelWrapper) ListVolumesCallCount() int { - fake.listVolumesMutex.RLock() - defer fake.listVolumesMutex.RUnlock() - return len(fake.listVolumesArgsForCall) -} - -func (fake *FakeScbeDataModelWrapper) ListVolumesReturns(result1 []scbe.ScbeVolume, result2 error) { - fake.ListVolumesStub = nil - fake.listVolumesReturns = struct { - result1 []scbe.ScbeVolume - result2 error - }{result1, result2} -} - -func (fake *FakeScbeDataModelWrapper) ListVolumesReturnsOnCall(i int, result1 []scbe.ScbeVolume, result2 error) { - fake.ListVolumesStub = nil - if fake.listVolumesReturnsOnCall == nil { - fake.listVolumesReturnsOnCall = make(map[int]struct { - result1 []scbe.ScbeVolume - result2 error - }) - } - fake.listVolumesReturnsOnCall[i] = struct { - result1 []scbe.ScbeVolume - result2 error - }{result1, result2} -} - -func (fake *FakeScbeDataModelWrapper) UpdateDatabaseVolume(newVolume *scbe.ScbeVolume) { - fake.updateDatabaseVolumeMutex.Lock() - fake.updateDatabaseVolumeArgsForCall = append(fake.updateDatabaseVolumeArgsForCall, struct { - newVolume *scbe.ScbeVolume - }{newVolume}) - fake.recordInvocation("UpdateDatabaseVolume", []interface{}{newVolume}) - fake.updateDatabaseVolumeMutex.Unlock() - if fake.UpdateDatabaseVolumeStub != nil { - fake.UpdateDatabaseVolumeStub(newVolume) - } -} - -func (fake *FakeScbeDataModelWrapper) UpdateDatabaseVolumeCallCount() int { - fake.updateDatabaseVolumeMutex.RLock() - defer fake.updateDatabaseVolumeMutex.RUnlock() - return len(fake.updateDatabaseVolumeArgsForCall) -} - -func (fake *FakeScbeDataModelWrapper) UpdateDatabaseVolumeArgsForCall(i int) *scbe.ScbeVolume { - fake.updateDatabaseVolumeMutex.RLock() - defer fake.updateDatabaseVolumeMutex.RUnlock() - return fake.updateDatabaseVolumeArgsForCall[i].newVolume -} - -func (fake *FakeScbeDataModelWrapper) Invocations() map[string][][]interface{} { - fake.invocationsMutex.RLock() - defer fake.invocationsMutex.RUnlock() - fake.getVolumeMutex.RLock() - defer fake.getVolumeMutex.RUnlock() - fake.deleteVolumeMutex.RLock() - defer fake.deleteVolumeMutex.RUnlock() - fake.insertVolumeMutex.RLock() - defer fake.insertVolumeMutex.RUnlock() - fake.listVolumesMutex.RLock() - defer fake.listVolumesMutex.RUnlock() - fake.updateDatabaseVolumeMutex.RLock() - defer fake.updateDatabaseVolumeMutex.RUnlock() - copiedInvocations := map[string][][]interface{}{} - for key, value := range fake.invocations { - copiedInvocations[key] = value - } - return copiedInvocations -} - -func (fake *FakeScbeDataModelWrapper) recordInvocation(key string, args []interface{}) { - fake.invocationsMutex.Lock() - defer fake.invocationsMutex.Unlock() - if fake.invocations == nil { - fake.invocations = map[string][][]interface{}{} - } - if fake.invocations[key] == nil { - fake.invocations[key] = [][]interface{}{} - } - fake.invocations[key] = append(fake.invocations[key], args) -} - -var _ scbe.ScbeDataModelWrapper = new(FakeScbeDataModelWrapper) diff --git a/fakes/fake_scbe_rest_client.go b/fakes/fake_scbe_rest_client.go index 56c9f081..b44065f3 100644 --- a/fakes/fake_scbe_rest_client.go +++ b/fakes/fake_scbe_rest_client.go @@ -8,21 +8,12 @@ import ( ) type FakeScbeRestClient struct { - LoginStub func() error - loginMutex sync.RWMutex - loginArgsForCall []struct{} - loginReturns struct { - result1 error - } - loginReturnsOnCall map[int]struct { - result1 error - } - CreateVolumeStub func(volName string, serviceName string, size int) (scbe.ScbeVolumeInfo, error) + CreateVolumeStub func(string, string, int) (scbe.ScbeVolumeInfo, error) createVolumeMutex sync.RWMutex createVolumeArgsForCall []struct { - volName string - serviceName string - size int + arg1 string + arg2 string + arg3 int } createVolumeReturns struct { result1 scbe.ScbeVolumeInfo @@ -32,10 +23,34 @@ type FakeScbeRestClient struct { result1 scbe.ScbeVolumeInfo result2 error } - GetVolumesStub func(wwn string) ([]scbe.ScbeVolumeInfo, error) + DeleteVolumeStub func(string) error + deleteVolumeMutex sync.RWMutex + deleteVolumeArgsForCall []struct { + arg1 string + } + deleteVolumeReturns struct { + result1 error + } + deleteVolumeReturnsOnCall map[int]struct { + result1 error + } + GetVolMappingStub func(string) (scbe.ScbeVolumeMapInfo, error) + getVolMappingMutex sync.RWMutex + getVolMappingArgsForCall []struct { + arg1 string + } + getVolMappingReturns struct { + result1 scbe.ScbeVolumeMapInfo + result2 error + } + getVolMappingReturnsOnCall map[int]struct { + result1 scbe.ScbeVolumeMapInfo + result2 error + } + GetVolumesStub func(string) ([]scbe.ScbeVolumeInfo, error) getVolumesMutex sync.RWMutex getVolumesArgsForCall []struct { - wwn string + arg1 string } getVolumesReturns struct { result1 []scbe.ScbeVolumeInfo @@ -45,22 +60,21 @@ type FakeScbeRestClient struct { result1 []scbe.ScbeVolumeInfo result2 error } - DeleteVolumeStub func(wwn string) error - deleteVolumeMutex sync.RWMutex - deleteVolumeArgsForCall []struct { - wwn string + LoginStub func() error + loginMutex sync.RWMutex + loginArgsForCall []struct { } - deleteVolumeReturns struct { + loginReturns struct { result1 error } - deleteVolumeReturnsOnCall map[int]struct { + loginReturnsOnCall map[int]struct { result1 error } - MapVolumeStub func(wwn string, host string) (scbe.ScbeResponseMapping, error) + MapVolumeStub func(string, string) (scbe.ScbeResponseMapping, error) mapVolumeMutex sync.RWMutex mapVolumeArgsForCall []struct { - wwn string - host string + arg1 string + arg2 string } mapVolumeReturns struct { result1 scbe.ScbeResponseMapping @@ -70,35 +84,10 @@ type FakeScbeRestClient struct { result1 scbe.ScbeResponseMapping result2 error } - UnmapVolumeStub func(wwn string, host string) error - unmapVolumeMutex sync.RWMutex - unmapVolumeArgsForCall []struct { - wwn string - host string - } - unmapVolumeReturns struct { - result1 error - } - unmapVolumeReturnsOnCall map[int]struct { - result1 error - } - GetVolMappingStub func(wwn string) (scbe.ScbeVolumeMapInfo, error) - getVolMappingMutex sync.RWMutex - getVolMappingArgsForCall []struct { - wwn string - } - getVolMappingReturns struct { - result1 scbe.ScbeVolumeMapInfo - result2 error - } - getVolMappingReturnsOnCall map[int]struct { - result1 scbe.ScbeVolumeMapInfo - result2 error - } - ServiceExistStub func(serviceName string) (bool, error) + ServiceExistStub func(string) (bool, error) serviceExistMutex sync.RWMutex serviceExistArgsForCall []struct { - serviceName string + arg1 string } serviceExistReturns struct { result1 bool @@ -108,67 +97,40 @@ type FakeScbeRestClient struct { result1 bool result2 error } - invocations map[string][][]interface{} - invocationsMutex sync.RWMutex -} - -func (fake *FakeScbeRestClient) Login() error { - fake.loginMutex.Lock() - ret, specificReturn := fake.loginReturnsOnCall[len(fake.loginArgsForCall)] - fake.loginArgsForCall = append(fake.loginArgsForCall, struct{}{}) - fake.recordInvocation("Login", []interface{}{}) - fake.loginMutex.Unlock() - if fake.LoginStub != nil { - return fake.LoginStub() - } - if specificReturn { - return ret.result1 + UnmapVolumeStub func(string, string) error + unmapVolumeMutex sync.RWMutex + unmapVolumeArgsForCall []struct { + arg1 string + arg2 string } - return fake.loginReturns.result1 -} - -func (fake *FakeScbeRestClient) LoginCallCount() int { - fake.loginMutex.RLock() - defer fake.loginMutex.RUnlock() - return len(fake.loginArgsForCall) -} - -func (fake *FakeScbeRestClient) LoginReturns(result1 error) { - fake.LoginStub = nil - fake.loginReturns = struct { + unmapVolumeReturns struct { result1 error - }{result1} -} - -func (fake *FakeScbeRestClient) LoginReturnsOnCall(i int, result1 error) { - fake.LoginStub = nil - if fake.loginReturnsOnCall == nil { - fake.loginReturnsOnCall = make(map[int]struct { - result1 error - }) } - fake.loginReturnsOnCall[i] = struct { + unmapVolumeReturnsOnCall map[int]struct { result1 error - }{result1} + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex } -func (fake *FakeScbeRestClient) CreateVolume(volName string, serviceName string, size int) (scbe.ScbeVolumeInfo, error) { +func (fake *FakeScbeRestClient) CreateVolume(arg1 string, arg2 string, arg3 int) (scbe.ScbeVolumeInfo, error) { fake.createVolumeMutex.Lock() ret, specificReturn := fake.createVolumeReturnsOnCall[len(fake.createVolumeArgsForCall)] fake.createVolumeArgsForCall = append(fake.createVolumeArgsForCall, struct { - volName string - serviceName string - size int - }{volName, serviceName, size}) - fake.recordInvocation("CreateVolume", []interface{}{volName, serviceName, size}) + arg1 string + arg2 string + arg3 int + }{arg1, arg2, arg3}) + fake.recordInvocation("CreateVolume", []interface{}{arg1, arg2, arg3}) fake.createVolumeMutex.Unlock() if fake.CreateVolumeStub != nil { - return fake.CreateVolumeStub(volName, serviceName, size) + return fake.CreateVolumeStub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 } - return fake.createVolumeReturns.result1, fake.createVolumeReturns.result2 + fakeReturns := fake.createVolumeReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeScbeRestClient) CreateVolumeCallCount() int { @@ -177,13 +139,22 @@ func (fake *FakeScbeRestClient) CreateVolumeCallCount() int { return len(fake.createVolumeArgsForCall) } +func (fake *FakeScbeRestClient) CreateVolumeCalls(stub func(string, string, int) (scbe.ScbeVolumeInfo, error)) { + fake.createVolumeMutex.Lock() + defer fake.createVolumeMutex.Unlock() + fake.CreateVolumeStub = stub +} + func (fake *FakeScbeRestClient) CreateVolumeArgsForCall(i int) (string, string, int) { fake.createVolumeMutex.RLock() defer fake.createVolumeMutex.RUnlock() - return fake.createVolumeArgsForCall[i].volName, fake.createVolumeArgsForCall[i].serviceName, fake.createVolumeArgsForCall[i].size + argsForCall := fake.createVolumeArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 } func (fake *FakeScbeRestClient) CreateVolumeReturns(result1 scbe.ScbeVolumeInfo, result2 error) { + fake.createVolumeMutex.Lock() + defer fake.createVolumeMutex.Unlock() fake.CreateVolumeStub = nil fake.createVolumeReturns = struct { result1 scbe.ScbeVolumeInfo @@ -192,6 +163,8 @@ func (fake *FakeScbeRestClient) CreateVolumeReturns(result1 scbe.ScbeVolumeInfo, } func (fake *FakeScbeRestClient) CreateVolumeReturnsOnCall(i int, result1 scbe.ScbeVolumeInfo, result2 error) { + fake.createVolumeMutex.Lock() + defer fake.createVolumeMutex.Unlock() fake.CreateVolumeStub = nil if fake.createVolumeReturnsOnCall == nil { fake.createVolumeReturnsOnCall = make(map[int]struct { @@ -205,21 +178,145 @@ func (fake *FakeScbeRestClient) CreateVolumeReturnsOnCall(i int, result1 scbe.Sc }{result1, result2} } -func (fake *FakeScbeRestClient) GetVolumes(wwn string) ([]scbe.ScbeVolumeInfo, error) { +func (fake *FakeScbeRestClient) DeleteVolume(arg1 string) error { + fake.deleteVolumeMutex.Lock() + ret, specificReturn := fake.deleteVolumeReturnsOnCall[len(fake.deleteVolumeArgsForCall)] + fake.deleteVolumeArgsForCall = append(fake.deleteVolumeArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("DeleteVolume", []interface{}{arg1}) + fake.deleteVolumeMutex.Unlock() + if fake.DeleteVolumeStub != nil { + return fake.DeleteVolumeStub(arg1) + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.deleteVolumeReturns + return fakeReturns.result1 +} + +func (fake *FakeScbeRestClient) DeleteVolumeCallCount() int { + fake.deleteVolumeMutex.RLock() + defer fake.deleteVolumeMutex.RUnlock() + return len(fake.deleteVolumeArgsForCall) +} + +func (fake *FakeScbeRestClient) DeleteVolumeCalls(stub func(string) error) { + fake.deleteVolumeMutex.Lock() + defer fake.deleteVolumeMutex.Unlock() + fake.DeleteVolumeStub = stub +} + +func (fake *FakeScbeRestClient) DeleteVolumeArgsForCall(i int) string { + fake.deleteVolumeMutex.RLock() + defer fake.deleteVolumeMutex.RUnlock() + argsForCall := fake.deleteVolumeArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeScbeRestClient) DeleteVolumeReturns(result1 error) { + fake.deleteVolumeMutex.Lock() + defer fake.deleteVolumeMutex.Unlock() + fake.DeleteVolumeStub = nil + fake.deleteVolumeReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeScbeRestClient) DeleteVolumeReturnsOnCall(i int, result1 error) { + fake.deleteVolumeMutex.Lock() + defer fake.deleteVolumeMutex.Unlock() + fake.DeleteVolumeStub = nil + if fake.deleteVolumeReturnsOnCall == nil { + fake.deleteVolumeReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.deleteVolumeReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeScbeRestClient) GetVolMapping(arg1 string) (scbe.ScbeVolumeMapInfo, error) { + fake.getVolMappingMutex.Lock() + ret, specificReturn := fake.getVolMappingReturnsOnCall[len(fake.getVolMappingArgsForCall)] + fake.getVolMappingArgsForCall = append(fake.getVolMappingArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("GetVolMapping", []interface{}{arg1}) + fake.getVolMappingMutex.Unlock() + if fake.GetVolMappingStub != nil { + return fake.GetVolMappingStub(arg1) + } + if specificReturn { + return ret.result1, ret.result2 + } + fakeReturns := fake.getVolMappingReturns + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeScbeRestClient) GetVolMappingCallCount() int { + fake.getVolMappingMutex.RLock() + defer fake.getVolMappingMutex.RUnlock() + return len(fake.getVolMappingArgsForCall) +} + +func (fake *FakeScbeRestClient) GetVolMappingCalls(stub func(string) (scbe.ScbeVolumeMapInfo, error)) { + fake.getVolMappingMutex.Lock() + defer fake.getVolMappingMutex.Unlock() + fake.GetVolMappingStub = stub +} + +func (fake *FakeScbeRestClient) GetVolMappingArgsForCall(i int) string { + fake.getVolMappingMutex.RLock() + defer fake.getVolMappingMutex.RUnlock() + argsForCall := fake.getVolMappingArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeScbeRestClient) GetVolMappingReturns(result1 scbe.ScbeVolumeMapInfo, result2 error) { + fake.getVolMappingMutex.Lock() + defer fake.getVolMappingMutex.Unlock() + fake.GetVolMappingStub = nil + fake.getVolMappingReturns = struct { + result1 scbe.ScbeVolumeMapInfo + result2 error + }{result1, result2} +} + +func (fake *FakeScbeRestClient) GetVolMappingReturnsOnCall(i int, result1 scbe.ScbeVolumeMapInfo, result2 error) { + fake.getVolMappingMutex.Lock() + defer fake.getVolMappingMutex.Unlock() + fake.GetVolMappingStub = nil + if fake.getVolMappingReturnsOnCall == nil { + fake.getVolMappingReturnsOnCall = make(map[int]struct { + result1 scbe.ScbeVolumeMapInfo + result2 error + }) + } + fake.getVolMappingReturnsOnCall[i] = struct { + result1 scbe.ScbeVolumeMapInfo + result2 error + }{result1, result2} +} + +func (fake *FakeScbeRestClient) GetVolumes(arg1 string) ([]scbe.ScbeVolumeInfo, error) { fake.getVolumesMutex.Lock() ret, specificReturn := fake.getVolumesReturnsOnCall[len(fake.getVolumesArgsForCall)] fake.getVolumesArgsForCall = append(fake.getVolumesArgsForCall, struct { - wwn string - }{wwn}) - fake.recordInvocation("GetVolumes", []interface{}{wwn}) + arg1 string + }{arg1}) + fake.recordInvocation("GetVolumes", []interface{}{arg1}) fake.getVolumesMutex.Unlock() if fake.GetVolumesStub != nil { - return fake.GetVolumesStub(wwn) + return fake.GetVolumesStub(arg1) } if specificReturn { return ret.result1, ret.result2 } - return fake.getVolumesReturns.result1, fake.getVolumesReturns.result2 + fakeReturns := fake.getVolumesReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeScbeRestClient) GetVolumesCallCount() int { @@ -228,13 +325,22 @@ func (fake *FakeScbeRestClient) GetVolumesCallCount() int { return len(fake.getVolumesArgsForCall) } +func (fake *FakeScbeRestClient) GetVolumesCalls(stub func(string) ([]scbe.ScbeVolumeInfo, error)) { + fake.getVolumesMutex.Lock() + defer fake.getVolumesMutex.Unlock() + fake.GetVolumesStub = stub +} + func (fake *FakeScbeRestClient) GetVolumesArgsForCall(i int) string { fake.getVolumesMutex.RLock() defer fake.getVolumesMutex.RUnlock() - return fake.getVolumesArgsForCall[i].wwn + argsForCall := fake.getVolumesArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeScbeRestClient) GetVolumesReturns(result1 []scbe.ScbeVolumeInfo, result2 error) { + fake.getVolumesMutex.Lock() + defer fake.getVolumesMutex.Unlock() fake.GetVolumesStub = nil fake.getVolumesReturns = struct { result1 []scbe.ScbeVolumeInfo @@ -243,6 +349,8 @@ func (fake *FakeScbeRestClient) GetVolumesReturns(result1 []scbe.ScbeVolumeInfo, } func (fake *FakeScbeRestClient) GetVolumesReturnsOnCall(i int, result1 []scbe.ScbeVolumeInfo, result2 error) { + fake.getVolumesMutex.Lock() + defer fake.getVolumesMutex.Unlock() fake.GetVolumesStub = nil if fake.getVolumesReturnsOnCall == nil { fake.getVolumesReturnsOnCall = make(map[int]struct { @@ -256,70 +364,75 @@ func (fake *FakeScbeRestClient) GetVolumesReturnsOnCall(i int, result1 []scbe.Sc }{result1, result2} } -func (fake *FakeScbeRestClient) DeleteVolume(wwn string) error { - fake.deleteVolumeMutex.Lock() - ret, specificReturn := fake.deleteVolumeReturnsOnCall[len(fake.deleteVolumeArgsForCall)] - fake.deleteVolumeArgsForCall = append(fake.deleteVolumeArgsForCall, struct { - wwn string - }{wwn}) - fake.recordInvocation("DeleteVolume", []interface{}{wwn}) - fake.deleteVolumeMutex.Unlock() - if fake.DeleteVolumeStub != nil { - return fake.DeleteVolumeStub(wwn) +func (fake *FakeScbeRestClient) Login() error { + fake.loginMutex.Lock() + ret, specificReturn := fake.loginReturnsOnCall[len(fake.loginArgsForCall)] + fake.loginArgsForCall = append(fake.loginArgsForCall, struct { + }{}) + fake.recordInvocation("Login", []interface{}{}) + fake.loginMutex.Unlock() + if fake.LoginStub != nil { + return fake.LoginStub() } if specificReturn { return ret.result1 } - return fake.deleteVolumeReturns.result1 + fakeReturns := fake.loginReturns + return fakeReturns.result1 } -func (fake *FakeScbeRestClient) DeleteVolumeCallCount() int { - fake.deleteVolumeMutex.RLock() - defer fake.deleteVolumeMutex.RUnlock() - return len(fake.deleteVolumeArgsForCall) +func (fake *FakeScbeRestClient) LoginCallCount() int { + fake.loginMutex.RLock() + defer fake.loginMutex.RUnlock() + return len(fake.loginArgsForCall) } -func (fake *FakeScbeRestClient) DeleteVolumeArgsForCall(i int) string { - fake.deleteVolumeMutex.RLock() - defer fake.deleteVolumeMutex.RUnlock() - return fake.deleteVolumeArgsForCall[i].wwn +func (fake *FakeScbeRestClient) LoginCalls(stub func() error) { + fake.loginMutex.Lock() + defer fake.loginMutex.Unlock() + fake.LoginStub = stub } -func (fake *FakeScbeRestClient) DeleteVolumeReturns(result1 error) { - fake.DeleteVolumeStub = nil - fake.deleteVolumeReturns = struct { +func (fake *FakeScbeRestClient) LoginReturns(result1 error) { + fake.loginMutex.Lock() + defer fake.loginMutex.Unlock() + fake.LoginStub = nil + fake.loginReturns = struct { result1 error }{result1} } -func (fake *FakeScbeRestClient) DeleteVolumeReturnsOnCall(i int, result1 error) { - fake.DeleteVolumeStub = nil - if fake.deleteVolumeReturnsOnCall == nil { - fake.deleteVolumeReturnsOnCall = make(map[int]struct { +func (fake *FakeScbeRestClient) LoginReturnsOnCall(i int, result1 error) { + fake.loginMutex.Lock() + defer fake.loginMutex.Unlock() + fake.LoginStub = nil + if fake.loginReturnsOnCall == nil { + fake.loginReturnsOnCall = make(map[int]struct { result1 error }) } - fake.deleteVolumeReturnsOnCall[i] = struct { + fake.loginReturnsOnCall[i] = struct { result1 error }{result1} } -func (fake *FakeScbeRestClient) MapVolume(wwn string, host string) (scbe.ScbeResponseMapping, error) { +func (fake *FakeScbeRestClient) MapVolume(arg1 string, arg2 string) (scbe.ScbeResponseMapping, error) { fake.mapVolumeMutex.Lock() ret, specificReturn := fake.mapVolumeReturnsOnCall[len(fake.mapVolumeArgsForCall)] fake.mapVolumeArgsForCall = append(fake.mapVolumeArgsForCall, struct { - wwn string - host string - }{wwn, host}) - fake.recordInvocation("MapVolume", []interface{}{wwn, host}) + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("MapVolume", []interface{}{arg1, arg2}) fake.mapVolumeMutex.Unlock() if fake.MapVolumeStub != nil { - return fake.MapVolumeStub(wwn, host) + return fake.MapVolumeStub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - return fake.mapVolumeReturns.result1, fake.mapVolumeReturns.result2 + fakeReturns := fake.mapVolumeReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeScbeRestClient) MapVolumeCallCount() int { @@ -328,13 +441,22 @@ func (fake *FakeScbeRestClient) MapVolumeCallCount() int { return len(fake.mapVolumeArgsForCall) } +func (fake *FakeScbeRestClient) MapVolumeCalls(stub func(string, string) (scbe.ScbeResponseMapping, error)) { + fake.mapVolumeMutex.Lock() + defer fake.mapVolumeMutex.Unlock() + fake.MapVolumeStub = stub +} + func (fake *FakeScbeRestClient) MapVolumeArgsForCall(i int) (string, string) { fake.mapVolumeMutex.RLock() defer fake.mapVolumeMutex.RUnlock() - return fake.mapVolumeArgsForCall[i].wwn, fake.mapVolumeArgsForCall[i].host + argsForCall := fake.mapVolumeArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } func (fake *FakeScbeRestClient) MapVolumeReturns(result1 scbe.ScbeResponseMapping, result2 error) { + fake.mapVolumeMutex.Lock() + defer fake.mapVolumeMutex.Unlock() fake.MapVolumeStub = nil fake.mapVolumeReturns = struct { result1 scbe.ScbeResponseMapping @@ -343,6 +465,8 @@ func (fake *FakeScbeRestClient) MapVolumeReturns(result1 scbe.ScbeResponseMappin } func (fake *FakeScbeRestClient) MapVolumeReturnsOnCall(i int, result1 scbe.ScbeResponseMapping, result2 error) { + fake.mapVolumeMutex.Lock() + defer fake.mapVolumeMutex.Unlock() fake.MapVolumeStub = nil if fake.mapVolumeReturnsOnCall == nil { fake.mapVolumeReturnsOnCall = make(map[int]struct { @@ -356,121 +480,22 @@ func (fake *FakeScbeRestClient) MapVolumeReturnsOnCall(i int, result1 scbe.ScbeR }{result1, result2} } -func (fake *FakeScbeRestClient) UnmapVolume(wwn string, host string) error { - fake.unmapVolumeMutex.Lock() - ret, specificReturn := fake.unmapVolumeReturnsOnCall[len(fake.unmapVolumeArgsForCall)] - fake.unmapVolumeArgsForCall = append(fake.unmapVolumeArgsForCall, struct { - wwn string - host string - }{wwn, host}) - fake.recordInvocation("UnmapVolume", []interface{}{wwn, host}) - fake.unmapVolumeMutex.Unlock() - if fake.UnmapVolumeStub != nil { - return fake.UnmapVolumeStub(wwn, host) - } - if specificReturn { - return ret.result1 - } - return fake.unmapVolumeReturns.result1 -} - -func (fake *FakeScbeRestClient) UnmapVolumeCallCount() int { - fake.unmapVolumeMutex.RLock() - defer fake.unmapVolumeMutex.RUnlock() - return len(fake.unmapVolumeArgsForCall) -} - -func (fake *FakeScbeRestClient) UnmapVolumeArgsForCall(i int) (string, string) { - fake.unmapVolumeMutex.RLock() - defer fake.unmapVolumeMutex.RUnlock() - return fake.unmapVolumeArgsForCall[i].wwn, fake.unmapVolumeArgsForCall[i].host -} - -func (fake *FakeScbeRestClient) UnmapVolumeReturns(result1 error) { - fake.UnmapVolumeStub = nil - fake.unmapVolumeReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeScbeRestClient) UnmapVolumeReturnsOnCall(i int, result1 error) { - fake.UnmapVolumeStub = nil - if fake.unmapVolumeReturnsOnCall == nil { - fake.unmapVolumeReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.unmapVolumeReturnsOnCall[i] = struct { - result1 error - }{result1} -} - -func (fake *FakeScbeRestClient) GetVolMapping(wwn string) (scbe.ScbeVolumeMapInfo, error) { - fake.getVolMappingMutex.Lock() - ret, specificReturn := fake.getVolMappingReturnsOnCall[len(fake.getVolMappingArgsForCall)] - fake.getVolMappingArgsForCall = append(fake.getVolMappingArgsForCall, struct { - wwn string - }{wwn}) - fake.recordInvocation("GetVolMapping", []interface{}{wwn}) - fake.getVolMappingMutex.Unlock() - if fake.GetVolMappingStub != nil { - return fake.GetVolMappingStub(wwn) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fake.getVolMappingReturns.result1, fake.getVolMappingReturns.result2 -} - -func (fake *FakeScbeRestClient) GetVolMappingCallCount() int { - fake.getVolMappingMutex.RLock() - defer fake.getVolMappingMutex.RUnlock() - return len(fake.getVolMappingArgsForCall) -} - -func (fake *FakeScbeRestClient) GetVolMappingArgsForCall(i int) string { - fake.getVolMappingMutex.RLock() - defer fake.getVolMappingMutex.RUnlock() - return fake.getVolMappingArgsForCall[i].wwn -} - -func (fake *FakeScbeRestClient) GetVolMappingReturns(result1 scbe.ScbeVolumeMapInfo, result2 error) { - fake.GetVolMappingStub = nil - fake.getVolMappingReturns = struct { - result1 scbe.ScbeVolumeMapInfo - result2 error - }{result1, result2} -} - -func (fake *FakeScbeRestClient) GetVolMappingReturnsOnCall(i int, result1 scbe.ScbeVolumeMapInfo, result2 error) { - fake.GetVolMappingStub = nil - if fake.getVolMappingReturnsOnCall == nil { - fake.getVolMappingReturnsOnCall = make(map[int]struct { - result1 scbe.ScbeVolumeMapInfo - result2 error - }) - } - fake.getVolMappingReturnsOnCall[i] = struct { - result1 scbe.ScbeVolumeMapInfo - result2 error - }{result1, result2} -} - -func (fake *FakeScbeRestClient) ServiceExist(serviceName string) (bool, error) { +func (fake *FakeScbeRestClient) ServiceExist(arg1 string) (bool, error) { fake.serviceExistMutex.Lock() ret, specificReturn := fake.serviceExistReturnsOnCall[len(fake.serviceExistArgsForCall)] fake.serviceExistArgsForCall = append(fake.serviceExistArgsForCall, struct { - serviceName string - }{serviceName}) - fake.recordInvocation("ServiceExist", []interface{}{serviceName}) + arg1 string + }{arg1}) + fake.recordInvocation("ServiceExist", []interface{}{arg1}) fake.serviceExistMutex.Unlock() if fake.ServiceExistStub != nil { - return fake.ServiceExistStub(serviceName) + return fake.ServiceExistStub(arg1) } if specificReturn { return ret.result1, ret.result2 } - return fake.serviceExistReturns.result1, fake.serviceExistReturns.result2 + fakeReturns := fake.serviceExistReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeScbeRestClient) ServiceExistCallCount() int { @@ -479,13 +504,22 @@ func (fake *FakeScbeRestClient) ServiceExistCallCount() int { return len(fake.serviceExistArgsForCall) } +func (fake *FakeScbeRestClient) ServiceExistCalls(stub func(string) (bool, error)) { + fake.serviceExistMutex.Lock() + defer fake.serviceExistMutex.Unlock() + fake.ServiceExistStub = stub +} + func (fake *FakeScbeRestClient) ServiceExistArgsForCall(i int) string { fake.serviceExistMutex.RLock() defer fake.serviceExistMutex.RUnlock() - return fake.serviceExistArgsForCall[i].serviceName + argsForCall := fake.serviceExistArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeScbeRestClient) ServiceExistReturns(result1 bool, result2 error) { + fake.serviceExistMutex.Lock() + defer fake.serviceExistMutex.Unlock() fake.ServiceExistStub = nil fake.serviceExistReturns = struct { result1 bool @@ -494,6 +528,8 @@ func (fake *FakeScbeRestClient) ServiceExistReturns(result1 bool, result2 error) } func (fake *FakeScbeRestClient) ServiceExistReturnsOnCall(i int, result1 bool, result2 error) { + fake.serviceExistMutex.Lock() + defer fake.serviceExistMutex.Unlock() fake.ServiceExistStub = nil if fake.serviceExistReturnsOnCall == nil { fake.serviceExistReturnsOnCall = make(map[int]struct { @@ -507,25 +543,86 @@ func (fake *FakeScbeRestClient) ServiceExistReturnsOnCall(i int, result1 bool, r }{result1, result2} } +func (fake *FakeScbeRestClient) UnmapVolume(arg1 string, arg2 string) error { + fake.unmapVolumeMutex.Lock() + ret, specificReturn := fake.unmapVolumeReturnsOnCall[len(fake.unmapVolumeArgsForCall)] + fake.unmapVolumeArgsForCall = append(fake.unmapVolumeArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("UnmapVolume", []interface{}{arg1, arg2}) + fake.unmapVolumeMutex.Unlock() + if fake.UnmapVolumeStub != nil { + return fake.UnmapVolumeStub(arg1, arg2) + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.unmapVolumeReturns + return fakeReturns.result1 +} + +func (fake *FakeScbeRestClient) UnmapVolumeCallCount() int { + fake.unmapVolumeMutex.RLock() + defer fake.unmapVolumeMutex.RUnlock() + return len(fake.unmapVolumeArgsForCall) +} + +func (fake *FakeScbeRestClient) UnmapVolumeCalls(stub func(string, string) error) { + fake.unmapVolumeMutex.Lock() + defer fake.unmapVolumeMutex.Unlock() + fake.UnmapVolumeStub = stub +} + +func (fake *FakeScbeRestClient) UnmapVolumeArgsForCall(i int) (string, string) { + fake.unmapVolumeMutex.RLock() + defer fake.unmapVolumeMutex.RUnlock() + argsForCall := fake.unmapVolumeArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeScbeRestClient) UnmapVolumeReturns(result1 error) { + fake.unmapVolumeMutex.Lock() + defer fake.unmapVolumeMutex.Unlock() + fake.UnmapVolumeStub = nil + fake.unmapVolumeReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeScbeRestClient) UnmapVolumeReturnsOnCall(i int, result1 error) { + fake.unmapVolumeMutex.Lock() + defer fake.unmapVolumeMutex.Unlock() + fake.UnmapVolumeStub = nil + if fake.unmapVolumeReturnsOnCall == nil { + fake.unmapVolumeReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.unmapVolumeReturnsOnCall[i] = struct { + result1 error + }{result1} +} + func (fake *FakeScbeRestClient) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() - fake.loginMutex.RLock() - defer fake.loginMutex.RUnlock() fake.createVolumeMutex.RLock() defer fake.createVolumeMutex.RUnlock() - fake.getVolumesMutex.RLock() - defer fake.getVolumesMutex.RUnlock() fake.deleteVolumeMutex.RLock() defer fake.deleteVolumeMutex.RUnlock() - fake.mapVolumeMutex.RLock() - defer fake.mapVolumeMutex.RUnlock() - fake.unmapVolumeMutex.RLock() - defer fake.unmapVolumeMutex.RUnlock() fake.getVolMappingMutex.RLock() defer fake.getVolMappingMutex.RUnlock() + fake.getVolumesMutex.RLock() + defer fake.getVolumesMutex.RUnlock() + fake.loginMutex.RLock() + defer fake.loginMutex.RUnlock() + fake.mapVolumeMutex.RLock() + defer fake.mapVolumeMutex.RUnlock() fake.serviceExistMutex.RLock() defer fake.serviceExistMutex.RUnlock() + fake.unmapVolumeMutex.RLock() + defer fake.unmapVolumeMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} for key, value := range fake.invocations { copiedInvocations[key] = value diff --git a/fakes/fake_simple_rest_client.go b/fakes/fake_simple_rest_client.go index e961f6c8..8b03ddd4 100644 --- a/fakes/fake_simple_rest_client.go +++ b/fakes/fake_simple_rest_client.go @@ -8,36 +8,26 @@ import ( ) type FakeSimpleRestClient struct { - LoginStub func() error - loginMutex sync.RWMutex - loginArgsForCall []struct{} - loginReturns struct { - result1 error - } - loginReturnsOnCall map[int]struct { - result1 error - } - PostStub func(resource_url string, payload []byte, exitStatus int, v interface{}) error - postMutex sync.RWMutex - postArgsForCall []struct { - resource_url string - payload []byte - exitStatus int - v interface{} + DeleteStub func(string, []byte, int) error + deleteMutex sync.RWMutex + deleteArgsForCall []struct { + arg1 string + arg2 []byte + arg3 int } - postReturns struct { + deleteReturns struct { result1 error } - postReturnsOnCall map[int]struct { + deleteReturnsOnCall map[int]struct { result1 error } - GetStub func(resource_url string, params map[string]string, exitStatus int, v interface{}) error + GetStub func(string, map[string]string, int, interface{}) error getMutex sync.RWMutex getArgsForCall []struct { - resource_url string - params map[string]string - exitStatus int - v interface{} + arg1 string + arg2 map[string]string + arg3 int + arg4 interface{} } getReturns struct { result1 error @@ -45,137 +35,120 @@ type FakeSimpleRestClient struct { getReturnsOnCall map[int]struct { result1 error } - DeleteStub func(resource_url string, payload []byte, exitStatus int) error - deleteMutex sync.RWMutex - deleteArgsForCall []struct { - resource_url string - payload []byte - exitStatus int + LoginStub func() error + loginMutex sync.RWMutex + loginArgsForCall []struct { } - deleteReturns struct { + loginReturns struct { result1 error } - deleteReturnsOnCall map[int]struct { + loginReturnsOnCall map[int]struct { result1 error } - invocations map[string][][]interface{} - invocationsMutex sync.RWMutex -} - -func (fake *FakeSimpleRestClient) Login() error { - fake.loginMutex.Lock() - ret, specificReturn := fake.loginReturnsOnCall[len(fake.loginArgsForCall)] - fake.loginArgsForCall = append(fake.loginArgsForCall, struct{}{}) - fake.recordInvocation("Login", []interface{}{}) - fake.loginMutex.Unlock() - if fake.LoginStub != nil { - return fake.LoginStub() - } - if specificReturn { - return ret.result1 + PostStub func(string, []byte, int, interface{}) error + postMutex sync.RWMutex + postArgsForCall []struct { + arg1 string + arg2 []byte + arg3 int + arg4 interface{} } - return fake.loginReturns.result1 -} - -func (fake *FakeSimpleRestClient) LoginCallCount() int { - fake.loginMutex.RLock() - defer fake.loginMutex.RUnlock() - return len(fake.loginArgsForCall) -} - -func (fake *FakeSimpleRestClient) LoginReturns(result1 error) { - fake.LoginStub = nil - fake.loginReturns = struct { + postReturns struct { result1 error - }{result1} -} - -func (fake *FakeSimpleRestClient) LoginReturnsOnCall(i int, result1 error) { - fake.LoginStub = nil - if fake.loginReturnsOnCall == nil { - fake.loginReturnsOnCall = make(map[int]struct { - result1 error - }) } - fake.loginReturnsOnCall[i] = struct { + postReturnsOnCall map[int]struct { result1 error - }{result1} + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex } -func (fake *FakeSimpleRestClient) Post(resource_url string, payload []byte, exitStatus int, v interface{}) error { - var payloadCopy []byte - if payload != nil { - payloadCopy = make([]byte, len(payload)) - copy(payloadCopy, payload) +func (fake *FakeSimpleRestClient) Delete(arg1 string, arg2 []byte, arg3 int) error { + var arg2Copy []byte + if arg2 != nil { + arg2Copy = make([]byte, len(arg2)) + copy(arg2Copy, arg2) } - fake.postMutex.Lock() - ret, specificReturn := fake.postReturnsOnCall[len(fake.postArgsForCall)] - fake.postArgsForCall = append(fake.postArgsForCall, struct { - resource_url string - payload []byte - exitStatus int - v interface{} - }{resource_url, payloadCopy, exitStatus, v}) - fake.recordInvocation("Post", []interface{}{resource_url, payloadCopy, exitStatus, v}) - fake.postMutex.Unlock() - if fake.PostStub != nil { - return fake.PostStub(resource_url, payload, exitStatus, v) + fake.deleteMutex.Lock() + ret, specificReturn := fake.deleteReturnsOnCall[len(fake.deleteArgsForCall)] + fake.deleteArgsForCall = append(fake.deleteArgsForCall, struct { + arg1 string + arg2 []byte + arg3 int + }{arg1, arg2Copy, arg3}) + fake.recordInvocation("Delete", []interface{}{arg1, arg2Copy, arg3}) + fake.deleteMutex.Unlock() + if fake.DeleteStub != nil { + return fake.DeleteStub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - return fake.postReturns.result1 + fakeReturns := fake.deleteReturns + return fakeReturns.result1 } -func (fake *FakeSimpleRestClient) PostCallCount() int { - fake.postMutex.RLock() - defer fake.postMutex.RUnlock() - return len(fake.postArgsForCall) +func (fake *FakeSimpleRestClient) DeleteCallCount() int { + fake.deleteMutex.RLock() + defer fake.deleteMutex.RUnlock() + return len(fake.deleteArgsForCall) } -func (fake *FakeSimpleRestClient) PostArgsForCall(i int) (string, []byte, int, interface{}) { - fake.postMutex.RLock() - defer fake.postMutex.RUnlock() - return fake.postArgsForCall[i].resource_url, fake.postArgsForCall[i].payload, fake.postArgsForCall[i].exitStatus, fake.postArgsForCall[i].v +func (fake *FakeSimpleRestClient) DeleteCalls(stub func(string, []byte, int) error) { + fake.deleteMutex.Lock() + defer fake.deleteMutex.Unlock() + fake.DeleteStub = stub } -func (fake *FakeSimpleRestClient) PostReturns(result1 error) { - fake.PostStub = nil - fake.postReturns = struct { +func (fake *FakeSimpleRestClient) DeleteArgsForCall(i int) (string, []byte, int) { + fake.deleteMutex.RLock() + defer fake.deleteMutex.RUnlock() + argsForCall := fake.deleteArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 +} + +func (fake *FakeSimpleRestClient) DeleteReturns(result1 error) { + fake.deleteMutex.Lock() + defer fake.deleteMutex.Unlock() + fake.DeleteStub = nil + fake.deleteReturns = struct { result1 error }{result1} } -func (fake *FakeSimpleRestClient) PostReturnsOnCall(i int, result1 error) { - fake.PostStub = nil - if fake.postReturnsOnCall == nil { - fake.postReturnsOnCall = make(map[int]struct { +func (fake *FakeSimpleRestClient) DeleteReturnsOnCall(i int, result1 error) { + fake.deleteMutex.Lock() + defer fake.deleteMutex.Unlock() + fake.DeleteStub = nil + if fake.deleteReturnsOnCall == nil { + fake.deleteReturnsOnCall = make(map[int]struct { result1 error }) } - fake.postReturnsOnCall[i] = struct { + fake.deleteReturnsOnCall[i] = struct { result1 error }{result1} } -func (fake *FakeSimpleRestClient) Get(resource_url string, params map[string]string, exitStatus int, v interface{}) error { +func (fake *FakeSimpleRestClient) Get(arg1 string, arg2 map[string]string, arg3 int, arg4 interface{}) error { fake.getMutex.Lock() ret, specificReturn := fake.getReturnsOnCall[len(fake.getArgsForCall)] fake.getArgsForCall = append(fake.getArgsForCall, struct { - resource_url string - params map[string]string - exitStatus int - v interface{} - }{resource_url, params, exitStatus, v}) - fake.recordInvocation("Get", []interface{}{resource_url, params, exitStatus, v}) + arg1 string + arg2 map[string]string + arg3 int + arg4 interface{} + }{arg1, arg2, arg3, arg4}) + fake.recordInvocation("Get", []interface{}{arg1, arg2, arg3, arg4}) fake.getMutex.Unlock() if fake.GetStub != nil { - return fake.GetStub(resource_url, params, exitStatus, v) + return fake.GetStub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1 } - return fake.getReturns.result1 + fakeReturns := fake.getReturns + return fakeReturns.result1 } func (fake *FakeSimpleRestClient) GetCallCount() int { @@ -184,13 +157,22 @@ func (fake *FakeSimpleRestClient) GetCallCount() int { return len(fake.getArgsForCall) } +func (fake *FakeSimpleRestClient) GetCalls(stub func(string, map[string]string, int, interface{}) error) { + fake.getMutex.Lock() + defer fake.getMutex.Unlock() + fake.GetStub = stub +} + func (fake *FakeSimpleRestClient) GetArgsForCall(i int) (string, map[string]string, int, interface{}) { fake.getMutex.RLock() defer fake.getMutex.RUnlock() - return fake.getArgsForCall[i].resource_url, fake.getArgsForCall[i].params, fake.getArgsForCall[i].exitStatus, fake.getArgsForCall[i].v + argsForCall := fake.getArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4 } func (fake *FakeSimpleRestClient) GetReturns(result1 error) { + fake.getMutex.Lock() + defer fake.getMutex.Unlock() fake.GetStub = nil fake.getReturns = struct { result1 error @@ -198,6 +180,8 @@ func (fake *FakeSimpleRestClient) GetReturns(result1 error) { } func (fake *FakeSimpleRestClient) GetReturnsOnCall(i int, result1 error) { + fake.getMutex.Lock() + defer fake.getMutex.Unlock() fake.GetStub = nil if fake.getReturnsOnCall == nil { fake.getReturnsOnCall = make(map[int]struct { @@ -209,57 +193,122 @@ func (fake *FakeSimpleRestClient) GetReturnsOnCall(i int, result1 error) { }{result1} } -func (fake *FakeSimpleRestClient) Delete(resource_url string, payload []byte, exitStatus int) error { - var payloadCopy []byte - if payload != nil { - payloadCopy = make([]byte, len(payload)) - copy(payloadCopy, payload) +func (fake *FakeSimpleRestClient) Login() error { + fake.loginMutex.Lock() + ret, specificReturn := fake.loginReturnsOnCall[len(fake.loginArgsForCall)] + fake.loginArgsForCall = append(fake.loginArgsForCall, struct { + }{}) + fake.recordInvocation("Login", []interface{}{}) + fake.loginMutex.Unlock() + if fake.LoginStub != nil { + return fake.LoginStub() } - fake.deleteMutex.Lock() - ret, specificReturn := fake.deleteReturnsOnCall[len(fake.deleteArgsForCall)] - fake.deleteArgsForCall = append(fake.deleteArgsForCall, struct { - resource_url string - payload []byte - exitStatus int - }{resource_url, payloadCopy, exitStatus}) - fake.recordInvocation("Delete", []interface{}{resource_url, payloadCopy, exitStatus}) - fake.deleteMutex.Unlock() - if fake.DeleteStub != nil { - return fake.DeleteStub(resource_url, payload, exitStatus) + if specificReturn { + return ret.result1 + } + fakeReturns := fake.loginReturns + return fakeReturns.result1 +} + +func (fake *FakeSimpleRestClient) LoginCallCount() int { + fake.loginMutex.RLock() + defer fake.loginMutex.RUnlock() + return len(fake.loginArgsForCall) +} + +func (fake *FakeSimpleRestClient) LoginCalls(stub func() error) { + fake.loginMutex.Lock() + defer fake.loginMutex.Unlock() + fake.LoginStub = stub +} + +func (fake *FakeSimpleRestClient) LoginReturns(result1 error) { + fake.loginMutex.Lock() + defer fake.loginMutex.Unlock() + fake.LoginStub = nil + fake.loginReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeSimpleRestClient) LoginReturnsOnCall(i int, result1 error) { + fake.loginMutex.Lock() + defer fake.loginMutex.Unlock() + fake.LoginStub = nil + if fake.loginReturnsOnCall == nil { + fake.loginReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.loginReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeSimpleRestClient) Post(arg1 string, arg2 []byte, arg3 int, arg4 interface{}) error { + var arg2Copy []byte + if arg2 != nil { + arg2Copy = make([]byte, len(arg2)) + copy(arg2Copy, arg2) + } + fake.postMutex.Lock() + ret, specificReturn := fake.postReturnsOnCall[len(fake.postArgsForCall)] + fake.postArgsForCall = append(fake.postArgsForCall, struct { + arg1 string + arg2 []byte + arg3 int + arg4 interface{} + }{arg1, arg2Copy, arg3, arg4}) + fake.recordInvocation("Post", []interface{}{arg1, arg2Copy, arg3, arg4}) + fake.postMutex.Unlock() + if fake.PostStub != nil { + return fake.PostStub(arg1, arg2, arg3, arg4) } if specificReturn { return ret.result1 } - return fake.deleteReturns.result1 + fakeReturns := fake.postReturns + return fakeReturns.result1 } -func (fake *FakeSimpleRestClient) DeleteCallCount() int { - fake.deleteMutex.RLock() - defer fake.deleteMutex.RUnlock() - return len(fake.deleteArgsForCall) +func (fake *FakeSimpleRestClient) PostCallCount() int { + fake.postMutex.RLock() + defer fake.postMutex.RUnlock() + return len(fake.postArgsForCall) } -func (fake *FakeSimpleRestClient) DeleteArgsForCall(i int) (string, []byte, int) { - fake.deleteMutex.RLock() - defer fake.deleteMutex.RUnlock() - return fake.deleteArgsForCall[i].resource_url, fake.deleteArgsForCall[i].payload, fake.deleteArgsForCall[i].exitStatus +func (fake *FakeSimpleRestClient) PostCalls(stub func(string, []byte, int, interface{}) error) { + fake.postMutex.Lock() + defer fake.postMutex.Unlock() + fake.PostStub = stub } -func (fake *FakeSimpleRestClient) DeleteReturns(result1 error) { - fake.DeleteStub = nil - fake.deleteReturns = struct { +func (fake *FakeSimpleRestClient) PostArgsForCall(i int) (string, []byte, int, interface{}) { + fake.postMutex.RLock() + defer fake.postMutex.RUnlock() + argsForCall := fake.postArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4 +} + +func (fake *FakeSimpleRestClient) PostReturns(result1 error) { + fake.postMutex.Lock() + defer fake.postMutex.Unlock() + fake.PostStub = nil + fake.postReturns = struct { result1 error }{result1} } -func (fake *FakeSimpleRestClient) DeleteReturnsOnCall(i int, result1 error) { - fake.DeleteStub = nil - if fake.deleteReturnsOnCall == nil { - fake.deleteReturnsOnCall = make(map[int]struct { +func (fake *FakeSimpleRestClient) PostReturnsOnCall(i int, result1 error) { + fake.postMutex.Lock() + defer fake.postMutex.Unlock() + fake.PostStub = nil + if fake.postReturnsOnCall == nil { + fake.postReturnsOnCall = make(map[int]struct { result1 error }) } - fake.deleteReturnsOnCall[i] = struct { + fake.postReturnsOnCall[i] = struct { result1 error }{result1} } @@ -267,14 +316,14 @@ func (fake *FakeSimpleRestClient) DeleteReturnsOnCall(i int, result1 error) { func (fake *FakeSimpleRestClient) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() + fake.deleteMutex.RLock() + defer fake.deleteMutex.RUnlock() + fake.getMutex.RLock() + defer fake.getMutex.RUnlock() fake.loginMutex.RLock() defer fake.loginMutex.RUnlock() fake.postMutex.RLock() defer fake.postMutex.RUnlock() - fake.getMutex.RLock() - defer fake.getMutex.RUnlock() - fake.deleteMutex.RLock() - defer fake.deleteMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} for key, value := range fake.invocations { copiedInvocations[key] = value diff --git a/fakes/fake_spectrum.go b/fakes/fake_spectrum.go index 40a177bc..4e637afc 100644 --- a/fakes/fake_spectrum.go +++ b/fakes/fake_spectrum.go @@ -1,19 +1,3 @@ -/** - * Copyright 2017 IBM Corp. - * - * 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. - */ - // Code generated by counterfeiter. DO NOT EDIT. package fakes @@ -25,45 +9,58 @@ import ( ) type FakeSpectrumScaleConnector struct { - GetClusterIdStub func() (string, error) - getClusterIdMutex sync.RWMutex - getClusterIdArgsForCall []struct{} - getClusterIdReturns struct { - result1 string - result2 error + CheckIfFSQuotaEnabledStub func(string) error + checkIfFSQuotaEnabledMutex sync.RWMutex + checkIfFSQuotaEnabledArgsForCall []struct { + arg1 string } - getClusterIdReturnsOnCall map[int]struct { - result1 string - result2 error + checkIfFSQuotaEnabledReturns struct { + result1 error } - IsFilesystemMountedStub func(filesystemName string) (bool, error) - isFilesystemMountedMutex sync.RWMutex - isFilesystemMountedArgsForCall []struct { - filesystemName string + checkIfFSQuotaEnabledReturnsOnCall map[int]struct { + result1 error } - isFilesystemMountedReturns struct { - result1 bool - result2 error + CreateFilesetStub func(string, string, map[string]interface{}) error + createFilesetMutex sync.RWMutex + createFilesetArgsForCall []struct { + arg1 string + arg2 string + arg3 map[string]interface{} } - isFilesystemMountedReturnsOnCall map[int]struct { - result1 bool - result2 error + createFilesetReturns struct { + result1 error } - ListFilesystemsStub func() ([]string, error) - listFilesystemsMutex sync.RWMutex - listFilesystemsArgsForCall []struct{} - listFilesystemsReturns struct { - result1 []string + createFilesetReturnsOnCall map[int]struct { + result1 error + } + DeleteFilesetStub func(string, string) error + deleteFilesetMutex sync.RWMutex + deleteFilesetArgsForCall []struct { + arg1 string + arg2 string + } + deleteFilesetReturns struct { + result1 error + } + deleteFilesetReturnsOnCall map[int]struct { + result1 error + } + GetClusterIdStub func() (string, error) + getClusterIdMutex sync.RWMutex + getClusterIdArgsForCall []struct { + } + getClusterIdReturns struct { + result1 string result2 error } - listFilesystemsReturnsOnCall map[int]struct { - result1 []string + getClusterIdReturnsOnCall map[int]struct { + result1 string result2 error } - GetFilesystemMountpointStub func(filesystemName string) (string, error) + GetFilesystemMountpointStub func(string) (string, error) getFilesystemMountpointMutex sync.RWMutex getFilesystemMountpointArgsForCall []struct { - filesystemName string + arg1 string } getFilesystemMountpointReturns struct { result1 string @@ -73,36 +70,38 @@ type FakeSpectrumScaleConnector struct { result1 string result2 error } - CreateFilesetStub func(filesystemName string, filesetName string, opts map[string]interface{}) error - createFilesetMutex sync.RWMutex - createFilesetArgsForCall []struct { - filesystemName string - filesetName string - opts map[string]interface{} + IsFilesetLinkedStub func(string, string) (bool, error) + isFilesetLinkedMutex sync.RWMutex + isFilesetLinkedArgsForCall []struct { + arg1 string + arg2 string } - createFilesetReturns struct { - result1 error + isFilesetLinkedReturns struct { + result1 bool + result2 error } - createFilesetReturnsOnCall map[int]struct { - result1 error + isFilesetLinkedReturnsOnCall map[int]struct { + result1 bool + result2 error } - DeleteFilesetStub func(filesystemName string, filesetName string) error - deleteFilesetMutex sync.RWMutex - deleteFilesetArgsForCall []struct { - filesystemName string - filesetName string + IsFilesystemMountedStub func(string) (bool, error) + isFilesystemMountedMutex sync.RWMutex + isFilesystemMountedArgsForCall []struct { + arg1 string } - deleteFilesetReturns struct { - result1 error + isFilesystemMountedReturns struct { + result1 bool + result2 error } - deleteFilesetReturnsOnCall map[int]struct { - result1 error + isFilesystemMountedReturnsOnCall map[int]struct { + result1 bool + result2 error } - LinkFilesetStub func(filesystemName string, filesetName string) error + LinkFilesetStub func(string, string) error linkFilesetMutex sync.RWMutex linkFilesetArgsForCall []struct { - filesystemName string - filesetName string + arg1 string + arg2 string } linkFilesetReturns struct { result1 error @@ -110,22 +109,38 @@ type FakeSpectrumScaleConnector struct { linkFilesetReturnsOnCall map[int]struct { result1 error } - UnlinkFilesetStub func(filesystemName string, filesetName string) error - unlinkFilesetMutex sync.RWMutex - unlinkFilesetArgsForCall []struct { - filesystemName string - filesetName string + ListFilesetStub func(string, string) (resources.Volume, error) + listFilesetMutex sync.RWMutex + listFilesetArgsForCall []struct { + arg1 string + arg2 string } - unlinkFilesetReturns struct { - result1 error + listFilesetReturns struct { + result1 resources.Volume + result2 error } - unlinkFilesetReturnsOnCall map[int]struct { - result1 error + listFilesetReturnsOnCall map[int]struct { + result1 resources.Volume + result2 error + } + ListFilesetQuotaStub func(string, string) (string, error) + listFilesetQuotaMutex sync.RWMutex + listFilesetQuotaArgsForCall []struct { + arg1 string + arg2 string + } + listFilesetQuotaReturns struct { + result1 string + result2 error + } + listFilesetQuotaReturnsOnCall map[int]struct { + result1 string + result2 error } - ListFilesetsStub func(filesystemName string) ([]resources.Volume, error) + ListFilesetsStub func(string) ([]resources.Volume, error) listFilesetsMutex sync.RWMutex listFilesetsArgsForCall []struct { - filesystemName string + arg1 string } listFilesetsReturns struct { result1 []resources.Volume @@ -135,68 +150,24 @@ type FakeSpectrumScaleConnector struct { result1 []resources.Volume result2 error } - ListFilesetStub func(filesystemName string, filesetName string) (resources.Volume, error) - listFilesetMutex sync.RWMutex - listFilesetArgsForCall []struct { - filesystemName string - filesetName string - } - listFilesetReturns struct { - result1 resources.Volume - result2 error - } - listFilesetReturnsOnCall map[int]struct { - result1 resources.Volume - result2 error - } - IsFilesetLinkedStub func(filesystemName string, filesetName string) (bool, error) - isFilesetLinkedMutex sync.RWMutex - isFilesetLinkedArgsForCall []struct { - filesystemName string - filesetName string + ListFilesystemsStub func() ([]string, error) + listFilesystemsMutex sync.RWMutex + listFilesystemsArgsForCall []struct { } - isFilesetLinkedReturns struct { - result1 bool + listFilesystemsReturns struct { + result1 []string result2 error } - isFilesetLinkedReturnsOnCall map[int]struct { - result1 bool + listFilesystemsReturnsOnCall map[int]struct { + result1 []string result2 error } - - CheckIfFSQuotaEnabledStub func(filesystemName string) (error) - checkIfFSQuotaEnabledMutex sync.RWMutex - checkIfFSQuotaEnabledArgsForCall []struct { - filesystemName string - } - checkIfFSQuotaEnabledReturns struct { - result1 error - } - checkIfFSQuotaEnabledReturnsOnCall map[int]struct { - result1 error - } - - ListFilesetQuotaStub func(filesystemName string, filesetName string) (string, error) - listFilesetQuotaMutex sync.RWMutex - listFilesetQuotaArgsForCall []struct { - filesystemName string - filesetName string - } - listFilesetQuotaReturns struct { - result1 string - result2 error - } - listFilesetQuotaReturnsOnCall map[int]struct { - result1 string - result2 error - } - - SetFilesetQuotaStub func(filesystemName string, filesetName string, quota string) error + SetFilesetQuotaStub func(string, string, string) error setFilesetQuotaMutex sync.RWMutex setFilesetQuotaArgsForCall []struct { - filesystemName string - filesetName string - quota string + arg1 string + arg2 string + arg3 string } setFilesetQuotaReturns struct { result1 error @@ -204,238 +175,100 @@ type FakeSpectrumScaleConnector struct { setFilesetQuotaReturnsOnCall map[int]struct { result1 error } - ExportNfsStub func(volumeMountpoint string, clientConfig string) error - exportNfsMutex sync.RWMutex - exportNfsArgsForCall []struct { - volumeMountpoint string - clientConfig string - } - exportNfsReturns struct { - result1 error - } - exportNfsReturnsOnCall map[int]struct { - result1 error - } - UnexportNfsStub func(volumeMountpoint string) error - unexportNfsMutex sync.RWMutex - unexportNfsArgsForCall []struct { - volumeMountpoint string + UnlinkFilesetStub func(string, string) error + unlinkFilesetMutex sync.RWMutex + unlinkFilesetArgsForCall []struct { + arg1 string + arg2 string } - unexportNfsReturns struct { + unlinkFilesetReturns struct { result1 error } - unexportNfsReturnsOnCall map[int]struct { + unlinkFilesetReturnsOnCall map[int]struct { result1 error } invocations map[string][][]interface{} invocationsMutex sync.RWMutex } -func (fake *FakeSpectrumScaleConnector) GetClusterId() (string, error) { - fake.getClusterIdMutex.Lock() - ret, specificReturn := fake.getClusterIdReturnsOnCall[len(fake.getClusterIdArgsForCall)] - fake.getClusterIdArgsForCall = append(fake.getClusterIdArgsForCall, struct{}{}) - fake.recordInvocation("GetClusterId", []interface{}{}) - fake.getClusterIdMutex.Unlock() - if fake.GetClusterIdStub != nil { - return fake.GetClusterIdStub() - } - if specificReturn { - return ret.result1, ret.result2 - } - return fake.getClusterIdReturns.result1, fake.getClusterIdReturns.result2 -} - -func (fake *FakeSpectrumScaleConnector) GetClusterIdCallCount() int { - fake.getClusterIdMutex.RLock() - defer fake.getClusterIdMutex.RUnlock() - return len(fake.getClusterIdArgsForCall) -} - -func (fake *FakeSpectrumScaleConnector) GetClusterIdReturns(result1 string, result2 error) { - fake.GetClusterIdStub = nil - fake.getClusterIdReturns = struct { - result1 string - result2 error - }{result1, result2} -} - -func (fake *FakeSpectrumScaleConnector) GetClusterIdReturnsOnCall(i int, result1 string, result2 error) { - fake.GetClusterIdStub = nil - if fake.getClusterIdReturnsOnCall == nil { - fake.getClusterIdReturnsOnCall = make(map[int]struct { - result1 string - result2 error - }) - } - fake.getClusterIdReturnsOnCall[i] = struct { - result1 string - result2 error - }{result1, result2} -} - -func (fake *FakeSpectrumScaleConnector) IsFilesystemMounted(filesystemName string) (bool, error) { - fake.isFilesystemMountedMutex.Lock() - ret, specificReturn := fake.isFilesystemMountedReturnsOnCall[len(fake.isFilesystemMountedArgsForCall)] - fake.isFilesystemMountedArgsForCall = append(fake.isFilesystemMountedArgsForCall, struct { - filesystemName string - }{filesystemName}) - fake.recordInvocation("IsFilesystemMounted", []interface{}{filesystemName}) - fake.isFilesystemMountedMutex.Unlock() - if fake.IsFilesystemMountedStub != nil { - return fake.IsFilesystemMountedStub(filesystemName) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fake.isFilesystemMountedReturns.result1, fake.isFilesystemMountedReturns.result2 -} - -func (fake *FakeSpectrumScaleConnector) IsFilesystemMountedCallCount() int { - fake.isFilesystemMountedMutex.RLock() - defer fake.isFilesystemMountedMutex.RUnlock() - return len(fake.isFilesystemMountedArgsForCall) -} - -func (fake *FakeSpectrumScaleConnector) IsFilesystemMountedArgsForCall(i int) string { - fake.isFilesystemMountedMutex.RLock() - defer fake.isFilesystemMountedMutex.RUnlock() - return fake.isFilesystemMountedArgsForCall[i].filesystemName -} - -func (fake *FakeSpectrumScaleConnector) IsFilesystemMountedReturns(result1 bool, result2 error) { - fake.IsFilesystemMountedStub = nil - fake.isFilesystemMountedReturns = struct { - result1 bool - result2 error - }{result1, result2} -} - -func (fake *FakeSpectrumScaleConnector) IsFilesystemMountedReturnsOnCall(i int, result1 bool, result2 error) { - fake.IsFilesystemMountedStub = nil - if fake.isFilesystemMountedReturnsOnCall == nil { - fake.isFilesystemMountedReturnsOnCall = make(map[int]struct { - result1 bool - result2 error - }) - } - fake.isFilesystemMountedReturnsOnCall[i] = struct { - result1 bool - result2 error - }{result1, result2} -} - -func (fake *FakeSpectrumScaleConnector) ListFilesystems() ([]string, error) { - fake.listFilesystemsMutex.Lock() - ret, specificReturn := fake.listFilesystemsReturnsOnCall[len(fake.listFilesystemsArgsForCall)] - fake.listFilesystemsArgsForCall = append(fake.listFilesystemsArgsForCall, struct{}{}) - fake.recordInvocation("ListFilesystems", []interface{}{}) - fake.listFilesystemsMutex.Unlock() - if fake.ListFilesystemsStub != nil { - return fake.ListFilesystemsStub() +func (fake *FakeSpectrumScaleConnector) CheckIfFSQuotaEnabled(arg1 string) error { + fake.checkIfFSQuotaEnabledMutex.Lock() + ret, specificReturn := fake.checkIfFSQuotaEnabledReturnsOnCall[len(fake.checkIfFSQuotaEnabledArgsForCall)] + fake.checkIfFSQuotaEnabledArgsForCall = append(fake.checkIfFSQuotaEnabledArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("CheckIfFSQuotaEnabled", []interface{}{arg1}) + fake.checkIfFSQuotaEnabledMutex.Unlock() + if fake.CheckIfFSQuotaEnabledStub != nil { + return fake.CheckIfFSQuotaEnabledStub(arg1) } if specificReturn { - return ret.result1, ret.result2 - } - return fake.listFilesystemsReturns.result1, fake.listFilesystemsReturns.result2 -} - -func (fake *FakeSpectrumScaleConnector) ListFilesystemsCallCount() int { - fake.listFilesystemsMutex.RLock() - defer fake.listFilesystemsMutex.RUnlock() - return len(fake.listFilesystemsArgsForCall) -} - -func (fake *FakeSpectrumScaleConnector) ListFilesystemsReturns(result1 []string, result2 error) { - fake.ListFilesystemsStub = nil - fake.listFilesystemsReturns = struct { - result1 []string - result2 error - }{result1, result2} -} - -func (fake *FakeSpectrumScaleConnector) ListFilesystemsReturnsOnCall(i int, result1 []string, result2 error) { - fake.ListFilesystemsStub = nil - if fake.listFilesystemsReturnsOnCall == nil { - fake.listFilesystemsReturnsOnCall = make(map[int]struct { - result1 []string - result2 error - }) + return ret.result1 } - fake.listFilesystemsReturnsOnCall[i] = struct { - result1 []string - result2 error - }{result1, result2} + fakeReturns := fake.checkIfFSQuotaEnabledReturns + return fakeReturns.result1 } -func (fake *FakeSpectrumScaleConnector) GetFilesystemMountpoint(filesystemName string) (string, error) { - fake.getFilesystemMountpointMutex.Lock() - ret, specificReturn := fake.getFilesystemMountpointReturnsOnCall[len(fake.getFilesystemMountpointArgsForCall)] - fake.getFilesystemMountpointArgsForCall = append(fake.getFilesystemMountpointArgsForCall, struct { - filesystemName string - }{filesystemName}) - fake.recordInvocation("GetFilesystemMountpoint", []interface{}{filesystemName}) - fake.getFilesystemMountpointMutex.Unlock() - if fake.GetFilesystemMountpointStub != nil { - return fake.GetFilesystemMountpointStub(filesystemName) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fake.getFilesystemMountpointReturns.result1, fake.getFilesystemMountpointReturns.result2 +func (fake *FakeSpectrumScaleConnector) CheckIfFSQuotaEnabledCallCount() int { + fake.checkIfFSQuotaEnabledMutex.RLock() + defer fake.checkIfFSQuotaEnabledMutex.RUnlock() + return len(fake.checkIfFSQuotaEnabledArgsForCall) } -func (fake *FakeSpectrumScaleConnector) GetFilesystemMountpointCallCount() int { - fake.getFilesystemMountpointMutex.RLock() - defer fake.getFilesystemMountpointMutex.RUnlock() - return len(fake.getFilesystemMountpointArgsForCall) +func (fake *FakeSpectrumScaleConnector) CheckIfFSQuotaEnabledCalls(stub func(string) error) { + fake.checkIfFSQuotaEnabledMutex.Lock() + defer fake.checkIfFSQuotaEnabledMutex.Unlock() + fake.CheckIfFSQuotaEnabledStub = stub } -func (fake *FakeSpectrumScaleConnector) GetFilesystemMountpointArgsForCall(i int) string { - fake.getFilesystemMountpointMutex.RLock() - defer fake.getFilesystemMountpointMutex.RUnlock() - return fake.getFilesystemMountpointArgsForCall[i].filesystemName +func (fake *FakeSpectrumScaleConnector) CheckIfFSQuotaEnabledArgsForCall(i int) string { + fake.checkIfFSQuotaEnabledMutex.RLock() + defer fake.checkIfFSQuotaEnabledMutex.RUnlock() + argsForCall := fake.checkIfFSQuotaEnabledArgsForCall[i] + return argsForCall.arg1 } -func (fake *FakeSpectrumScaleConnector) GetFilesystemMountpointReturns(result1 string, result2 error) { - fake.GetFilesystemMountpointStub = nil - fake.getFilesystemMountpointReturns = struct { - result1 string - result2 error - }{result1, result2} +func (fake *FakeSpectrumScaleConnector) CheckIfFSQuotaEnabledReturns(result1 error) { + fake.checkIfFSQuotaEnabledMutex.Lock() + defer fake.checkIfFSQuotaEnabledMutex.Unlock() + fake.CheckIfFSQuotaEnabledStub = nil + fake.checkIfFSQuotaEnabledReturns = struct { + result1 error + }{result1} } -func (fake *FakeSpectrumScaleConnector) GetFilesystemMountpointReturnsOnCall(i int, result1 string, result2 error) { - fake.GetFilesystemMountpointStub = nil - if fake.getFilesystemMountpointReturnsOnCall == nil { - fake.getFilesystemMountpointReturnsOnCall = make(map[int]struct { - result1 string - result2 error +func (fake *FakeSpectrumScaleConnector) CheckIfFSQuotaEnabledReturnsOnCall(i int, result1 error) { + fake.checkIfFSQuotaEnabledMutex.Lock() + defer fake.checkIfFSQuotaEnabledMutex.Unlock() + fake.CheckIfFSQuotaEnabledStub = nil + if fake.checkIfFSQuotaEnabledReturnsOnCall == nil { + fake.checkIfFSQuotaEnabledReturnsOnCall = make(map[int]struct { + result1 error }) } - fake.getFilesystemMountpointReturnsOnCall[i] = struct { - result1 string - result2 error - }{result1, result2} + fake.checkIfFSQuotaEnabledReturnsOnCall[i] = struct { + result1 error + }{result1} } -func (fake *FakeSpectrumScaleConnector) CreateFileset(filesystemName string, filesetName string, opts map[string]interface{}) error { +func (fake *FakeSpectrumScaleConnector) CreateFileset(arg1 string, arg2 string, arg3 map[string]interface{}) error { fake.createFilesetMutex.Lock() ret, specificReturn := fake.createFilesetReturnsOnCall[len(fake.createFilesetArgsForCall)] fake.createFilesetArgsForCall = append(fake.createFilesetArgsForCall, struct { - filesystemName string - filesetName string - opts map[string]interface{} - }{filesystemName, filesetName, opts}) - fake.recordInvocation("CreateFileset", []interface{}{filesystemName, filesetName, opts}) + arg1 string + arg2 string + arg3 map[string]interface{} + }{arg1, arg2, arg3}) + fake.recordInvocation("CreateFileset", []interface{}{arg1, arg2, arg3}) fake.createFilesetMutex.Unlock() if fake.CreateFilesetStub != nil { - return fake.CreateFilesetStub(filesystemName, filesetName, opts) + return fake.CreateFilesetStub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - return fake.createFilesetReturns.result1 + fakeReturns := fake.createFilesetReturns + return fakeReturns.result1 } func (fake *FakeSpectrumScaleConnector) CreateFilesetCallCount() int { @@ -444,13 +277,22 @@ func (fake *FakeSpectrumScaleConnector) CreateFilesetCallCount() int { return len(fake.createFilesetArgsForCall) } +func (fake *FakeSpectrumScaleConnector) CreateFilesetCalls(stub func(string, string, map[string]interface{}) error) { + fake.createFilesetMutex.Lock() + defer fake.createFilesetMutex.Unlock() + fake.CreateFilesetStub = stub +} + func (fake *FakeSpectrumScaleConnector) CreateFilesetArgsForCall(i int) (string, string, map[string]interface{}) { fake.createFilesetMutex.RLock() defer fake.createFilesetMutex.RUnlock() - return fake.createFilesetArgsForCall[i].filesystemName, fake.createFilesetArgsForCall[i].filesetName, fake.createFilesetArgsForCall[i].opts + argsForCall := fake.createFilesetArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 } func (fake *FakeSpectrumScaleConnector) CreateFilesetReturns(result1 error) { + fake.createFilesetMutex.Lock() + defer fake.createFilesetMutex.Unlock() fake.CreateFilesetStub = nil fake.createFilesetReturns = struct { result1 error @@ -458,6 +300,8 @@ func (fake *FakeSpectrumScaleConnector) CreateFilesetReturns(result1 error) { } func (fake *FakeSpectrumScaleConnector) CreateFilesetReturnsOnCall(i int, result1 error) { + fake.createFilesetMutex.Lock() + defer fake.createFilesetMutex.Unlock() fake.CreateFilesetStub = nil if fake.createFilesetReturnsOnCall == nil { fake.createFilesetReturnsOnCall = make(map[int]struct { @@ -469,22 +313,23 @@ func (fake *FakeSpectrumScaleConnector) CreateFilesetReturnsOnCall(i int, result }{result1} } -func (fake *FakeSpectrumScaleConnector) DeleteFileset(filesystemName string, filesetName string) error { +func (fake *FakeSpectrumScaleConnector) DeleteFileset(arg1 string, arg2 string) error { fake.deleteFilesetMutex.Lock() ret, specificReturn := fake.deleteFilesetReturnsOnCall[len(fake.deleteFilesetArgsForCall)] fake.deleteFilesetArgsForCall = append(fake.deleteFilesetArgsForCall, struct { - filesystemName string - filesetName string - }{filesystemName, filesetName}) - fake.recordInvocation("DeleteFileset", []interface{}{filesystemName, filesetName}) + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("DeleteFileset", []interface{}{arg1, arg2}) fake.deleteFilesetMutex.Unlock() if fake.DeleteFilesetStub != nil { - return fake.DeleteFilesetStub(filesystemName, filesetName) + return fake.DeleteFilesetStub(arg1, arg2) } if specificReturn { return ret.result1 } - return fake.deleteFilesetReturns.result1 + fakeReturns := fake.deleteFilesetReturns + return fakeReturns.result1 } func (fake *FakeSpectrumScaleConnector) DeleteFilesetCallCount() int { @@ -493,13 +338,22 @@ func (fake *FakeSpectrumScaleConnector) DeleteFilesetCallCount() int { return len(fake.deleteFilesetArgsForCall) } +func (fake *FakeSpectrumScaleConnector) DeleteFilesetCalls(stub func(string, string) error) { + fake.deleteFilesetMutex.Lock() + defer fake.deleteFilesetMutex.Unlock() + fake.DeleteFilesetStub = stub +} + func (fake *FakeSpectrumScaleConnector) DeleteFilesetArgsForCall(i int) (string, string) { fake.deleteFilesetMutex.RLock() defer fake.deleteFilesetMutex.RUnlock() - return fake.deleteFilesetArgsForCall[i].filesystemName, fake.deleteFilesetArgsForCall[i].filesetName + argsForCall := fake.deleteFilesetArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } func (fake *FakeSpectrumScaleConnector) DeleteFilesetReturns(result1 error) { + fake.deleteFilesetMutex.Lock() + defer fake.deleteFilesetMutex.Unlock() fake.DeleteFilesetStub = nil fake.deleteFilesetReturns = struct { result1 error @@ -507,6 +361,8 @@ func (fake *FakeSpectrumScaleConnector) DeleteFilesetReturns(result1 error) { } func (fake *FakeSpectrumScaleConnector) DeleteFilesetReturnsOnCall(i int, result1 error) { + fake.deleteFilesetMutex.Lock() + defer fake.deleteFilesetMutex.Unlock() fake.DeleteFilesetStub = nil if fake.deleteFilesetReturnsOnCall == nil { fake.deleteFilesetReturnsOnCall = make(map[int]struct { @@ -518,171 +374,329 @@ func (fake *FakeSpectrumScaleConnector) DeleteFilesetReturnsOnCall(i int, result }{result1} } -func (fake *FakeSpectrumScaleConnector) LinkFileset(filesystemName string, filesetName string) error { - fake.linkFilesetMutex.Lock() - ret, specificReturn := fake.linkFilesetReturnsOnCall[len(fake.linkFilesetArgsForCall)] - fake.linkFilesetArgsForCall = append(fake.linkFilesetArgsForCall, struct { - filesystemName string - filesetName string - }{filesystemName, filesetName}) - fake.recordInvocation("LinkFileset", []interface{}{filesystemName, filesetName}) - fake.linkFilesetMutex.Unlock() - if fake.LinkFilesetStub != nil { - return fake.LinkFilesetStub(filesystemName, filesetName) +func (fake *FakeSpectrumScaleConnector) GetClusterId() (string, error) { + fake.getClusterIdMutex.Lock() + ret, specificReturn := fake.getClusterIdReturnsOnCall[len(fake.getClusterIdArgsForCall)] + fake.getClusterIdArgsForCall = append(fake.getClusterIdArgsForCall, struct { + }{}) + fake.recordInvocation("GetClusterId", []interface{}{}) + fake.getClusterIdMutex.Unlock() + if fake.GetClusterIdStub != nil { + return fake.GetClusterIdStub() } if specificReturn { - return ret.result1 + return ret.result1, ret.result2 } - return fake.linkFilesetReturns.result1 + fakeReturns := fake.getClusterIdReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeSpectrumScaleConnector) LinkFilesetCallCount() int { - fake.linkFilesetMutex.RLock() - defer fake.linkFilesetMutex.RUnlock() - return len(fake.linkFilesetArgsForCall) +func (fake *FakeSpectrumScaleConnector) GetClusterIdCallCount() int { + fake.getClusterIdMutex.RLock() + defer fake.getClusterIdMutex.RUnlock() + return len(fake.getClusterIdArgsForCall) } -func (fake *FakeSpectrumScaleConnector) LinkFilesetArgsForCall(i int) (string, string) { - fake.linkFilesetMutex.RLock() - defer fake.linkFilesetMutex.RUnlock() - return fake.linkFilesetArgsForCall[i].filesystemName, fake.linkFilesetArgsForCall[i].filesetName +func (fake *FakeSpectrumScaleConnector) GetClusterIdCalls(stub func() (string, error)) { + fake.getClusterIdMutex.Lock() + defer fake.getClusterIdMutex.Unlock() + fake.GetClusterIdStub = stub } -func (fake *FakeSpectrumScaleConnector) LinkFilesetReturns(result1 error) { - fake.LinkFilesetStub = nil - fake.linkFilesetReturns = struct { - result1 error - }{result1} +func (fake *FakeSpectrumScaleConnector) GetClusterIdReturns(result1 string, result2 error) { + fake.getClusterIdMutex.Lock() + defer fake.getClusterIdMutex.Unlock() + fake.GetClusterIdStub = nil + fake.getClusterIdReturns = struct { + result1 string + result2 error + }{result1, result2} } -func (fake *FakeSpectrumScaleConnector) LinkFilesetReturnsOnCall(i int, result1 error) { - fake.LinkFilesetStub = nil - if fake.linkFilesetReturnsOnCall == nil { - fake.linkFilesetReturnsOnCall = make(map[int]struct { - result1 error +func (fake *FakeSpectrumScaleConnector) GetClusterIdReturnsOnCall(i int, result1 string, result2 error) { + fake.getClusterIdMutex.Lock() + defer fake.getClusterIdMutex.Unlock() + fake.GetClusterIdStub = nil + if fake.getClusterIdReturnsOnCall == nil { + fake.getClusterIdReturnsOnCall = make(map[int]struct { + result1 string + result2 error }) } - fake.linkFilesetReturnsOnCall[i] = struct { - result1 error - }{result1} + fake.getClusterIdReturnsOnCall[i] = struct { + result1 string + result2 error + }{result1, result2} } -func (fake *FakeSpectrumScaleConnector) UnlinkFileset(filesystemName string, filesetName string) error { - fake.unlinkFilesetMutex.Lock() - ret, specificReturn := fake.unlinkFilesetReturnsOnCall[len(fake.unlinkFilesetArgsForCall)] - fake.unlinkFilesetArgsForCall = append(fake.unlinkFilesetArgsForCall, struct { - filesystemName string - filesetName string - }{filesystemName, filesetName}) - fake.recordInvocation("UnlinkFileset", []interface{}{filesystemName, filesetName}) - fake.unlinkFilesetMutex.Unlock() - if fake.UnlinkFilesetStub != nil { - return fake.UnlinkFilesetStub(filesystemName, filesetName) +func (fake *FakeSpectrumScaleConnector) GetFilesystemMountpoint(arg1 string) (string, error) { + fake.getFilesystemMountpointMutex.Lock() + ret, specificReturn := fake.getFilesystemMountpointReturnsOnCall[len(fake.getFilesystemMountpointArgsForCall)] + fake.getFilesystemMountpointArgsForCall = append(fake.getFilesystemMountpointArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("GetFilesystemMountpoint", []interface{}{arg1}) + fake.getFilesystemMountpointMutex.Unlock() + if fake.GetFilesystemMountpointStub != nil { + return fake.GetFilesystemMountpointStub(arg1) } if specificReturn { - return ret.result1 + return ret.result1, ret.result2 } - return fake.unlinkFilesetReturns.result1 + fakeReturns := fake.getFilesystemMountpointReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeSpectrumScaleConnector) UnlinkFilesetCallCount() int { - fake.unlinkFilesetMutex.RLock() - defer fake.unlinkFilesetMutex.RUnlock() - return len(fake.unlinkFilesetArgsForCall) +func (fake *FakeSpectrumScaleConnector) GetFilesystemMountpointCallCount() int { + fake.getFilesystemMountpointMutex.RLock() + defer fake.getFilesystemMountpointMutex.RUnlock() + return len(fake.getFilesystemMountpointArgsForCall) } -func (fake *FakeSpectrumScaleConnector) UnlinkFilesetArgsForCall(i int) (string, string) { - fake.unlinkFilesetMutex.RLock() - defer fake.unlinkFilesetMutex.RUnlock() - return fake.unlinkFilesetArgsForCall[i].filesystemName, fake.unlinkFilesetArgsForCall[i].filesetName +func (fake *FakeSpectrumScaleConnector) GetFilesystemMountpointCalls(stub func(string) (string, error)) { + fake.getFilesystemMountpointMutex.Lock() + defer fake.getFilesystemMountpointMutex.Unlock() + fake.GetFilesystemMountpointStub = stub } -func (fake *FakeSpectrumScaleConnector) UnlinkFilesetReturns(result1 error) { - fake.UnlinkFilesetStub = nil - fake.unlinkFilesetReturns = struct { - result1 error - }{result1} +func (fake *FakeSpectrumScaleConnector) GetFilesystemMountpointArgsForCall(i int) string { + fake.getFilesystemMountpointMutex.RLock() + defer fake.getFilesystemMountpointMutex.RUnlock() + argsForCall := fake.getFilesystemMountpointArgsForCall[i] + return argsForCall.arg1 } -func (fake *FakeSpectrumScaleConnector) UnlinkFilesetReturnsOnCall(i int, result1 error) { - fake.UnlinkFilesetStub = nil - if fake.unlinkFilesetReturnsOnCall == nil { - fake.unlinkFilesetReturnsOnCall = make(map[int]struct { - result1 error +func (fake *FakeSpectrumScaleConnector) GetFilesystemMountpointReturns(result1 string, result2 error) { + fake.getFilesystemMountpointMutex.Lock() + defer fake.getFilesystemMountpointMutex.Unlock() + fake.GetFilesystemMountpointStub = nil + fake.getFilesystemMountpointReturns = struct { + result1 string + result2 error + }{result1, result2} +} + +func (fake *FakeSpectrumScaleConnector) GetFilesystemMountpointReturnsOnCall(i int, result1 string, result2 error) { + fake.getFilesystemMountpointMutex.Lock() + defer fake.getFilesystemMountpointMutex.Unlock() + fake.GetFilesystemMountpointStub = nil + if fake.getFilesystemMountpointReturnsOnCall == nil { + fake.getFilesystemMountpointReturnsOnCall = make(map[int]struct { + result1 string + result2 error }) } - fake.unlinkFilesetReturnsOnCall[i] = struct { - result1 error - }{result1} + fake.getFilesystemMountpointReturnsOnCall[i] = struct { + result1 string + result2 error + }{result1, result2} } -func (fake *FakeSpectrumScaleConnector) ListFilesets(filesystemName string) ([]resources.Volume, error) { - fake.listFilesetsMutex.Lock() - ret, specificReturn := fake.listFilesetsReturnsOnCall[len(fake.listFilesetsArgsForCall)] - fake.listFilesetsArgsForCall = append(fake.listFilesetsArgsForCall, struct { - filesystemName string - }{filesystemName}) - fake.recordInvocation("ListFilesets", []interface{}{filesystemName}) - fake.listFilesetsMutex.Unlock() - if fake.ListFilesetsStub != nil { - return fake.ListFilesetsStub(filesystemName) +func (fake *FakeSpectrumScaleConnector) IsFilesetLinked(arg1 string, arg2 string) (bool, error) { + fake.isFilesetLinkedMutex.Lock() + ret, specificReturn := fake.isFilesetLinkedReturnsOnCall[len(fake.isFilesetLinkedArgsForCall)] + fake.isFilesetLinkedArgsForCall = append(fake.isFilesetLinkedArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("IsFilesetLinked", []interface{}{arg1, arg2}) + fake.isFilesetLinkedMutex.Unlock() + if fake.IsFilesetLinkedStub != nil { + return fake.IsFilesetLinkedStub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - return fake.listFilesetsReturns.result1, fake.listFilesetsReturns.result2 + fakeReturns := fake.isFilesetLinkedReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeSpectrumScaleConnector) ListFilesetsCallCount() int { - fake.listFilesetsMutex.RLock() - defer fake.listFilesetsMutex.RUnlock() - return len(fake.listFilesetsArgsForCall) +func (fake *FakeSpectrumScaleConnector) IsFilesetLinkedCallCount() int { + fake.isFilesetLinkedMutex.RLock() + defer fake.isFilesetLinkedMutex.RUnlock() + return len(fake.isFilesetLinkedArgsForCall) } -func (fake *FakeSpectrumScaleConnector) ListFilesetsArgsForCall(i int) string { - fake.listFilesetsMutex.RLock() - defer fake.listFilesetsMutex.RUnlock() - return fake.listFilesetsArgsForCall[i].filesystemName +func (fake *FakeSpectrumScaleConnector) IsFilesetLinkedCalls(stub func(string, string) (bool, error)) { + fake.isFilesetLinkedMutex.Lock() + defer fake.isFilesetLinkedMutex.Unlock() + fake.IsFilesetLinkedStub = stub +} + +func (fake *FakeSpectrumScaleConnector) IsFilesetLinkedArgsForCall(i int) (string, string) { + fake.isFilesetLinkedMutex.RLock() + defer fake.isFilesetLinkedMutex.RUnlock() + argsForCall := fake.isFilesetLinkedArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeSpectrumScaleConnector) IsFilesetLinkedReturns(result1 bool, result2 error) { + fake.isFilesetLinkedMutex.Lock() + defer fake.isFilesetLinkedMutex.Unlock() + fake.IsFilesetLinkedStub = nil + fake.isFilesetLinkedReturns = struct { + result1 bool + result2 error + }{result1, result2} +} + +func (fake *FakeSpectrumScaleConnector) IsFilesetLinkedReturnsOnCall(i int, result1 bool, result2 error) { + fake.isFilesetLinkedMutex.Lock() + defer fake.isFilesetLinkedMutex.Unlock() + fake.IsFilesetLinkedStub = nil + if fake.isFilesetLinkedReturnsOnCall == nil { + fake.isFilesetLinkedReturnsOnCall = make(map[int]struct { + result1 bool + result2 error + }) + } + fake.isFilesetLinkedReturnsOnCall[i] = struct { + result1 bool + result2 error + }{result1, result2} +} + +func (fake *FakeSpectrumScaleConnector) IsFilesystemMounted(arg1 string) (bool, error) { + fake.isFilesystemMountedMutex.Lock() + ret, specificReturn := fake.isFilesystemMountedReturnsOnCall[len(fake.isFilesystemMountedArgsForCall)] + fake.isFilesystemMountedArgsForCall = append(fake.isFilesystemMountedArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("IsFilesystemMounted", []interface{}{arg1}) + fake.isFilesystemMountedMutex.Unlock() + if fake.IsFilesystemMountedStub != nil { + return fake.IsFilesystemMountedStub(arg1) + } + if specificReturn { + return ret.result1, ret.result2 + } + fakeReturns := fake.isFilesystemMountedReturns + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeSpectrumScaleConnector) IsFilesystemMountedCallCount() int { + fake.isFilesystemMountedMutex.RLock() + defer fake.isFilesystemMountedMutex.RUnlock() + return len(fake.isFilesystemMountedArgsForCall) +} + +func (fake *FakeSpectrumScaleConnector) IsFilesystemMountedCalls(stub func(string) (bool, error)) { + fake.isFilesystemMountedMutex.Lock() + defer fake.isFilesystemMountedMutex.Unlock() + fake.IsFilesystemMountedStub = stub +} + +func (fake *FakeSpectrumScaleConnector) IsFilesystemMountedArgsForCall(i int) string { + fake.isFilesystemMountedMutex.RLock() + defer fake.isFilesystemMountedMutex.RUnlock() + argsForCall := fake.isFilesystemMountedArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeSpectrumScaleConnector) IsFilesystemMountedReturns(result1 bool, result2 error) { + fake.isFilesystemMountedMutex.Lock() + defer fake.isFilesystemMountedMutex.Unlock() + fake.IsFilesystemMountedStub = nil + fake.isFilesystemMountedReturns = struct { + result1 bool + result2 error + }{result1, result2} +} + +func (fake *FakeSpectrumScaleConnector) IsFilesystemMountedReturnsOnCall(i int, result1 bool, result2 error) { + fake.isFilesystemMountedMutex.Lock() + defer fake.isFilesystemMountedMutex.Unlock() + fake.IsFilesystemMountedStub = nil + if fake.isFilesystemMountedReturnsOnCall == nil { + fake.isFilesystemMountedReturnsOnCall = make(map[int]struct { + result1 bool + result2 error + }) + } + fake.isFilesystemMountedReturnsOnCall[i] = struct { + result1 bool + result2 error + }{result1, result2} +} + +func (fake *FakeSpectrumScaleConnector) LinkFileset(arg1 string, arg2 string) error { + fake.linkFilesetMutex.Lock() + ret, specificReturn := fake.linkFilesetReturnsOnCall[len(fake.linkFilesetArgsForCall)] + fake.linkFilesetArgsForCall = append(fake.linkFilesetArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("LinkFileset", []interface{}{arg1, arg2}) + fake.linkFilesetMutex.Unlock() + if fake.LinkFilesetStub != nil { + return fake.LinkFilesetStub(arg1, arg2) + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.linkFilesetReturns + return fakeReturns.result1 +} + +func (fake *FakeSpectrumScaleConnector) LinkFilesetCallCount() int { + fake.linkFilesetMutex.RLock() + defer fake.linkFilesetMutex.RUnlock() + return len(fake.linkFilesetArgsForCall) +} + +func (fake *FakeSpectrumScaleConnector) LinkFilesetCalls(stub func(string, string) error) { + fake.linkFilesetMutex.Lock() + defer fake.linkFilesetMutex.Unlock() + fake.LinkFilesetStub = stub +} + +func (fake *FakeSpectrumScaleConnector) LinkFilesetArgsForCall(i int) (string, string) { + fake.linkFilesetMutex.RLock() + defer fake.linkFilesetMutex.RUnlock() + argsForCall := fake.linkFilesetArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } -func (fake *FakeSpectrumScaleConnector) ListFilesetsReturns(result1 []resources.Volume, result2 error) { - fake.ListFilesetsStub = nil - fake.listFilesetsReturns = struct { - result1 []resources.Volume - result2 error - }{result1, result2} +func (fake *FakeSpectrumScaleConnector) LinkFilesetReturns(result1 error) { + fake.linkFilesetMutex.Lock() + defer fake.linkFilesetMutex.Unlock() + fake.LinkFilesetStub = nil + fake.linkFilesetReturns = struct { + result1 error + }{result1} } -func (fake *FakeSpectrumScaleConnector) ListFilesetsReturnsOnCall(i int, result1 []resources.Volume, result2 error) { - fake.ListFilesetsStub = nil - if fake.listFilesetsReturnsOnCall == nil { - fake.listFilesetsReturnsOnCall = make(map[int]struct { - result1 []resources.Volume - result2 error +func (fake *FakeSpectrumScaleConnector) LinkFilesetReturnsOnCall(i int, result1 error) { + fake.linkFilesetMutex.Lock() + defer fake.linkFilesetMutex.Unlock() + fake.LinkFilesetStub = nil + if fake.linkFilesetReturnsOnCall == nil { + fake.linkFilesetReturnsOnCall = make(map[int]struct { + result1 error }) } - fake.listFilesetsReturnsOnCall[i] = struct { - result1 []resources.Volume - result2 error - }{result1, result2} + fake.linkFilesetReturnsOnCall[i] = struct { + result1 error + }{result1} } -func (fake *FakeSpectrumScaleConnector) ListFileset(filesystemName string, filesetName string) (resources.Volume, error) { +func (fake *FakeSpectrumScaleConnector) ListFileset(arg1 string, arg2 string) (resources.Volume, error) { fake.listFilesetMutex.Lock() ret, specificReturn := fake.listFilesetReturnsOnCall[len(fake.listFilesetArgsForCall)] fake.listFilesetArgsForCall = append(fake.listFilesetArgsForCall, struct { - filesystemName string - filesetName string - }{filesystemName, filesetName}) - fake.recordInvocation("ListFileset", []interface{}{filesystemName, filesetName}) + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("ListFileset", []interface{}{arg1, arg2}) fake.listFilesetMutex.Unlock() if fake.ListFilesetStub != nil { - return fake.ListFilesetStub(filesystemName, filesetName) + return fake.ListFilesetStub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - return fake.listFilesetReturns.result1, fake.listFilesetReturns.result2 + fakeReturns := fake.listFilesetReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeSpectrumScaleConnector) ListFilesetCallCount() int { @@ -691,13 +705,22 @@ func (fake *FakeSpectrumScaleConnector) ListFilesetCallCount() int { return len(fake.listFilesetArgsForCall) } +func (fake *FakeSpectrumScaleConnector) ListFilesetCalls(stub func(string, string) (resources.Volume, error)) { + fake.listFilesetMutex.Lock() + defer fake.listFilesetMutex.Unlock() + fake.ListFilesetStub = stub +} + func (fake *FakeSpectrumScaleConnector) ListFilesetArgsForCall(i int) (string, string) { fake.listFilesetMutex.RLock() defer fake.listFilesetMutex.RUnlock() - return fake.listFilesetArgsForCall[i].filesystemName, fake.listFilesetArgsForCall[i].filesetName + argsForCall := fake.listFilesetArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } func (fake *FakeSpectrumScaleConnector) ListFilesetReturns(result1 resources.Volume, result2 error) { + fake.listFilesetMutex.Lock() + defer fake.listFilesetMutex.Unlock() fake.ListFilesetStub = nil fake.listFilesetReturns = struct { result1 resources.Volume @@ -706,6 +729,8 @@ func (fake *FakeSpectrumScaleConnector) ListFilesetReturns(result1 resources.Vol } func (fake *FakeSpectrumScaleConnector) ListFilesetReturnsOnCall(i int, result1 resources.Volume, result2 error) { + fake.listFilesetMutex.Lock() + defer fake.listFilesetMutex.Unlock() fake.ListFilesetStub = nil if fake.listFilesetReturnsOnCall == nil { fake.listFilesetReturnsOnCall = make(map[int]struct { @@ -719,176 +744,206 @@ func (fake *FakeSpectrumScaleConnector) ListFilesetReturnsOnCall(i int, result1 }{result1, result2} } -func (fake *FakeSpectrumScaleConnector) IsFilesetLinked(filesystemName string, filesetName string) (bool, error) { - fake.isFilesetLinkedMutex.Lock() - ret, specificReturn := fake.isFilesetLinkedReturnsOnCall[len(fake.isFilesetLinkedArgsForCall)] - fake.isFilesetLinkedArgsForCall = append(fake.isFilesetLinkedArgsForCall, struct { - filesystemName string - filesetName string - }{filesystemName, filesetName}) - fake.recordInvocation("IsFilesetLinked", []interface{}{filesystemName, filesetName}) - fake.isFilesetLinkedMutex.Unlock() - if fake.IsFilesetLinkedStub != nil { - return fake.IsFilesetLinkedStub(filesystemName, filesetName) +func (fake *FakeSpectrumScaleConnector) ListFilesetQuota(arg1 string, arg2 string) (string, error) { + fake.listFilesetQuotaMutex.Lock() + ret, specificReturn := fake.listFilesetQuotaReturnsOnCall[len(fake.listFilesetQuotaArgsForCall)] + fake.listFilesetQuotaArgsForCall = append(fake.listFilesetQuotaArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("ListFilesetQuota", []interface{}{arg1, arg2}) + fake.listFilesetQuotaMutex.Unlock() + if fake.ListFilesetQuotaStub != nil { + return fake.ListFilesetQuotaStub(arg1, arg2) } if specificReturn { return ret.result1, ret.result2 } - return fake.isFilesetLinkedReturns.result1, fake.isFilesetLinkedReturns.result2 + fakeReturns := fake.listFilesetQuotaReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeSpectrumScaleConnector) IsFilesetLinkedCallCount() int { - fake.isFilesetLinkedMutex.RLock() - defer fake.isFilesetLinkedMutex.RUnlock() - return len(fake.isFilesetLinkedArgsForCall) +func (fake *FakeSpectrumScaleConnector) ListFilesetQuotaCallCount() int { + fake.listFilesetQuotaMutex.RLock() + defer fake.listFilesetQuotaMutex.RUnlock() + return len(fake.listFilesetQuotaArgsForCall) } -func (fake *FakeSpectrumScaleConnector) IsFilesetLinkedArgsForCall(i int) (string, string) { - fake.isFilesetLinkedMutex.RLock() - defer fake.isFilesetLinkedMutex.RUnlock() - return fake.isFilesetLinkedArgsForCall[i].filesystemName, fake.isFilesetLinkedArgsForCall[i].filesetName +func (fake *FakeSpectrumScaleConnector) ListFilesetQuotaCalls(stub func(string, string) (string, error)) { + fake.listFilesetQuotaMutex.Lock() + defer fake.listFilesetQuotaMutex.Unlock() + fake.ListFilesetQuotaStub = stub } -func (fake *FakeSpectrumScaleConnector) IsFilesetLinkedReturns(result1 bool, result2 error) { - fake.IsFilesetLinkedStub = nil - fake.isFilesetLinkedReturns = struct { - result1 bool +func (fake *FakeSpectrumScaleConnector) ListFilesetQuotaArgsForCall(i int) (string, string) { + fake.listFilesetQuotaMutex.RLock() + defer fake.listFilesetQuotaMutex.RUnlock() + argsForCall := fake.listFilesetQuotaArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeSpectrumScaleConnector) ListFilesetQuotaReturns(result1 string, result2 error) { + fake.listFilesetQuotaMutex.Lock() + defer fake.listFilesetQuotaMutex.Unlock() + fake.ListFilesetQuotaStub = nil + fake.listFilesetQuotaReturns = struct { + result1 string result2 error }{result1, result2} } -func (fake *FakeSpectrumScaleConnector) IsFilesetLinkedReturnsOnCall(i int, result1 bool, result2 error) { - fake.IsFilesetLinkedStub = nil - if fake.isFilesetLinkedReturnsOnCall == nil { - fake.isFilesetLinkedReturnsOnCall = make(map[int]struct { - result1 bool +func (fake *FakeSpectrumScaleConnector) ListFilesetQuotaReturnsOnCall(i int, result1 string, result2 error) { + fake.listFilesetQuotaMutex.Lock() + defer fake.listFilesetQuotaMutex.Unlock() + fake.ListFilesetQuotaStub = nil + if fake.listFilesetQuotaReturnsOnCall == nil { + fake.listFilesetQuotaReturnsOnCall = make(map[int]struct { + result1 string result2 error }) } - fake.isFilesetLinkedReturnsOnCall[i] = struct { - result1 bool + fake.listFilesetQuotaReturnsOnCall[i] = struct { + result1 string result2 error }{result1, result2} } -func (fake *FakeSpectrumScaleConnector) CheckIfFSQuotaEnabled(filesystemName string) (error) { - fake.checkIfFSQuotaEnabledMutex.Lock() - ret, specificReturn := fake.checkIfFSQuotaEnabledReturnsOnCall[len(fake.checkIfFSQuotaEnabledArgsForCall)] - fake.checkIfFSQuotaEnabledArgsForCall = append(fake.checkIfFSQuotaEnabledArgsForCall, struct { - filesystemName string - }{filesystemName}) - fake.recordInvocation("CheckIfFSQuotaEnabled", []interface{}{filesystemName}) - fake.checkIfFSQuotaEnabledMutex.Unlock() - if fake.CheckIfFSQuotaEnabledStub != nil { - return fake.CheckIfFSQuotaEnabledStub(filesystemName) +func (fake *FakeSpectrumScaleConnector) ListFilesets(arg1 string) ([]resources.Volume, error) { + fake.listFilesetsMutex.Lock() + ret, specificReturn := fake.listFilesetsReturnsOnCall[len(fake.listFilesetsArgsForCall)] + fake.listFilesetsArgsForCall = append(fake.listFilesetsArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("ListFilesets", []interface{}{arg1}) + fake.listFilesetsMutex.Unlock() + if fake.ListFilesetsStub != nil { + return fake.ListFilesetsStub(arg1) } if specificReturn { - return ret.result1 + return ret.result1, ret.result2 } - return fake.checkIfFSQuotaEnabledReturns.result1 + fakeReturns := fake.listFilesetsReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeSpectrumScaleConnector) CheckIfFSQuotaEnabledCallCount() int { - fake.checkIfFSQuotaEnabledMutex.RLock() - defer fake.checkIfFSQuotaEnabledMutex.RUnlock() - return len(fake.checkIfFSQuotaEnabledArgsForCall) +func (fake *FakeSpectrumScaleConnector) ListFilesetsCallCount() int { + fake.listFilesetsMutex.RLock() + defer fake.listFilesetsMutex.RUnlock() + return len(fake.listFilesetsArgsForCall) } -func (fake *FakeSpectrumScaleConnector) CheckIfFSQuotaEnabledArgsForCall(i int) (string) { - fake.checkIfFSQuotaEnabledMutex.RLock() - defer fake.checkIfFSQuotaEnabledMutex.RUnlock() - return fake.checkIfFSQuotaEnabledArgsForCall[i].filesystemName +func (fake *FakeSpectrumScaleConnector) ListFilesetsCalls(stub func(string) ([]resources.Volume, error)) { + fake.listFilesetsMutex.Lock() + defer fake.listFilesetsMutex.Unlock() + fake.ListFilesetsStub = stub } -func (fake *FakeSpectrumScaleConnector) CheckIfFSQuotaEnabledReturns(result1 error) { - fake.CheckIfFSQuotaEnabledStub = nil - fake.checkIfFSQuotaEnabledReturns = struct { - result1 error - }{result1} +func (fake *FakeSpectrumScaleConnector) ListFilesetsArgsForCall(i int) string { + fake.listFilesetsMutex.RLock() + defer fake.listFilesetsMutex.RUnlock() + argsForCall := fake.listFilesetsArgsForCall[i] + return argsForCall.arg1 } -func (fake *FakeSpectrumScaleConnector) CheckIfFSQuotaEnabledReturnsOnCall(i int, result1 error) { - fake.CheckIfFSQuotaEnabledStub = nil - if fake.checkIfFSQuotaEnabledReturnsOnCall == nil { - fake.checkIfFSQuotaEnabledReturnsOnCall = make(map[int]struct { - result1 error +func (fake *FakeSpectrumScaleConnector) ListFilesetsReturns(result1 []resources.Volume, result2 error) { + fake.listFilesetsMutex.Lock() + defer fake.listFilesetsMutex.Unlock() + fake.ListFilesetsStub = nil + fake.listFilesetsReturns = struct { + result1 []resources.Volume + result2 error + }{result1, result2} +} + +func (fake *FakeSpectrumScaleConnector) ListFilesetsReturnsOnCall(i int, result1 []resources.Volume, result2 error) { + fake.listFilesetsMutex.Lock() + defer fake.listFilesetsMutex.Unlock() + fake.ListFilesetsStub = nil + if fake.listFilesetsReturnsOnCall == nil { + fake.listFilesetsReturnsOnCall = make(map[int]struct { + result1 []resources.Volume + result2 error }) } - fake.checkIfFSQuotaEnabledReturnsOnCall[i] = struct { - result1 error - }{result1} + fake.listFilesetsReturnsOnCall[i] = struct { + result1 []resources.Volume + result2 error + }{result1, result2} } +func (fake *FakeSpectrumScaleConnector) ListFilesystems() ([]string, error) { + fake.listFilesystemsMutex.Lock() + ret, specificReturn := fake.listFilesystemsReturnsOnCall[len(fake.listFilesystemsArgsForCall)] + fake.listFilesystemsArgsForCall = append(fake.listFilesystemsArgsForCall, struct { + }{}) + fake.recordInvocation("ListFilesystems", []interface{}{}) + fake.listFilesystemsMutex.Unlock() + if fake.ListFilesystemsStub != nil { + return fake.ListFilesystemsStub() + } + if specificReturn { + return ret.result1, ret.result2 + } + fakeReturns := fake.listFilesystemsReturns + return fakeReturns.result1, fakeReturns.result2 +} -func (fake *FakeSpectrumScaleConnector) ListFilesetQuota(filesystemName string, filesetName string) (string, error) { - fake.listFilesetQuotaMutex.Lock() - ret, specificReturn := fake.listFilesetQuotaReturnsOnCall[len(fake.listFilesetQuotaArgsForCall)] - fake.listFilesetQuotaArgsForCall = append(fake.listFilesetQuotaArgsForCall, struct { - filesystemName string - filesetName string - }{filesystemName, filesetName}) - fake.recordInvocation("ListFilesetQuota", []interface{}{filesystemName, filesetName}) - fake.listFilesetQuotaMutex.Unlock() - if fake.ListFilesetQuotaStub != nil { - return fake.ListFilesetQuotaStub(filesystemName, filesetName) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fake.listFilesetQuotaReturns.result1, fake.listFilesetQuotaReturns.result2 +func (fake *FakeSpectrumScaleConnector) ListFilesystemsCallCount() int { + fake.listFilesystemsMutex.RLock() + defer fake.listFilesystemsMutex.RUnlock() + return len(fake.listFilesystemsArgsForCall) } -func (fake *FakeSpectrumScaleConnector) ListFilesetQuotaCallCount() int { - fake.listFilesetQuotaMutex.RLock() - defer fake.listFilesetQuotaMutex.RUnlock() - return len(fake.listFilesetQuotaArgsForCall) +func (fake *FakeSpectrumScaleConnector) ListFilesystemsCalls(stub func() ([]string, error)) { + fake.listFilesystemsMutex.Lock() + defer fake.listFilesystemsMutex.Unlock() + fake.ListFilesystemsStub = stub } -func (fake *FakeSpectrumScaleConnector) ListFilesetQuotaArgsForCall(i int) (string, string) { - fake.listFilesetQuotaMutex.RLock() - defer fake.listFilesetQuotaMutex.RUnlock() - return fake.listFilesetQuotaArgsForCall[i].filesystemName, fake.listFilesetQuotaArgsForCall[i].filesetName +func (fake *FakeSpectrumScaleConnector) ListFilesystemsReturns(result1 []string, result2 error) { + fake.listFilesystemsMutex.Lock() + defer fake.listFilesystemsMutex.Unlock() + fake.ListFilesystemsStub = nil + fake.listFilesystemsReturns = struct { + result1 []string + result2 error + }{result1, result2} } -func (fake *FakeSpectrumScaleConnector) ListFilesetQuotaReturns(result1 string, result2 error) { - fake.ListFilesetQuotaStub = nil - fake.listFilesetQuotaReturns = struct { - result1 string - result2 error - }{result1, result2} +func (fake *FakeSpectrumScaleConnector) ListFilesystemsReturnsOnCall(i int, result1 []string, result2 error) { + fake.listFilesystemsMutex.Lock() + defer fake.listFilesystemsMutex.Unlock() + fake.ListFilesystemsStub = nil + if fake.listFilesystemsReturnsOnCall == nil { + fake.listFilesystemsReturnsOnCall = make(map[int]struct { + result1 []string + result2 error + }) + } + fake.listFilesystemsReturnsOnCall[i] = struct { + result1 []string + result2 error + }{result1, result2} } -func (fake *FakeSpectrumScaleConnector) ListFilesetQuotaReturnsOnCall(i int, result1 string, result2 error) { - fake.ListFilesetQuotaStub = nil - if fake.listFilesetQuotaReturnsOnCall == nil { - fake.listFilesetQuotaReturnsOnCall = make(map[int]struct { - result1 string - result2 error - }) - } - fake.listFilesetQuotaReturnsOnCall[i] = struct { - result1 string - result2 error - }{result1, result2} -} - -func (fake *FakeSpectrumScaleConnector) SetFilesetQuota(filesystemName string, filesetName string, quota string) error { +func (fake *FakeSpectrumScaleConnector) SetFilesetQuota(arg1 string, arg2 string, arg3 string) error { fake.setFilesetQuotaMutex.Lock() ret, specificReturn := fake.setFilesetQuotaReturnsOnCall[len(fake.setFilesetQuotaArgsForCall)] fake.setFilesetQuotaArgsForCall = append(fake.setFilesetQuotaArgsForCall, struct { - filesystemName string - filesetName string - quota string - }{filesystemName, filesetName, quota}) - fake.recordInvocation("SetFilesetQuota", []interface{}{filesystemName, filesetName, quota}) + arg1 string + arg2 string + arg3 string + }{arg1, arg2, arg3}) + fake.recordInvocation("SetFilesetQuota", []interface{}{arg1, arg2, arg3}) fake.setFilesetQuotaMutex.Unlock() if fake.SetFilesetQuotaStub != nil { - return fake.SetFilesetQuotaStub(filesystemName, filesetName, quota) + return fake.SetFilesetQuotaStub(arg1, arg2, arg3) } if specificReturn { return ret.result1 } - return fake.setFilesetQuotaReturns.result1 + fakeReturns := fake.setFilesetQuotaReturns + return fakeReturns.result1 } func (fake *FakeSpectrumScaleConnector) SetFilesetQuotaCallCount() int { @@ -897,13 +952,22 @@ func (fake *FakeSpectrumScaleConnector) SetFilesetQuotaCallCount() int { return len(fake.setFilesetQuotaArgsForCall) } +func (fake *FakeSpectrumScaleConnector) SetFilesetQuotaCalls(stub func(string, string, string) error) { + fake.setFilesetQuotaMutex.Lock() + defer fake.setFilesetQuotaMutex.Unlock() + fake.SetFilesetQuotaStub = stub +} + func (fake *FakeSpectrumScaleConnector) SetFilesetQuotaArgsForCall(i int) (string, string, string) { fake.setFilesetQuotaMutex.RLock() defer fake.setFilesetQuotaMutex.RUnlock() - return fake.setFilesetQuotaArgsForCall[i].filesystemName, fake.setFilesetQuotaArgsForCall[i].filesetName, fake.setFilesetQuotaArgsForCall[i].quota + argsForCall := fake.setFilesetQuotaArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 } func (fake *FakeSpectrumScaleConnector) SetFilesetQuotaReturns(result1 error) { + fake.setFilesetQuotaMutex.Lock() + defer fake.setFilesetQuotaMutex.Unlock() fake.SetFilesetQuotaStub = nil fake.setFilesetQuotaReturns = struct { result1 error @@ -911,6 +975,8 @@ func (fake *FakeSpectrumScaleConnector) SetFilesetQuotaReturns(result1 error) { } func (fake *FakeSpectrumScaleConnector) SetFilesetQuotaReturnsOnCall(i int, result1 error) { + fake.setFilesetQuotaMutex.Lock() + defer fake.setFilesetQuotaMutex.Unlock() fake.SetFilesetQuotaStub = nil if fake.setFilesetQuotaReturnsOnCall == nil { fake.setFilesetQuotaReturnsOnCall = make(map[int]struct { @@ -922,99 +988,63 @@ func (fake *FakeSpectrumScaleConnector) SetFilesetQuotaReturnsOnCall(i int, resu }{result1} } -func (fake *FakeSpectrumScaleConnector) ExportNfs(volumeMountpoint string, clientConfig string) error { - fake.exportNfsMutex.Lock() - ret, specificReturn := fake.exportNfsReturnsOnCall[len(fake.exportNfsArgsForCall)] - fake.exportNfsArgsForCall = append(fake.exportNfsArgsForCall, struct { - volumeMountpoint string - clientConfig string - }{volumeMountpoint, clientConfig}) - fake.recordInvocation("ExportNfs", []interface{}{volumeMountpoint, clientConfig}) - fake.exportNfsMutex.Unlock() - if fake.ExportNfsStub != nil { - return fake.ExportNfsStub(volumeMountpoint, clientConfig) +func (fake *FakeSpectrumScaleConnector) UnlinkFileset(arg1 string, arg2 string) error { + fake.unlinkFilesetMutex.Lock() + ret, specificReturn := fake.unlinkFilesetReturnsOnCall[len(fake.unlinkFilesetArgsForCall)] + fake.unlinkFilesetArgsForCall = append(fake.unlinkFilesetArgsForCall, struct { + arg1 string + arg2 string + }{arg1, arg2}) + fake.recordInvocation("UnlinkFileset", []interface{}{arg1, arg2}) + fake.unlinkFilesetMutex.Unlock() + if fake.UnlinkFilesetStub != nil { + return fake.UnlinkFilesetStub(arg1, arg2) } if specificReturn { return ret.result1 } - return fake.exportNfsReturns.result1 -} - -func (fake *FakeSpectrumScaleConnector) ExportNfsCallCount() int { - fake.exportNfsMutex.RLock() - defer fake.exportNfsMutex.RUnlock() - return len(fake.exportNfsArgsForCall) -} - -func (fake *FakeSpectrumScaleConnector) ExportNfsArgsForCall(i int) (string, string) { - fake.exportNfsMutex.RLock() - defer fake.exportNfsMutex.RUnlock() - return fake.exportNfsArgsForCall[i].volumeMountpoint, fake.exportNfsArgsForCall[i].clientConfig -} - -func (fake *FakeSpectrumScaleConnector) ExportNfsReturns(result1 error) { - fake.ExportNfsStub = nil - fake.exportNfsReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeSpectrumScaleConnector) ExportNfsReturnsOnCall(i int, result1 error) { - fake.ExportNfsStub = nil - if fake.exportNfsReturnsOnCall == nil { - fake.exportNfsReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.exportNfsReturnsOnCall[i] = struct { - result1 error - }{result1} + fakeReturns := fake.unlinkFilesetReturns + return fakeReturns.result1 } -func (fake *FakeSpectrumScaleConnector) UnexportNfs(volumeMountpoint string) error { - fake.unexportNfsMutex.Lock() - ret, specificReturn := fake.unexportNfsReturnsOnCall[len(fake.unexportNfsArgsForCall)] - fake.unexportNfsArgsForCall = append(fake.unexportNfsArgsForCall, struct { - volumeMountpoint string - }{volumeMountpoint}) - fake.recordInvocation("UnexportNfs", []interface{}{volumeMountpoint}) - fake.unexportNfsMutex.Unlock() - if fake.UnexportNfsStub != nil { - return fake.UnexportNfsStub(volumeMountpoint) - } - if specificReturn { - return ret.result1 - } - return fake.unexportNfsReturns.result1 +func (fake *FakeSpectrumScaleConnector) UnlinkFilesetCallCount() int { + fake.unlinkFilesetMutex.RLock() + defer fake.unlinkFilesetMutex.RUnlock() + return len(fake.unlinkFilesetArgsForCall) } -func (fake *FakeSpectrumScaleConnector) UnexportNfsCallCount() int { - fake.unexportNfsMutex.RLock() - defer fake.unexportNfsMutex.RUnlock() - return len(fake.unexportNfsArgsForCall) +func (fake *FakeSpectrumScaleConnector) UnlinkFilesetCalls(stub func(string, string) error) { + fake.unlinkFilesetMutex.Lock() + defer fake.unlinkFilesetMutex.Unlock() + fake.UnlinkFilesetStub = stub } -func (fake *FakeSpectrumScaleConnector) UnexportNfsArgsForCall(i int) string { - fake.unexportNfsMutex.RLock() - defer fake.unexportNfsMutex.RUnlock() - return fake.unexportNfsArgsForCall[i].volumeMountpoint +func (fake *FakeSpectrumScaleConnector) UnlinkFilesetArgsForCall(i int) (string, string) { + fake.unlinkFilesetMutex.RLock() + defer fake.unlinkFilesetMutex.RUnlock() + argsForCall := fake.unlinkFilesetArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 } -func (fake *FakeSpectrumScaleConnector) UnexportNfsReturns(result1 error) { - fake.UnexportNfsStub = nil - fake.unexportNfsReturns = struct { +func (fake *FakeSpectrumScaleConnector) UnlinkFilesetReturns(result1 error) { + fake.unlinkFilesetMutex.Lock() + defer fake.unlinkFilesetMutex.Unlock() + fake.UnlinkFilesetStub = nil + fake.unlinkFilesetReturns = struct { result1 error }{result1} } -func (fake *FakeSpectrumScaleConnector) UnexportNfsReturnsOnCall(i int, result1 error) { - fake.UnexportNfsStub = nil - if fake.unexportNfsReturnsOnCall == nil { - fake.unexportNfsReturnsOnCall = make(map[int]struct { +func (fake *FakeSpectrumScaleConnector) UnlinkFilesetReturnsOnCall(i int, result1 error) { + fake.unlinkFilesetMutex.Lock() + defer fake.unlinkFilesetMutex.Unlock() + fake.UnlinkFilesetStub = nil + if fake.unlinkFilesetReturnsOnCall == nil { + fake.unlinkFilesetReturnsOnCall = make(map[int]struct { result1 error }) } - fake.unexportNfsReturnsOnCall[i] = struct { + fake.unlinkFilesetReturnsOnCall[i] = struct { result1 error }{result1} } @@ -1022,39 +1052,39 @@ func (fake *FakeSpectrumScaleConnector) UnexportNfsReturnsOnCall(i int, result1 func (fake *FakeSpectrumScaleConnector) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() - fake.getClusterIdMutex.RLock() - defer fake.getClusterIdMutex.RUnlock() - fake.isFilesystemMountedMutex.RLock() - defer fake.isFilesystemMountedMutex.RUnlock() - fake.listFilesystemsMutex.RLock() - defer fake.listFilesystemsMutex.RUnlock() - fake.getFilesystemMountpointMutex.RLock() - defer fake.getFilesystemMountpointMutex.RUnlock() + fake.checkIfFSQuotaEnabledMutex.RLock() + defer fake.checkIfFSQuotaEnabledMutex.RUnlock() fake.createFilesetMutex.RLock() defer fake.createFilesetMutex.RUnlock() fake.deleteFilesetMutex.RLock() defer fake.deleteFilesetMutex.RUnlock() + fake.getClusterIdMutex.RLock() + defer fake.getClusterIdMutex.RUnlock() + fake.getFilesystemMountpointMutex.RLock() + defer fake.getFilesystemMountpointMutex.RUnlock() + fake.isFilesetLinkedMutex.RLock() + defer fake.isFilesetLinkedMutex.RUnlock() + fake.isFilesystemMountedMutex.RLock() + defer fake.isFilesystemMountedMutex.RUnlock() fake.linkFilesetMutex.RLock() defer fake.linkFilesetMutex.RUnlock() - fake.unlinkFilesetMutex.RLock() - defer fake.unlinkFilesetMutex.RUnlock() - fake.listFilesetsMutex.RLock() - defer fake.listFilesetsMutex.RUnlock() fake.listFilesetMutex.RLock() defer fake.listFilesetMutex.RUnlock() - fake.isFilesetLinkedMutex.RLock() - defer fake.isFilesetLinkedMutex.RUnlock() fake.listFilesetQuotaMutex.RLock() defer fake.listFilesetQuotaMutex.RUnlock() + fake.listFilesetsMutex.RLock() + defer fake.listFilesetsMutex.RUnlock() + fake.listFilesystemsMutex.RLock() + defer fake.listFilesystemsMutex.RUnlock() fake.setFilesetQuotaMutex.RLock() defer fake.setFilesetQuotaMutex.RUnlock() - fake.checkIfFSQuotaEnabledMutex.RLock() - defer fake.checkIfFSQuotaEnabledMutex.RUnlock() - fake.exportNfsMutex.RLock() - defer fake.exportNfsMutex.RUnlock() - fake.unexportNfsMutex.RLock() - defer fake.unexportNfsMutex.RUnlock() - return fake.invocations + fake.unlinkFilesetMutex.RLock() + defer fake.unlinkFilesetMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations } func (fake *FakeSpectrumScaleConnector) recordInvocation(key string, args []interface{}) { diff --git a/fakes/fake_storage_client.go b/fakes/fake_storage_client.go index b33aec93..19eeffb1 100644 --- a/fakes/fake_storage_client.go +++ b/fakes/fake_storage_client.go @@ -1,20 +1,4 @@ -/** - * Copyright 2016, 2017 IBM Corp. - * - * 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. - */ - -// This file was generated by counterfeiter +// Code generated by counterfeiter. DO NOT EDIT. package fakes import ( @@ -24,10 +8,10 @@ import ( ) type FakeStorageClient struct { - ActivateStub func(activateRequest resources.ActivateRequest) error + ActivateStub func(resources.ActivateRequest) error activateMutex sync.RWMutex activateArgsForCall []struct { - activateRequest resources.ActivateRequest + arg1 resources.ActivateRequest } activateReturns struct { result1 error @@ -35,10 +19,23 @@ type FakeStorageClient struct { activateReturnsOnCall map[int]struct { result1 error } - CreateVolumeStub func(createVolumeRequest resources.CreateVolumeRequest) error + AttachStub func(resources.AttachRequest) (string, error) + attachMutex sync.RWMutex + attachArgsForCall []struct { + arg1 resources.AttachRequest + } + attachReturns struct { + result1 string + result2 error + } + attachReturnsOnCall map[int]struct { + result1 string + result2 error + } + CreateVolumeStub func(resources.CreateVolumeRequest) error createVolumeMutex sync.RWMutex createVolumeArgsForCall []struct { - createVolumeRequest resources.CreateVolumeRequest + arg1 resources.CreateVolumeRequest } createVolumeReturns struct { result1 error @@ -46,34 +43,21 @@ type FakeStorageClient struct { createVolumeReturnsOnCall map[int]struct { result1 error } - RemoveVolumeStub func(removeVolumeRequest resources.RemoveVolumeRequest) error - removeVolumeMutex sync.RWMutex - removeVolumeArgsForCall []struct { - removeVolumeRequest resources.RemoveVolumeRequest + DetachStub func(resources.DetachRequest) error + detachMutex sync.RWMutex + detachArgsForCall []struct { + arg1 resources.DetachRequest } - removeVolumeReturns struct { + detachReturns struct { result1 error } - removeVolumeReturnsOnCall map[int]struct { + detachReturnsOnCall map[int]struct { result1 error } - ListVolumesStub func(listVolumeRequest resources.ListVolumesRequest) ([]resources.Volume, error) - listVolumesMutex sync.RWMutex - listVolumesArgsForCall []struct { - listVolumeRequest resources.ListVolumesRequest - } - listVolumesReturns struct { - result1 []resources.Volume - result2 error - } - listVolumesReturnsOnCall map[int]struct { - result1 []resources.Volume - result2 error - } - GetVolumeStub func(getVolumeRequest resources.GetVolumeRequest) (resources.Volume, error) + GetVolumeStub func(resources.GetVolumeRequest) (resources.Volume, error) getVolumeMutex sync.RWMutex getVolumeArgsForCall []struct { - getVolumeRequest resources.GetVolumeRequest + arg1 resources.GetVolumeRequest } getVolumeReturns struct { result1 resources.Volume @@ -83,10 +67,10 @@ type FakeStorageClient struct { result1 resources.Volume result2 error } - GetVolumeConfigStub func(getVolumeConfigRequest resources.GetVolumeConfigRequest) (map[string]interface{}, error) + GetVolumeConfigStub func(resources.GetVolumeConfigRequest) (map[string]interface{}, error) getVolumeConfigMutex sync.RWMutex getVolumeConfigArgsForCall []struct { - getVolumeConfigRequest resources.GetVolumeConfigRequest + arg1 resources.GetVolumeConfigRequest } getVolumeConfigReturns struct { result1 map[string]interface{} @@ -96,49 +80,50 @@ type FakeStorageClient struct { result1 map[string]interface{} result2 error } - AttachStub func(attachRequest resources.AttachRequest) (string, error) - attachMutex sync.RWMutex - attachArgsForCall []struct { - attachRequest resources.AttachRequest + ListVolumesStub func(resources.ListVolumesRequest) ([]resources.Volume, error) + listVolumesMutex sync.RWMutex + listVolumesArgsForCall []struct { + arg1 resources.ListVolumesRequest } - attachReturns struct { - result1 string + listVolumesReturns struct { + result1 []resources.Volume result2 error } - attachReturnsOnCall map[int]struct { - result1 string + listVolumesReturnsOnCall map[int]struct { + result1 []resources.Volume result2 error } - DetachStub func(detachRequest resources.DetachRequest) error - detachMutex sync.RWMutex - detachArgsForCall []struct { - detachRequest resources.DetachRequest + RemoveVolumeStub func(resources.RemoveVolumeRequest) error + removeVolumeMutex sync.RWMutex + removeVolumeArgsForCall []struct { + arg1 resources.RemoveVolumeRequest } - detachReturns struct { + removeVolumeReturns struct { result1 error } - detachReturnsOnCall map[int]struct { + removeVolumeReturnsOnCall map[int]struct { result1 error } invocations map[string][][]interface{} invocationsMutex sync.RWMutex } -func (fake *FakeStorageClient) Activate(activateRequest resources.ActivateRequest) error { +func (fake *FakeStorageClient) Activate(arg1 resources.ActivateRequest) error { fake.activateMutex.Lock() ret, specificReturn := fake.activateReturnsOnCall[len(fake.activateArgsForCall)] fake.activateArgsForCall = append(fake.activateArgsForCall, struct { - activateRequest resources.ActivateRequest - }{activateRequest}) - fake.recordInvocation("Activate", []interface{}{activateRequest}) + arg1 resources.ActivateRequest + }{arg1}) + fake.recordInvocation("Activate", []interface{}{arg1}) fake.activateMutex.Unlock() if fake.ActivateStub != nil { - return fake.ActivateStub(activateRequest) + return fake.ActivateStub(arg1) } if specificReturn { return ret.result1 } - return fake.activateReturns.result1 + fakeReturns := fake.activateReturns + return fakeReturns.result1 } func (fake *FakeStorageClient) ActivateCallCount() int { @@ -147,13 +132,22 @@ func (fake *FakeStorageClient) ActivateCallCount() int { return len(fake.activateArgsForCall) } +func (fake *FakeStorageClient) ActivateCalls(stub func(resources.ActivateRequest) error) { + fake.activateMutex.Lock() + defer fake.activateMutex.Unlock() + fake.ActivateStub = stub +} + func (fake *FakeStorageClient) ActivateArgsForCall(i int) resources.ActivateRequest { fake.activateMutex.RLock() defer fake.activateMutex.RUnlock() - return fake.activateArgsForCall[i].activateRequest + argsForCall := fake.activateArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeStorageClient) ActivateReturns(result1 error) { + fake.activateMutex.Lock() + defer fake.activateMutex.Unlock() fake.ActivateStub = nil fake.activateReturns = struct { result1 error @@ -161,6 +155,8 @@ func (fake *FakeStorageClient) ActivateReturns(result1 error) { } func (fake *FakeStorageClient) ActivateReturnsOnCall(i int, result1 error) { + fake.activateMutex.Lock() + defer fake.activateMutex.Unlock() fake.ActivateStub = nil if fake.activateReturnsOnCall == nil { fake.activateReturnsOnCall = make(map[int]struct { @@ -172,21 +168,85 @@ func (fake *FakeStorageClient) ActivateReturnsOnCall(i int, result1 error) { }{result1} } -func (fake *FakeStorageClient) CreateVolume(createVolumeRequest resources.CreateVolumeRequest) error { +func (fake *FakeStorageClient) Attach(arg1 resources.AttachRequest) (string, error) { + fake.attachMutex.Lock() + ret, specificReturn := fake.attachReturnsOnCall[len(fake.attachArgsForCall)] + fake.attachArgsForCall = append(fake.attachArgsForCall, struct { + arg1 resources.AttachRequest + }{arg1}) + fake.recordInvocation("Attach", []interface{}{arg1}) + fake.attachMutex.Unlock() + if fake.AttachStub != nil { + return fake.AttachStub(arg1) + } + if specificReturn { + return ret.result1, ret.result2 + } + fakeReturns := fake.attachReturns + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeStorageClient) AttachCallCount() int { + fake.attachMutex.RLock() + defer fake.attachMutex.RUnlock() + return len(fake.attachArgsForCall) +} + +func (fake *FakeStorageClient) AttachCalls(stub func(resources.AttachRequest) (string, error)) { + fake.attachMutex.Lock() + defer fake.attachMutex.Unlock() + fake.AttachStub = stub +} + +func (fake *FakeStorageClient) AttachArgsForCall(i int) resources.AttachRequest { + fake.attachMutex.RLock() + defer fake.attachMutex.RUnlock() + argsForCall := fake.attachArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeStorageClient) AttachReturns(result1 string, result2 error) { + fake.attachMutex.Lock() + defer fake.attachMutex.Unlock() + fake.AttachStub = nil + fake.attachReturns = struct { + result1 string + result2 error + }{result1, result2} +} + +func (fake *FakeStorageClient) AttachReturnsOnCall(i int, result1 string, result2 error) { + fake.attachMutex.Lock() + defer fake.attachMutex.Unlock() + fake.AttachStub = nil + if fake.attachReturnsOnCall == nil { + fake.attachReturnsOnCall = make(map[int]struct { + result1 string + result2 error + }) + } + fake.attachReturnsOnCall[i] = struct { + result1 string + result2 error + }{result1, result2} +} + +func (fake *FakeStorageClient) CreateVolume(arg1 resources.CreateVolumeRequest) error { fake.createVolumeMutex.Lock() ret, specificReturn := fake.createVolumeReturnsOnCall[len(fake.createVolumeArgsForCall)] fake.createVolumeArgsForCall = append(fake.createVolumeArgsForCall, struct { - createVolumeRequest resources.CreateVolumeRequest - }{createVolumeRequest}) - fake.recordInvocation("CreateVolume", []interface{}{createVolumeRequest}) + arg1 resources.CreateVolumeRequest + }{arg1}) + fake.recordInvocation("CreateVolume", []interface{}{arg1}) fake.createVolumeMutex.Unlock() if fake.CreateVolumeStub != nil { - return fake.CreateVolumeStub(createVolumeRequest) + return fake.CreateVolumeStub(arg1) } if specificReturn { return ret.result1 } - return fake.createVolumeReturns.result1 + fakeReturns := fake.createVolumeReturns + return fakeReturns.result1 } func (fake *FakeStorageClient) CreateVolumeCallCount() int { @@ -195,13 +255,22 @@ func (fake *FakeStorageClient) CreateVolumeCallCount() int { return len(fake.createVolumeArgsForCall) } +func (fake *FakeStorageClient) CreateVolumeCalls(stub func(resources.CreateVolumeRequest) error) { + fake.createVolumeMutex.Lock() + defer fake.createVolumeMutex.Unlock() + fake.CreateVolumeStub = stub +} + func (fake *FakeStorageClient) CreateVolumeArgsForCall(i int) resources.CreateVolumeRequest { fake.createVolumeMutex.RLock() defer fake.createVolumeMutex.RUnlock() - return fake.createVolumeArgsForCall[i].createVolumeRequest + argsForCall := fake.createVolumeArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeStorageClient) CreateVolumeReturns(result1 error) { + fake.createVolumeMutex.Lock() + defer fake.createVolumeMutex.Unlock() fake.CreateVolumeStub = nil fake.createVolumeReturns = struct { result1 error @@ -209,6 +278,8 @@ func (fake *FakeStorageClient) CreateVolumeReturns(result1 error) { } func (fake *FakeStorageClient) CreateVolumeReturnsOnCall(i int, result1 error) { + fake.createVolumeMutex.Lock() + defer fake.createVolumeMutex.Unlock() fake.CreateVolumeStub = nil if fake.createVolumeReturnsOnCall == nil { fake.createVolumeReturnsOnCall = make(map[int]struct { @@ -220,120 +291,82 @@ func (fake *FakeStorageClient) CreateVolumeReturnsOnCall(i int, result1 error) { }{result1} } -func (fake *FakeStorageClient) RemoveVolume(removeVolumeRequest resources.RemoveVolumeRequest) error { - fake.removeVolumeMutex.Lock() - ret, specificReturn := fake.removeVolumeReturnsOnCall[len(fake.removeVolumeArgsForCall)] - fake.removeVolumeArgsForCall = append(fake.removeVolumeArgsForCall, struct { - removeVolumeRequest resources.RemoveVolumeRequest - }{removeVolumeRequest}) - fake.recordInvocation("RemoveVolume", []interface{}{removeVolumeRequest}) - fake.removeVolumeMutex.Unlock() - if fake.RemoveVolumeStub != nil { - return fake.RemoveVolumeStub(removeVolumeRequest) +func (fake *FakeStorageClient) Detach(arg1 resources.DetachRequest) error { + fake.detachMutex.Lock() + ret, specificReturn := fake.detachReturnsOnCall[len(fake.detachArgsForCall)] + fake.detachArgsForCall = append(fake.detachArgsForCall, struct { + arg1 resources.DetachRequest + }{arg1}) + fake.recordInvocation("Detach", []interface{}{arg1}) + fake.detachMutex.Unlock() + if fake.DetachStub != nil { + return fake.DetachStub(arg1) } if specificReturn { return ret.result1 } - return fake.removeVolumeReturns.result1 + fakeReturns := fake.detachReturns + return fakeReturns.result1 } -func (fake *FakeStorageClient) RemoveVolumeCallCount() int { - fake.removeVolumeMutex.RLock() - defer fake.removeVolumeMutex.RUnlock() - return len(fake.removeVolumeArgsForCall) +func (fake *FakeStorageClient) DetachCallCount() int { + fake.detachMutex.RLock() + defer fake.detachMutex.RUnlock() + return len(fake.detachArgsForCall) } -func (fake *FakeStorageClient) RemoveVolumeArgsForCall(i int) resources.RemoveVolumeRequest { - fake.removeVolumeMutex.RLock() - defer fake.removeVolumeMutex.RUnlock() - return fake.removeVolumeArgsForCall[i].removeVolumeRequest +func (fake *FakeStorageClient) DetachCalls(stub func(resources.DetachRequest) error) { + fake.detachMutex.Lock() + defer fake.detachMutex.Unlock() + fake.DetachStub = stub } -func (fake *FakeStorageClient) RemoveVolumeReturns(result1 error) { - fake.RemoveVolumeStub = nil - fake.removeVolumeReturns = struct { +func (fake *FakeStorageClient) DetachArgsForCall(i int) resources.DetachRequest { + fake.detachMutex.RLock() + defer fake.detachMutex.RUnlock() + argsForCall := fake.detachArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeStorageClient) DetachReturns(result1 error) { + fake.detachMutex.Lock() + defer fake.detachMutex.Unlock() + fake.DetachStub = nil + fake.detachReturns = struct { result1 error }{result1} } -func (fake *FakeStorageClient) RemoveVolumeReturnsOnCall(i int, result1 error) { - fake.RemoveVolumeStub = nil - if fake.removeVolumeReturnsOnCall == nil { - fake.removeVolumeReturnsOnCall = make(map[int]struct { +func (fake *FakeStorageClient) DetachReturnsOnCall(i int, result1 error) { + fake.detachMutex.Lock() + defer fake.detachMutex.Unlock() + fake.DetachStub = nil + if fake.detachReturnsOnCall == nil { + fake.detachReturnsOnCall = make(map[int]struct { result1 error }) } - fake.removeVolumeReturnsOnCall[i] = struct { + fake.detachReturnsOnCall[i] = struct { result1 error }{result1} } -func (fake *FakeStorageClient) ListVolumes(listVolumeRequest resources.ListVolumesRequest) ([]resources.Volume, error) { - fake.listVolumesMutex.Lock() - ret, specificReturn := fake.listVolumesReturnsOnCall[len(fake.listVolumesArgsForCall)] - fake.listVolumesArgsForCall = append(fake.listVolumesArgsForCall, struct { - listVolumeRequest resources.ListVolumesRequest - }{listVolumeRequest}) - fake.recordInvocation("ListVolumes", []interface{}{listVolumeRequest}) - fake.listVolumesMutex.Unlock() - if fake.ListVolumesStub != nil { - return fake.ListVolumesStub(listVolumeRequest) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fake.listVolumesReturns.result1, fake.listVolumesReturns.result2 -} - -func (fake *FakeStorageClient) ListVolumesCallCount() int { - fake.listVolumesMutex.RLock() - defer fake.listVolumesMutex.RUnlock() - return len(fake.listVolumesArgsForCall) -} - -func (fake *FakeStorageClient) ListVolumesArgsForCall(i int) resources.ListVolumesRequest { - fake.listVolumesMutex.RLock() - defer fake.listVolumesMutex.RUnlock() - return fake.listVolumesArgsForCall[i].listVolumeRequest -} - -func (fake *FakeStorageClient) ListVolumesReturns(result1 []resources.Volume, result2 error) { - fake.ListVolumesStub = nil - fake.listVolumesReturns = struct { - result1 []resources.Volume - result2 error - }{result1, result2} -} - -func (fake *FakeStorageClient) ListVolumesReturnsOnCall(i int, result1 []resources.Volume, result2 error) { - fake.ListVolumesStub = nil - if fake.listVolumesReturnsOnCall == nil { - fake.listVolumesReturnsOnCall = make(map[int]struct { - result1 []resources.Volume - result2 error - }) - } - fake.listVolumesReturnsOnCall[i] = struct { - result1 []resources.Volume - result2 error - }{result1, result2} -} - -func (fake *FakeStorageClient) GetVolume(getVolumeRequest resources.GetVolumeRequest) (resources.Volume, error) { +func (fake *FakeStorageClient) GetVolume(arg1 resources.GetVolumeRequest) (resources.Volume, error) { fake.getVolumeMutex.Lock() ret, specificReturn := fake.getVolumeReturnsOnCall[len(fake.getVolumeArgsForCall)] fake.getVolumeArgsForCall = append(fake.getVolumeArgsForCall, struct { - getVolumeRequest resources.GetVolumeRequest - }{getVolumeRequest}) - fake.recordInvocation("GetVolume", []interface{}{getVolumeRequest}) + arg1 resources.GetVolumeRequest + }{arg1}) + fake.recordInvocation("GetVolume", []interface{}{arg1}) fake.getVolumeMutex.Unlock() if fake.GetVolumeStub != nil { - return fake.GetVolumeStub(getVolumeRequest) + return fake.GetVolumeStub(arg1) } if specificReturn { return ret.result1, ret.result2 } - return fake.getVolumeReturns.result1, fake.getVolumeReturns.result2 + fakeReturns := fake.getVolumeReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeStorageClient) GetVolumeCallCount() int { @@ -342,13 +375,22 @@ func (fake *FakeStorageClient) GetVolumeCallCount() int { return len(fake.getVolumeArgsForCall) } +func (fake *FakeStorageClient) GetVolumeCalls(stub func(resources.GetVolumeRequest) (resources.Volume, error)) { + fake.getVolumeMutex.Lock() + defer fake.getVolumeMutex.Unlock() + fake.GetVolumeStub = stub +} + func (fake *FakeStorageClient) GetVolumeArgsForCall(i int) resources.GetVolumeRequest { fake.getVolumeMutex.RLock() defer fake.getVolumeMutex.RUnlock() - return fake.getVolumeArgsForCall[i].getVolumeRequest + argsForCall := fake.getVolumeArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeStorageClient) GetVolumeReturns(result1 resources.Volume, result2 error) { + fake.getVolumeMutex.Lock() + defer fake.getVolumeMutex.Unlock() fake.GetVolumeStub = nil fake.getVolumeReturns = struct { result1 resources.Volume @@ -357,6 +399,8 @@ func (fake *FakeStorageClient) GetVolumeReturns(result1 resources.Volume, result } func (fake *FakeStorageClient) GetVolumeReturnsOnCall(i int, result1 resources.Volume, result2 error) { + fake.getVolumeMutex.Lock() + defer fake.getVolumeMutex.Unlock() fake.GetVolumeStub = nil if fake.getVolumeReturnsOnCall == nil { fake.getVolumeReturnsOnCall = make(map[int]struct { @@ -370,21 +414,22 @@ func (fake *FakeStorageClient) GetVolumeReturnsOnCall(i int, result1 resources.V }{result1, result2} } -func (fake *FakeStorageClient) GetVolumeConfig(getVolumeConfigRequest resources.GetVolumeConfigRequest) (map[string]interface{}, error) { +func (fake *FakeStorageClient) GetVolumeConfig(arg1 resources.GetVolumeConfigRequest) (map[string]interface{}, error) { fake.getVolumeConfigMutex.Lock() ret, specificReturn := fake.getVolumeConfigReturnsOnCall[len(fake.getVolumeConfigArgsForCall)] fake.getVolumeConfigArgsForCall = append(fake.getVolumeConfigArgsForCall, struct { - getVolumeConfigRequest resources.GetVolumeConfigRequest - }{getVolumeConfigRequest}) - fake.recordInvocation("GetVolumeConfig", []interface{}{getVolumeConfigRequest}) + arg1 resources.GetVolumeConfigRequest + }{arg1}) + fake.recordInvocation("GetVolumeConfig", []interface{}{arg1}) fake.getVolumeConfigMutex.Unlock() if fake.GetVolumeConfigStub != nil { - return fake.GetVolumeConfigStub(getVolumeConfigRequest) + return fake.GetVolumeConfigStub(arg1) } if specificReturn { return ret.result1, ret.result2 } - return fake.getVolumeConfigReturns.result1, fake.getVolumeConfigReturns.result2 + fakeReturns := fake.getVolumeConfigReturns + return fakeReturns.result1, fakeReturns.result2 } func (fake *FakeStorageClient) GetVolumeConfigCallCount() int { @@ -393,13 +438,22 @@ func (fake *FakeStorageClient) GetVolumeConfigCallCount() int { return len(fake.getVolumeConfigArgsForCall) } +func (fake *FakeStorageClient) GetVolumeConfigCalls(stub func(resources.GetVolumeConfigRequest) (map[string]interface{}, error)) { + fake.getVolumeConfigMutex.Lock() + defer fake.getVolumeConfigMutex.Unlock() + fake.GetVolumeConfigStub = stub +} + func (fake *FakeStorageClient) GetVolumeConfigArgsForCall(i int) resources.GetVolumeConfigRequest { fake.getVolumeConfigMutex.RLock() defer fake.getVolumeConfigMutex.RUnlock() - return fake.getVolumeConfigArgsForCall[i].getVolumeConfigRequest + argsForCall := fake.getVolumeConfigArgsForCall[i] + return argsForCall.arg1 } func (fake *FakeStorageClient) GetVolumeConfigReturns(result1 map[string]interface{}, result2 error) { + fake.getVolumeConfigMutex.Lock() + defer fake.getVolumeConfigMutex.Unlock() fake.GetVolumeConfigStub = nil fake.getVolumeConfigReturns = struct { result1 map[string]interface{} @@ -408,6 +462,8 @@ func (fake *FakeStorageClient) GetVolumeConfigReturns(result1 map[string]interfa } func (fake *FakeStorageClient) GetVolumeConfigReturnsOnCall(i int, result1 map[string]interface{}, result2 error) { + fake.getVolumeConfigMutex.Lock() + defer fake.getVolumeConfigMutex.Unlock() fake.GetVolumeConfigStub = nil if fake.getVolumeConfigReturnsOnCall == nil { fake.getVolumeConfigReturnsOnCall = make(map[int]struct { @@ -421,101 +477,125 @@ func (fake *FakeStorageClient) GetVolumeConfigReturnsOnCall(i int, result1 map[s }{result1, result2} } -func (fake *FakeStorageClient) Attach(attachRequest resources.AttachRequest) (string, error) { - fake.attachMutex.Lock() - ret, specificReturn := fake.attachReturnsOnCall[len(fake.attachArgsForCall)] - fake.attachArgsForCall = append(fake.attachArgsForCall, struct { - attachRequest resources.AttachRequest - }{attachRequest}) - fake.recordInvocation("Attach", []interface{}{attachRequest}) - fake.attachMutex.Unlock() - if fake.AttachStub != nil { - return fake.AttachStub(attachRequest) +func (fake *FakeStorageClient) ListVolumes(arg1 resources.ListVolumesRequest) ([]resources.Volume, error) { + fake.listVolumesMutex.Lock() + ret, specificReturn := fake.listVolumesReturnsOnCall[len(fake.listVolumesArgsForCall)] + fake.listVolumesArgsForCall = append(fake.listVolumesArgsForCall, struct { + arg1 resources.ListVolumesRequest + }{arg1}) + fake.recordInvocation("ListVolumes", []interface{}{arg1}) + fake.listVolumesMutex.Unlock() + if fake.ListVolumesStub != nil { + return fake.ListVolumesStub(arg1) } if specificReturn { return ret.result1, ret.result2 } - return fake.attachReturns.result1, fake.attachReturns.result2 + fakeReturns := fake.listVolumesReturns + return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeStorageClient) AttachCallCount() int { - fake.attachMutex.RLock() - defer fake.attachMutex.RUnlock() - return len(fake.attachArgsForCall) +func (fake *FakeStorageClient) ListVolumesCallCount() int { + fake.listVolumesMutex.RLock() + defer fake.listVolumesMutex.RUnlock() + return len(fake.listVolumesArgsForCall) } -func (fake *FakeStorageClient) AttachArgsForCall(i int) resources.AttachRequest { - fake.attachMutex.RLock() - defer fake.attachMutex.RUnlock() - return fake.attachArgsForCall[i].attachRequest +func (fake *FakeStorageClient) ListVolumesCalls(stub func(resources.ListVolumesRequest) ([]resources.Volume, error)) { + fake.listVolumesMutex.Lock() + defer fake.listVolumesMutex.Unlock() + fake.ListVolumesStub = stub } -func (fake *FakeStorageClient) AttachReturns(result1 string, result2 error) { - fake.AttachStub = nil - fake.attachReturns = struct { - result1 string +func (fake *FakeStorageClient) ListVolumesArgsForCall(i int) resources.ListVolumesRequest { + fake.listVolumesMutex.RLock() + defer fake.listVolumesMutex.RUnlock() + argsForCall := fake.listVolumesArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeStorageClient) ListVolumesReturns(result1 []resources.Volume, result2 error) { + fake.listVolumesMutex.Lock() + defer fake.listVolumesMutex.Unlock() + fake.ListVolumesStub = nil + fake.listVolumesReturns = struct { + result1 []resources.Volume result2 error }{result1, result2} } -func (fake *FakeStorageClient) AttachReturnsOnCall(i int, result1 string, result2 error) { - fake.AttachStub = nil - if fake.attachReturnsOnCall == nil { - fake.attachReturnsOnCall = make(map[int]struct { - result1 string +func (fake *FakeStorageClient) ListVolumesReturnsOnCall(i int, result1 []resources.Volume, result2 error) { + fake.listVolumesMutex.Lock() + defer fake.listVolumesMutex.Unlock() + fake.ListVolumesStub = nil + if fake.listVolumesReturnsOnCall == nil { + fake.listVolumesReturnsOnCall = make(map[int]struct { + result1 []resources.Volume result2 error }) } - fake.attachReturnsOnCall[i] = struct { - result1 string + fake.listVolumesReturnsOnCall[i] = struct { + result1 []resources.Volume result2 error }{result1, result2} } -func (fake *FakeStorageClient) Detach(detachRequest resources.DetachRequest) error { - fake.detachMutex.Lock() - ret, specificReturn := fake.detachReturnsOnCall[len(fake.detachArgsForCall)] - fake.detachArgsForCall = append(fake.detachArgsForCall, struct { - detachRequest resources.DetachRequest - }{detachRequest}) - fake.recordInvocation("Detach", []interface{}{detachRequest}) - fake.detachMutex.Unlock() - if fake.DetachStub != nil { - return fake.DetachStub(detachRequest) +func (fake *FakeStorageClient) RemoveVolume(arg1 resources.RemoveVolumeRequest) error { + fake.removeVolumeMutex.Lock() + ret, specificReturn := fake.removeVolumeReturnsOnCall[len(fake.removeVolumeArgsForCall)] + fake.removeVolumeArgsForCall = append(fake.removeVolumeArgsForCall, struct { + arg1 resources.RemoveVolumeRequest + }{arg1}) + fake.recordInvocation("RemoveVolume", []interface{}{arg1}) + fake.removeVolumeMutex.Unlock() + if fake.RemoveVolumeStub != nil { + return fake.RemoveVolumeStub(arg1) } if specificReturn { return ret.result1 } - return fake.detachReturns.result1 + fakeReturns := fake.removeVolumeReturns + return fakeReturns.result1 } -func (fake *FakeStorageClient) DetachCallCount() int { - fake.detachMutex.RLock() - defer fake.detachMutex.RUnlock() - return len(fake.detachArgsForCall) +func (fake *FakeStorageClient) RemoveVolumeCallCount() int { + fake.removeVolumeMutex.RLock() + defer fake.removeVolumeMutex.RUnlock() + return len(fake.removeVolumeArgsForCall) } -func (fake *FakeStorageClient) DetachArgsForCall(i int) resources.DetachRequest { - fake.detachMutex.RLock() - defer fake.detachMutex.RUnlock() - return fake.detachArgsForCall[i].detachRequest +func (fake *FakeStorageClient) RemoveVolumeCalls(stub func(resources.RemoveVolumeRequest) error) { + fake.removeVolumeMutex.Lock() + defer fake.removeVolumeMutex.Unlock() + fake.RemoveVolumeStub = stub } -func (fake *FakeStorageClient) DetachReturns(result1 error) { - fake.DetachStub = nil - fake.detachReturns = struct { +func (fake *FakeStorageClient) RemoveVolumeArgsForCall(i int) resources.RemoveVolumeRequest { + fake.removeVolumeMutex.RLock() + defer fake.removeVolumeMutex.RUnlock() + argsForCall := fake.removeVolumeArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeStorageClient) RemoveVolumeReturns(result1 error) { + fake.removeVolumeMutex.Lock() + defer fake.removeVolumeMutex.Unlock() + fake.RemoveVolumeStub = nil + fake.removeVolumeReturns = struct { result1 error }{result1} } -func (fake *FakeStorageClient) DetachReturnsOnCall(i int, result1 error) { - fake.DetachStub = nil - if fake.detachReturnsOnCall == nil { - fake.detachReturnsOnCall = make(map[int]struct { +func (fake *FakeStorageClient) RemoveVolumeReturnsOnCall(i int, result1 error) { + fake.removeVolumeMutex.Lock() + defer fake.removeVolumeMutex.Unlock() + fake.RemoveVolumeStub = nil + if fake.removeVolumeReturnsOnCall == nil { + fake.removeVolumeReturnsOnCall = make(map[int]struct { result1 error }) } - fake.detachReturnsOnCall[i] = struct { + fake.removeVolumeReturnsOnCall[i] = struct { result1 error }{result1} } @@ -525,21 +605,25 @@ func (fake *FakeStorageClient) Invocations() map[string][][]interface{} { defer fake.invocationsMutex.RUnlock() fake.activateMutex.RLock() defer fake.activateMutex.RUnlock() + fake.attachMutex.RLock() + defer fake.attachMutex.RUnlock() fake.createVolumeMutex.RLock() defer fake.createVolumeMutex.RUnlock() - fake.removeVolumeMutex.RLock() - defer fake.removeVolumeMutex.RUnlock() - fake.listVolumesMutex.RLock() - defer fake.listVolumesMutex.RUnlock() + fake.detachMutex.RLock() + defer fake.detachMutex.RUnlock() fake.getVolumeMutex.RLock() defer fake.getVolumeMutex.RUnlock() fake.getVolumeConfigMutex.RLock() defer fake.getVolumeConfigMutex.RUnlock() - fake.attachMutex.RLock() - defer fake.attachMutex.RUnlock() - fake.detachMutex.RLock() - defer fake.detachMutex.RUnlock() - return fake.invocations + fake.listVolumesMutex.RLock() + defer fake.listVolumesMutex.RUnlock() + fake.removeVolumeMutex.RLock() + defer fake.removeVolumeMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations } func (fake *FakeStorageClient) recordInvocation(key string, args []interface{}) { diff --git a/local/scbe/datamodel_wrapper.go b/local/scbe/datamodel_wrapper.go index 83ac9709..3b84f479 100644 --- a/local/scbe/datamodel_wrapper.go +++ b/local/scbe/datamodel_wrapper.go @@ -22,7 +22,6 @@ import ( "github.com/IBM/ubiquity/utils/logs" ) -//go:generate counterfeiter -o ../../fakes/fake_ScbeDataModelWrapper.go . ScbeDataModelWrapper type ScbeDataModelWrapper interface { GetVolume(name string, mustExist bool) (ScbeVolume, error) DeleteVolume(name string) error @@ -96,7 +95,6 @@ func (d *scbeDataModelWrapper) DeleteVolume(name string) error { defer d.logger.Trace(logs.DEBUG)() var err error - if database.IsDatabaseVolume(name) { if d.dbVolume == nil { d.logger.Warning("Idempotent issue encountered - db volume is nil. continuing with deletion flow") diff --git a/local/scbe/scbe_rest_client.go b/local/scbe/scbe_rest_client.go index 93722a79..416aee7a 100644 --- a/local/scbe/scbe_rest_client.go +++ b/local/scbe/scbe_rest_client.go @@ -25,7 +25,7 @@ import ( "github.com/IBM/ubiquity/utils/logs" ) -//go:generate counterfeiter -o ../fakes/fake_scbe_rest_client.go . ScbeRestClient +//go:generate counterfeiter -o ../../fakes/fake_scbe_rest_client.go . ScbeRestClient type ScbeRestClient interface { Login() error CreateVolume(volName string, serviceName string, size int) (ScbeVolumeInfo, error) diff --git a/local/scbe/simple_rest_client.go b/local/scbe/simple_rest_client.go index 8410521f..194d9252 100644 --- a/local/scbe/simple_rest_client.go +++ b/local/scbe/simple_rest_client.go @@ -23,18 +23,19 @@ import ( "encoding/json" "errors" "fmt" - "github.com/IBM/ubiquity/resources" - "github.com/IBM/ubiquity/utils" - "github.com/IBM/ubiquity/utils/logs" "io/ioutil" "net/http" "os" "strings" "sync" + + "github.com/IBM/ubiquity/resources" + "github.com/IBM/ubiquity/utils" + "github.com/IBM/ubiquity/utils/logs" ) // SimpleRestClient is an interface that wrapper the http requests to provide easy REST API operations, -//go:generate counterfeiter -o ../fakes/fake_simple_rest_client.go . SimpleRestClient +//go:generate counterfeiter -o ../../fakes/fake_simple_rest_client.go . SimpleRestClient type SimpleRestClient interface { // Authenticate the server, prepare headers and save the token Login() error diff --git a/remote/mounter/block_device_mounter_utils/block_device_mounter_utils.go b/remote/mounter/block_device_mounter_utils/block_device_mounter_utils.go index 9b1d9186..691987c4 100644 --- a/remote/mounter/block_device_mounter_utils/block_device_mounter_utils.go +++ b/remote/mounter/block_device_mounter_utils/block_device_mounter_utils.go @@ -22,6 +22,7 @@ import ( "time" "github.com/IBM/ubiquity/remote/mounter/block_device_utils" + "github.com/IBM/ubiquity/resources" "github.com/IBM/ubiquity/utils/logs" "github.com/nightlyone/lockfile" ) @@ -153,9 +154,11 @@ func (b *blockDeviceMounterUtils) UnmountDeviceFlow(devicePath string, volumeWwn // 2. SCSI rescan // 3. multipathing rescan // return error if one of the steps fail -func (b *blockDeviceMounterUtils) RescanAll(wwn string, rescanForCleanUp bool, extraLunZeroScanning bool) error { +func (b *blockDeviceMounterUtils) RescanAll(volumeMountProperties *resources.VolumeMountProperties) error { defer b.logger.Trace(logs.INFO) + wwn := volumeMountProperties.WWN + // locking for concurrent rescans and reduce rescans if no need b.logger.Debug("Ask for rescanLock for volumeWWN", logs.Args{{"volumeWWN", wwn}}) for { @@ -170,38 +173,41 @@ func (b *blockDeviceMounterUtils) RescanAll(wwn string, rescanForCleanUp bool, e defer b.rescanFlock.Unlock() defer b.logger.Debug("Released rescanLock for volumeWWN", logs.Args{{"volumeWWN", wwn}}) - if !rescanForCleanUp { - // Only when run rescan for new device, try to check if its already exist to reduce rescans - device, _ := b.Discover(wwn, false) // no deep discovery + // Only when run rescan for new device, try to check if its already exist to reduce rescans + device, _ := b.Discover(wwn, false) // no deep discovery - if device != "" { - // if need rescan for discover new device but the new device is already exist then skip the rescan - b.logger.Debug( - "Skip rescan, because there is already multiple device for volumeWWN", - logs.Args{{"volumeWWN", wwn}, {"multiple", device}}) - return nil - } + if device != "" { + // if need rescan for discover new device but the new device is already exist then skip the rescan + b.logger.Debug( + "Skip rescan, because there is already multiple device for volumeWWN", + logs.Args{{"volumeWWN", wwn}, {"multiple", device}}) + return nil } - // TODO : if rescanForCleanUp we need to check if block device is not longer exist and if so skip the rescan! // Do the rescans operations // in case of FC : if no iscsiadm on the machine or no session login - this will log a warning not fail! - if err := b.blockDeviceUtils.Rescan(block_device_utils.ISCSI); err != nil { + if err := b.blockDeviceUtils.Rescan(block_device_utils.ISCSI, volumeMountProperties); err != nil { return b.logger.ErrorRet(err, "ISCSI Rescan failed", logs.Args{{"protocol", block_device_utils.ISCSI}}) } - if extraLunZeroScanning { - if err := b.blockDeviceUtils.RescanSCSILun0(); err != nil { - return b.logger.ErrorRet(err, "Rescan failed for FC Lun0", logs.Args{{"protocol", block_device_utils.SCSI}}) - } - } else { - if err := b.blockDeviceUtils.Rescan(block_device_utils.SCSI); err != nil { - return b.logger.ErrorRet(err, "OS Rescan failed", logs.Args{{"protocol", block_device_utils.SCSI}}) - } + + if err := b.blockDeviceUtils.Rescan(block_device_utils.SCSI, volumeMountProperties); err != nil { + return b.logger.ErrorRet(err, "OS Rescan failed", logs.Args{{"protocol", block_device_utils.SCSI}}) } - if !rescanForCleanUp { - if err := b.blockDeviceUtils.ReloadMultipath(); err != nil { - return b.logger.ErrorRet(err, "ReloadMultipath failed") - } + if err := b.blockDeviceUtils.ReloadMultipath(); err != nil { + return b.logger.ErrorRet(err, "ReloadMultipath failed") + } + return nil +} + +// DisconnectAll remove the device from host after the volume is unmapped. +func (b *blockDeviceMounterUtils) CleanupAll(volumeMountProperties *resources.VolumeMountProperties) error { + // in case of FC : if no iscsiadm on the machine or no session login - this will log a warning not fail! + if err := b.blockDeviceUtils.CleanupDevices(block_device_utils.ISCSI, volumeMountProperties); err != nil { + return b.logger.ErrorRet(err, "ISCSI Disconnect failed", logs.Args{{"protocol", block_device_utils.ISCSI}}) + } + + if err := b.blockDeviceUtils.CleanupDevices(block_device_utils.SCSI, volumeMountProperties); err != nil { + return b.logger.ErrorRet(err, "OS Disconnect failed", logs.Args{{"protocol", block_device_utils.SCSI}}) } return nil } diff --git a/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go b/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go index 13dc5e8d..2c220d7e 100644 --- a/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go +++ b/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go @@ -24,6 +24,7 @@ import ( "github.com/IBM/ubiquity/fakes" "github.com/IBM/ubiquity/remote/mounter/block_device_mounter_utils" "github.com/IBM/ubiquity/remote/mounter/block_device_utils" + "github.com/IBM/ubiquity/resources" "github.com/IBM/ubiquity/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -36,6 +37,7 @@ var _ = Describe("block_device_mounter_utils_test", func() { err error callErr error = errors.New("error") ) + volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: float64(1)} BeforeEach(func() { fakeBlockDeviceUtils = new(fakes.FakeBlockDeviceUtils) @@ -193,44 +195,31 @@ var _ = Describe("block_device_mounter_utils_test", func() { Context(".RescanAll", func() { It("should succeed to skip rescan we try to rescan(for discover) a wwn that is already descovered", func() { fakeBlockDeviceUtils.DiscoverReturns("wwn", nil) - err = blockDeviceMounterUtils.RescanAll("wwn", false, false) + err = blockDeviceMounterUtils.RescanAll(volumeMountProperties) Expect(err).NotTo(HaveOccurred()) Expect(fakeBlockDeviceUtils.RescanCallCount()).To(Equal(0)) }) It("should fail if iscsi rescan fail", func() { fakeBlockDeviceUtils.RescanReturnsOnCall(0, callErr) fakeBlockDeviceUtils.DiscoverReturns("", fmt.Errorf("device not exist yet")) - err = blockDeviceMounterUtils.RescanAll("wwn", false, false) + err = blockDeviceMounterUtils.RescanAll(volumeMountProperties) Expect(err).To(HaveOccurred()) Expect(err).To(MatchError(callErr)) Expect(fakeBlockDeviceUtils.RescanCallCount()).To(Equal(1)) - protocol := fakeBlockDeviceUtils.RescanArgsForCall(0) + protocol, _ := fakeBlockDeviceUtils.RescanArgsForCall(0) Expect(protocol).To(Equal(block_device_utils.ISCSI)) }) It("should fail if scsi rescan fail", func() { fakeBlockDeviceUtils.RescanReturnsOnCall(0, nil) fakeBlockDeviceUtils.RescanReturnsOnCall(1, callErr) fakeBlockDeviceUtils.DiscoverReturns("", fmt.Errorf("device not exist yet")) - err = blockDeviceMounterUtils.RescanAll("wwn", false, false) + err = blockDeviceMounterUtils.RescanAll(volumeMountProperties) Expect(err).To(HaveOccurred()) Expect(err).To(MatchError(callErr)) Expect(fakeBlockDeviceUtils.RescanCallCount()).To(Equal(2)) - protocol := fakeBlockDeviceUtils.RescanArgsForCall(0) + protocol, _ := fakeBlockDeviceUtils.RescanArgsForCall(0) Expect(protocol).To(Equal(block_device_utils.ISCSI)) - protocol = fakeBlockDeviceUtils.RescanArgsForCall(1) - Expect(protocol).To(Equal(block_device_utils.SCSI)) - }) - It("should fail if scsi rescan fail even if for clean up", func() { - fakeBlockDeviceUtils.RescanReturnsOnCall(0, nil) - fakeBlockDeviceUtils.RescanReturnsOnCall(1, callErr) - fakeBlockDeviceUtils.DiscoverReturns("", fmt.Errorf("device not exist yet")) - err = blockDeviceMounterUtils.RescanAll("wwn", true, false) - Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError(callErr)) - Expect(fakeBlockDeviceUtils.RescanCallCount()).To(Equal(2)) - protocol := fakeBlockDeviceUtils.RescanArgsForCall(0) - Expect(protocol).To(Equal(block_device_utils.ISCSI)) - protocol = fakeBlockDeviceUtils.RescanArgsForCall(1) + protocol, _ = fakeBlockDeviceUtils.RescanArgsForCall(1) Expect(protocol).To(Equal(block_device_utils.SCSI)) }) It("should fail if ReloadMultipath fail", func() { @@ -238,13 +227,13 @@ var _ = Describe("block_device_mounter_utils_test", func() { fakeBlockDeviceUtils.RescanReturnsOnCall(1, nil) fakeBlockDeviceUtils.ReloadMultipathReturns(callErr) fakeBlockDeviceUtils.DiscoverReturns("", fmt.Errorf("device not exist yet")) - err = blockDeviceMounterUtils.RescanAll("wwn", false, false) + err = blockDeviceMounterUtils.RescanAll(volumeMountProperties) Expect(err).To(HaveOccurred()) Expect(err).To(MatchError(callErr)) Expect(fakeBlockDeviceUtils.RescanCallCount()).To(Equal(2)) - protocol := fakeBlockDeviceUtils.RescanArgsForCall(0) + protocol, _ := fakeBlockDeviceUtils.RescanArgsForCall(0) Expect(protocol).To(Equal(block_device_utils.ISCSI)) - protocol = fakeBlockDeviceUtils.RescanArgsForCall(1) + protocol, _ = fakeBlockDeviceUtils.RescanArgsForCall(1) Expect(protocol).To(Equal(block_device_utils.SCSI)) Expect(fakeBlockDeviceUtils.ReloadMultipathCallCount()).To(Equal(1)) @@ -254,12 +243,12 @@ var _ = Describe("block_device_mounter_utils_test", func() { fakeBlockDeviceUtils.RescanReturnsOnCall(1, nil) fakeBlockDeviceUtils.ReloadMultipathReturns(nil) fakeBlockDeviceUtils.DiscoverReturns("", fmt.Errorf("device not exist yet")) - err = blockDeviceMounterUtils.RescanAll("wwn", false, false) + err = blockDeviceMounterUtils.RescanAll(volumeMountProperties) Expect(err).NotTo(HaveOccurred()) Expect(fakeBlockDeviceUtils.RescanCallCount()).To(Equal(2)) - protocol := fakeBlockDeviceUtils.RescanArgsForCall(0) + protocol, _ := fakeBlockDeviceUtils.RescanArgsForCall(0) Expect(protocol).To(Equal(block_device_utils.ISCSI)) - protocol = fakeBlockDeviceUtils.RescanArgsForCall(1) + protocol, _ = fakeBlockDeviceUtils.RescanArgsForCall(1) Expect(protocol).To(Equal(block_device_utils.SCSI)) Expect(fakeBlockDeviceUtils.ReloadMultipathCallCount()).To(Equal(1)) }) @@ -296,6 +285,40 @@ var _ = Describe("block_device_mounter_utils_test", func() { Expect(fakeBlockDeviceUtils.CleanupCallCount()).To(Equal(1)) }) }) + Context(".CleanupAll", func() { + It("should fail if iscsi cleanup fail", func() { + fakeBlockDeviceUtils.CleanupDevicesReturnsOnCall(0, callErr) + err = blockDeviceMounterUtils.CleanupAll(volumeMountProperties) + Expect(err).To(HaveOccurred()) + Expect(err).To(MatchError(callErr)) + Expect(fakeBlockDeviceUtils.CleanupDevicesCallCount()).To(Equal(1)) + protocol, _ := fakeBlockDeviceUtils.CleanupDevicesArgsForCall(0) + Expect(protocol).To(Equal(block_device_utils.ISCSI)) + }) + It("should fail if scsi cleanup fail", func() { + fakeBlockDeviceUtils.CleanupDevicesReturnsOnCall(0, nil) + fakeBlockDeviceUtils.CleanupDevicesReturnsOnCall(1, callErr) + err = blockDeviceMounterUtils.CleanupAll(volumeMountProperties) + Expect(err).To(HaveOccurred()) + Expect(err).To(MatchError(callErr)) + Expect(fakeBlockDeviceUtils.CleanupDevicesCallCount()).To(Equal(2)) + protocol, _ := fakeBlockDeviceUtils.CleanupDevicesArgsForCall(0) + Expect(protocol).To(Equal(block_device_utils.ISCSI)) + protocol, _ = fakeBlockDeviceUtils.CleanupDevicesArgsForCall(1) + Expect(protocol).To(Equal(block_device_utils.SCSI)) + }) + It("should succeed to cleanup all", func() { + fakeBlockDeviceUtils.CleanupDevicesReturnsOnCall(0, nil) + fakeBlockDeviceUtils.CleanupDevicesReturnsOnCall(1, nil) + err = blockDeviceMounterUtils.CleanupAll(volumeMountProperties) + Expect(err).NotTo(HaveOccurred()) + Expect(fakeBlockDeviceUtils.CleanupDevicesCallCount()).To(Equal(2)) + protocol, _ := fakeBlockDeviceUtils.CleanupDevicesArgsForCall(0) + Expect(protocol).To(Equal(block_device_utils.ISCSI)) + protocol, _ = fakeBlockDeviceUtils.CleanupDevicesArgsForCall(1) + Expect(protocol).To(Equal(block_device_utils.SCSI)) + }) + }) }) func TestGetBlockDeviceMounterUtils(t *testing.T) { diff --git a/remote/mounter/block_device_mounter_utils/resources.go b/remote/mounter/block_device_mounter_utils/resources.go index 10022314..9e8008f5 100644 --- a/remote/mounter/block_device_mounter_utils/resources.go +++ b/remote/mounter/block_device_mounter_utils/resources.go @@ -16,9 +16,12 @@ package block_device_mounter_utils -//go:generate counterfeiter -o ../fakes/fake_block_device_mounter_utils.go . BlockDeviceMounterUtils +import "github.com/IBM/ubiquity/resources" + +//go:generate counterfeiter -o ../../../fakes/fake_block_device_mounter_utils.go . BlockDeviceMounterUtils type BlockDeviceMounterUtils interface { - RescanAll(wwn string, rescanForCleanUp bool, extraLunZeroScanning bool) error + RescanAll(volumeMountProperties *resources.VolumeMountProperties) error + CleanupAll(volumeMountProperties *resources.VolumeMountProperties) error MountDeviceFlow(devicePath string, fsType string, mountPoint string) error Discover(volumeWwn string, deepDiscovery bool) (string, error) UnmountDeviceFlow(devicePath string, volumeWwn string) error diff --git a/remote/mounter/block_device_utils/block_device_utils.go b/remote/mounter/block_device_utils/block_device_utils.go index 94924fc8..98651211 100644 --- a/remote/mounter/block_device_utils/block_device_utils.go +++ b/remote/mounter/block_device_utils/block_device_utils.go @@ -1,26 +1,34 @@ package block_device_utils import ( + "regexp" + + "github.com/IBM/ubiquity/remote/mounter/initiator" + "github.com/IBM/ubiquity/remote/mounter/initiator/connectors" "github.com/IBM/ubiquity/utils" "github.com/IBM/ubiquity/utils/logs" - "regexp" ) type blockDeviceUtils struct { logger logs.Logger exec utils.Executor regExAlreadyMounted *regexp.Regexp + fcConnector initiator.Connector } func NewBlockDeviceUtils() BlockDeviceUtils { - return newBlockDeviceUtils(utils.NewExecutor()) + return newBlockDeviceUtils(utils.NewExecutor(), nil) } func NewBlockDeviceUtilsWithExecutor(executor utils.Executor) BlockDeviceUtils { - return newBlockDeviceUtils(executor) + return newBlockDeviceUtils(executor, nil) } -func newBlockDeviceUtils(executor utils.Executor) BlockDeviceUtils { +func NewBlockDeviceUtilsWithExecutorAndConnector(executor utils.Executor, fcConnector initiator.Connector) BlockDeviceUtils { + return newBlockDeviceUtils(executor, fcConnector) +} + +func newBlockDeviceUtils(executor utils.Executor, fcConnector initiator.Connector) BlockDeviceUtils { logger := logs.GetLogger() // Prepare regex that going to be used in unmount interface @@ -30,5 +38,8 @@ func newBlockDeviceUtils(executor utils.Executor) BlockDeviceUtils { panic("failed prepare Already unmount regex") } - return &blockDeviceUtils{logger: logger, exec: executor, regExAlreadyMounted: regex} + if fcConnector == nil { + fcConnector = connectors.NewFibreChannelConnectorWithExecutor(executor) + } + return &blockDeviceUtils{logger: logger, exec: executor, regExAlreadyMounted: regex, fcConnector: fcConnector} } diff --git a/remote/mounter/block_device_utils/block_device_utils_test.go b/remote/mounter/block_device_utils/block_device_utils_test.go index 0115ceca..67d38441 100644 --- a/remote/mounter/block_device_utils/block_device_utils_test.go +++ b/remote/mounter/block_device_utils/block_device_utils_test.go @@ -22,11 +22,12 @@ import ( "github.com/IBM/ubiquity/fakes" "github.com/IBM/ubiquity/remote/mounter/block_device_utils" + fakeinitiator "github.com/IBM/ubiquity/remote/mounter/initiator/fakes" + "github.com/IBM/ubiquity/resources" "github.com/IBM/ubiquity/utils" "context" "io/ioutil" - "os" "os/exec" "strings" "testing" @@ -37,76 +38,71 @@ import ( var _ = Describe("block_device_utils_test", func() { var ( - fakeExec *fakes.FakeExecutor - bdUtils block_device_utils.BlockDeviceUtils - err error - cmdErr error = errors.New("command error") + fakeExec *fakes.FakeExecutor + fakeFcConnector *fakeinitiator.FakeConnector + bdUtils block_device_utils.BlockDeviceUtils + err error + cmdErr error = errors.New("command error") ) + volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: float64(1)} BeforeEach(func() { fakeExec = new(fakes.FakeExecutor) - bdUtils = block_device_utils.NewBlockDeviceUtilsWithExecutor(fakeExec) + fakeFcConnector = new(fakeinitiator.FakeConnector) + bdUtils = block_device_utils.NewBlockDeviceUtilsWithExecutorAndConnector(fakeExec, fakeFcConnector) }) Context(".Rescan", func() { It("Rescan ISCSI calls 'sudo iscsiadm -m session --rescan'", func() { - err = bdUtils.Rescan(block_device_utils.ISCSI) + err = bdUtils.Rescan(block_device_utils.ISCSI, volumeMountProperties) Expect(err).ToNot(HaveOccurred()) Expect(fakeExec.ExecuteWithTimeoutCallCount()).To(Equal(1)) _, cmd, args := fakeExec.ExecuteWithTimeoutArgsForCall(0) Expect(cmd).To(Equal("iscsiadm")) Expect(args).To(Equal([]string{"-m", "session", "--rescan"})) }) - It("Rescan SCSI calls 'sudo rescan-scsi-bus -r'", func() { - err = bdUtils.Rescan(block_device_utils.SCSI) + It(`Rescan SCSI calls fcConnector.ConnectVolume`, func() { + fakeExec.ExecuteWithTimeoutReturns([]byte(volumeMountProperties.WWN), nil) + err = bdUtils.Rescan(block_device_utils.SCSI, volumeMountProperties) Expect(err).ToNot(HaveOccurred()) Expect(fakeExec.ExecuteWithTimeoutCallCount()).To(Equal(1)) _, cmd, args := fakeExec.ExecuteWithTimeoutArgsForCall(0) - Expect(cmd).To(Equal("rescan-scsi-bus")) - Expect(args).To(Equal([]string{"-r"})) + // check the existence of the new volume after rescan using multipath -ll + Expect(cmd).To(Equal("multipath")) + Expect(args).To(Equal([]string{"-ll"})) + Expect(fakeFcConnector.ConnectVolumeCallCount()).To(Equal(1)) }) It("Rescan ISCSI does not fail if iscsiadm command missing", func() { fakeExec.IsExecutableReturns(cmdErr) - err = bdUtils.Rescan(block_device_utils.ISCSI) + err = bdUtils.Rescan(block_device_utils.ISCSI, volumeMountProperties) Expect(err).To(Not(HaveOccurred())) Expect(fakeExec.ExecuteCallCount()).To(Equal(0)) Expect(fakeExec.IsExecutableCallCount()).To(Equal(1)) Expect(fakeExec.IsExecutableArgsForCall(0)).To(Equal("iscsiadm")) }) - It("Rescan SCSI fails if rescan-scsi-bus command missing", func() { - fakeExec.IsExecutableReturns(cmdErr) - err = bdUtils.Rescan(block_device_utils.SCSI) - Expect(err).To(HaveOccurred()) - Expect(fakeExec.ExecuteWithTimeoutCallCount()).To(Equal(0)) - Expect(fakeExec.IsExecutableCallCount()).To(Equal(2)) - Expect(fakeExec.IsExecutableArgsForCall(0)).To(Equal("rescan-scsi-bus")) - Expect(fakeExec.IsExecutableArgsForCall(1)).To(Equal("rescan-scsi-bus.sh")) - }) It("Rescan ISCSI fails if iscsiadm execution fails", func() { fakeExec.ExecuteWithTimeoutReturns([]byte{}, cmdErr) - err = bdUtils.Rescan(block_device_utils.ISCSI) - Expect(err.Error()).To(MatchRegexp(cmdErr.Error())) - }) - It("Rescan SCSI fails if rescan-scsi-bus execution fails", func() { - fakeExec.ExecuteWithTimeoutReturns([]byte{}, cmdErr) - err = bdUtils.Rescan(block_device_utils.SCSI) + err = bdUtils.Rescan(block_device_utils.ISCSI, volumeMountProperties) Expect(err.Error()).To(MatchRegexp(cmdErr.Error())) }) It("Rescan fails if unknown protocol", func() { - err = bdUtils.Rescan(2) + err = bdUtils.Rescan(2, volumeMountProperties) Expect(err).To(HaveOccurred()) }) - It("Rescan SCSI lun0", func() { - dir, _ := ioutil.TempDir("", "") - os.Mkdir(dir+"/host33", os.ModePerm) - os.Mkdir(dir+"/host34", os.ModePerm) - block_device_utils.FcHostDir = dir + "/" - block_device_utils.ScsiHostDir = dir + "/" - err = bdUtils.RescanSCSILun0() + }) + Context(".CleanupDevices", func() { + It("Cleanup ISCSI calls 'sudo iscsiadm -m session --rescan'", func() { + err = bdUtils.CleanupDevices(block_device_utils.ISCSI, volumeMountProperties) Expect(err).ToNot(HaveOccurred()) - os.RemoveAll(dir) - block_device_utils.FcHostDir = "/sys/class/fc_host/" - block_device_utils.ScsiHostDir = "/sys/class/scsi_host/" + Expect(fakeExec.ExecuteWithTimeoutCallCount()).To(Equal(1)) + _, cmd, args := fakeExec.ExecuteWithTimeoutArgsForCall(0) + Expect(cmd).To(Equal("iscsiadm")) + Expect(args).To(Equal([]string{"-m", "session", "--rescan"})) + }) + It(`Cleanup SCSI calls fcConnector.DisconnectVolume`, func() { + err = bdUtils.CleanupDevices(block_device_utils.SCSI, volumeMountProperties) + Expect(err).ToNot(HaveOccurred()) + Expect(fakeFcConnector.DisconnectVolumeCallCount()).To(Equal(1)) }) }) Context(".ReloadMultipath", func() { @@ -615,10 +611,14 @@ mpathhb (36001738cfc9035eb0000000000cea###) dm-3 ##,## mpoint := "mpoint" err = bdUtils.MountFs(mpath, mpoint) Expect(err).To(Not(HaveOccurred())) - Expect(fakeExec.ExecuteWithTimeoutCallCount()).To(Equal(1)) + Expect(fakeExec.ExecuteWithTimeoutCallCount()).To(Equal(2)) _, cmd, args := fakeExec.ExecuteWithTimeoutArgsForCall(0) Expect(cmd).To(Equal("mount")) Expect(args).To(Equal([]string{mpath, mpoint})) + + _, cmd, args = fakeExec.ExecuteWithTimeoutArgsForCall(1) + Expect(cmd).To(Equal("chmod")) + Expect(args).To(Equal([]string{"775", mpoint})) }) It("MountFs fails if mount command missing", func() { mpath := "mpath" @@ -636,6 +636,15 @@ mpathhb (36001738cfc9035eb0000000000cea###) dm-3 ##,## Expect(err).To(HaveOccurred()) Expect(err.Error()).To(MatchRegexp(cmdErr.Error())) }) + It("MountFs fails if chmod command fails", func() { + mpath := "mpath" + mpoint := "mpoint" + fakeExec.ExecuteWithTimeoutReturnsOnCall(0, []byte{}, nil) + fakeExec.ExecuteWithTimeoutReturnsOnCall(1, []byte{}, cmdErr) + err = bdUtils.MountFs(mpath, mpoint) + Expect(err).To(HaveOccurred()) + Expect(err.Error()).To(MatchRegexp(cmdErr.Error())) + }) }) Context(".IsDeviceMounted", func() { It("should fail if mount command missing", func() { diff --git a/remote/mounter/block_device_utils/fs.go b/remote/mounter/block_device_utils/fs.go index f2af2273..a836a68c 100644 --- a/remote/mounter/block_device_utils/fs.go +++ b/remote/mounter/block_device_utils/fs.go @@ -32,6 +32,7 @@ const ( TimeoutMilisecondMountCmdIsDeviceMounted = 20 * 1000 // max to wait for mount command TimeoutMilisecondMountCmdMountFs = 120 * 1000 // max to wait for mounting device TimeoutMilisecondUmountCmdUmountFs = 30 * 1000 // max wait timeout for umount command + TimeoutMilisecondChmodCmd = 3 * 1000 ) func (b *blockDeviceUtils) CheckFs(mpath string) (bool, error) { @@ -73,6 +74,8 @@ func (b *blockDeviceUtils) MakeFs(mpath string, fsType string) error { func (b *blockDeviceUtils) MountFs(mpath string, mpoint string) error { defer b.logger.Trace(logs.DEBUG)() mountCmd := "mount" + chmodCmd := "chmod" + if err := b.exec.IsExecutable(mountCmd); err != nil { return b.logger.ErrorRet(&commandNotFoundError{mountCmd, err}, "failed") } @@ -80,6 +83,13 @@ func (b *blockDeviceUtils) MountFs(mpath string, mpoint string) error { if _, err := b.exec.ExecuteWithTimeout(TimeoutMilisecondMountCmdMountFs, mountCmd, args); err != nil { return b.logger.ErrorRet(&CommandExecuteError{mountCmd, err}, "failed") } + + // Set explicitly the PV mountpoint permission to 775 + args = []string{"775", mpoint} + if _, err := b.exec.ExecuteWithTimeout(TimeoutMilisecondChmodCmd, chmodCmd, args); err != nil { + return b.logger.ErrorRet(&CommandExecuteError{chmodCmd, err}, "failed") + } + b.logger.Info("mounted", logs.Args{{"mpoint", mpoint}}) return nil } diff --git a/remote/mounter/block_device_utils/mpath.go b/remote/mounter/block_device_utils/mpath.go index 87dc247a..381cd514 100644 --- a/remote/mounter/block_device_utils/mpath.go +++ b/remote/mounter/block_device_utils/mpath.go @@ -24,6 +24,7 @@ import ( "regexp" "strings" + "github.com/IBM/ubiquity/utils" "github.com/IBM/ubiquity/utils/logs" ) @@ -56,27 +57,12 @@ func (b *blockDeviceUtils) ReloadMultipath() error { func (b *blockDeviceUtils) Discover(volumeWwn string, deepDiscovery bool) (string, error) { defer b.logger.Trace(logs.DEBUG, logs.Args{{"volumeWwn", volumeWwn}, {"deepDiscovery", deepDiscovery}})() - if err := b.exec.IsExecutable(multipathCmd); err != nil { - return "", b.logger.ErrorRet(&commandNotFoundError{multipathCmd, err}, "failed") - } - args := []string{"-ll"} - outputBytes, err := b.exec.ExecuteWithTimeout(DiscoverTimeout, multipathCmd, args) + + outputBytes, dev, _, err := utils.GetMultipathOutputAndDeviceMapperAndDevice(volumeWwn, b.exec) if err != nil { - return "", b.logger.ErrorRet(&CommandExecuteError{multipathCmd, err}, "failed") - } - scanner := bufio.NewScanner(strings.NewReader(string(outputBytes[:]))) - pattern := "(?i)" + volumeWwn - regex, err := regexp.Compile(pattern) - if err != nil { - return "", b.logger.ErrorRet(err, "failed") - } - dev := "" - for scanner.Scan() { - if regex.MatchString(scanner.Text()) { - dev = strings.Split(scanner.Text(), " ")[0] - break - } + return "", err } + mpath := "" if dev == "" { if !deepDiscovery { diff --git a/remote/mounter/block_device_utils/rescan.go b/remote/mounter/block_device_utils/rescan.go index 3ea1d4a9..58b4bb65 100644 --- a/remote/mounter/block_device_utils/rescan.go +++ b/remote/mounter/block_device_utils/rescan.go @@ -17,11 +17,11 @@ package block_device_utils import ( - "errors" - "fmt" - "io/ioutil" + "time" + "github.com/IBM/ubiquity/resources" + "github.com/IBM/ubiquity/utils" "github.com/IBM/ubiquity/utils/logs" ) @@ -31,12 +31,12 @@ const rescanScsiTimeout = 2 * 60 * 1000 var FcHostDir = "/sys/class/fc_host/" var ScsiHostDir = "/sys/class/scsi_host/" -func (b *blockDeviceUtils) Rescan(protocol Protocol) error { +func (b *blockDeviceUtils) Rescan(protocol Protocol, volumeMountProperties *resources.VolumeMountProperties) error { defer b.logger.Trace(logs.DEBUG)() switch protocol { case SCSI: - return b.RescanSCSI() + return b.RescanSCSI(volumeMountProperties) case ISCSI: return b.RescanISCSI() default: @@ -44,6 +44,19 @@ func (b *blockDeviceUtils) Rescan(protocol Protocol) error { } } +func (b *blockDeviceUtils) CleanupDevices(protocol Protocol, volumeMountProperties *resources.VolumeMountProperties) error { + defer b.logger.Trace(logs.DEBUG)() + + switch protocol { + case SCSI: + return b.CleanupSCSIDevices(volumeMountProperties) + case ISCSI: + return b.CleanupISCSIDevices() + default: + return b.logger.ErrorRet(&unsupportedProtocolError{protocol}, "failed") + } +} + func (b *blockDeviceUtils) RescanISCSI() error { defer b.logger.Trace(logs.DEBUG)() rescanCmd := "iscsiadm" @@ -67,49 +80,28 @@ func (b *blockDeviceUtils) RescanISCSI() error { return nil } -func (b *blockDeviceUtils) RescanSCSI() error { +func (b *blockDeviceUtils) RescanSCSI(volumeMountProperties *resources.VolumeMountProperties) error { defer b.logger.Trace(logs.DEBUG)() - commands := []string{"rescan-scsi-bus", "rescan-scsi-bus.sh"} - rescanCmd := "" - for _, cmd := range commands { - if err := b.exec.IsExecutable(cmd); err == nil { - rescanCmd = cmd - break + + var err error + for i := 0; i < 6; i++ { + if err = b.fcConnector.ConnectVolume(volumeMountProperties); err != nil { + return b.logger.ErrorRet(err, "RescanSCSI failed", logs.Args{{"volumeWWN", volumeMountProperties.WWN}}) } + if _, _, _, err = utils.GetMultipathOutputAndDeviceMapperAndDevice(volumeMountProperties.WWN, b.exec); err == nil { + return nil + } + b.logger.Warning("Can't find the new volume in multipath output after rescan, sleep one second and try again.") + time.Sleep(1 * time.Second) } - if rescanCmd == "" { - return b.logger.ErrorRet(&commandNotFoundError{commands[0], errors.New("")}, "failed") - } - args := []string{"-r"} // TODO should use -r only in clean up - if _, err := b.exec.ExecuteWithTimeout(rescanScsiTimeout, rescanCmd, args); err != nil { - return b.logger.ErrorRet(&CommandExecuteError{rescanCmd, err}, "failed") - } - return nil + return b.logger.ErrorRet(err, "RescanSCSI failed", logs.Args{{"volumeWWN", volumeMountProperties.WWN}}) } -func (b *blockDeviceUtils) RescanSCSILun0() error { - defer b.logger.Trace(logs.DEBUG)() - hostInfos, err := ioutil.ReadDir(FcHostDir) - if err != nil { - return b.logger.ErrorRet(err, "Getting fc_host failed.", logs.Args{{"FcHostDir", FcHostDir}}) - } - if len(hostInfos) == 0 { - err := fmt.Errorf("There is no fc_host found, please check the fc host.") - return b.logger.ErrorRet(err, "There is no fc_host found.", logs.Args{{"FcHostDir", FcHostDir}}) - } +// TODO: improve it to make it faster, for more details, see os_brick project. +func (b *blockDeviceUtils) CleanupISCSIDevices() error { + return b.RescanISCSI() +} - for _, host := range hostInfos { - b.logger.Debug("scan the host", logs.Args{{"name: ", host.Name()}}) - fcHostFile := FcHostDir + host.Name() + "/issue_lip" - if err := ioutil.WriteFile(fcHostFile, []byte("1"), 0200); err != nil { - b.logger.Debug("Write issue_lip failed", logs.Args{{"err", err}}) - } - filename := ScsiHostDir + host.Name() + "/scan" - b.logger.Debug("ScsiHostDir", logs.Args{{"ScsiHostDir", ScsiHostDir}}) - if err := ioutil.WriteFile(filename, []byte("- - -"), 0200); err != nil { - b.logger.Debug("Write file scan failed", logs.Args{{"err", err}}) - continue - } - } - return nil +func (b *blockDeviceUtils) CleanupSCSIDevices(volumeMountProperties *resources.VolumeMountProperties) error { + return b.fcConnector.DisconnectVolume(volumeMountProperties) } diff --git a/remote/mounter/block_device_utils/resources.go b/remote/mounter/block_device_utils/resources.go index 78945322..f8a8bfb4 100644 --- a/remote/mounter/block_device_utils/resources.go +++ b/remote/mounter/block_device_utils/resources.go @@ -16,6 +16,10 @@ package block_device_utils +import ( + "github.com/IBM/ubiquity/resources" +) + type Protocol int const ( @@ -23,10 +27,10 @@ const ( ISCSI ) -//go:generate counterfeiter -o ../fakes/fake_block_device_utils.go . BlockDeviceUtils +//go:generate counterfeiter -o ../../../fakes/fake_block_device_utils.go . BlockDeviceUtils type BlockDeviceUtils interface { - Rescan(protocol Protocol) error - RescanSCSILun0() error + Rescan(protocol Protocol, volumes *resources.VolumeMountProperties) error + CleanupDevices(protocol Protocol, volumes *resources.VolumeMountProperties) error ReloadMultipath() error Discover(volumeWwn string, deepDiscovery bool) (string, error) GetWwnByScsiInq(mpathOutput string, dev string) (string, error) diff --git a/remote/mounter/initiator/connectors/connectors_suite_test.go b/remote/mounter/initiator/connectors/connectors_suite_test.go new file mode 100644 index 00000000..5b4a4a1b --- /dev/null +++ b/remote/mounter/initiator/connectors/connectors_suite_test.go @@ -0,0 +1,16 @@ +package connectors_test + +import ( + "testing" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + + "github.com/IBM/ubiquity/utils" +) + +func TestConnectors(t *testing.T) { + RegisterFailHandler(Fail) + defer utils.InitUbiquityServerTestLogger()() + RunSpecs(t, "Connectors Suite") +} diff --git a/remote/mounter/initiator/connectors/fibre_channel.go b/remote/mounter/initiator/connectors/fibre_channel.go new file mode 100644 index 00000000..0c5449f9 --- /dev/null +++ b/remote/mounter/initiator/connectors/fibre_channel.go @@ -0,0 +1,87 @@ +package connectors + +import ( + "fmt" + + "github.com/IBM/ubiquity/remote/mounter/initiator" + "github.com/IBM/ubiquity/resources" + "github.com/IBM/ubiquity/utils" + "github.com/IBM/ubiquity/utils/logs" +) + +type fibreChannelConnector struct { + exec utils.Executor + logger logs.Logger + linuxfc initiator.Initiator +} + +func NewFibreChannelConnector() initiator.Connector { + return newFibreChannelConnector() +} + +func NewFibreChannelConnectorWithExecutor(executor utils.Executor) initiator.Connector { + return newFibreChannelConnectorWithExecutorAndLogger(executor) +} + +func NewFibreChannelConnectorWithAllFields(executor utils.Executor, linuxfc initiator.Initiator) initiator.Connector { + logger := logs.GetLogger() + return &fibreChannelConnector{logger: logger, exec: executor, linuxfc: linuxfc} +} + +func newFibreChannelConnector() *fibreChannelConnector { + executor := utils.NewExecutor() + return newFibreChannelConnectorWithExecutorAndLogger(executor) +} + +func newFibreChannelConnectorWithExecutorAndLogger(executor utils.Executor) *fibreChannelConnector { + logger := logs.GetLogger() + linuxfc := initiator.NewLinuxFibreChannelWithExecutor(executor) + + return &fibreChannelConnector{logger: logger, exec: executor, linuxfc: linuxfc} +} + +// ConnectVolume attach the volume to host by rescaning all the active FC HBAs. +func (c *fibreChannelConnector) ConnectVolume(volumeMountProperties *resources.VolumeMountProperties) error { + hbas := c.linuxfc.GetHBAs() + + if len(hbas) == 0 { + c.logger.Warning("No FC HBA is found.") + return nil + } + + return c.linuxfc.RescanHosts(hbas, volumeMountProperties) +} + +// DisconnectVolume removes a volume from host by echo "1" to all scsi device's /delete +func (c *fibreChannelConnector) DisconnectVolume(volumeMountProperties *resources.VolumeMountProperties) error { + devices := []string{} + _, _, devNames, err := utils.GetMultipathOutputAndDeviceMapperAndDevice(volumeMountProperties.WWN, c.exec) + if err != nil { + return c.logger.ErrorRet(err, "Failed to get multipath output before disconnecting volume") + } + for _, devName := range devNames { + device := fmt.Sprintf("/dev/%s", devName) + devices = append(devices, device) + } + + c.logger.Debug("Remove devices", logs.Args{{"names", devices}}) + err = c.removeDevices(devices) + if err != nil { + return c.logger.ErrorRet(err, "Failed to remove devices") + } + + if _, devMapper, _, _ := utils.GetMultipathOutputAndDeviceMapperAndDevice(volumeMountProperties.WWN, c.exec); devMapper != "" { + // flush multipath if device still exists after disconnection + c.linuxfc.FlushMultipath(devMapper) + } + return nil +} + +func (c *fibreChannelConnector) removeDevices(devices []string) error { + // Do we need to flush io? + var err error + for _, device := range devices { + err = c.linuxfc.RemoveSCSIDevice(device) + } + return err +} diff --git a/remote/mounter/initiator/connectors/fibre_channel_test.go b/remote/mounter/initiator/connectors/fibre_channel_test.go new file mode 100644 index 00000000..aa74f0cb --- /dev/null +++ b/remote/mounter/initiator/connectors/fibre_channel_test.go @@ -0,0 +1,75 @@ +package connectors_test + +import ( + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + + "github.com/IBM/ubiquity/fakes" + "github.com/IBM/ubiquity/remote/mounter/initiator" + "github.com/IBM/ubiquity/remote/mounter/initiator/connectors" + fakeinitiator "github.com/IBM/ubiquity/remote/mounter/initiator/fakes" + "github.com/IBM/ubiquity/resources" +) + +var fakeWwn = "6005076306ffd69d0000000000001004" + +var fakeMultipathOutput = ` +mpathg (36005076306ffd69d0000000000001004) dm-14 IBM ,2107900 +size=1.0G features='1 queue_if_no_path' hwhandler='0' wp=rw +` + "`-+- policy='service-time 0' prio=1 status=active" + ` + |- 29:0:1:1 sda 8:64 active ready running + |- 29:0:6:1 sdb 8:80 active ready running + ` + "`- 29:0:7:1 sdc 8:96 active ready running" + ` +mpathf (36005076306ffd69d000000000000010a) dm-2 IBM ,2107900 +size=2.0G features='1 queue_if_no_path' hwhandler='0' wp=rw +` + "`-+- policy='service-time 0' prio=1 status=enabled" + ` + |- 29:0:1:0 sdb 8:16 active ready running + |- 29:0:6:0 sdc 8:32 active ready running + ` + "`- 29:0:7:0 sdd 8:48 active ready running\n" + +var _ = Describe("Test Fibre Channel Connector", func() { + var ( + fakeExec *fakes.FakeExecutor + fakeInitiator *fakeinitiator.FakeInitiator + fcConnector initiator.Connector + ) + volumeMountProperties := &resources.VolumeMountProperties{WWN: fakeWwn, LunNumber: float64(1)} + + BeforeEach(func() { + fakeExec = new(fakes.FakeExecutor) + fakeInitiator = new(fakeinitiator.FakeInitiator) + fcConnector = connectors.NewFibreChannelConnectorWithAllFields(fakeExec, fakeInitiator) + }) + + Context("ConnectVolume", func() { + + BeforeEach(func() { + fakeInitiator.GetHBAsReturns([]string{"host0"}) + }) + + It("should rescan all host HBAs", func() { + err := fcConnector.ConnectVolume(volumeMountProperties) + Ω(err).ShouldNot(HaveOccurred()) + Expect(fakeInitiator.RescanHostsCallCount()).To(Equal(1)) + }) + }) + + Context("DisconnectVolume", func() { + + BeforeEach(func() { + fakeExec.ExecuteWithTimeoutReturns([]byte(fakeMultipathOutput), nil) + }) + + It("should remove all the scsi devices", func() { + err := fcConnector.DisconnectVolume(volumeMountProperties) + Ω(err).ShouldNot(HaveOccurred()) + Expect(fakeInitiator.RemoveSCSIDeviceCallCount()).To(Equal(3)) + var a byte = 97 + for i := 0; i < 3; i++ { + expectDev := "/dev/sd" + string(a+byte(i)) + dev := fakeInitiator.RemoveSCSIDeviceArgsForCall(i) + Expect(dev).To(Equal(expectDev)) + } + }) + }) +}) diff --git a/remote/mounter/initiator/fakes/fake_base_initiator.go b/remote/mounter/initiator/fakes/fake_base_initiator.go new file mode 100644 index 00000000..e2fe9801 --- /dev/null +++ b/remote/mounter/initiator/fakes/fake_base_initiator.go @@ -0,0 +1,148 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package fakes + +import ( + "sync" + + "github.com/IBM/ubiquity/remote/mounter/initiator" +) + +type FakeBaseInitiator struct { + FlushMultipathStub func(string) + flushMultipathMutex sync.RWMutex + flushMultipathArgsForCall []struct { + arg1 string + } + RemoveSCSIDeviceStub func(string) error + removeSCSIDeviceMutex sync.RWMutex + removeSCSIDeviceArgsForCall []struct { + arg1 string + } + removeSCSIDeviceReturns struct { + result1 error + } + removeSCSIDeviceReturnsOnCall map[int]struct { + result1 error + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakeBaseInitiator) FlushMultipath(arg1 string) { + fake.flushMultipathMutex.Lock() + fake.flushMultipathArgsForCall = append(fake.flushMultipathArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("FlushMultipath", []interface{}{arg1}) + fake.flushMultipathMutex.Unlock() + if fake.FlushMultipathStub != nil { + fake.FlushMultipathStub(arg1) + } +} + +func (fake *FakeBaseInitiator) FlushMultipathCallCount() int { + fake.flushMultipathMutex.RLock() + defer fake.flushMultipathMutex.RUnlock() + return len(fake.flushMultipathArgsForCall) +} + +func (fake *FakeBaseInitiator) FlushMultipathCalls(stub func(string)) { + fake.flushMultipathMutex.Lock() + defer fake.flushMultipathMutex.Unlock() + fake.FlushMultipathStub = stub +} + +func (fake *FakeBaseInitiator) FlushMultipathArgsForCall(i int) string { + fake.flushMultipathMutex.RLock() + defer fake.flushMultipathMutex.RUnlock() + argsForCall := fake.flushMultipathArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeBaseInitiator) RemoveSCSIDevice(arg1 string) error { + fake.removeSCSIDeviceMutex.Lock() + ret, specificReturn := fake.removeSCSIDeviceReturnsOnCall[len(fake.removeSCSIDeviceArgsForCall)] + fake.removeSCSIDeviceArgsForCall = append(fake.removeSCSIDeviceArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("RemoveSCSIDevice", []interface{}{arg1}) + fake.removeSCSIDeviceMutex.Unlock() + if fake.RemoveSCSIDeviceStub != nil { + return fake.RemoveSCSIDeviceStub(arg1) + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.removeSCSIDeviceReturns + return fakeReturns.result1 +} + +func (fake *FakeBaseInitiator) RemoveSCSIDeviceCallCount() int { + fake.removeSCSIDeviceMutex.RLock() + defer fake.removeSCSIDeviceMutex.RUnlock() + return len(fake.removeSCSIDeviceArgsForCall) +} + +func (fake *FakeBaseInitiator) RemoveSCSIDeviceCalls(stub func(string) error) { + fake.removeSCSIDeviceMutex.Lock() + defer fake.removeSCSIDeviceMutex.Unlock() + fake.RemoveSCSIDeviceStub = stub +} + +func (fake *FakeBaseInitiator) RemoveSCSIDeviceArgsForCall(i int) string { + fake.removeSCSIDeviceMutex.RLock() + defer fake.removeSCSIDeviceMutex.RUnlock() + argsForCall := fake.removeSCSIDeviceArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeBaseInitiator) RemoveSCSIDeviceReturns(result1 error) { + fake.removeSCSIDeviceMutex.Lock() + defer fake.removeSCSIDeviceMutex.Unlock() + fake.RemoveSCSIDeviceStub = nil + fake.removeSCSIDeviceReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeBaseInitiator) RemoveSCSIDeviceReturnsOnCall(i int, result1 error) { + fake.removeSCSIDeviceMutex.Lock() + defer fake.removeSCSIDeviceMutex.Unlock() + fake.RemoveSCSIDeviceStub = nil + if fake.removeSCSIDeviceReturnsOnCall == nil { + fake.removeSCSIDeviceReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.removeSCSIDeviceReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeBaseInitiator) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.flushMultipathMutex.RLock() + defer fake.flushMultipathMutex.RUnlock() + fake.removeSCSIDeviceMutex.RLock() + defer fake.removeSCSIDeviceMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *FakeBaseInitiator) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +} + +var _ initiator.BaseInitiator = new(FakeBaseInitiator) diff --git a/remote/mounter/initiator/fakes/fake_connector.go b/remote/mounter/initiator/fakes/fake_connector.go new file mode 100644 index 00000000..b0823a79 --- /dev/null +++ b/remote/mounter/initiator/fakes/fake_connector.go @@ -0,0 +1,184 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package fakes + +import ( + "sync" + + "github.com/IBM/ubiquity/remote/mounter/initiator" + "github.com/IBM/ubiquity/resources" +) + +type FakeConnector struct { + ConnectVolumeStub func(*resources.VolumeMountProperties) error + connectVolumeMutex sync.RWMutex + connectVolumeArgsForCall []struct { + arg1 *resources.VolumeMountProperties + } + connectVolumeReturns struct { + result1 error + } + connectVolumeReturnsOnCall map[int]struct { + result1 error + } + DisconnectVolumeStub func(*resources.VolumeMountProperties) error + disconnectVolumeMutex sync.RWMutex + disconnectVolumeArgsForCall []struct { + arg1 *resources.VolumeMountProperties + } + disconnectVolumeReturns struct { + result1 error + } + disconnectVolumeReturnsOnCall map[int]struct { + result1 error + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakeConnector) ConnectVolume(arg1 *resources.VolumeMountProperties) error { + fake.connectVolumeMutex.Lock() + ret, specificReturn := fake.connectVolumeReturnsOnCall[len(fake.connectVolumeArgsForCall)] + fake.connectVolumeArgsForCall = append(fake.connectVolumeArgsForCall, struct { + arg1 *resources.VolumeMountProperties + }{arg1}) + fake.recordInvocation("ConnectVolume", []interface{}{arg1}) + fake.connectVolumeMutex.Unlock() + if fake.ConnectVolumeStub != nil { + return fake.ConnectVolumeStub(arg1) + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.connectVolumeReturns + return fakeReturns.result1 +} + +func (fake *FakeConnector) ConnectVolumeCallCount() int { + fake.connectVolumeMutex.RLock() + defer fake.connectVolumeMutex.RUnlock() + return len(fake.connectVolumeArgsForCall) +} + +func (fake *FakeConnector) ConnectVolumeCalls(stub func(*resources.VolumeMountProperties) error) { + fake.connectVolumeMutex.Lock() + defer fake.connectVolumeMutex.Unlock() + fake.ConnectVolumeStub = stub +} + +func (fake *FakeConnector) ConnectVolumeArgsForCall(i int) *resources.VolumeMountProperties { + fake.connectVolumeMutex.RLock() + defer fake.connectVolumeMutex.RUnlock() + argsForCall := fake.connectVolumeArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeConnector) ConnectVolumeReturns(result1 error) { + fake.connectVolumeMutex.Lock() + defer fake.connectVolumeMutex.Unlock() + fake.ConnectVolumeStub = nil + fake.connectVolumeReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeConnector) ConnectVolumeReturnsOnCall(i int, result1 error) { + fake.connectVolumeMutex.Lock() + defer fake.connectVolumeMutex.Unlock() + fake.ConnectVolumeStub = nil + if fake.connectVolumeReturnsOnCall == nil { + fake.connectVolumeReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.connectVolumeReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeConnector) DisconnectVolume(arg1 *resources.VolumeMountProperties) error { + fake.disconnectVolumeMutex.Lock() + ret, specificReturn := fake.disconnectVolumeReturnsOnCall[len(fake.disconnectVolumeArgsForCall)] + fake.disconnectVolumeArgsForCall = append(fake.disconnectVolumeArgsForCall, struct { + arg1 *resources.VolumeMountProperties + }{arg1}) + fake.recordInvocation("DisconnectVolume", []interface{}{arg1}) + fake.disconnectVolumeMutex.Unlock() + if fake.DisconnectVolumeStub != nil { + return fake.DisconnectVolumeStub(arg1) + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.disconnectVolumeReturns + return fakeReturns.result1 +} + +func (fake *FakeConnector) DisconnectVolumeCallCount() int { + fake.disconnectVolumeMutex.RLock() + defer fake.disconnectVolumeMutex.RUnlock() + return len(fake.disconnectVolumeArgsForCall) +} + +func (fake *FakeConnector) DisconnectVolumeCalls(stub func(*resources.VolumeMountProperties) error) { + fake.disconnectVolumeMutex.Lock() + defer fake.disconnectVolumeMutex.Unlock() + fake.DisconnectVolumeStub = stub +} + +func (fake *FakeConnector) DisconnectVolumeArgsForCall(i int) *resources.VolumeMountProperties { + fake.disconnectVolumeMutex.RLock() + defer fake.disconnectVolumeMutex.RUnlock() + argsForCall := fake.disconnectVolumeArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeConnector) DisconnectVolumeReturns(result1 error) { + fake.disconnectVolumeMutex.Lock() + defer fake.disconnectVolumeMutex.Unlock() + fake.DisconnectVolumeStub = nil + fake.disconnectVolumeReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeConnector) DisconnectVolumeReturnsOnCall(i int, result1 error) { + fake.disconnectVolumeMutex.Lock() + defer fake.disconnectVolumeMutex.Unlock() + fake.DisconnectVolumeStub = nil + if fake.disconnectVolumeReturnsOnCall == nil { + fake.disconnectVolumeReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.disconnectVolumeReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeConnector) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.connectVolumeMutex.RLock() + defer fake.connectVolumeMutex.RUnlock() + fake.disconnectVolumeMutex.RLock() + defer fake.disconnectVolumeMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *FakeConnector) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +} + +var _ initiator.Connector = new(FakeConnector) diff --git a/remote/mounter/initiator/fakes/fake_initiator.go b/remote/mounter/initiator/fakes/fake_initiator.go new file mode 100644 index 00000000..acf074ef --- /dev/null +++ b/remote/mounter/initiator/fakes/fake_initiator.go @@ -0,0 +1,293 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package fakes + +import ( + "sync" + + "github.com/IBM/ubiquity/remote/mounter/initiator" + "github.com/IBM/ubiquity/resources" +) + +type FakeInitiator struct { + FlushMultipathStub func(string) + flushMultipathMutex sync.RWMutex + flushMultipathArgsForCall []struct { + arg1 string + } + GetHBAsStub func() []string + getHBAsMutex sync.RWMutex + getHBAsArgsForCall []struct { + } + getHBAsReturns struct { + result1 []string + } + getHBAsReturnsOnCall map[int]struct { + result1 []string + } + RemoveSCSIDeviceStub func(string) error + removeSCSIDeviceMutex sync.RWMutex + removeSCSIDeviceArgsForCall []struct { + arg1 string + } + removeSCSIDeviceReturns struct { + result1 error + } + removeSCSIDeviceReturnsOnCall map[int]struct { + result1 error + } + RescanHostsStub func([]string, *resources.VolumeMountProperties) error + rescanHostsMutex sync.RWMutex + rescanHostsArgsForCall []struct { + arg1 []string + arg2 *resources.VolumeMountProperties + } + rescanHostsReturns struct { + result1 error + } + rescanHostsReturnsOnCall map[int]struct { + result1 error + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakeInitiator) FlushMultipath(arg1 string) { + fake.flushMultipathMutex.Lock() + fake.flushMultipathArgsForCall = append(fake.flushMultipathArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("FlushMultipath", []interface{}{arg1}) + fake.flushMultipathMutex.Unlock() + if fake.FlushMultipathStub != nil { + fake.FlushMultipathStub(arg1) + } +} + +func (fake *FakeInitiator) FlushMultipathCallCount() int { + fake.flushMultipathMutex.RLock() + defer fake.flushMultipathMutex.RUnlock() + return len(fake.flushMultipathArgsForCall) +} + +func (fake *FakeInitiator) FlushMultipathCalls(stub func(string)) { + fake.flushMultipathMutex.Lock() + defer fake.flushMultipathMutex.Unlock() + fake.FlushMultipathStub = stub +} + +func (fake *FakeInitiator) FlushMultipathArgsForCall(i int) string { + fake.flushMultipathMutex.RLock() + defer fake.flushMultipathMutex.RUnlock() + argsForCall := fake.flushMultipathArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeInitiator) GetHBAs() []string { + fake.getHBAsMutex.Lock() + ret, specificReturn := fake.getHBAsReturnsOnCall[len(fake.getHBAsArgsForCall)] + fake.getHBAsArgsForCall = append(fake.getHBAsArgsForCall, struct { + }{}) + fake.recordInvocation("GetHBAs", []interface{}{}) + fake.getHBAsMutex.Unlock() + if fake.GetHBAsStub != nil { + return fake.GetHBAsStub() + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.getHBAsReturns + return fakeReturns.result1 +} + +func (fake *FakeInitiator) GetHBAsCallCount() int { + fake.getHBAsMutex.RLock() + defer fake.getHBAsMutex.RUnlock() + return len(fake.getHBAsArgsForCall) +} + +func (fake *FakeInitiator) GetHBAsCalls(stub func() []string) { + fake.getHBAsMutex.Lock() + defer fake.getHBAsMutex.Unlock() + fake.GetHBAsStub = stub +} + +func (fake *FakeInitiator) GetHBAsReturns(result1 []string) { + fake.getHBAsMutex.Lock() + defer fake.getHBAsMutex.Unlock() + fake.GetHBAsStub = nil + fake.getHBAsReturns = struct { + result1 []string + }{result1} +} + +func (fake *FakeInitiator) GetHBAsReturnsOnCall(i int, result1 []string) { + fake.getHBAsMutex.Lock() + defer fake.getHBAsMutex.Unlock() + fake.GetHBAsStub = nil + if fake.getHBAsReturnsOnCall == nil { + fake.getHBAsReturnsOnCall = make(map[int]struct { + result1 []string + }) + } + fake.getHBAsReturnsOnCall[i] = struct { + result1 []string + }{result1} +} + +func (fake *FakeInitiator) RemoveSCSIDevice(arg1 string) error { + fake.removeSCSIDeviceMutex.Lock() + ret, specificReturn := fake.removeSCSIDeviceReturnsOnCall[len(fake.removeSCSIDeviceArgsForCall)] + fake.removeSCSIDeviceArgsForCall = append(fake.removeSCSIDeviceArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("RemoveSCSIDevice", []interface{}{arg1}) + fake.removeSCSIDeviceMutex.Unlock() + if fake.RemoveSCSIDeviceStub != nil { + return fake.RemoveSCSIDeviceStub(arg1) + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.removeSCSIDeviceReturns + return fakeReturns.result1 +} + +func (fake *FakeInitiator) RemoveSCSIDeviceCallCount() int { + fake.removeSCSIDeviceMutex.RLock() + defer fake.removeSCSIDeviceMutex.RUnlock() + return len(fake.removeSCSIDeviceArgsForCall) +} + +func (fake *FakeInitiator) RemoveSCSIDeviceCalls(stub func(string) error) { + fake.removeSCSIDeviceMutex.Lock() + defer fake.removeSCSIDeviceMutex.Unlock() + fake.RemoveSCSIDeviceStub = stub +} + +func (fake *FakeInitiator) RemoveSCSIDeviceArgsForCall(i int) string { + fake.removeSCSIDeviceMutex.RLock() + defer fake.removeSCSIDeviceMutex.RUnlock() + argsForCall := fake.removeSCSIDeviceArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeInitiator) RemoveSCSIDeviceReturns(result1 error) { + fake.removeSCSIDeviceMutex.Lock() + defer fake.removeSCSIDeviceMutex.Unlock() + fake.RemoveSCSIDeviceStub = nil + fake.removeSCSIDeviceReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeInitiator) RemoveSCSIDeviceReturnsOnCall(i int, result1 error) { + fake.removeSCSIDeviceMutex.Lock() + defer fake.removeSCSIDeviceMutex.Unlock() + fake.RemoveSCSIDeviceStub = nil + if fake.removeSCSIDeviceReturnsOnCall == nil { + fake.removeSCSIDeviceReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.removeSCSIDeviceReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeInitiator) RescanHosts(arg1 []string, arg2 *resources.VolumeMountProperties) error { + var arg1Copy []string + if arg1 != nil { + arg1Copy = make([]string, len(arg1)) + copy(arg1Copy, arg1) + } + fake.rescanHostsMutex.Lock() + ret, specificReturn := fake.rescanHostsReturnsOnCall[len(fake.rescanHostsArgsForCall)] + fake.rescanHostsArgsForCall = append(fake.rescanHostsArgsForCall, struct { + arg1 []string + arg2 *resources.VolumeMountProperties + }{arg1Copy, arg2}) + fake.recordInvocation("RescanHosts", []interface{}{arg1Copy, arg2}) + fake.rescanHostsMutex.Unlock() + if fake.RescanHostsStub != nil { + return fake.RescanHostsStub(arg1, arg2) + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.rescanHostsReturns + return fakeReturns.result1 +} + +func (fake *FakeInitiator) RescanHostsCallCount() int { + fake.rescanHostsMutex.RLock() + defer fake.rescanHostsMutex.RUnlock() + return len(fake.rescanHostsArgsForCall) +} + +func (fake *FakeInitiator) RescanHostsCalls(stub func([]string, *resources.VolumeMountProperties) error) { + fake.rescanHostsMutex.Lock() + defer fake.rescanHostsMutex.Unlock() + fake.RescanHostsStub = stub +} + +func (fake *FakeInitiator) RescanHostsArgsForCall(i int) ([]string, *resources.VolumeMountProperties) { + fake.rescanHostsMutex.RLock() + defer fake.rescanHostsMutex.RUnlock() + argsForCall := fake.rescanHostsArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeInitiator) RescanHostsReturns(result1 error) { + fake.rescanHostsMutex.Lock() + defer fake.rescanHostsMutex.Unlock() + fake.RescanHostsStub = nil + fake.rescanHostsReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeInitiator) RescanHostsReturnsOnCall(i int, result1 error) { + fake.rescanHostsMutex.Lock() + defer fake.rescanHostsMutex.Unlock() + fake.RescanHostsStub = nil + if fake.rescanHostsReturnsOnCall == nil { + fake.rescanHostsReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.rescanHostsReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeInitiator) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.flushMultipathMutex.RLock() + defer fake.flushMultipathMutex.RUnlock() + fake.getHBAsMutex.RLock() + defer fake.getHBAsMutex.RUnlock() + fake.removeSCSIDeviceMutex.RLock() + defer fake.removeSCSIDeviceMutex.RUnlock() + fake.rescanHostsMutex.RLock() + defer fake.rescanHostsMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *FakeInitiator) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +} + +var _ initiator.Initiator = new(FakeInitiator) diff --git a/remote/mounter/initiator/initiator_suite_test.go b/remote/mounter/initiator/initiator_suite_test.go new file mode 100644 index 00000000..faf4396c --- /dev/null +++ b/remote/mounter/initiator/initiator_suite_test.go @@ -0,0 +1,16 @@ +package initiator_test + +import ( + "testing" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + + "github.com/IBM/ubiquity/utils" +) + +func TestInitiators(t *testing.T) { + RegisterFailHandler(Fail) + defer utils.InitUbiquityServerTestLogger()() + RunSpecs(t, "Initiators Suite") +} diff --git a/remote/mounter/initiator/linuxfc.go b/remote/mounter/initiator/linuxfc.go new file mode 100644 index 00000000..44d5a9c5 --- /dev/null +++ b/remote/mounter/initiator/linuxfc.go @@ -0,0 +1,225 @@ +package initiator + +import ( + "fmt" + "io/ioutil" + "os" + "strings" + + "github.com/IBM/ubiquity/resources" + "github.com/IBM/ubiquity/utils" + "github.com/IBM/ubiquity/utils/logs" +) + +const SYSTOOL = "systool" +const SYSTOOL_TIMEOUT = 5 * 1000 + +var RESET_LIP = true + +var FC_HOST_SYSFS_PATH = "/sys/class/fc_host" +var SCSI_HOST_SYSFS_PATH = "/sys/class/scsi_host" + +type linuxFibreChannel struct { + *linuxSCSI +} + +func NewLinuxFibreChannel() Initiator { + return newLinuxFibreChannel() +} + +func NewLinuxFibreChannelWithExecutor(executor utils.Executor) Initiator { + return newLinuxFibreChannelWithExecutor(executor) +} + +func newLinuxFibreChannel() *linuxFibreChannel { + executor := utils.NewExecutor() + return newLinuxFibreChannelWithExecutor(executor) +} + +func newLinuxFibreChannelWithExecutor(executor utils.Executor) *linuxFibreChannel { + logger := logs.GetLogger() + return &linuxFibreChannel{&linuxSCSI{logger: logger, exec: executor}} +} + +func (lfc *linuxFibreChannel) hasFCSupport() bool { + fileInfo, err := os.Stat(FC_HOST_SYSFS_PATH) + if err != nil { + return false + } + return fileInfo.IsDir() +} + +// Try to get the HBA channel and SCSI target for an HBA. +// return a string with "channel, target, lun" entries, the channel and target +// may be '-' wildcards if unable to determine them. +func (lfc *linuxFibreChannel) getHBAChannelScsiTarget(volumeMountProperties *resources.VolumeMountProperties) string { + //TODO: get channel and target + if volumeMountProperties.LunNumber == float64(-1) { + return "- - -" + } + // use %g to print a float64 to int + return fmt.Sprintf("- - %g", volumeMountProperties.LunNumber) +} + +// GetHBAs return all the FC HBAs in the system +func (lfc *linuxFibreChannel) GetHBAs() []string { + if !lfc.hasFCSupport() { + return []string{} + } + + if err := lfc.exec.IsExecutable(SYSTOOL); err != nil { + lfc.logger.Warning(fmt.Sprintf("No systool installed, get from path %s instead.", FC_HOST_SYSFS_PATH)) + return lfc.getFcHBAsByPath() + } + + out, err := lfc.exec.ExecuteWithTimeout(SYSTOOL_TIMEOUT, SYSTOOL, []string{"-c", "fc_host", "-v"}) + if err != nil { + lfc.logger.Warning(fmt.Sprintf("Executing systool failed with error: %v. Get from path %s instead.", err, FC_HOST_SYSFS_PATH)) + return lfc.getFcHBAsByPath() + } + + // No FC HBAs were found + if len(out) == 0 { + return []string{} + } + hbas := generateHBAsInfoFromSystoolOutput(out) + lfc.logger.Debug(fmt.Sprintf("Find %d HBAs from systool output, getting the name of the online one(s)", len(hbas))) + hbaNames := []string{} + for _, hba := range hbas { + if hba["port_state"] == "Online" { + hbaNames = append(hbaNames, hba["ClassDevice"]) + } + } + return hbaNames +} + +// getFcHBAsByPath returns the FC HBA names under path /sys/class/fc_host +func (lfc *linuxFibreChannel) getFcHBAsByPath() []string { + hbas := []string{} + hostInfos, err := ioutil.ReadDir(FC_HOST_SYSFS_PATH) + if err != nil { + return []string{} + } + + for _, host := range hostInfos { + hbas = append(hbas, host.Name()) + } + return hbas +} + +// RescanHosts rescan all the host HBAs for a certain lun if LunNumber is specified, +// if not, means LunNumber is -1, rescan all the luns. +func (lfc *linuxFibreChannel) RescanHosts(hbas []string, volumeMountProperties *resources.VolumeMountProperties) error { + defer lfc.logger.Trace(logs.DEBUG)() + + ctl := lfc.getHBAChannelScsiTarget(volumeMountProperties) + + for _, hba := range hbas { + + if RESET_LIP { + lfc.lipReset(hba) + } + + hbaPath := SCSI_HOST_SYSFS_PATH + "/" + hba + "/scan" + lfc.logger.Debug(fmt.Sprintf(`Scanning HBA with command: echo "%s" > %s`, ctl, hbaPath)) + if err := ioutil.WriteFile(hbaPath, []byte(ctl), 0666); err != nil { + lfc.logger.Warning("Failed to scan HBA", logs.Args{{"name", hba}, {"err", err}}) + continue + } + } + return nil +} + +func (lfc *linuxFibreChannel) lipReset(hba string) { + path := FC_HOST_SYSFS_PATH + "/" + hba + "/issue_lip" + lfc.logger.Debug(fmt.Sprintf(`Resetting LIP with command: echo "1" > %s`, path)) + if err := ioutil.WriteFile(path, []byte("1"), 0666); err != nil { + lfc.logger.Warning("Failed to reset LIP", logs.Args{{"name", hba}, {"err", err}}) + } +} + +/* +generateHBAsInfoFromSystoolOutput analysises the output of command "systool -c fc_host -v", +and generates a list of HBA info. + +A sample output is: +Class = "fc_host" + + Class Device = "host0" + Class Device path = "/sys/devices/css0/0.0.0000/0.0.a200/host0/fc_host/host0" + active_fc4s = "0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 " + dev_loss_tmo = "60" + maxframe_size = "2112 bytes" + node_name = "0x5005076400c1b2b8" + permanent_port_name = "0xc05076e5118011d1" + port_id = "0x0ecfd3" + port_name = "0xc05076e511803cb0" + port_state = "Online" + port_type = "NPIV VPORT" + serial_number = "IBM0200000001B2B8" + speed = "8 Gbit" + supported_classes = "Class 2, Class 3" + supported_fc4s = "0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 " + supported_speeds = "4 Gbit, 8 Gbit, 16 Gbit" + symbolic_name = "IBM 3906 0200000001B2B8 PCHID: 011D NPIV UlpId: 004C0308 DEVNO: 0.0.a200 NAME: stk8s008" + tgtid_bind_type = "wwpn (World Wide Port Name)" + uevent = + + Device = "host0" + Device path = "/sys/devices/css0/0.0.0000/0.0.a200/host0" + uevent = "DEVTYPE=scsi_host" + + + Class Device = "host1" + Class Device path = "/sys/devices/css0/0.0.0001/0.0.a300/host1/fc_host/host1" + active_fc4s = "0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 " + dev_loss_tmo = "60" + maxframe_size = "2112 bytes" + node_name = "0x5005076400c1b2b8" + permanent_port_name = "0xc05076e511801811" + port_id = "0x0fc613" + port_name = "0xc05076e511803b48" + port_state = "Online" + port_type = "NPIV VPORT" + serial_number = "IBM0200000001B2B8" + speed = "8 Gbit" + supported_classes = "Class 2, Class 3" + supported_fc4s = "0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 " + supported_speeds = "4 Gbit, 8 Gbit, 16 Gbit" + symbolic_name = "IBM 3906 0200000001B2B8 PCHID: 0181 NPIV UlpId: 00450308 DEVNO: 0.0.a300 NAME: stk8s008" + tgtid_bind_type = "wwpn (World Wide Port Name)" + uevent = + + Device = "host1" + Device path = "/sys/devices/css0/0.0.0001/0.0.a300/host1" + uevent = "DEVTYPE=scsi_host" + + +*/ +func generateHBAsInfoFromSystoolOutput(out []byte) []map[string]string { + lines := strings.Split(string(out), "\n") + // ignore the first 2 lines + lines = lines[2:] + hbas := []map[string]string{} + hba := map[string]string{} + lastline := "" + for _, line := range lines { + line = strings.TrimSpace(line) + // 2 newlines denotes a new hba port + if line == "" && lastline == "" { + if len(hba) > 0 { + hbas = append(hbas, hba) + hba = map[string]string{} + } + } else { + val := strings.Split(line, "=") + if len(val) == 2 { + key := strings.Replace(strings.TrimSpace(val[0]), " ", "", -1) + value := strings.Replace(strings.TrimSpace(val[1]), `"`, "", -1) + hba[key] = value + } + } + lastline = line + } + return hbas +} diff --git a/remote/mounter/initiator/linuxfc_test.go b/remote/mounter/initiator/linuxfc_test.go new file mode 100644 index 00000000..432a7474 --- /dev/null +++ b/remote/mounter/initiator/linuxfc_test.go @@ -0,0 +1,261 @@ +package initiator_test + +import ( + "errors" + "fmt" + "io/ioutil" + "os" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + + "github.com/IBM/ubiquity/fakes" + "github.com/IBM/ubiquity/remote/mounter/initiator" + "github.com/IBM/ubiquity/resources" +) + +const tmp_prefix = "/tmp/ubiquity_test" + +const FAKE_FC_HOST_SYSFS_PATH = tmp_prefix + "/sys/class/fc_host" +const FAKE_SCSI_HOST_SYSFS_PATH = tmp_prefix + "/sys/class/scsi_host" +const FAKE_SYS_BLOCK_PATH = tmp_prefix + "/sys/block" + +var fakeSystoolOutput = `Class = "fc_host" + + Class Device = "host0" + Class Device path = "/sys/devices/css0/0.0.0000/0.0.a200/host0/fc_host/host0" + active_fc4s = "0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 " + dev_loss_tmo = "60" + maxframe_size = "2112 bytes" + node_name = "0x5005076400c1b2b8" + permanent_port_name = "0xc05076e5118011d1" + port_id = "0x0ecfd3" + port_name = "0xc05076e511803cb0" + port_state = "Online" + port_type = "NPIV VPORT" + serial_number = "IBM0200000001B2B8" + speed = "8 Gbit" + supported_classes = "Class 2, Class 3" + supported_fc4s = "0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 " + supported_speeds = "4 Gbit, 8 Gbit, 16 Gbit" + symbolic_name = "IBM 3906 0200000001B2B8 PCHID: 011D NPIV UlpId: 004C0308 DEVNO: 0.0.a200 NAME: stk8s008" + tgtid_bind_type = "wwpn (World Wide Port Name)" + uevent = + + Device = "host0" + Device path = "/sys/devices/css0/0.0.0000/0.0.a200/host0" + uevent = "DEVTYPE=scsi_host" + + + Class Device = "host1" + Class Device path = "/sys/devices/css0/0.0.0001/0.0.a300/host1/fc_host/host1" + active_fc4s = "0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 " + dev_loss_tmo = "60" + maxframe_size = "2112 bytes" + node_name = "0x5005076400c1b2b8" + permanent_port_name = "0xc05076e511801811" + port_id = "0x0fc613" + port_name = "0xc05076e511803b48" + port_state = "Online" + port_type = "NPIV VPORT" + serial_number = "IBM0200000001B2B8" + speed = "8 Gbit" + supported_classes = "Class 2, Class 3" + supported_fc4s = "0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 " + supported_speeds = "4 Gbit, 8 Gbit, 16 Gbit" + symbolic_name = "IBM 3906 0200000001B2B8 PCHID: 0181 NPIV UlpId: 00450308 DEVNO: 0.0.a300 NAME: stk8s008" + tgtid_bind_type = "wwpn (World Wide Port Name)" + uevent = + + Device = "host1" + Device path = "/sys/devices/css0/0.0.0001/0.0.a300/host1" + uevent = "DEVTYPE=scsi_host" + + +` + +var _ = Describe("Test FC Initiator", func() { + var ( + fakeExec *fakes.FakeExecutor + fcInitiator initiator.Initiator + realFcSysPath string + realScsiSysPath string + realSysBlockPath string + cmdErr error = errors.New("command error") + ) + volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: float64(1)} + + BeforeEach(func() { + err := os.MkdirAll(FAKE_FC_HOST_SYSFS_PATH, os.ModePerm) + Ω(err).ShouldNot(HaveOccurred()) + + err = os.MkdirAll(FAKE_SCSI_HOST_SYSFS_PATH, os.ModePerm) + Ω(err).ShouldNot(HaveOccurred()) + + err = os.MkdirAll(FAKE_SYS_BLOCK_PATH, os.ModePerm) + Ω(err).ShouldNot(HaveOccurred()) + + realFcSysPath = initiator.FC_HOST_SYSFS_PATH + realScsiSysPath = initiator.SCSI_HOST_SYSFS_PATH + realSysBlockPath = initiator.SYS_BLOCK_PATH + initiator.FC_HOST_SYSFS_PATH = FAKE_FC_HOST_SYSFS_PATH + initiator.SCSI_HOST_SYSFS_PATH = FAKE_SCSI_HOST_SYSFS_PATH + initiator.SYS_BLOCK_PATH = FAKE_SYS_BLOCK_PATH + + fakeExec = new(fakes.FakeExecutor) + fcInitiator = initiator.NewLinuxFibreChannelWithExecutor(fakeExec) + }) + + AfterEach(func() { + initiator.FC_HOST_SYSFS_PATH = realFcSysPath + initiator.SCSI_HOST_SYSFS_PATH = realScsiSysPath + initiator.SYS_BLOCK_PATH = realSysBlockPath + + err := os.RemoveAll(tmp_prefix) + Ω(err).ShouldNot(HaveOccurred()) + }) + + Context("GetHBAs", func() { + + Context("get HBAs from systool", func() { + BeforeEach(func() { + fakeExec.ExecuteWithTimeoutReturns([]byte(fakeSystoolOutput), nil) + }) + + It("should get from systool if it is installed", func() { + hbas := fcInitiator.GetHBAs() + Expect(hbas).To(Equal([]string{"host0", "host1"})) + }) + }) + + Context("get HBAs from sys fc path", func() { + hbas := []string{"host0", "host1", "host2"} + + BeforeEach(func() { + for _, hba := range hbas { + fullPath := FAKE_FC_HOST_SYSFS_PATH + "/" + hba + err := os.MkdirAll(fullPath, os.ModePerm) + Ω(err).ShouldNot(HaveOccurred()) + } + }) + + It("should get from sys fc path if systool is not installed", func() { + fakeExec.IsExecutableReturns(cmdErr) + hbasRes := fcInitiator.GetHBAs() + Expect(hbasRes).To(Equal(hbas)) + }) + + It("should get from sys fc path if systool returns error", func() { + fakeExec.ExecuteWithTimeoutReturns([]byte{}, cmdErr) + hbasRes := fcInitiator.GetHBAs() + Expect(hbasRes).To(Equal(hbas)) + }) + }) + + }) + + Context("RescanHosts", func() { + var hbas = []string{"host0"} + var scanPath = FAKE_SCSI_HOST_SYSFS_PATH + "/" + hbas[0] + var scanFile = scanPath + "/scan" + var lipPath = FAKE_FC_HOST_SYSFS_PATH + "/" + hbas[0] + var lipFile = lipPath + "/issue_lip" + var realLipResetBool bool + + BeforeEach(func() { + err := os.MkdirAll(scanPath, os.ModePerm) + Ω(err).ShouldNot(HaveOccurred()) + _, err = os.Create(scanFile) + Ω(err).ShouldNot(HaveOccurred()) + + err = os.MkdirAll(lipPath, os.ModePerm) + Ω(err).ShouldNot(HaveOccurred()) + _, err = os.Create(lipFile) + Ω(err).ShouldNot(HaveOccurred()) + }) + + Context("RESET_LIP is true", func() { + BeforeEach(func() { + realLipResetBool = initiator.RESET_LIP + initiator.RESET_LIP = true + }) + + AfterEach(func() { + initiator.RESET_LIP = realLipResetBool + }) + + It("should write '- - lunid' to the hba scan file", func() { + err := fcInitiator.RescanHosts(hbas, volumeMountProperties) + Ω(err).ShouldNot(HaveOccurred()) + data, err := ioutil.ReadFile(scanFile) + Ω(err).ShouldNot(HaveOccurred()) + Expect(string(data)).To(Equal(fmt.Sprintf("- - %g", volumeMountProperties.LunNumber))) + }) + + It("should write '1' to the hba lip file", func() { + err := fcInitiator.RescanHosts(hbas, volumeMountProperties) + Ω(err).ShouldNot(HaveOccurred()) + data, err := ioutil.ReadFile(lipFile) + Ω(err).ShouldNot(HaveOccurred()) + Expect(string(data)).To(Equal("1")) + }) + }) + + Context("RESET_LIP is false", func() { + BeforeEach(func() { + realLipResetBool = initiator.RESET_LIP + initiator.RESET_LIP = false + }) + + AfterEach(func() { + initiator.RESET_LIP = realLipResetBool + }) + + It("should write nothing to the hba lip file", func() { + err := fcInitiator.RescanHosts(hbas, volumeMountProperties) + Ω(err).ShouldNot(HaveOccurred()) + data, err := ioutil.ReadFile(lipFile) + Ω(err).ShouldNot(HaveOccurred()) + Expect(string(data)).To(Equal("")) + }) + }) + + }) + + Context("RemoveSCSIDevice", func() { + var devName = "sda" + var dev = "/dev/" + devName + var deletePath = FAKE_SYS_BLOCK_PATH + fmt.Sprintf("/%s/device", devName) + var deleteFile = deletePath + "/delete" + + BeforeEach(func() { + err := os.MkdirAll(deletePath, os.ModePerm) + Ω(err).ShouldNot(HaveOccurred()) + _, err = os.Create(deleteFile) + Ω(err).ShouldNot(HaveOccurred()) + }) + + It("should write 1 to the device delete file", func() { + err := fcInitiator.RemoveSCSIDevice(dev) + Ω(err).ShouldNot(HaveOccurred()) + data, err := ioutil.ReadFile(deleteFile) + Ω(err).ShouldNot(HaveOccurred()) + Expect(string(data)).To(Equal("1")) + }) + }) + + Context("FlushMultipath", func() { + + It("should flush once if succeeds", func() { + fakeExec.ExecuteWithTimeoutReturns([]byte{}, nil) + fcInitiator.FlushMultipath("fake") + Expect(fakeExec.ExecuteWithTimeoutCallCount()).To(Equal(1)) + }) + + It("should flush twice if fails", func() { + fakeExec.ExecuteWithTimeoutReturns([]byte{}, cmdErr) + fcInitiator.FlushMultipath("fake") + Expect(fakeExec.ExecuteWithTimeoutCallCount()).To(Equal(2)) + }) + }) +}) diff --git a/remote/mounter/initiator/linuxscsi.go b/remote/mounter/initiator/linuxscsi.go new file mode 100644 index 00000000..b335b41b --- /dev/null +++ b/remote/mounter/initiator/linuxscsi.go @@ -0,0 +1,51 @@ +package initiator + +import ( + "fmt" + "io/ioutil" + "os" + "strings" + + "github.com/IBM/ubiquity/utils" + "github.com/IBM/ubiquity/utils/logs" +) + +const multipathCmd = "multipath" +const FlushTimeout = 10 * 1000 + +var SYS_BLOCK_PATH = "/sys/block" + +type linuxSCSI struct { + exec utils.Executor + logger logs.Logger +} + +// FlushMultipath flushes the device, if it is failed becasue of device in use, retry again. +func (ls *linuxSCSI) FlushMultipath(deviceMapName string) { + if err := ls.exec.IsExecutable(multipathCmd); err != nil { + return + } + + for i := 0; i < 2; i++ { + args := []string{"-f", deviceMapName} + ls.logger.Info(fmt.Sprintf("Flush multipath by running: multipath -f %s", deviceMapName)) + _, err := ls.exec.ExecuteWithTimeout(FlushTimeout, multipathCmd, args) + if err == nil { + return + } + } +} + +// RemoveSCSIDevice removes a scsi device based upon /dev/sdX name. +func (ls *linuxSCSI) RemoveSCSIDevice(device string) error { + deviceName := strings.Replace(device, "/dev/", "", 1) + path := SYS_BLOCK_PATH + fmt.Sprintf("/%s/device/delete", deviceName) + if _, err := os.Stat(path); !os.IsNotExist(err) { + ls.logger.Debug(fmt.Sprintf("Remove SCSI device %s with %s", device, path)) + if err := ioutil.WriteFile(path, []byte("1"), 0666); err != nil { + cmd := fmt.Sprintf(`echo "1" > %s`, path) + return ls.logger.ErrorRet(&utils.CommandExecuteError{cmd, err}, "failed") + } + } + return nil +} diff --git a/remote/mounter/initiator/resources.go b/remote/mounter/initiator/resources.go new file mode 100644 index 00000000..83f53a77 --- /dev/null +++ b/remote/mounter/initiator/resources.go @@ -0,0 +1,22 @@ +package initiator + +import "github.com/IBM/ubiquity/resources" + +//go:generate counterfeiter -o fakes/fake_base_initiator.go . BaseInitiator +type BaseInitiator interface { + RemoveSCSIDevice(device string) error + FlushMultipath(deviceMapName string) +} + +//go:generate counterfeiter -o fakes/fake_initiator.go . Initiator +type Initiator interface { + BaseInitiator + GetHBAs() []string + RescanHosts(hbas []string, volumeMountProperties *resources.VolumeMountProperties) error +} + +//go:generate counterfeiter -o fakes/fake_connector.go . Connector +type Connector interface { + ConnectVolume(volumeMountProperties *resources.VolumeMountProperties) error + DisconnectVolume(volumeMountProperties *resources.VolumeMountProperties) error +} diff --git a/remote/mounter/mounter_factory.go b/remote/mounter/mounter_factory.go index 7ee0c382..3f5a6943 100644 --- a/remote/mounter/mounter_factory.go +++ b/remote/mounter/mounter_factory.go @@ -1,12 +1,13 @@ package mounter import ( + "log" + "github.com/IBM/ubiquity/resources" "github.com/IBM/ubiquity/utils/logs" - "log" ) -//go:generate counterfeiter -o ../fakes/fake_mounter_factory.go . MounterFactory +//go:generate counterfeiter -o ../../fakes/fake_mounter_factory.go . MounterFactory type MounterFactory interface { GetMounterPerBackend(backend string, legacyLogger *log.Logger, pluginConfig resources.UbiquityPluginConfig, requestContext resources.RequestContext) (resources.Mounter, error) } diff --git a/remote/mounter/scbe.go b/remote/mounter/scbe.go index 54036c98..19b5f2a2 100644 --- a/remote/mounter/scbe.go +++ b/remote/mounter/scbe.go @@ -50,35 +50,29 @@ func NewScbeMounterWithExecuter(blockDeviceMounterUtils block_device_mounter_uti return newScbMounter(blockDeviceMounterUtils, executer) } +func (s *scbeMounter) prepareVolumeMountProperties(vcGetter resources.VolumeConfigGetter) *resources.VolumeMountProperties { + volumeConfig := vcGetter.GetVolumeConfig() + volumeWWN := volumeConfig["Wwn"].(string) + volumeLunNumber := float64(-1) + if volumeLunNumberInterface, exists := volumeConfig[resources.ScbeKeyVolAttachLunNumToHost]; exists { + volumeLunNumber = volumeLunNumberInterface.(float64) + } + return &resources.VolumeMountProperties{WWN: volumeWWN, LunNumber: volumeLunNumber} +} + func (s *scbeMounter) Mount(mountRequest resources.MountRequest) (string, error) { defer s.logger.Trace(logs.DEBUG)() - volumeWWN := mountRequest.VolumeConfig["Wwn"].(string) + volumeMountProperties := s.prepareVolumeMountProperties(&mountRequest) // Rescan OS - if err := s.blockDeviceMounterUtils.RescanAll(volumeWWN, false, false); err != nil { + if err := s.blockDeviceMounterUtils.RescanAll(volumeMountProperties); err != nil { return "", s.logger.ErrorRet(err, "RescanAll failed") } // Discover device - devicePath, err := s.blockDeviceMounterUtils.Discover(volumeWWN, true) + devicePath, err := s.blockDeviceMounterUtils.Discover(volumeMountProperties.WWN, true) if err != nil { - // Known issue: UB-1103 in https://www.ibm.com/support/knowledgecenter/SS6JWS_3.4.0/RN/sc_rn_knownissues.html - // XIV doesn't using Lun Number 0, We don't care the storage type here. - // For DS8k and Storwize Lun0, "rescan-scsi-bus.sh -r" cannot discover the LUN0, need to use rescanLun0 instead - s.logger.Info("volumeConfig: ", logs.Args{{"volumeConfig: ", mountRequest.VolumeConfig}}) - _, ok := err.(*block_device_utils.VolumeNotFoundError) - if ok && isLun0(mountRequest) { - s.logger.Info("It is the first lun of DS8K or Storwize, will try to rescan lun0") - if err := s.blockDeviceMounterUtils.RescanAll(volumeWWN, false, true); err != nil { - return "", s.logger.ErrorRet(err, "Rescan lun0 failed", logs.Args{{"volumeWWN", volumeWWN}}) - } - devicePath, err = s.blockDeviceMounterUtils.Discover(volumeWWN, true) - if err != nil { - return "", s.logger.ErrorRet(err, "Discover failed after run rescan and also additional rescan with special lun0 scanning", logs.Args{{"volumeWWN", volumeWWN}}) - } - } else { - return "", s.logger.ErrorRet(err, "Discover failed", logs.Args{{"volumeWWN", volumeWWN}}) - } + return "", s.logger.ErrorRet(err, "Discover failed", logs.Args{{"volumeWWN", volumeMountProperties.WWN}}) } // Create mount point if needed // TODO consider to move it inside the util @@ -160,22 +154,11 @@ func (s *scbeMounter) Unmount(unmountRequest resources.UnmountRequest) error { func (s *scbeMounter) ActionAfterDetach(request resources.AfterDetachRequest) error { defer s.logger.Trace(logs.DEBUG)() - volumeWWN := request.VolumeConfig["Wwn"].(string) + volumeMountProperties := s.prepareVolumeMountProperties(&request) - // Rescan OS - if err := s.blockDeviceMounterUtils.RescanAll(volumeWWN, true, false); err != nil { - return s.logger.ErrorRet(err, "RescanAll failed") + // Cleanup volume + if err := s.blockDeviceMounterUtils.CleanupAll(volumeMountProperties); err != nil { + return s.logger.ErrorRet(err, "CleanupAll failed") } return nil } - -func isLun0(mountRequest resources.MountRequest) bool { - lunNumber, ok := mountRequest.VolumeConfig[resources.ScbeKeyVolAttachLunNumToHost] - if !ok { - return false - } - if int(lunNumber.(float64)) == 0 { - return true - } - return false -} diff --git a/remote/mounter/scbe_test.go b/remote/mounter/scbe_test.go index e1131a1f..bc839e2f 100644 --- a/remote/mounter/scbe_test.go +++ b/remote/mounter/scbe_test.go @@ -32,12 +32,6 @@ var _ = Describe("scbe_mounter_test", func() { callErr error = &block_device_utils.VolumeNotFoundError{"wwn"} - mountRequestForDS8kLun0 = resources.MountRequest{Mountpoint: "test_mountpointDS8k", VolumeConfig: map[string]interface{}{"Name": "u_vol", "PhysicalCapacity": fakePhysicalCapacity, - "Profile": fakeProfile, "StorageType": fakeDS8kStoragetType, "UsedCapacity": fakeUsedCapacity, "Wwn": "wwn", "attach-to": "xnode1", - "LogicalCapacity": fakeLogicalCapacity, "LunNumber": float64(0), "PoolName": "pool", "StorageName": "IBM.2107", "fstype": "ext4"}} - mountRequestForSVCLun0 = resources.MountRequest{Mountpoint: "test_mountpointSVC", VolumeConfig: map[string]interface{}{"Name": "u_vol", "PhysicalCapacity": fakePhysicalCapacity, - "Profile": fakeProfile, "StorageType": fakeV7kStorageType, "UsedCapacity": fakeUsedCapacity, "Wwn": "wwn", "attach-to": "node1", - "LogicalCapacity": fakeLogicalCapacity, "LunNumber": float64(0), "PoolName": "pool", "StorageName": "IBM.2706", "fstype": "ext4"}} mountRequestForDS8kLun1 = resources.MountRequest{Mountpoint: "test_mountpointDS8k", VolumeConfig: map[string]interface{}{"Name": "u_vol", "PhysicalCapacity": fakePhysicalCapacity, "Profile": fakeProfile, "StorageType": fakeDS8kStoragetType, "UsedCapacity": fakeUsedCapacity, "Wwn": "wwn", "attach-to": "node1", "LogicalCapacity": fakeLogicalCapacity, "LunNumber": float64(1), "PoolName": "pool", "StorageName": "IBM.2107", "fstype": "ext4"}} @@ -159,21 +153,9 @@ var _ = Describe("scbe_mounter_test", func() { }) }) Context("Mount", func() { - It("should success to discover ds8k with lun0", func() { - fakeBdUtils.DiscoverReturnsOnCall(0, "", callErr) - fakeBdUtils.DiscoverReturnsOnCall(1, "wwn", nil) - fakeBdUtils.RescanAllReturnsOnCall(0, nil) - fakeBdUtils.RescanAllReturnsOnCall(1, nil) - _, err := scbeMounter.Mount(mountRequestForDS8kLun0) - Expect(err).ToNot(HaveOccurred()) - }) - It("should success to discover svc with lun0", func() { - fakeBdUtils.DiscoverReturnsOnCall(0, "wwn", nil) - fakeBdUtils.DiscoverReturnsOnCall(1, "wwn", nil) - fakeBdUtils.RescanAllReturnsOnCall(0, nil) - fakeBdUtils.RescanAllReturnsOnCall(1, nil) - _, err := scbeMounter.Mount(mountRequestForSVCLun0) - Expect(err).ToNot(HaveOccurred()) + It("should be true to discover ", func() { + _, err := scbeMounter.Mount(mountRequestForDS8kLun1) + Expect(err).NotTo(HaveOccurred()) }) It("should fail to discover ds8k with lun1 if failed to discover with '-r' ", func() { fakeBdUtils.DiscoverReturns("", callErr) @@ -206,6 +188,14 @@ var _ = Describe("scbe_mounter_test", func() { Expect(err).To(HaveOccurred()) }) }) + Context("ActionAfterDetach", func() { + It("should call CleanupAll ", func() { + req := resources.AfterDetachRequest{VolumeConfig: map[string]interface{}{"Wwn": "wwn", "LunNumber": float64(1)}} + err := scbeMounter.ActionAfterDetach(req) + Expect(err).NotTo(HaveOccurred()) + Expect(fakeBdUtils.CleanupAllCallCount()).To(Equal(1)) + }) + }) }) func TestSCBEMounter(t *testing.T) { diff --git a/resources/resources.go b/resources/resources.go index 40f8849e..24187e38 100644 --- a/resources/resources.go +++ b/resources/resources.go @@ -195,6 +195,10 @@ type Mounter interface { ActionAfterDetach(request AfterDetachRequest) error } +type VolumeConfigGetter interface { + GetVolumeConfig() map[string]interface{} +} + type ActivateRequest struct { CredentialInfo CredentialInfo Backends []string @@ -261,6 +265,12 @@ type MountRequest struct { Context RequestContext } +func (r *MountRequest) GetVolumeConfig() map[string]interface{} { + return r.VolumeConfig +} + +var _ VolumeConfigGetter = &MountRequest{} + type UnmountRequest struct { // TODO missing Mountpoint string VolumeConfig map[string]interface{} @@ -270,6 +280,13 @@ type AfterDetachRequest struct { VolumeConfig map[string]interface{} Context RequestContext } + +func (r *AfterDetachRequest) GetVolumeConfig() map[string]interface{} { + return r.VolumeConfig +} + +var _ VolumeConfigGetter = &AfterDetachRequest{} + type AttachResponse struct { Mountpoint string Err string @@ -338,3 +355,8 @@ type RequestContext struct { Id string ActionName string } + +type VolumeMountProperties struct { + WWN string + LunNumber float64 +} diff --git a/utils/error.go b/utils/error.go index b6e2987e..eb5a71e7 100644 --- a/utils/error.go +++ b/utils/error.go @@ -14,7 +14,6 @@ * limitations under the License. */ - package utils import ( @@ -28,3 +27,21 @@ type NoENVKeyError struct { func (e *NoENVKeyError) Error() string { return fmt.Sprintf("ENV Key [%s] not exist.", e.EnvKeyName) } + +type CommandExecuteError struct { + Cmd string + Err error +} + +func (e *CommandExecuteError) Error() string { + return fmt.Sprintf("command [%v] execution failure [%v]", e.Cmd, e.Err) +} + +type CommandNotFoundError struct { + Cmd string + Err error +} + +func (e *CommandNotFoundError) Error() string { + return fmt.Sprintf("command [%v] is not found [%v]", e.Cmd, e.Err) +} diff --git a/utils/mpath.go b/utils/mpath.go new file mode 100644 index 00000000..7e8ee448 --- /dev/null +++ b/utils/mpath.go @@ -0,0 +1,81 @@ +package utils + +import ( + "bufio" + "regexp" + "strings" +) + +const multipathCmd = "multipath" +const MultipathTimeout = 10 * 1000 + +/* +GetMultipathOutputAndDeviceMapperAndDevice analysises the output of command "multipath -ll", +and find the device mapper and device names according to the given WWN. + +For example: +Input: +6005076306ffd69d0000000000001004 + +Multipath output: +mpathg (36005076306ffd69d0000000000001004) dm-14 IBM ,2107900 +size=1.0G features='1 queue_if_no_path' hwhandler='0' wp=rw +`-+- policy='service-time 0' prio=1 status=active + |- 29:0:1:1 sde 8:64 active ready running + |- 29:0:6:1 sdf 8:80 active ready running + `- 29:0:7:1 sdg 8:96 active ready running +mpathf (36005076306ffd69d000000000000010a) dm-2 IBM ,2107900 +size=2.0G features='1 queue_if_no_path' hwhandler='0' wp=rw +`-+- policy='service-time 0' prio=1 status=enabled + |- 29:0:1:0 sdb 8:16 active ready running + |- 29:0:6:0 sdc 8:32 active ready running + `- 29:0:7:0 sdd 8:48 active ready running + +Output: +fullOutput, mpathg, [sde, sdf, sdg], nil +*/ +func GetMultipathOutputAndDeviceMapperAndDevice(volumeWwn string, exec Executor) ([]byte, string, []string, error) { + if err := exec.IsExecutable(multipathCmd); err != nil { + return []byte{}, "", []string{}, &CommandNotFoundError{multipathCmd, err} + } + args := []string{"-ll"} + outputBytes, err := exec.ExecuteWithTimeout(MultipathTimeout, multipathCmd, args) + if err != nil { + return []byte{}, "", []string{}, &CommandExecuteError{multipathCmd, err} + } + scanner := bufio.NewScanner(strings.NewReader(string(outputBytes[:]))) + headerPattern := "(?i)" + volumeWwn + headerRegex, err := regexp.Compile(headerPattern) + if err != nil { + return []byte{}, "", []string{}, err + } + bodyPattern := "[0-9]+:[0-9]+:[0-9]+:[0-9]+ " + bodyRegex, err := regexp.Compile(bodyPattern) + if err != nil { + return []byte{}, "", []string{}, err + } + devMapper := "" + for scanner.Scan() { + if headerRegex.MatchString(scanner.Text()) { + devMapper = strings.Split(scanner.Text(), " ")[0] + break + } + } + deviceNames := []string{} + if devMapper != "" { + // skip next two lines + scanner.Scan() + scanner.Scan() + for scanner.Scan() { + text := scanner.Text() + text = strings.TrimSpace(text) + if bodyRegex.MatchString(text) { + deviceName := strings.Split(text, " ")[2] + deviceNames = append(deviceNames, deviceName) + } else { + break + } + } + } + return outputBytes, devMapper, deviceNames, nil +} diff --git a/utils/mpath_test.go b/utils/mpath_test.go new file mode 100644 index 00000000..2c8717c8 --- /dev/null +++ b/utils/mpath_test.go @@ -0,0 +1,59 @@ +package utils_test + +import ( + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + + "github.com/IBM/ubiquity/fakes" + "github.com/IBM/ubiquity/utils" +) + +const ( + fakePhysicalCapacity = 2040 + fakeLogicalCapacity = 2040 + fakeUsedCapacity = 2040 + fakeDS8kStoragetType = "2107" + fakeV7kStorageType = "2076" + fakeA9kStorageType = "2810" + fakeProfile = "gold" +) + +var fakeWwn = "6005076306ffd69d0000000000001004" + +var fakeMultipathOutput = ` +mpathg (36005076306ffd69d0000000000001004) dm-14 IBM ,2107900 +size=1.0G features='1 queue_if_no_path' hwhandler='0' wp=rw +` + "`-+- policy='service-time 0' prio=1 status=active" + ` + |- 29:0:1:1 sde 8:64 active ready running + |- 29:0:6:1 sdf 8:80 active ready running + ` + "`- 29:0:7:1 sdg 8:96 active ready running" + ` +mpathf (36005076306ffd69d000000000000010a) dm-2 IBM ,2107900 +size=2.0G features='1 queue_if_no_path' hwhandler='0' wp=rw +` + "`-+- policy='service-time 0' prio=1 status=enabled" + ` + |- 29:0:1:0 sdb 8:16 active ready running + |- 29:0:6:0 sdc 8:32 active ready running + ` + "`- 29:0:7:0 sdd 8:48 active ready running\n" + +var _ = Describe("scbe_mounter_test", func() { + var ( + fakeExec *fakes.FakeExecutor + ) + + BeforeEach(func() { + fakeExec = new(fakes.FakeExecutor) + }) + + Context("GetMultipathOutputAndDeviceMapperAndDevice", func() { + + BeforeEach(func() { + fakeExec.ExecuteWithTimeoutReturns([]byte(fakeMultipathOutput), nil) + }) + + It("should call DisconnectAll ", func() { + _, devMapper, devNames, err := utils.GetMultipathOutputAndDeviceMapperAndDevice(fakeWwn, fakeExec) + Ω(err).ShouldNot(HaveOccurred()) + Expect(devMapper).To(Equal("mpathg")) + Expect(devNames).To(Equal([]string{"sde", "sdf", "sdg"})) + }) + }) +}) From dfcc9d84b9a516693ed48fc55557ef555623cb6e Mon Sep 17 00:00:00 2001 From: Shay Berman Date: Thu, 14 Mar 2019 10:33:47 +0200 Subject: [PATCH 26/36] Update notices file for v2.1.0 --- ...ile_for_ibm_storage_enabler_for_containers | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/scripts/notices_file_for_ibm_storage_enabler_for_containers b/scripts/notices_file_for_ibm_storage_enabler_for_containers index cfeaf205..ebd38a74 100644 --- a/scripts/notices_file_for_ibm_storage_enabler_for_containers +++ b/scripts/notices_file_for_ibm_storage_enabler_for_containers @@ -5,10 +5,13 @@ This file details additional Software License Agreements and third party notices and information that are required to be reproduced for the following programs: -IBM Storage Enabler for Containers Version 2.0 -IBM Storage Kubernetes FlexVolume Version 2.0 -IBM Storage Kubernetes Dynamic Provisioner Version 2.0 -IBM Storage Enabler for Containers DB Version 2.0 +IBM Storage Enabler for Containers Version 2.1.0 +IBM Storage Enabler for Containers DB Version 2.1.0 +IBM Storage Enabler for Containers Helm Utils Version 2.1.0 +IBM Storage Kubernetes Dynamic Provisioner Version 2.1.0 +IBM Storage Kubernetes FlexVolume Version 2.1.0 +IBM Storage Kubernetes FlexVolume Sidecar Version 2.1.0 + =========================================================================== Section 1 - TERMS AND CONDITIONS FOR SEPARATELY LICENSED CODE @@ -634,6 +637,7 @@ based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the + Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. @@ -1894,6 +1898,7 @@ SUCH DAMAGE. --------------------------------------------------------------------------- + Copyright (c) 1998-2004 Dag-Erling Cïdan Smørgrav All rights reserved. @@ -2613,7 +2618,7 @@ Offer to obtain source code for GNU GPL and GNU LGPL licensed software distributed with the IBM Storage Enabler for Containers, IBM Storage Kubernetes FlexVolume, IBM Storage Kubernetes Dynamic Provisioner, IBM Storage Enabler for Containers DB, and IBM Storage Enabler for Containers -Helm Utils Version 2.0: +Helm Utils Version 2.1.0: alpine-baselayout version 3.1.0 apk-tools version 2.10.1 @@ -2644,8 +2649,8 @@ END OF Offer for GNU GPL and LGPL Source Code =========================================================================== END OF TERMS AND CONDITIONS FOR SEPARATELY LICENSED CODE for IBM Storage -Enabler for Containers 2.0, IBM Storage Kubernetes FlexVolume 2.0, -and IBM Storage Kubernetes Dynamic Provisioner 2.0 +Enabler for Containers 2.1.0, IBM Storage Kubernetes FlexVolume 2.1.0, +and IBM Storage Kubernetes Dynamic Provisioner 2.1.0 =========================================================================== @@ -2685,6 +2690,7 @@ Portions of Curl version 7.61.1 glog commit level 23def4e gnostic commit level 0c51083 gofuzz commit level 44d8105 +golang/mock commit level e698a2e groupcache commit level 02826c3 jsonpointer commit level 46af16f jsonreference commit level 13c6e35 @@ -3254,6 +3260,7 @@ distribution. contributors may be used to endorse or promote products derived from this software without specific prior written permission. + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -10722,7 +10729,8 @@ END Mozilla Public License, Version 2.0 ===================================================================== END OF NOTICES AND INFORMATION FOR IBM Storage Enabler for -Containers, Kubermetes FlexVolume, Kubermetes Dynamic -Provisioner, and Enabler for Containers DB Version 2.0 +Containers, Containers DB, Containers Helm Utils, and +Kubermetes Dynamic Provisioner, FlexVolume, FlexVolumne +Sidecar, Version 2.1.0 ===================================================================== From 91b55dc79980d23ad6668457a0002c956f3591c8 Mon Sep 17 00:00:00 2001 From: 27149chen <7991675+27149chen@users.noreply.github.com> Date: Thu, 14 Mar 2019 11:32:16 +0200 Subject: [PATCH 27/36] change LunNumber from float64 to int (#296) Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> --- .../block_device_utils_mounter_test.go | 2 +- .../mounter/block_device_utils/block_device_utils_test.go | 2 +- remote/mounter/initiator/connectors/fibre_channel_test.go | 2 +- remote/mounter/initiator/linuxfc.go | 5 ++--- remote/mounter/initiator/linuxfc_test.go | 4 ++-- remote/mounter/scbe.go | 8 ++++++-- remote/mounter/scbe_test.go | 2 +- resources/resources.go | 2 +- 8 files changed, 15 insertions(+), 12 deletions(-) diff --git a/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go b/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go index 2c220d7e..da8eda5a 100644 --- a/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go +++ b/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go @@ -37,7 +37,7 @@ var _ = Describe("block_device_mounter_utils_test", func() { err error callErr error = errors.New("error") ) - volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: float64(1)} + volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: 1} BeforeEach(func() { fakeBlockDeviceUtils = new(fakes.FakeBlockDeviceUtils) diff --git a/remote/mounter/block_device_utils/block_device_utils_test.go b/remote/mounter/block_device_utils/block_device_utils_test.go index 67d38441..adce3cbb 100644 --- a/remote/mounter/block_device_utils/block_device_utils_test.go +++ b/remote/mounter/block_device_utils/block_device_utils_test.go @@ -44,7 +44,7 @@ var _ = Describe("block_device_utils_test", func() { err error cmdErr error = errors.New("command error") ) - volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: float64(1)} + volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: 1} BeforeEach(func() { fakeExec = new(fakes.FakeExecutor) diff --git a/remote/mounter/initiator/connectors/fibre_channel_test.go b/remote/mounter/initiator/connectors/fibre_channel_test.go index aa74f0cb..dd9f998d 100644 --- a/remote/mounter/initiator/connectors/fibre_channel_test.go +++ b/remote/mounter/initiator/connectors/fibre_channel_test.go @@ -33,7 +33,7 @@ var _ = Describe("Test Fibre Channel Connector", func() { fakeInitiator *fakeinitiator.FakeInitiator fcConnector initiator.Connector ) - volumeMountProperties := &resources.VolumeMountProperties{WWN: fakeWwn, LunNumber: float64(1)} + volumeMountProperties := &resources.VolumeMountProperties{WWN: fakeWwn, LunNumber: 1} BeforeEach(func() { fakeExec = new(fakes.FakeExecutor) diff --git a/remote/mounter/initiator/linuxfc.go b/remote/mounter/initiator/linuxfc.go index dd57ca05..8c428cf0 100644 --- a/remote/mounter/initiator/linuxfc.go +++ b/remote/mounter/initiator/linuxfc.go @@ -53,11 +53,10 @@ func (lfc *linuxFibreChannel) hasFCSupport() bool { // may be '-' wildcards if unable to determine them. func (lfc *linuxFibreChannel) getHBAChannelScsiTarget(volumeMountProperties *resources.VolumeMountProperties) string { //TODO: get channel and target - if volumeMountProperties.LunNumber == float64(-1) { + if volumeMountProperties.LunNumber == -1 { return "- - -" } - // use %g to print a float64 to int - return fmt.Sprintf("- - %g", volumeMountProperties.LunNumber) + return fmt.Sprintf("- - %d", volumeMountProperties.LunNumber) } // GetHBAs return all the FC HBAs in the system diff --git a/remote/mounter/initiator/linuxfc_test.go b/remote/mounter/initiator/linuxfc_test.go index 9b468ea0..9a4f743a 100644 --- a/remote/mounter/initiator/linuxfc_test.go +++ b/remote/mounter/initiator/linuxfc_test.go @@ -83,7 +83,7 @@ var _ = Describe("Test FC Initiator", func() { realSysBlockPath string cmdErr error = errors.New("command error") ) - volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: float64(1)} + volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: 1} BeforeEach(func() { err := os.MkdirAll(FAKE_FC_HOST_SYSFS_PATH, os.ModePerm) @@ -187,7 +187,7 @@ var _ = Describe("Test FC Initiator", func() { Ω(err).ShouldNot(HaveOccurred()) data, err := ioutil.ReadFile(scanFile) Ω(err).ShouldNot(HaveOccurred()) - Expect(string(data)).To(Equal(fmt.Sprintf("- - %g", volumeMountProperties.LunNumber))) + Expect(string(data)).To(Equal(fmt.Sprintf("- - %d", volumeMountProperties.LunNumber))) }) It("should write '1' to the hba lip file", func() { diff --git a/remote/mounter/scbe.go b/remote/mounter/scbe.go index 19b5f2a2..d924bf7a 100644 --- a/remote/mounter/scbe.go +++ b/remote/mounter/scbe.go @@ -53,9 +53,13 @@ func NewScbeMounterWithExecuter(blockDeviceMounterUtils block_device_mounter_uti func (s *scbeMounter) prepareVolumeMountProperties(vcGetter resources.VolumeConfigGetter) *resources.VolumeMountProperties { volumeConfig := vcGetter.GetVolumeConfig() volumeWWN := volumeConfig["Wwn"].(string) - volumeLunNumber := float64(-1) + volumeLunNumber := -1 if volumeLunNumberInterface, exists := volumeConfig[resources.ScbeKeyVolAttachLunNumToHost]; exists { - volumeLunNumber = volumeLunNumberInterface.(float64) + + // LunNumber is int, but after json.Marshal and json.UNmarshal it will become float64. + // see https://stackoverflow.com/questions/39152481/unmarshaling-a-json-integer-to-an-empty-interface-results-in-wrong-type-assertio + // but LunNumber should be int, so convert it here. + volumeLunNumber = int(volumeLunNumberInterface.(float64)) } return &resources.VolumeMountProperties{WWN: volumeWWN, LunNumber: volumeLunNumber} } diff --git a/remote/mounter/scbe_test.go b/remote/mounter/scbe_test.go index bc839e2f..bb5c1b9c 100644 --- a/remote/mounter/scbe_test.go +++ b/remote/mounter/scbe_test.go @@ -40,7 +40,7 @@ var _ = Describe("scbe_mounter_test", func() { "LogicalCapacity": fakeLogicalCapacity, "LunNumber": float64(1), "PoolName": "pool", "StorageName": "IBM.2706", "fstype": "ext4"}} mountRequestForDS8kLun2 = resources.MountRequest{Mountpoint: "test_mountpointDS8k", VolumeConfig: map[string]interface{}{"Name": "u_vol", "PhysicalCapacity": fakePhysicalCapacity, "Profile": fakeProfile, "UsedCapacity": fakeUsedCapacity, "Wwn": "wwn", "attach-to": "node1", - "LogicalCapacity": fakeLogicalCapacity, "LunNumber": float64(1), "PoolName": "pool", "StorageName": "IBM.2107", "fstype": "ext4"}} + "LogicalCapacity": fakeLogicalCapacity, "LunNumber": float64(1074741264), "PoolName": "pool", "StorageName": "IBM.2107", "fstype": "ext4"}} mountRequestForDS8kLun3 = resources.MountRequest{Mountpoint: "test_mountpointDS8k", VolumeConfig: map[string]interface{}{"Name": "u_vol", "PhysicalCapacity": fakePhysicalCapacity, "Profile": fakeProfile, "StorageType": fakeDS8kStoragetType, "UsedCapacity": fakeUsedCapacity, "Wwn": "wwn", "attach-to": "node1", "LogicalCapacity": fakeLogicalCapacity, "PoolName": "pool", "StorageName": "IBM.2107", "fstype": "ext4"}} diff --git a/resources/resources.go b/resources/resources.go index 24187e38..f6b55ff9 100644 --- a/resources/resources.go +++ b/resources/resources.go @@ -358,5 +358,5 @@ type RequestContext struct { type VolumeMountProperties struct { WWN string - LunNumber float64 + LunNumber int } From f01ccd3c14610f26a2209e9324f5ef5cabf2c9e2 Mon Sep 17 00:00:00 2001 From: 27149chen <7991675+27149chen@users.noreply.github.com> Date: Tue, 26 Mar 2019 11:23:30 +0200 Subject: [PATCH 28/36] Feature/ub 1941 unmount fix (#299) cleanup fc&iscsi devices after unmount --- .../block_device_mounter_utils.go | 2 +- .../block_device_utils_mounter_test.go | 8 +-- .../block_device_utils/block_device_utils.go | 22 ++++--- .../block_device_utils_test.go | 35 ++++++++--- remote/mounter/block_device_utils/rescan.go | 31 +++++++--- .../initiator/connectors/fibre_channel.go | 62 ++++--------------- .../connectors/fibre_channel_test.go | 3 +- remote/mounter/initiator/connectors/iscsi.go | 41 ++++++++++++ .../initiator/connectors/iscsi_test.go | 47 ++++++++++++++ remote/mounter/initiator/connectors/scsi.go | 61 ++++++++++++++++++ remote/mounter/initiator/linuxfc.go | 2 +- remote/mounter/initiator/linuxfc_test.go | 4 +- remote/mounter/initiator/linuxiscsi.go | 37 +++++++++++ remote/mounter/initiator/linuxscsi.go | 5 +- remote/mounter/scbe.go | 8 +-- remote/mounter/scbe_test.go | 8 --- utils/mpath.go | 8 ++- utils/mpath_test.go | 28 +++++++-- 18 files changed, 307 insertions(+), 105 deletions(-) create mode 100644 remote/mounter/initiator/connectors/iscsi.go create mode 100644 remote/mounter/initiator/connectors/iscsi_test.go create mode 100644 remote/mounter/initiator/connectors/scsi.go create mode 100644 remote/mounter/initiator/linuxiscsi.go diff --git a/remote/mounter/block_device_mounter_utils/block_device_mounter_utils.go b/remote/mounter/block_device_mounter_utils/block_device_mounter_utils.go index 691987c4..fe6a60ba 100644 --- a/remote/mounter/block_device_mounter_utils/block_device_mounter_utils.go +++ b/remote/mounter/block_device_mounter_utils/block_device_mounter_utils.go @@ -142,7 +142,7 @@ func (b *blockDeviceMounterUtils) UnmountDeviceFlow(devicePath string, volumeWwn defer b.mpathFlock.Unlock() defer b.logger.Debug("Released mpathLock for device", logs.Args{{"device", devicePath}}) - if err := b.blockDeviceUtils.Cleanup(devicePath); err != nil { + if err := b.CleanupAll(&resources.VolumeMountProperties{WWN: volumeWwn}); err != nil { return b.logger.ErrorRet(err, "Cleanup failed") } diff --git a/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go b/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go index da8eda5a..bb2b7f08 100644 --- a/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go +++ b/remote/mounter/block_device_mounter_utils/block_device_utils_mounter_test.go @@ -271,18 +271,18 @@ var _ = Describe("block_device_mounter_utils_test", func() { }) It("should fail if Cleanup failed", func() { fakeBlockDeviceUtils.UmountFsReturns(nil) - fakeBlockDeviceUtils.CleanupReturns(callErr) + fakeBlockDeviceUtils.CleanupDevicesReturns(callErr) err = blockDeviceMounterUtils.UnmountDeviceFlow("fake_device", "6001738CFC9035EA0000000000795164") Expect(err).To(HaveOccurred()) Expect(err).To(MatchError(callErr)) - Expect(fakeBlockDeviceUtils.CleanupCallCount()).To(Equal(1)) + Expect(fakeBlockDeviceUtils.CleanupDevicesCallCount()).To(Equal(1)) }) It("should succees if all is cool", func() { fakeBlockDeviceUtils.UmountFsReturns(nil) - fakeBlockDeviceUtils.CleanupReturns(nil) + fakeBlockDeviceUtils.CleanupDevicesReturns(nil) err = blockDeviceMounterUtils.UnmountDeviceFlow("fake_device", "6001738CFC9035EA0000000000795164") Expect(err).NotTo(HaveOccurred()) - Expect(fakeBlockDeviceUtils.CleanupCallCount()).To(Equal(1)) + Expect(fakeBlockDeviceUtils.CleanupDevicesCallCount()).To(Equal(2)) }) }) Context(".CleanupAll", func() { diff --git a/remote/mounter/block_device_utils/block_device_utils.go b/remote/mounter/block_device_utils/block_device_utils.go index 98651211..f29a89a4 100644 --- a/remote/mounter/block_device_utils/block_device_utils.go +++ b/remote/mounter/block_device_utils/block_device_utils.go @@ -14,21 +14,22 @@ type blockDeviceUtils struct { exec utils.Executor regExAlreadyMounted *regexp.Regexp fcConnector initiator.Connector + iscsiConnector initiator.Connector } func NewBlockDeviceUtils() BlockDeviceUtils { - return newBlockDeviceUtils(utils.NewExecutor(), nil) + return newBlockDeviceUtils(utils.NewExecutor()) } func NewBlockDeviceUtilsWithExecutor(executor utils.Executor) BlockDeviceUtils { - return newBlockDeviceUtils(executor, nil) + return newBlockDeviceUtils(executor) } -func NewBlockDeviceUtilsWithExecutorAndConnector(executor utils.Executor, fcConnector initiator.Connector) BlockDeviceUtils { - return newBlockDeviceUtils(executor, fcConnector) +func NewBlockDeviceUtilsWithExecutorAndConnector(executor utils.Executor, conns ...initiator.Connector) BlockDeviceUtils { + return newBlockDeviceUtils(executor, conns...) } -func newBlockDeviceUtils(executor utils.Executor, fcConnector initiator.Connector) BlockDeviceUtils { +func newBlockDeviceUtils(executor utils.Executor, conns ...initiator.Connector) BlockDeviceUtils { logger := logs.GetLogger() // Prepare regex that going to be used in unmount interface @@ -38,8 +39,15 @@ func newBlockDeviceUtils(executor utils.Executor, fcConnector initiator.Connecto panic("failed prepare Already unmount regex") } - if fcConnector == nil { + var fcConnector, iscsiConnector initiator.Connector + + if len(conns) == 0 { fcConnector = connectors.NewFibreChannelConnectorWithExecutor(executor) + iscsiConnector = connectors.NewISCSIConnectorWithExecutor(executor) + } else { + fcConnector = conns[0] + iscsiConnector = conns[1] } - return &blockDeviceUtils{logger: logger, exec: executor, regExAlreadyMounted: regex, fcConnector: fcConnector} + + return &blockDeviceUtils{logger: logger, exec: executor, regExAlreadyMounted: regex, fcConnector: fcConnector, iscsiConnector: iscsiConnector} } diff --git a/remote/mounter/block_device_utils/block_device_utils_test.go b/remote/mounter/block_device_utils/block_device_utils_test.go index adce3cbb..e09ef010 100644 --- a/remote/mounter/block_device_utils/block_device_utils_test.go +++ b/remote/mounter/block_device_utils/block_device_utils_test.go @@ -36,20 +36,37 @@ import ( . "github.com/onsi/gomega" ) +var fakeMultipathOutputWithMultiplePathGroups = ` +mpathc (6005076306ffd69d0000000000001004) dm-4 IBM ,2145 +size=1.0G features='0' hwhandler='0' wp=rw +|-+- policy='service-time 0' prio=50 status=active +| '- 43:0:0:3 sda 8:112 active ready running +-+- policy='service-time 0' prio=10 status=enabled + '- 44:0:0:3 sdb 8:144 active ready running +mpathb (3600507680c87011598000000000013a7) dm-3 IBM ,2145 +size=1.0G features='1 queue_if_no_path' hwhandler='0' wp=rw +|-+- policy='service-time 0' prio=50 status=active +| '- 44:0:0:0 sdc 8:32 active ready running +'-+- policy='service-time 0' prio=10 status=enabled + '- 43:0:0:0 sdb 8:16 active ready running +` + var _ = Describe("block_device_utils_test", func() { var ( - fakeExec *fakes.FakeExecutor - fakeFcConnector *fakeinitiator.FakeConnector - bdUtils block_device_utils.BlockDeviceUtils - err error - cmdErr error = errors.New("command error") + fakeExec *fakes.FakeExecutor + fakeFcConnector *fakeinitiator.FakeConnector + fakeISCSIConnector *fakeinitiator.FakeConnector + bdUtils block_device_utils.BlockDeviceUtils + err error + cmdErr error = errors.New("command error") ) - volumeMountProperties := &resources.VolumeMountProperties{WWN: "wwn", LunNumber: 1} + volumeMountProperties := &resources.VolumeMountProperties{WWN: "6005076306ffd69d0000000000001004", LunNumber: 1} BeforeEach(func() { fakeExec = new(fakes.FakeExecutor) fakeFcConnector = new(fakeinitiator.FakeConnector) - bdUtils = block_device_utils.NewBlockDeviceUtilsWithExecutorAndConnector(fakeExec, fakeFcConnector) + fakeISCSIConnector = new(fakeinitiator.FakeConnector) + bdUtils = block_device_utils.NewBlockDeviceUtilsWithExecutorAndConnector(fakeExec, fakeFcConnector, fakeISCSIConnector) }) Context(".Rescan", func() { @@ -62,7 +79,7 @@ var _ = Describe("block_device_utils_test", func() { Expect(args).To(Equal([]string{"-m", "session", "--rescan"})) }) It(`Rescan SCSI calls fcConnector.ConnectVolume`, func() { - fakeExec.ExecuteWithTimeoutReturns([]byte(volumeMountProperties.WWN), nil) + fakeExec.ExecuteWithTimeoutReturns([]byte(fakeMultipathOutputWithMultiplePathGroups), nil) err = bdUtils.Rescan(block_device_utils.SCSI, volumeMountProperties) Expect(err).ToNot(HaveOccurred()) Expect(fakeExec.ExecuteWithTimeoutCallCount()).To(Equal(1)) @@ -91,6 +108,7 @@ var _ = Describe("block_device_utils_test", func() { }) }) Context(".CleanupDevices", func() { + It("Cleanup ISCSI calls 'sudo iscsiadm -m session --rescan'", func() { err = bdUtils.CleanupDevices(block_device_utils.ISCSI, volumeMountProperties) Expect(err).ToNot(HaveOccurred()) @@ -98,6 +116,7 @@ var _ = Describe("block_device_utils_test", func() { _, cmd, args := fakeExec.ExecuteWithTimeoutArgsForCall(0) Expect(cmd).To(Equal("iscsiadm")) Expect(args).To(Equal([]string{"-m", "session", "--rescan"})) + Expect(fakeISCSIConnector.DisconnectVolumeCallCount()).To(Equal(1)) }) It(`Cleanup SCSI calls fcConnector.DisconnectVolume`, func() { err = bdUtils.CleanupDevices(block_device_utils.SCSI, volumeMountProperties) diff --git a/remote/mounter/block_device_utils/rescan.go b/remote/mounter/block_device_utils/rescan.go index 58b4bb65..fa3cddcc 100644 --- a/remote/mounter/block_device_utils/rescan.go +++ b/remote/mounter/block_device_utils/rescan.go @@ -27,6 +27,7 @@ import ( const rescanIscsiTimeout = 1 * 60 * 1000 const rescanScsiTimeout = 2 * 60 * 1000 +const iscsiAdm = "iscsiadm" var FcHostDir = "/sys/class/fc_host/" var ScsiHostDir = "/sys/class/scsi_host/" @@ -51,7 +52,7 @@ func (b *blockDeviceUtils) CleanupDevices(protocol Protocol, volumeMountProperti case SCSI: return b.CleanupSCSIDevices(volumeMountProperties) case ISCSI: - return b.CleanupISCSIDevices() + return b.CleanupISCSIDevices(volumeMountProperties) default: return b.logger.ErrorRet(&unsupportedProtocolError{protocol}, "failed") } @@ -59,22 +60,22 @@ func (b *blockDeviceUtils) CleanupDevices(protocol Protocol, volumeMountProperti func (b *blockDeviceUtils) RescanISCSI() error { defer b.logger.Trace(logs.DEBUG)() - rescanCmd := "iscsiadm" - if err := b.exec.IsExecutable(rescanCmd); err != nil { + + if err := b.exec.IsExecutable(iscsiAdm); err != nil { b.logger.Debug("No iscisadm installed skipping ISCSI rescan") return nil } args := []string{"-m", "session", "--rescan"} - if _, err := b.exec.ExecuteWithTimeout(rescanIscsiTimeout, rescanCmd, args); err != nil { + if _, err := b.exec.ExecuteWithTimeout(rescanIscsiTimeout, iscsiAdm, args); err != nil { if b.IsExitStatusCode(err, 21) { // error code 21 : ISCSI_ERR_NO_OBJS_FOUND - no records/targets/sessions/portals found to execute operation on. - b.logger.Warning(NoIscsiadmCommnadWarningMessage, logs.Args{{"command", fmt.Sprintf("[%s %s]", rescanCmd, args)}}) + b.logger.Warning(NoIscsiadmCommnadWarningMessage, logs.Args{{"command", fmt.Sprintf("[%s %s]", iscsiAdm, args)}}) return nil } else { - return b.logger.ErrorRet(&CommandExecuteError{rescanCmd, err}, "failed") + return b.logger.ErrorRet(&CommandExecuteError{iscsiAdm, err}, "failed") } } return nil @@ -84,11 +85,13 @@ func (b *blockDeviceUtils) RescanSCSI(volumeMountProperties *resources.VolumeMou defer b.logger.Trace(logs.DEBUG)() var err error + var devMapper string + var deviceNames []string for i := 0; i < 6; i++ { if err = b.fcConnector.ConnectVolume(volumeMountProperties); err != nil { return b.logger.ErrorRet(err, "RescanSCSI failed", logs.Args{{"volumeWWN", volumeMountProperties.WWN}}) } - if _, _, _, err = utils.GetMultipathOutputAndDeviceMapperAndDevice(volumeMountProperties.WWN, b.exec); err == nil { + if _, devMapper, deviceNames, err = utils.GetMultipathOutputAndDeviceMapperAndDevice(volumeMountProperties.WWN, b.exec); err == nil && devMapper != "" && len(deviceNames) > 0 { return nil } b.logger.Warning("Can't find the new volume in multipath output after rescan, sleep one second and try again.") @@ -98,10 +101,20 @@ func (b *blockDeviceUtils) RescanSCSI(volumeMountProperties *resources.VolumeMou } // TODO: improve it to make it faster, for more details, see os_brick project. -func (b *blockDeviceUtils) CleanupISCSIDevices() error { - return b.RescanISCSI() +func (b *blockDeviceUtils) CleanupISCSIDevices(volumeMountProperties *resources.VolumeMountProperties) error { + defer b.logger.Trace(logs.DEBUG)() + + if err := b.exec.IsExecutable(iscsiAdm); err != nil { + b.logger.Debug("No iscisadm installed skipping ISCSI rescan") + return nil + } + + b.RescanISCSI() + return b.iscsiConnector.DisconnectVolume(volumeMountProperties) } func (b *blockDeviceUtils) CleanupSCSIDevices(volumeMountProperties *resources.VolumeMountProperties) error { + defer b.logger.Trace(logs.DEBUG)() + return b.fcConnector.DisconnectVolume(volumeMountProperties) } diff --git a/remote/mounter/initiator/connectors/fibre_channel.go b/remote/mounter/initiator/connectors/fibre_channel.go index 0c5449f9..ee8280cc 100644 --- a/remote/mounter/initiator/connectors/fibre_channel.go +++ b/remote/mounter/initiator/connectors/fibre_channel.go @@ -1,8 +1,6 @@ package connectors import ( - "fmt" - "github.com/IBM/ubiquity/remote/mounter/initiator" "github.com/IBM/ubiquity/resources" "github.com/IBM/ubiquity/utils" @@ -10,9 +8,7 @@ import ( ) type fibreChannelConnector struct { - exec utils.Executor - logger logs.Logger - linuxfc initiator.Initiator + *scsiConnector } func NewFibreChannelConnector() initiator.Connector { @@ -20,68 +16,34 @@ func NewFibreChannelConnector() initiator.Connector { } func NewFibreChannelConnectorWithExecutor(executor utils.Executor) initiator.Connector { - return newFibreChannelConnectorWithExecutorAndLogger(executor) + logger := logs.GetLogger() + return newFibreChannelConnectorWithExecutorAndLogger(executor, logger) } -func NewFibreChannelConnectorWithAllFields(executor utils.Executor, linuxfc initiator.Initiator) initiator.Connector { +func NewFibreChannelConnectorWithAllFields(executor utils.Executor, initi initiator.Initiator) initiator.Connector { logger := logs.GetLogger() - return &fibreChannelConnector{logger: logger, exec: executor, linuxfc: linuxfc} + return &fibreChannelConnector{&scsiConnector{logger: logger, exec: executor, initiator: initi}} } func newFibreChannelConnector() *fibreChannelConnector { executor := utils.NewExecutor() - return newFibreChannelConnectorWithExecutorAndLogger(executor) -} - -func newFibreChannelConnectorWithExecutorAndLogger(executor utils.Executor) *fibreChannelConnector { logger := logs.GetLogger() - linuxfc := initiator.NewLinuxFibreChannelWithExecutor(executor) + return newFibreChannelConnectorWithExecutorAndLogger(executor, logger) +} - return &fibreChannelConnector{logger: logger, exec: executor, linuxfc: linuxfc} +func newFibreChannelConnectorWithExecutorAndLogger(executor utils.Executor, logger logs.Logger) *fibreChannelConnector { + initi := initiator.NewLinuxFibreChannelWithExecutor(executor) + return &fibreChannelConnector{&scsiConnector{logger: logger, exec: executor, initiator: initi}} } // ConnectVolume attach the volume to host by rescaning all the active FC HBAs. func (c *fibreChannelConnector) ConnectVolume(volumeMountProperties *resources.VolumeMountProperties) error { - hbas := c.linuxfc.GetHBAs() + hbas := c.initiator.GetHBAs() if len(hbas) == 0 { c.logger.Warning("No FC HBA is found.") return nil } - return c.linuxfc.RescanHosts(hbas, volumeMountProperties) -} - -// DisconnectVolume removes a volume from host by echo "1" to all scsi device's /delete -func (c *fibreChannelConnector) DisconnectVolume(volumeMountProperties *resources.VolumeMountProperties) error { - devices := []string{} - _, _, devNames, err := utils.GetMultipathOutputAndDeviceMapperAndDevice(volumeMountProperties.WWN, c.exec) - if err != nil { - return c.logger.ErrorRet(err, "Failed to get multipath output before disconnecting volume") - } - for _, devName := range devNames { - device := fmt.Sprintf("/dev/%s", devName) - devices = append(devices, device) - } - - c.logger.Debug("Remove devices", logs.Args{{"names", devices}}) - err = c.removeDevices(devices) - if err != nil { - return c.logger.ErrorRet(err, "Failed to remove devices") - } - - if _, devMapper, _, _ := utils.GetMultipathOutputAndDeviceMapperAndDevice(volumeMountProperties.WWN, c.exec); devMapper != "" { - // flush multipath if device still exists after disconnection - c.linuxfc.FlushMultipath(devMapper) - } - return nil -} - -func (c *fibreChannelConnector) removeDevices(devices []string) error { - // Do we need to flush io? - var err error - for _, device := range devices { - err = c.linuxfc.RemoveSCSIDevice(device) - } - return err + return c.initiator.RescanHosts(hbas, volumeMountProperties) } diff --git a/remote/mounter/initiator/connectors/fibre_channel_test.go b/remote/mounter/initiator/connectors/fibre_channel_test.go index dd9f998d..ae2ba4b6 100644 --- a/remote/mounter/initiator/connectors/fibre_channel_test.go +++ b/remote/mounter/initiator/connectors/fibre_channel_test.go @@ -60,9 +60,10 @@ var _ = Describe("Test Fibre Channel Connector", func() { fakeExec.ExecuteWithTimeoutReturns([]byte(fakeMultipathOutput), nil) }) - It("should remove all the scsi devices", func() { + It("should call multipath and remove all the scsi devices", func() { err := fcConnector.DisconnectVolume(volumeMountProperties) Ω(err).ShouldNot(HaveOccurred()) + Expect(fakeExec.ExecuteWithTimeoutCallCount()).To(Equal(1)) Expect(fakeInitiator.RemoveSCSIDeviceCallCount()).To(Equal(3)) var a byte = 97 for i := 0; i < 3; i++ { diff --git a/remote/mounter/initiator/connectors/iscsi.go b/remote/mounter/initiator/connectors/iscsi.go new file mode 100644 index 00000000..37c44ab9 --- /dev/null +++ b/remote/mounter/initiator/connectors/iscsi.go @@ -0,0 +1,41 @@ +package connectors + +import ( + "github.com/IBM/ubiquity/remote/mounter/initiator" + "github.com/IBM/ubiquity/resources" + "github.com/IBM/ubiquity/utils" + "github.com/IBM/ubiquity/utils/logs" +) + +type iscsiConnector struct { + *scsiConnector +} + +func NewISCSIConnector() initiator.Connector { + return newISCSIConnector() +} + +func NewISCSIConnectorWithExecutor(executor utils.Executor) initiator.Connector { + logger := logs.GetLogger() + return newISCSIConnectorWithExecutorAndLogger(executor, logger) +} + +func NewISCSIConnectorWithAllFields(executor utils.Executor, initi initiator.Initiator) initiator.Connector { + logger := logs.GetLogger() + return &iscsiConnector{&scsiConnector{logger: logger, exec: executor, initiator: initi}} +} + +func newISCSIConnector() *iscsiConnector { + executor := utils.NewExecutor() + logger := logs.GetLogger() + return newISCSIConnectorWithExecutorAndLogger(executor, logger) +} + +func newISCSIConnectorWithExecutorAndLogger(executor utils.Executor, logger logs.Logger) *iscsiConnector { + initi := initiator.NewLinuxISCSIWithExecutor(executor) + return &iscsiConnector{&scsiConnector{logger: logger, exec: executor, initiator: initi}} +} + +func (c *iscsiConnector) ConnectVolume(volumeMountProperties *resources.VolumeMountProperties) error { + return nil +} diff --git a/remote/mounter/initiator/connectors/iscsi_test.go b/remote/mounter/initiator/connectors/iscsi_test.go new file mode 100644 index 00000000..b00bf1ce --- /dev/null +++ b/remote/mounter/initiator/connectors/iscsi_test.go @@ -0,0 +1,47 @@ +package connectors_test + +import ( + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + + "github.com/IBM/ubiquity/fakes" + "github.com/IBM/ubiquity/remote/mounter/initiator" + "github.com/IBM/ubiquity/remote/mounter/initiator/connectors" + fakeinitiator "github.com/IBM/ubiquity/remote/mounter/initiator/fakes" + "github.com/IBM/ubiquity/resources" +) + +var _ = Describe("Test ISCSI Connector", func() { + var ( + fakeExec *fakes.FakeExecutor + fakeInitiator *fakeinitiator.FakeInitiator + iscsiConnector initiator.Connector + ) + volumeMountProperties := &resources.VolumeMountProperties{WWN: fakeWwn, LunNumber: 1} + + BeforeEach(func() { + fakeExec = new(fakes.FakeExecutor) + fakeInitiator = new(fakeinitiator.FakeInitiator) + iscsiConnector = connectors.NewISCSIConnectorWithAllFields(fakeExec, fakeInitiator) + }) + + Context("DisconnectVolume", func() { + + BeforeEach(func() { + fakeExec.ExecuteWithTimeoutReturns([]byte(fakeMultipathOutput), nil) + }) + + It("should call multipath and remove all the iscsi devices", func() { + err := iscsiConnector.DisconnectVolume(volumeMountProperties) + Ω(err).ShouldNot(HaveOccurred()) + Expect(fakeExec.ExecuteWithTimeoutCallCount()).To(Equal(1)) + Expect(fakeInitiator.RemoveSCSIDeviceCallCount()).To(Equal(3)) + var a byte = 97 + for i := 0; i < 3; i++ { + expectDev := "/dev/sd" + string(a+byte(i)) + dev := fakeInitiator.RemoveSCSIDeviceArgsForCall(i) + Expect(dev).To(Equal(expectDev)) + } + }) + }) +}) diff --git a/remote/mounter/initiator/connectors/scsi.go b/remote/mounter/initiator/connectors/scsi.go new file mode 100644 index 00000000..7b1b26f2 --- /dev/null +++ b/remote/mounter/initiator/connectors/scsi.go @@ -0,0 +1,61 @@ +package connectors + +import ( + "fmt" + + "github.com/IBM/ubiquity/remote/mounter/initiator" + "github.com/IBM/ubiquity/resources" + "github.com/IBM/ubiquity/utils" + "github.com/IBM/ubiquity/utils/logs" +) + +type scsiConnector struct { + exec utils.Executor + logger logs.Logger + initiator initiator.Initiator +} + +// DisconnectVolume will do following things: +// 1. flush multipath device: multipath -f /dev/mapper/mpathx +// 2. flush device io for all devices: blockdev --flushbufs /dev/sdx (not implemented yet) +// 3. remove all devices by path from host: echo 1 > /sys/block/sdx/device/delete +func (c *scsiConnector) DisconnectVolume(volumeMountProperties *resources.VolumeMountProperties) error { + + devices := []string{} + _, devMapper, devNames, err := utils.GetMultipathOutputAndDeviceMapperAndDevice(volumeMountProperties.WWN, c.exec) + if err != nil { + return c.logger.ErrorRet(err, "Failed to get multipath output before disconnecting volume") + } + if devMapper == "" { + // The device is already removed + return nil + } + + // flush multipath device + c.logger.Info("Flush multipath device", logs.Args{{"name", devMapper}}) + c.initiator.FlushMultipath(devMapper) + + for _, devName := range devNames { + device := fmt.Sprintf("/dev/%s", devName) + devices = append(devices, device) + } + + c.logger.Info("Remove devices", logs.Args{{"names", devices}}) + err = c.removeDevices(devices) + if err != nil { + return c.logger.ErrorRet(err, "Failed to remove devices") + } + + // If flushing the multipath failed before, try now after we have removed the devices. + c.logger.Info("Flush multipath device again after removing the devices", logs.Args{{"name", devMapper}}) + c.initiator.FlushMultipath(devMapper) + return nil +} + +func (c *scsiConnector) removeDevices(devices []string) error { + var err error + for _, device := range devices { + err = c.initiator.RemoveSCSIDevice(device) + } + return err +} diff --git a/remote/mounter/initiator/linuxfc.go b/remote/mounter/initiator/linuxfc.go index 8c428cf0..1a2e6c5f 100644 --- a/remote/mounter/initiator/linuxfc.go +++ b/remote/mounter/initiator/linuxfc.go @@ -123,7 +123,7 @@ func (lfc *linuxFibreChannel) RescanHosts(hbas []string, volumeMountProperties * hbaPath := SCSI_HOST_SYSFS_PATH + "/" + hba + "/scan" lfc.logger.Debug(fmt.Sprintf(`Scanning HBA with command: echo "%s" > %s`, ctl, hbaPath)) if err := ioutil.WriteFile(hbaPath, []byte(ctl), 0666); err != nil { - lfc.logger.Warning("Failed to scan HBA", logs.Args{{"name", hba}, {"err", err}}) + lfc.logger.Warning("Failed to scan HBA", logs.Args{{"name", hba}, {"ctl", ctl}, {"err", err}}) continue } } diff --git a/remote/mounter/initiator/linuxfc_test.go b/remote/mounter/initiator/linuxfc_test.go index 9a4f743a..48791638 100644 --- a/remote/mounter/initiator/linuxfc_test.go +++ b/remote/mounter/initiator/linuxfc_test.go @@ -242,10 +242,10 @@ var _ = Describe("Test FC Initiator", func() { Expect(fakeExec.ExecuteWithTimeoutCallCount()).To(Equal(1)) }) - It("should flush twice if fails", func() { + It("should flush 3 times if fails", func() { fakeExec.ExecuteWithTimeoutReturns([]byte{}, cmdErr) fcInitiator.FlushMultipath("fake") - Expect(fakeExec.ExecuteWithTimeoutCallCount()).To(Equal(2)) + Expect(fakeExec.ExecuteWithTimeoutCallCount()).To(Equal(3)) }) }) }) diff --git a/remote/mounter/initiator/linuxiscsi.go b/remote/mounter/initiator/linuxiscsi.go new file mode 100644 index 00000000..33418777 --- /dev/null +++ b/remote/mounter/initiator/linuxiscsi.go @@ -0,0 +1,37 @@ +package initiator + +import ( + "github.com/IBM/ubiquity/resources" + "github.com/IBM/ubiquity/utils" + "github.com/IBM/ubiquity/utils/logs" +) + +type linuxISCSI struct { + *linuxSCSI +} + +func NewLinuxISCSI() Initiator { + return newLinuxISCSI() +} + +func NewLinuxISCSIWithExecutor(executor utils.Executor) Initiator { + return newLinuxISCSIWithExecutor(executor) +} + +func newLinuxISCSI() *linuxISCSI { + executor := utils.NewExecutor() + return newLinuxISCSIWithExecutor(executor) +} + +func newLinuxISCSIWithExecutor(executor utils.Executor) *linuxISCSI { + logger := logs.GetLogger() + return &linuxISCSI{&linuxSCSI{logger: logger, exec: executor}} +} + +func (li *linuxISCSI) GetHBAs() []string { + return []string{} +} + +func (li *linuxISCSI) RescanHosts(hbas []string, volumeMountProperties *resources.VolumeMountProperties) error { + return nil +} diff --git a/remote/mounter/initiator/linuxscsi.go b/remote/mounter/initiator/linuxscsi.go index b335b41b..32285429 100644 --- a/remote/mounter/initiator/linuxscsi.go +++ b/remote/mounter/initiator/linuxscsi.go @@ -12,6 +12,7 @@ import ( const multipathCmd = "multipath" const FlushTimeout = 10 * 1000 +const FlushRetries = 3 var SYS_BLOCK_PATH = "/sys/block" @@ -20,13 +21,13 @@ type linuxSCSI struct { logger logs.Logger } -// FlushMultipath flushes the device, if it is failed becasue of device in use, retry again. +// FlushMultipath flushes the device, retry 3 times if it is failed. func (ls *linuxSCSI) FlushMultipath(deviceMapName string) { if err := ls.exec.IsExecutable(multipathCmd); err != nil { return } - for i := 0; i < 2; i++ { + for i := 0; i < FlushRetries; i++ { args := []string{"-f", deviceMapName} ls.logger.Info(fmt.Sprintf("Flush multipath by running: multipath -f %s", deviceMapName)) _, err := ls.exec.ExecuteWithTimeout(FlushTimeout, multipathCmd, args) diff --git a/remote/mounter/scbe.go b/remote/mounter/scbe.go index d924bf7a..a866c1ae 100644 --- a/remote/mounter/scbe.go +++ b/remote/mounter/scbe.go @@ -157,12 +157,6 @@ func (s *scbeMounter) Unmount(unmountRequest resources.UnmountRequest) error { } func (s *scbeMounter) ActionAfterDetach(request resources.AfterDetachRequest) error { - defer s.logger.Trace(logs.DEBUG)() - volumeMountProperties := s.prepareVolumeMountProperties(&request) - - // Cleanup volume - if err := s.blockDeviceMounterUtils.CleanupAll(volumeMountProperties); err != nil { - return s.logger.ErrorRet(err, "CleanupAll failed") - } + // no action after detach return nil } diff --git a/remote/mounter/scbe_test.go b/remote/mounter/scbe_test.go index bb5c1b9c..54197094 100644 --- a/remote/mounter/scbe_test.go +++ b/remote/mounter/scbe_test.go @@ -188,14 +188,6 @@ var _ = Describe("scbe_mounter_test", func() { Expect(err).To(HaveOccurred()) }) }) - Context("ActionAfterDetach", func() { - It("should call CleanupAll ", func() { - req := resources.AfterDetachRequest{VolumeConfig: map[string]interface{}{"Wwn": "wwn", "LunNumber": float64(1)}} - err := scbeMounter.ActionAfterDetach(req) - Expect(err).NotTo(HaveOccurred()) - Expect(fakeBdUtils.CleanupAllCallCount()).To(Equal(1)) - }) - }) }) func TestSCBEMounter(t *testing.T) { diff --git a/utils/mpath.go b/utils/mpath.go index 7e8ee448..6ed1cc11 100644 --- a/utils/mpath.go +++ b/utils/mpath.go @@ -66,12 +66,18 @@ func GetMultipathOutputAndDeviceMapperAndDevice(volumeWwn string, exec Executor) // skip next two lines scanner.Scan() scanner.Scan() + + skipped := false for scanner.Scan() { text := scanner.Text() text = strings.TrimSpace(text) if bodyRegex.MatchString(text) { - deviceName := strings.Split(text, " ")[2] + index := bodyRegex.FindStringIndex(text) + trimedText := text[index[0]:] + deviceName := strings.Split(trimedText, " ")[1] deviceNames = append(deviceNames, deviceName) + } else if !skipped { + skipped = true } else { break } diff --git a/utils/mpath_test.go b/utils/mpath_test.go index 2c8717c8..62c5a988 100644 --- a/utils/mpath_test.go +++ b/utils/mpath_test.go @@ -34,6 +34,21 @@ size=2.0G features='1 queue_if_no_path' hwhandler='0' wp=rw |- 29:0:6:0 sdc 8:32 active ready running ` + "`- 29:0:7:0 sdd 8:48 active ready running\n" +var fakeMultipathOutputWithMultiplePathGroups = ` +mpathc (6005076306ffd69d0000000000001004) dm-4 IBM ,2145 +size=1.0G features='0' hwhandler='0' wp=rw +|-+- policy='service-time 0' prio=50 status=active +| '- 43:0:0:3 sda 8:112 active ready running +-+- policy='service-time 0' prio=10 status=enabled + '- 44:0:0:3 sdb 8:144 active ready running +mpathb (3600507680c87011598000000000013a7) dm-3 IBM ,2145 +size=1.0G features='1 queue_if_no_path' hwhandler='0' wp=rw +|-+- policy='service-time 0' prio=50 status=active +| '- 44:0:0:0 sdc 8:32 active ready running +'-+- policy='service-time 0' prio=10 status=enabled + '- 43:0:0:0 sdb 8:16 active ready running +` + var _ = Describe("scbe_mounter_test", func() { var ( fakeExec *fakes.FakeExecutor @@ -45,15 +60,20 @@ var _ = Describe("scbe_mounter_test", func() { Context("GetMultipathOutputAndDeviceMapperAndDevice", func() { - BeforeEach(func() { + It("should get device names from multipath output", func() { fakeExec.ExecuteWithTimeoutReturns([]byte(fakeMultipathOutput), nil) - }) - - It("should call DisconnectAll ", func() { _, devMapper, devNames, err := utils.GetMultipathOutputAndDeviceMapperAndDevice(fakeWwn, fakeExec) Ω(err).ShouldNot(HaveOccurred()) Expect(devMapper).To(Equal("mpathg")) Expect(devNames).To(Equal([]string{"sde", "sdf", "sdg"})) }) + + It("should get device names from multipath output with multiple path groups", func() { + fakeExec.ExecuteWithTimeoutReturns([]byte(fakeMultipathOutputWithMultiplePathGroups), nil) + _, devMapper, devNames, err := utils.GetMultipathOutputAndDeviceMapperAndDevice(fakeWwn, fakeExec) + Ω(err).ShouldNot(HaveOccurred()) + Expect(devMapper).To(Equal("mpathc")) + Expect(devNames).To(Equal([]string{"sda", "sdb"})) + }) }) }) From 1236e3192c738263fcc92b9c4f777946d46389bb Mon Sep 17 00:00:00 2001 From: 27149chen <7991675+27149chen@users.noreply.github.com> Date: Mon, 25 Mar 2019 13:54:20 +0800 Subject: [PATCH 29/36] UB-1951 increase client timeout Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> --- remote/client_init.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remote/client_init.go b/remote/client_init.go index e4991cb4..ea89f9a0 100644 --- a/remote/client_init.go +++ b/remote/client_init.go @@ -69,7 +69,7 @@ func (s *remoteClient) initialize() error { protocol := s.getProtocol() s.storageApiURL = fmt.Sprintf(storageAPIURL, protocol, s.config.UbiquityServer.Address, s.config.UbiquityServer.Port) s.httpClient = &http.Client{ - Timeout: time.Second * 30, + Timeout: time.Second * 120, } verifyFileCA := os.Getenv(KeyVerifyCA) sslMode := strings.ToLower(os.Getenv(resources.KeySslMode)) From 1719153837f613cd763c81146f1a419d2e95bf18 Mon Sep 17 00:00:00 2001 From: 27149chen <7991675+27149chen@users.noreply.github.com> Date: Tue, 26 Mar 2019 15:00:46 +0200 Subject: [PATCH 30/36] UB-1956 scale password in plain text (#300) --- main.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 85a1d7c4..27ddd8bb 100644 --- a/main.go +++ b/main.go @@ -20,6 +20,7 @@ import ( "fmt" "log" "os" + //"path" "time" @@ -42,6 +43,7 @@ func main() { } configCopyWithPasswordStarred := config configCopyWithPasswordStarred.ScbeConfig.ConnectionInfo.CredentialInfo.Password = "****" + configCopyWithPasswordStarred.SpectrumScaleConfig.RestConfig.Password = "****" fmt.Printf("Starting Ubiquity Storage API server with config %#v\n", configCopyWithPasswordStarred) _, err = os.Stat(config.LogPath) if err != os.ErrNotExist { @@ -50,9 +52,9 @@ func main() { panic(fmt.Errorf("Failed to setup log dir")) } } - + defer utils.InitUbiquityServerLogger()() - + logger := logs.GetLogger() executor := utils.NewExecutor() From 97a5abaccc1ea9dee8c80e7c67e0dca894d7ea9f Mon Sep 17 00:00:00 2001 From: 27149chen <7991675+27149chen@users.noreply.github.com> Date: Wed, 27 Mar 2019 15:00:05 +0800 Subject: [PATCH 31/36] removed ScbeDataModelWrapper by mistake Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> --- fakes/fake_scbe_data_model_wrapper.go | 374 ++++++++++++++++++++++++++ local/scbe/datamodel_wrapper.go | 1 + 2 files changed, 375 insertions(+) create mode 100644 fakes/fake_scbe_data_model_wrapper.go diff --git a/fakes/fake_scbe_data_model_wrapper.go b/fakes/fake_scbe_data_model_wrapper.go new file mode 100644 index 00000000..1f53f716 --- /dev/null +++ b/fakes/fake_scbe_data_model_wrapper.go @@ -0,0 +1,374 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package fakes + +import ( + "sync" + + "github.com/IBM/ubiquity/local/scbe" +) + +type FakeScbeDataModelWrapper struct { + DeleteVolumeStub func(string) error + deleteVolumeMutex sync.RWMutex + deleteVolumeArgsForCall []struct { + arg1 string + } + deleteVolumeReturns struct { + result1 error + } + deleteVolumeReturnsOnCall map[int]struct { + result1 error + } + GetVolumeStub func(string, bool) (scbe.ScbeVolume, error) + getVolumeMutex sync.RWMutex + getVolumeArgsForCall []struct { + arg1 string + arg2 bool + } + getVolumeReturns struct { + result1 scbe.ScbeVolume + result2 error + } + getVolumeReturnsOnCall map[int]struct { + result1 scbe.ScbeVolume + result2 error + } + InsertVolumeStub func(string, string, string) error + insertVolumeMutex sync.RWMutex + insertVolumeArgsForCall []struct { + arg1 string + arg2 string + arg3 string + } + insertVolumeReturns struct { + result1 error + } + insertVolumeReturnsOnCall map[int]struct { + result1 error + } + ListVolumesStub func() ([]scbe.ScbeVolume, error) + listVolumesMutex sync.RWMutex + listVolumesArgsForCall []struct { + } + listVolumesReturns struct { + result1 []scbe.ScbeVolume + result2 error + } + listVolumesReturnsOnCall map[int]struct { + result1 []scbe.ScbeVolume + result2 error + } + UpdateDatabaseVolumeStub func(*scbe.ScbeVolume) + updateDatabaseVolumeMutex sync.RWMutex + updateDatabaseVolumeArgsForCall []struct { + arg1 *scbe.ScbeVolume + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakeScbeDataModelWrapper) DeleteVolume(arg1 string) error { + fake.deleteVolumeMutex.Lock() + ret, specificReturn := fake.deleteVolumeReturnsOnCall[len(fake.deleteVolumeArgsForCall)] + fake.deleteVolumeArgsForCall = append(fake.deleteVolumeArgsForCall, struct { + arg1 string + }{arg1}) + fake.recordInvocation("DeleteVolume", []interface{}{arg1}) + fake.deleteVolumeMutex.Unlock() + if fake.DeleteVolumeStub != nil { + return fake.DeleteVolumeStub(arg1) + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.deleteVolumeReturns + return fakeReturns.result1 +} + +func (fake *FakeScbeDataModelWrapper) DeleteVolumeCallCount() int { + fake.deleteVolumeMutex.RLock() + defer fake.deleteVolumeMutex.RUnlock() + return len(fake.deleteVolumeArgsForCall) +} + +func (fake *FakeScbeDataModelWrapper) DeleteVolumeCalls(stub func(string) error) { + fake.deleteVolumeMutex.Lock() + defer fake.deleteVolumeMutex.Unlock() + fake.DeleteVolumeStub = stub +} + +func (fake *FakeScbeDataModelWrapper) DeleteVolumeArgsForCall(i int) string { + fake.deleteVolumeMutex.RLock() + defer fake.deleteVolumeMutex.RUnlock() + argsForCall := fake.deleteVolumeArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeScbeDataModelWrapper) DeleteVolumeReturns(result1 error) { + fake.deleteVolumeMutex.Lock() + defer fake.deleteVolumeMutex.Unlock() + fake.DeleteVolumeStub = nil + fake.deleteVolumeReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeScbeDataModelWrapper) DeleteVolumeReturnsOnCall(i int, result1 error) { + fake.deleteVolumeMutex.Lock() + defer fake.deleteVolumeMutex.Unlock() + fake.DeleteVolumeStub = nil + if fake.deleteVolumeReturnsOnCall == nil { + fake.deleteVolumeReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.deleteVolumeReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeScbeDataModelWrapper) GetVolume(arg1 string, arg2 bool) (scbe.ScbeVolume, error) { + fake.getVolumeMutex.Lock() + ret, specificReturn := fake.getVolumeReturnsOnCall[len(fake.getVolumeArgsForCall)] + fake.getVolumeArgsForCall = append(fake.getVolumeArgsForCall, struct { + arg1 string + arg2 bool + }{arg1, arg2}) + fake.recordInvocation("GetVolume", []interface{}{arg1, arg2}) + fake.getVolumeMutex.Unlock() + if fake.GetVolumeStub != nil { + return fake.GetVolumeStub(arg1, arg2) + } + if specificReturn { + return ret.result1, ret.result2 + } + fakeReturns := fake.getVolumeReturns + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeScbeDataModelWrapper) GetVolumeCallCount() int { + fake.getVolumeMutex.RLock() + defer fake.getVolumeMutex.RUnlock() + return len(fake.getVolumeArgsForCall) +} + +func (fake *FakeScbeDataModelWrapper) GetVolumeCalls(stub func(string, bool) (scbe.ScbeVolume, error)) { + fake.getVolumeMutex.Lock() + defer fake.getVolumeMutex.Unlock() + fake.GetVolumeStub = stub +} + +func (fake *FakeScbeDataModelWrapper) GetVolumeArgsForCall(i int) (string, bool) { + fake.getVolumeMutex.RLock() + defer fake.getVolumeMutex.RUnlock() + argsForCall := fake.getVolumeArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeScbeDataModelWrapper) GetVolumeReturns(result1 scbe.ScbeVolume, result2 error) { + fake.getVolumeMutex.Lock() + defer fake.getVolumeMutex.Unlock() + fake.GetVolumeStub = nil + fake.getVolumeReturns = struct { + result1 scbe.ScbeVolume + result2 error + }{result1, result2} +} + +func (fake *FakeScbeDataModelWrapper) GetVolumeReturnsOnCall(i int, result1 scbe.ScbeVolume, result2 error) { + fake.getVolumeMutex.Lock() + defer fake.getVolumeMutex.Unlock() + fake.GetVolumeStub = nil + if fake.getVolumeReturnsOnCall == nil { + fake.getVolumeReturnsOnCall = make(map[int]struct { + result1 scbe.ScbeVolume + result2 error + }) + } + fake.getVolumeReturnsOnCall[i] = struct { + result1 scbe.ScbeVolume + result2 error + }{result1, result2} +} + +func (fake *FakeScbeDataModelWrapper) InsertVolume(arg1 string, arg2 string, arg3 string) error { + fake.insertVolumeMutex.Lock() + ret, specificReturn := fake.insertVolumeReturnsOnCall[len(fake.insertVolumeArgsForCall)] + fake.insertVolumeArgsForCall = append(fake.insertVolumeArgsForCall, struct { + arg1 string + arg2 string + arg3 string + }{arg1, arg2, arg3}) + fake.recordInvocation("InsertVolume", []interface{}{arg1, arg2, arg3}) + fake.insertVolumeMutex.Unlock() + if fake.InsertVolumeStub != nil { + return fake.InsertVolumeStub(arg1, arg2, arg3) + } + if specificReturn { + return ret.result1 + } + fakeReturns := fake.insertVolumeReturns + return fakeReturns.result1 +} + +func (fake *FakeScbeDataModelWrapper) InsertVolumeCallCount() int { + fake.insertVolumeMutex.RLock() + defer fake.insertVolumeMutex.RUnlock() + return len(fake.insertVolumeArgsForCall) +} + +func (fake *FakeScbeDataModelWrapper) InsertVolumeCalls(stub func(string, string, string) error) { + fake.insertVolumeMutex.Lock() + defer fake.insertVolumeMutex.Unlock() + fake.InsertVolumeStub = stub +} + +func (fake *FakeScbeDataModelWrapper) InsertVolumeArgsForCall(i int) (string, string, string) { + fake.insertVolumeMutex.RLock() + defer fake.insertVolumeMutex.RUnlock() + argsForCall := fake.insertVolumeArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 +} + +func (fake *FakeScbeDataModelWrapper) InsertVolumeReturns(result1 error) { + fake.insertVolumeMutex.Lock() + defer fake.insertVolumeMutex.Unlock() + fake.InsertVolumeStub = nil + fake.insertVolumeReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeScbeDataModelWrapper) InsertVolumeReturnsOnCall(i int, result1 error) { + fake.insertVolumeMutex.Lock() + defer fake.insertVolumeMutex.Unlock() + fake.InsertVolumeStub = nil + if fake.insertVolumeReturnsOnCall == nil { + fake.insertVolumeReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.insertVolumeReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeScbeDataModelWrapper) ListVolumes() ([]scbe.ScbeVolume, error) { + fake.listVolumesMutex.Lock() + ret, specificReturn := fake.listVolumesReturnsOnCall[len(fake.listVolumesArgsForCall)] + fake.listVolumesArgsForCall = append(fake.listVolumesArgsForCall, struct { + }{}) + fake.recordInvocation("ListVolumes", []interface{}{}) + fake.listVolumesMutex.Unlock() + if fake.ListVolumesStub != nil { + return fake.ListVolumesStub() + } + if specificReturn { + return ret.result1, ret.result2 + } + fakeReturns := fake.listVolumesReturns + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeScbeDataModelWrapper) ListVolumesCallCount() int { + fake.listVolumesMutex.RLock() + defer fake.listVolumesMutex.RUnlock() + return len(fake.listVolumesArgsForCall) +} + +func (fake *FakeScbeDataModelWrapper) ListVolumesCalls(stub func() ([]scbe.ScbeVolume, error)) { + fake.listVolumesMutex.Lock() + defer fake.listVolumesMutex.Unlock() + fake.ListVolumesStub = stub +} + +func (fake *FakeScbeDataModelWrapper) ListVolumesReturns(result1 []scbe.ScbeVolume, result2 error) { + fake.listVolumesMutex.Lock() + defer fake.listVolumesMutex.Unlock() + fake.ListVolumesStub = nil + fake.listVolumesReturns = struct { + result1 []scbe.ScbeVolume + result2 error + }{result1, result2} +} + +func (fake *FakeScbeDataModelWrapper) ListVolumesReturnsOnCall(i int, result1 []scbe.ScbeVolume, result2 error) { + fake.listVolumesMutex.Lock() + defer fake.listVolumesMutex.Unlock() + fake.ListVolumesStub = nil + if fake.listVolumesReturnsOnCall == nil { + fake.listVolumesReturnsOnCall = make(map[int]struct { + result1 []scbe.ScbeVolume + result2 error + }) + } + fake.listVolumesReturnsOnCall[i] = struct { + result1 []scbe.ScbeVolume + result2 error + }{result1, result2} +} + +func (fake *FakeScbeDataModelWrapper) UpdateDatabaseVolume(arg1 *scbe.ScbeVolume) { + fake.updateDatabaseVolumeMutex.Lock() + fake.updateDatabaseVolumeArgsForCall = append(fake.updateDatabaseVolumeArgsForCall, struct { + arg1 *scbe.ScbeVolume + }{arg1}) + fake.recordInvocation("UpdateDatabaseVolume", []interface{}{arg1}) + fake.updateDatabaseVolumeMutex.Unlock() + if fake.UpdateDatabaseVolumeStub != nil { + fake.UpdateDatabaseVolumeStub(arg1) + } +} + +func (fake *FakeScbeDataModelWrapper) UpdateDatabaseVolumeCallCount() int { + fake.updateDatabaseVolumeMutex.RLock() + defer fake.updateDatabaseVolumeMutex.RUnlock() + return len(fake.updateDatabaseVolumeArgsForCall) +} + +func (fake *FakeScbeDataModelWrapper) UpdateDatabaseVolumeCalls(stub func(*scbe.ScbeVolume)) { + fake.updateDatabaseVolumeMutex.Lock() + defer fake.updateDatabaseVolumeMutex.Unlock() + fake.UpdateDatabaseVolumeStub = stub +} + +func (fake *FakeScbeDataModelWrapper) UpdateDatabaseVolumeArgsForCall(i int) *scbe.ScbeVolume { + fake.updateDatabaseVolumeMutex.RLock() + defer fake.updateDatabaseVolumeMutex.RUnlock() + argsForCall := fake.updateDatabaseVolumeArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeScbeDataModelWrapper) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.deleteVolumeMutex.RLock() + defer fake.deleteVolumeMutex.RUnlock() + fake.getVolumeMutex.RLock() + defer fake.getVolumeMutex.RUnlock() + fake.insertVolumeMutex.RLock() + defer fake.insertVolumeMutex.RUnlock() + fake.listVolumesMutex.RLock() + defer fake.listVolumesMutex.RUnlock() + fake.updateDatabaseVolumeMutex.RLock() + defer fake.updateDatabaseVolumeMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *FakeScbeDataModelWrapper) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +} + +var _ scbe.ScbeDataModelWrapper = new(FakeScbeDataModelWrapper) diff --git a/local/scbe/datamodel_wrapper.go b/local/scbe/datamodel_wrapper.go index 3b84f479..1dbd015e 100644 --- a/local/scbe/datamodel_wrapper.go +++ b/local/scbe/datamodel_wrapper.go @@ -22,6 +22,7 @@ import ( "github.com/IBM/ubiquity/utils/logs" ) +//go:generate counterfeiter -o ../../fakes/fake_scbe_data_model_wrapper.go . ScbeDataModelWrapper type ScbeDataModelWrapper interface { GetVolume(name string, mustExist bool) (ScbeVolume, error) DeleteVolume(name string) error From 9820a842436c421101f7d72edc4fdce3204371b5 Mon Sep 17 00:00:00 2001 From: 27149chen <7991675+27149chen@users.noreply.github.com> Date: Wed, 27 Mar 2019 15:01:13 +0800 Subject: [PATCH 32/36] UB-1941 unmount fix Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> --- utils/mpath.go | 2 +- utils/mpath_test.go | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/utils/mpath.go b/utils/mpath.go index 6ed1cc11..f1b32c12 100644 --- a/utils/mpath.go +++ b/utils/mpath.go @@ -74,7 +74,7 @@ func GetMultipathOutputAndDeviceMapperAndDevice(volumeWwn string, exec Executor) if bodyRegex.MatchString(text) { index := bodyRegex.FindStringIndex(text) trimedText := text[index[0]:] - deviceName := strings.Split(trimedText, " ")[1] + deviceName := strings.Fields(trimedText)[1] deviceNames = append(deviceNames, deviceName) } else if !skipped { skipped = true diff --git a/utils/mpath_test.go b/utils/mpath_test.go index 62c5a988..caa47f27 100644 --- a/utils/mpath_test.go +++ b/utils/mpath_test.go @@ -49,6 +49,18 @@ size=1.0G features='1 queue_if_no_path' hwhandler='0' wp=rw '- 43:0:0:0 sdb 8:16 active ready running ` +var fakeMultipathOutputWithDifferentSpaces = ` +mpathj (6005076306ffd69d0000000000001004) dm-27 IBM ,2107900 +size=1.0G features='0' hwhandler='0' wp=rw +'-+- policy='service-time 0' prio=1 status=active + |- 33:0:12:1 sdcp 69:208 active ready running + |- 33:0:8:1 sdcn 69:176 active ready running + |- 33:0:9:1 sdco 69:192 active ready running + |- 34:0:10:1 sdcr 69:240 active ready running + |- 34:0:12:1 sdcs 70:0 active ready running + '- 34:0:9:1 sdcq 69:224 active ready running +` + var _ = Describe("scbe_mounter_test", func() { var ( fakeExec *fakes.FakeExecutor @@ -75,5 +87,13 @@ var _ = Describe("scbe_mounter_test", func() { Expect(devMapper).To(Equal("mpathc")) Expect(devNames).To(Equal([]string{"sda", "sdb"})) }) + + It("should get device names from multipath output with different spaces", func() { + fakeExec.ExecuteWithTimeoutReturns([]byte(fakeMultipathOutputWithDifferentSpaces), nil) + _, devMapper, devNames, err := utils.GetMultipathOutputAndDeviceMapperAndDevice(fakeWwn, fakeExec) + Ω(err).ShouldNot(HaveOccurred()) + Expect(devMapper).To(Equal("mpathj")) + Expect(devNames).To(Equal([]string{"sdcp", "sdcn", "sdco", "sdcr", "sdcs", "sdcq"})) + }) }) }) From 8994dcf0862ebc06c8a923d93ba078b4899c6f96 Mon Sep 17 00:00:00 2001 From: shay-berman Date: Thu, 28 Mar 2019 09:04:40 +0200 Subject: [PATCH 33/36] Remove ubiquity slack notifications (#301) --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 455dea03..0c1fef52 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,5 +10,3 @@ install: script: - sh scripts/run_units.sh -notifications: - slack: ibm-ubiquity:gb1UFkvWWjprPqokiklRRP1p From 3f22f0ef8a4ebccdfacf732d32c087986c51e2a6 Mon Sep 17 00:00:00 2001 From: 27149chen <7991675+27149chen@users.noreply.github.com> Date: Wed, 3 Apr 2019 08:37:21 +0300 Subject: [PATCH 34/36] update script for pushing iamges to docker hub (#302) Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> --- ...lper_to_push_ubiquity_images_and_manifests.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/scripts/ci/helper_to_push_ubiquity_images_and_manifests.sh b/scripts/ci/helper_to_push_ubiquity_images_and_manifests.sh index 7bea13f9..62883ed6 100755 --- a/scripts/ci/helper_to_push_ubiquity_images_and_manifests.sh +++ b/scripts/ci/helper_to_push_ubiquity_images_and_manifests.sh @@ -52,6 +52,8 @@ ubiquity_envs="in_UBIQUITY_IMAGE_AMD64 out_UBIQUITY_IMAGE_AMD64 in_UBIQUITY_IMAG ubiquity_db_envs="in_UBIQUITY_DB_IMAGE_AMD64 out_UBIQUITY_DB_IMAGE_AMD64 in_UBIQUITY_DB_IMAGE_PPC64LE out_UBIQUITY_DB_IMAGE_PPC64LE in_UBIQUITY_DB_IMAGE_S390X out_UBIQUITY_DB_IMAGE_S390X out_UBIQUITY_DB_IMAGE_MULTIARCH" ubiquity_provisioner_envs="in_UBIQUITY_K8S_PROVISIONER_IMAGE_AMD64 out_UBIQUITY_K8S_PROVISIONER_IMAGE_AMD64 in_UBIQUITY_K8S_PROVISIONER_IMAGE_PPC64LE out_UBIQUITY_K8S_PROVISIONER_IMAGE_PPC64LE in_UBIQUITY_K8S_PROVISIONER_IMAGE_S390X out_UBIQUITY_K8S_PROVISIONER_IMAGE_S390X out_UBIQUITY_K8S_PROVISIONER_IMAGE_MULTIARCH" ubiquity_flex_envs="in_UBIQUITY_K8S_FLEX_IMAGE_AMD64 out_UBIQUITY_K8S_FLEX_IMAGE_AMD64 in_UBIQUITY_K8S_FLEX_IMAGE_PPC64LE out_UBIQUITY_K8S_FLEX_IMAGE_PPC64LE in_UBIQUITY_K8S_FLEX_IMAGE_S390X out_UBIQUITY_K8S_FLEX_IMAGE_S390X out_UBIQUITY_K8S_FLEX_IMAGE_MULTIARCH" +ubiquity_flex_sidecar_envs="in_UBIQUITY_K8S_FLEX_SIDECAR_IMAGE_AMD64 out_UBIQUITY_K8S_FLEX_SIDECAR_IMAGE_AMD64 in_UBIQUITY_K8S_FLEX_SIDECAR_IMAGE_PPC64LE out_UBIQUITY_K8S_FLEX_SIDECAR_IMAGE_PPC64LE in_UBIQUITY_K8S_FLEX_SIDECAR_IMAGE_S390X out_UBIQUITY_K8S_FLEX_SIDECAR_IMAGE_S390X out_UBIQUITY_K8S_FLEX_SIDECAR_IMAGE_MULTIARCH" +ubiquity_helm_utils_envs="in_UBIQUITY_K8S_HELM_UTILS_IMAGE_AMD64 out_UBIQUITY_K8S_HELM_UTILS_IMAGE_AMD64 in_UBIQUITY_K8S_HELM_UTILS_IMAGE_PPC64LE out_UBIQUITY_K8S_HELM_UTILS_IMAGE_PPC64LE in_UBIQUITY_K8S_HELM_UTILS_IMAGE_S390X out_UBIQUITY_K8S_HELM_UTILS_IMAGE_S390X out_UBIQUITY_K8S_HELM_UTILS_IMAGE_MULTIARCH" HELPER_PUSH_IMAGE=./helper_to_push_docker_image.sh HELPER_PUSH_MANIFEST=./helper_to_push_docker_manifest.sh @@ -59,7 +61,7 @@ HELPER_PUSH_MANIFEST=./helper_to_push_docker_manifest.sh date # Validations [ -f $HELPER_PUSH_IMAGE -a -f $HELPER_PUSH_MANIFEST ] && : || exit 1 -for expected_env in $ubiquity_envs $ubiquity_db_envs $ubiquity_provisioner_envs $ubiquity_flex_envs; do +for expected_env in $ubiquity_envs $ubiquity_db_envs $ubiquity_provisioner_envs $ubiquity_flex_envs $ubiquity_flex_sidecar_envs $ubiquity_helm_utils_envs; do [ -z "`printenv $expected_env`" ] && { echo "Error: expected env [$expected_env] does not exist. Please set it first."; exit 1; } || : echo "$expected_env=`printenv $expected_env`" done @@ -67,10 +69,12 @@ done echo "TAG_LATEST=$TAG_LATEST" -push_arch_images_and_create_manifest_for_app "Ubiquity" $in_UBIQUITY_IMAGE_AMD64 $out_UBIQUITY_IMAGE_AMD64 $in_UBIQUITY_IMAGE_PPC64LE $out_UBIQUITY_IMAGE_PPC64LE $in_UBIQUITY_IMAGE_S390X $out_UBIQUITY_IMAGE_S390X $out_UBIQUITY_IMAGE_MULTIARCH $TAG_LATEST -push_arch_images_and_create_manifest_for_app "Ubiquity DB" $in_UBIQUITY_DB_IMAGE_AMD64 $out_UBIQUITY_DB_IMAGE_AMD64 $in_UBIQUITY_DB_IMAGE_PPC64LE $out_UBIQUITY_DB_IMAGE_PPC64LE $in_UBIQUITY_DB_IMAGE_S390X $out_UBIQUITY_DB_IMAGE_S390X $out_UBIQUITY_DB_IMAGE_MULTIARCH $TAG_LATEST -push_arch_images_and_create_manifest_for_app "Ubiquity provisioner" $in_UBIQUITY_K8S_PROVISIONER_IMAGE_AMD64 $out_UBIQUITY_K8S_PROVISIONER_IMAGE_AMD64 $in_UBIQUITY_K8S_PROVISIONER_IMAGE_PPC64LE $out_UBIQUITY_K8S_PROVISIONER_IMAGE_PPC64LE $in_UBIQUITY_K8S_PROVISIONER_IMAGE_S390X $out_UBIQUITY_K8S_PROVISIONER_IMAGE_S390X $out_UBIQUITY_K8S_PROVISIONER_IMAGE_MULTIARCH $TAG_LATEST -push_arch_images_and_create_manifest_for_app "Ubiquity flex" $in_UBIQUITY_K8S_FLEX_IMAGE_AMD64 $out_UBIQUITY_K8S_FLEX_IMAGE_AMD64 $in_UBIQUITY_K8S_FLEX_IMAGE_PPC64LE $out_UBIQUITY_K8S_FLEX_IMAGE_PPC64LE $in_UBIQUITY_K8S_FLEX_IMAGE_S390X $out_UBIQUITY_K8S_FLEX_IMAGE_S390X $out_UBIQUITY_K8S_FLEX_IMAGE_MULTIARCH $TAG_LATEST +push_arch_images_and_create_manifest_for_app "Ubiquity" $in_UBIQUITY_IMAGE_AMD64 $out_UBIQUITY_IMAGE_AMD64 $in_UBIQUITY_IMAGE_PPC64LE $out_UBIQUITY_IMAGE_PPC64LE $in_UBIQUITY_IMAGE_S390X $out_UBIQUITY_IMAGE_S390X $out_UBIQUITY_IMAGE_MULTIARCH $TAG_LATEST +push_arch_images_and_create_manifest_for_app "Ubiquity DB" $in_UBIQUITY_DB_IMAGE_AMD64 $out_UBIQUITY_DB_IMAGE_AMD64 $in_UBIQUITY_DB_IMAGE_PPC64LE $out_UBIQUITY_DB_IMAGE_PPC64LE $in_UBIQUITY_DB_IMAGE_S390X $out_UBIQUITY_DB_IMAGE_S390X $out_UBIQUITY_DB_IMAGE_MULTIARCH $TAG_LATEST +push_arch_images_and_create_manifest_for_app "Ubiquity provisioner" $in_UBIQUITY_K8S_PROVISIONER_IMAGE_AMD64 $out_UBIQUITY_K8S_PROVISIONER_IMAGE_AMD64 $in_UBIQUITY_K8S_PROVISIONER_IMAGE_PPC64LE $out_UBIQUITY_K8S_PROVISIONER_IMAGE_PPC64LE $in_UBIQUITY_K8S_PROVISIONER_IMAGE_S390X $out_UBIQUITY_K8S_PROVISIONER_IMAGE_S390X $out_UBIQUITY_K8S_PROVISIONER_IMAGE_MULTIARCH $TAG_LATEST +push_arch_images_and_create_manifest_for_app "Ubiquity flex" $in_UBIQUITY_K8S_FLEX_IMAGE_AMD64 $out_UBIQUITY_K8S_FLEX_IMAGE_AMD64 $in_UBIQUITY_K8S_FLEX_IMAGE_PPC64LE $out_UBIQUITY_K8S_FLEX_IMAGE_PPC64LE $in_UBIQUITY_K8S_FLEX_IMAGE_S390X $out_UBIQUITY_K8S_FLEX_IMAGE_S390X $out_UBIQUITY_K8S_FLEX_IMAGE_MULTIARCH $TAG_LATEST +push_arch_images_and_create_manifest_for_app "Ubiquity flex sidecar" $in_UBIQUITY_K8S_FLEX_SIDECAR_IMAGE_AMD64 $out_UBIQUITY_K8S_FLEX_SIDECAR_IMAGE_AMD64 $in_UBIQUITY_K8S_FLEX_SIDECAR_IMAGE_PPC64LE $out_UBIQUITY_K8S_FLEX_SIDECAR_IMAGE_PPC64LE $in_UBIQUITY_K8S_FLEX_SIDECAR_IMAGE_S390X $out_UBIQUITY_K8S_FLEX_SIDECAR_IMAGE_S390X $out_UBIQUITY_K8S_FLEX_SIDECAR_IMAGE_MULTIARCH $TAG_LATEST +push_arch_images_and_create_manifest_for_app "Ubiquity helm utils" $in_UBIQUITY_K8S_HELM_UTILS_IMAGE_AMD64 $out_UBIQUITY_K8S_HELM_UTILS_IMAGE_AMD64 $in_UBIQUITY_K8S_HELM_UTILS_IMAGE_PPC64LE $out_UBIQUITY_K8S_HELM_UTILS_IMAGE_PPC64LE $in_UBIQUITY_K8S_HELM_UTILS_IMAGE_S390X $out_UBIQUITY_K8S_HELM_UTILS_IMAGE_S390X $out_UBIQUITY_K8S_HELM_UTILS_IMAGE_MULTIARCH $TAG_LATEST date echo "######################################" @@ -82,5 +86,7 @@ echo $out_UBIQUITY_IMAGE_MULTIARCH echo $out_UBIQUITY_DB_IMAGE_MULTIARCH echo $out_UBIQUITY_K8S_PROVISIONER_IMAGE_MULTIARCH echo $out_UBIQUITY_K8S_FLEX_IMAGE_MULTIARCH +echo $out_UBIQUITY_K8S_FLEX_SIDECAR_IMAGE_MULTIARCH +echo $out_UBIQUITY_K8S_HELM_UTILS_IMAGE_MULTIARCH From b758e1f37a5d370c00deb79ed8721183ec7fbb5a Mon Sep 17 00:00:00 2001 From: 27149chen <7991675+27149chen@users.noreply.github.com> Date: Sun, 7 Apr 2019 17:18:59 +0300 Subject: [PATCH 35/36] UB-1977 exclude the warning messages in multipath output (#303) UB-1977 exclude the warning messages in multipath output Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> --- remote/mounter/block_device_utils/mpath.go | 2 + utils/mpath.go | 27 +++++++++++ utils/mpath_test.go | 56 ++++++++++++++++++++-- 3 files changed, 81 insertions(+), 4 deletions(-) diff --git a/remote/mounter/block_device_utils/mpath.go b/remote/mounter/block_device_utils/mpath.go index 381cd514..fb982a9b 100644 --- a/remote/mounter/block_device_utils/mpath.go +++ b/remote/mounter/block_device_utils/mpath.go @@ -111,6 +111,8 @@ func (b *blockDeviceUtils) mpathDevFullPath(dev string) string { func (b *blockDeviceUtils) DiscoverBySgInq(mpathOutput string, volumeWwn string) (string, error) { defer b.logger.Trace(logs.DEBUG)() + mpathOutput = utils.ExcludeNoTargetPortGroupMessagesFromMultipathOutput(mpathOutput, b.logger) + scanner := bufio.NewScanner(strings.NewReader(mpathOutput)) // regex to find all dm-X line from IBM vendor. // Note: searching "IBM" in the line also focus the search on IBM devices only and also eliminate the need to run sg_inq on faulty devices. diff --git a/utils/mpath.go b/utils/mpath.go index f1b32c12..4bf78c23 100644 --- a/utils/mpath.go +++ b/utils/mpath.go @@ -2,12 +2,16 @@ package utils import ( "bufio" + "fmt" "regexp" "strings" + + "github.com/IBM/ubiquity/utils/logs" ) const multipathCmd = "multipath" const MultipathTimeout = 10 * 1000 +const WarningNoTargetPortGroup = "couldn't get target port group" /* GetMultipathOutputAndDeviceMapperAndDevice analysises the output of command "multipath -ll", @@ -85,3 +89,26 @@ func GetMultipathOutputAndDeviceMapperAndDevice(volumeWwn string, exec Executor) } return outputBytes, devMapper, deviceNames, nil } + +func excludeWarningMessageLines(inputData string, warningPattern *regexp.Regexp, logger logs.Logger) string { + scanner := bufio.NewScanner(strings.NewReader(inputData)) + res := "" + for scanner.Scan() { + line := scanner.Text() + if warningPattern.MatchString(line) { + logger.Debug(fmt.Sprintf(`Found warning message line "%s", exclude it.`, line)) + continue + } + if res == "" { + res = line + } else { + res = res + "\n" + line + } + } + return res +} + +func ExcludeNoTargetPortGroupMessagesFromMultipathOutput(mpathOutput string, logger logs.Logger) string { + regex, _ := regexp.Compile(WarningNoTargetPortGroup) + return excludeWarningMessageLines(mpathOutput, regex, logger) +} diff --git a/utils/mpath_test.go b/utils/mpath_test.go index caa47f27..0572ef3b 100644 --- a/utils/mpath_test.go +++ b/utils/mpath_test.go @@ -6,6 +6,7 @@ import ( "github.com/IBM/ubiquity/fakes" "github.com/IBM/ubiquity/utils" + "github.com/IBM/ubiquity/utils/logs" ) const ( @@ -18,7 +19,7 @@ const ( fakeProfile = "gold" ) -var fakeWwn = "6005076306ffd69d0000000000001004" +var fakeWwn = "6005076306FFD69d0000000000001004" var fakeMultipathOutput = ` mpathg (36005076306ffd69d0000000000001004) dm-14 IBM ,2107900 @@ -35,7 +36,7 @@ size=2.0G features='1 queue_if_no_path' hwhandler='0' wp=rw ` + "`- 29:0:7:0 sdd 8:48 active ready running\n" var fakeMultipathOutputWithMultiplePathGroups = ` -mpathc (6005076306ffd69d0000000000001004) dm-4 IBM ,2145 +mpathc (36005076306ffd69d0000000000001004) dm-4 IBM ,2145 size=1.0G features='0' hwhandler='0' wp=rw |-+- policy='service-time 0' prio=50 status=active | '- 43:0:0:3 sda 8:112 active ready running @@ -50,7 +51,7 @@ size=1.0G features='1 queue_if_no_path' hwhandler='0' wp=rw ` var fakeMultipathOutputWithDifferentSpaces = ` -mpathj (6005076306ffd69d0000000000001004) dm-27 IBM ,2107900 +mpathj (36005076306ffd69d0000000000001004) dm-27 IBM ,2107900 size=1.0G features='0' hwhandler='0' wp=rw '-+- policy='service-time 0' prio=1 status=active |- 33:0:12:1 sdcp 69:208 active ready running @@ -61,7 +62,37 @@ size=1.0G features='0' hwhandler='0' wp=rw '- 34:0:9:1 sdcq 69:224 active ready running ` -var _ = Describe("scbe_mounter_test", func() { +var fakeMultipathOutputWithWarnings = ` +Apr 04 16:38:06 | sde: couldn't get target port group +Apr 04 16:38:06 | sdd: couldn't get target port group +mpathj (36005076306ffd69d0000000000001004) dm-17 IBM ,2145 +size=1.0G features='1 queue_if_no_path' hwhandler='0' wp=rw +|-+- policy='service-time 0' prio=0 status=enabled +| '- 39:0:0:1 sde 8:64 failed faulty running +'-+- policy='service-time 0' prio=0 status=enabled + '- 40:0:0:1 sdd 8:48 failed faulty running +mpathi (3600507680c8701159800000000001af3) dm-14 IBM ,2145 +size=20G features='1 queue_if_no_path' hwhandler='0' wp=rw +|-+- policy='service-time 0' prio=50 status=active +| '- 40:0:0:0 sdb 8:16 active ready running +'-+- policy='service-time 0' prio=10 status=enabled + '- 39:0:0:0 sdc 8:32 active ready running +` + +var fakeMultipathOutputWithWarningsExcluded = `mpathj (36005076306ffd69d0000000000001004) dm-17 IBM ,2145 +size=1.0G features='1 queue_if_no_path' hwhandler='0' wp=rw +|-+- policy='service-time 0' prio=0 status=enabled +| '- 39:0:0:1 sde 8:64 failed faulty running +'-+- policy='service-time 0' prio=0 status=enabled + '- 40:0:0:1 sdd 8:48 failed faulty running +mpathi (3600507680c8701159800000000001af3) dm-14 IBM ,2145 +size=20G features='1 queue_if_no_path' hwhandler='0' wp=rw +|-+- policy='service-time 0' prio=50 status=active +| '- 40:0:0:0 sdb 8:16 active ready running +'-+- policy='service-time 0' prio=10 status=enabled + '- 39:0:0:0 sdc 8:32 active ready running` + +var _ = Describe("multipath_utils_test", func() { var ( fakeExec *fakes.FakeExecutor ) @@ -95,5 +126,22 @@ var _ = Describe("scbe_mounter_test", func() { Expect(devMapper).To(Equal("mpathj")) Expect(devNames).To(Equal([]string{"sdcp", "sdcn", "sdco", "sdcr", "sdcs", "sdcq"})) }) + + It("should get device names from multipath output with warning header", func() { + fakeExec.ExecuteWithTimeoutReturns([]byte(fakeMultipathOutputWithWarnings), nil) + _, devMapper, devNames, err := utils.GetMultipathOutputAndDeviceMapperAndDevice(fakeWwn, fakeExec) + Ω(err).ShouldNot(HaveOccurred()) + Expect(devMapper).To(Equal("mpathj")) + Expect(devNames).To(Equal([]string{"sde", "sdd"})) + }) + }) + + Context("ExcludeNoTargetPortGroupMessagesFromMultipathOutput", func() { + + It("should exclude the warning messages from multipath output", func() { + logger := logs.GetLogger() + out := utils.ExcludeNoTargetPortGroupMessagesFromMultipathOutput(fakeMultipathOutputWithWarnings, logger) + Expect(out).To(Equal(fakeMultipathOutputWithWarningsExcluded)) + }) }) }) From 5b947e6e8a0dbc071560a2ea2686f7688f4bc4b6 Mon Sep 17 00:00:00 2001 From: 27149chen <7991675+27149chen@users.noreply.github.com> Date: Mon, 8 Apr 2019 13:52:18 +0800 Subject: [PATCH 36/36] UB-1977 exclude the warning messages in multipath output Signed-off-by: 27149chen <7991675+27149chen@users.noreply.github.com> --- remote/mounter/block_device_utils/mpath.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/remote/mounter/block_device_utils/mpath.go b/remote/mounter/block_device_utils/mpath.go index fb982a9b..893da376 100644 --- a/remote/mounter/block_device_utils/mpath.go +++ b/remote/mounter/block_device_utils/mpath.go @@ -81,8 +81,10 @@ func (b *blockDeviceUtils) Discover(volumeWwn string, deepDiscovery bool) (strin } else { mpath = b.mpathDevFullPath(dev) + mpathOutput := utils.ExcludeNoTargetPortGroupMessagesFromMultipathOutput(string(outputBytes[:]), b.logger) + // Validate that we have the correct wwn. - SqInqWwn, err := b.GetWwnByScsiInq(string(outputBytes[:]), mpath) + SqInqWwn, err := b.GetWwnByScsiInq(mpathOutput, mpath) if err != nil { switch err.(type) { case *FaultyDeviceError: