fix rebase error

fix test build failure
This commit is contained in:
andyzhangx
2018-01-30 14:02:49 +00:00
parent fc988d429b
commit bf0c6d84f5
3 changed files with 30 additions and 18 deletions

View File

@@ -930,7 +930,7 @@ func (fRTC *fakeRouteTablesClient) Get(resourceGroupName string, routeTableName
type fakeFileClient struct { type fakeFileClient struct {
} }
func (fFC *fakeFileClient) createFileShare(accountName, accountKey, name string, sizeGB int) error { func (fFC *fakeFileClient) createFileShare(accountName, accountKey, name string, sizeGiB int) error {
return nil return nil
} }
@@ -938,6 +938,10 @@ func (fFC *fakeFileClient) deleteFileShare(accountName, accountKey, name string)
return nil return nil
} }
func (fFC *fakeFileClient) resizeFileShare(accountName, accountKey, name string, sizeGiB int) error {
return nil
}
type fakeStorageAccountClient struct { type fakeStorageAccountClient struct {
mutex *sync.Mutex mutex *sync.Mutex
FakeStore map[string]map[string]storage.Account FakeStore map[string]map[string]storage.Account

View File

@@ -33,6 +33,7 @@ const (
type FileClient interface { type FileClient interface {
createFileShare(accountName, accountKey, name string, sizeGiB int) error createFileShare(accountName, accountKey, name string, sizeGiB int) error
deleteFileShare(accountName, accountKey, name string) error deleteFileShare(accountName, accountKey, name string) error
resizeFileShare(accountName, accountKey, name string, sizeGiB int) error
} }
// create file share // create file share
@@ -44,6 +45,10 @@ func (az *Cloud) deleteFileShare(accountName, accountKey, name string) error {
return az.FileClient.deleteFileShare(accountName, accountKey, name) return az.FileClient.deleteFileShare(accountName, accountKey, name)
} }
func (az *Cloud) resizeFileShare(accountName, accountKey, name string, sizeGiB int) error {
return az.FileClient.resizeFileShare(accountName, accountKey, name, sizeGiB)
}
type azureFileClient struct { type azureFileClient struct {
env azure.Environment env azure.Environment
} }
@@ -81,6 +86,25 @@ func (f *azureFileClient) deleteFileShare(accountName, accountKey, name string)
return fileClient.GetShareReference(name).Delete(nil) return fileClient.GetShareReference(name).Delete(nil)
} }
func (f *azureFileClient) resizeFileShare(accountName, accountKey, name string, sizeGiB int) error {
fileClient, err := f.getFileSvcClient(accountName, accountKey)
if err != nil {
return err
}
share := fileClient.GetShareReference(name)
if share.Properties.Quota >= sizeGiB {
glog.Warningf("file share size(%dGi) is already greater or equal than requested size(%dGi), accountName: %s, shareName: %s",
share.Properties.Quota, sizeGiB, accountName, name)
return nil
}
share.Properties.Quota = sizeGiB
if err = share.SetProperties(nil); err != nil {
return fmt.Errorf("failed to set quota on file share %s, err: %v", name, err)
}
glog.V(4).Infof("resize file share completed, accountName: %s, shareName: %s, sizeGiB: %d", accountName, name, sizeGiB)
return nil
}
func (f *azureFileClient) getFileSvcClient(accountName, accountKey string) (*azs.FileServiceClient, error) { func (f *azureFileClient) getFileSvcClient(accountName, accountKey string) (*azs.FileServiceClient, error) {
fileClient, err := azs.NewClient(accountName, accountKey, f.env.StorageEndpointSuffix, azs.DefaultAPIVersion, useHTTPS) fileClient, err := azs.NewClient(accountName, accountKey, f.env.StorageEndpointSuffix, azs.DefaultAPIVersion, useHTTPS)
if err != nil { if err != nil {

View File

@@ -72,21 +72,5 @@ func (az *Cloud) DeleteFileShare(accountName, key, name string) error {
// ResizeFileShare resizes a file share // ResizeFileShare resizes a file share
func (az *Cloud) ResizeFileShare(accountName, accountKey, name string, sizeGiB int) error { func (az *Cloud) ResizeFileShare(accountName, accountKey, name string, sizeGiB int) error {
fileClient, err := az.getFileSvcClient(accountName, accountKey) return az.resizeFileShare(accountName, accountKey, name, sizeGiB)
if err != nil {
return err
}
share := fileClient.GetShareReference(name)
if share.Properties.Quota >= sizeGiB {
glog.Warningf("file share size(%dGi) is already greater or equal than requested size(%dGi), accountName: %s, shareName: %s",
share.Properties.Quota, sizeGiB, accountName, name)
return nil
}
share.Properties.Quota = sizeGiB
if err = share.SetProperties(nil); err != nil {
return fmt.Errorf("failed to set quota on file share %s, err: %v", name, err)
}
glog.V(4).Infof("resize file share completed, accountName: %s, shareName: %s, sizeGiB: %d", accountName, name, sizeGiB)
return nil
} }