mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #8461 from rainzm/guestimage/public
fix(glance): allow public and private operations of guestimage
This commit is contained in:
@@ -541,7 +541,7 @@ func (self *SGuestImage) PerformPublic(
|
||||
return nil, errors.Wrap(err, "fail to fetch subimages of guest image")
|
||||
}
|
||||
for i := range images {
|
||||
_, err := images[i].PerformPublic(ctx, userCred, query, input)
|
||||
_, err := images[i].performPublic(ctx, userCred, query, input)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "fail to public subimage %s", images[i].GetId())
|
||||
}
|
||||
@@ -560,7 +560,7 @@ func (self *SGuestImage) PerformPrivate(
|
||||
return nil, errors.Wrap(err, "fail to fetch subimages of guest image")
|
||||
}
|
||||
for i := range images {
|
||||
_, err := images[i].PerformPrivate(ctx, userCred, query, input)
|
||||
_, err := images[i].performPrivate(ctx, userCred, query, input)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "fail to private subimage %s", images[i].GetId())
|
||||
}
|
||||
|
||||
@@ -1476,21 +1476,29 @@ func (img *SImage) PerformUpdateStatus(ctx context.Context, userCred mcclient.To
|
||||
}
|
||||
|
||||
func (img *SImage) PerformPublic(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input apis.PerformPublicProjectInput) (jsonutils.JSONObject, error) {
|
||||
if img.IsStandard.IsTrue() {
|
||||
return nil, errors.Wrap(httperrors.ErrForbidden, "cannot perform public for standard image")
|
||||
}
|
||||
if img.IsGuestImage.IsTrue() {
|
||||
return nil, errors.Wrap(httperrors.ErrForbidden, "cannot perform public for guest image")
|
||||
}
|
||||
return img.performPublic(ctx, userCred, query, input)
|
||||
}
|
||||
|
||||
func (img *SImage) performPublic(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input apis.PerformPublicProjectInput) (jsonutils.JSONObject, error) {
|
||||
if img.IsStandard.IsTrue() {
|
||||
return nil, errors.Wrap(httperrors.ErrForbidden, "cannot perform public for standard image")
|
||||
}
|
||||
return img.SSharableVirtualResourceBase.PerformPublic(ctx, userCred, query, input)
|
||||
}
|
||||
|
||||
func (img *SImage) PerformPrivate(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input apis.PerformPrivateInput) (jsonutils.JSONObject, error) {
|
||||
func (img *SImage) performPrivate(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input apis.PerformPrivateInput) (jsonutils.JSONObject, error) {
|
||||
if img.IsStandard.IsTrue() {
|
||||
return nil, errors.Wrap(httperrors.ErrForbidden, "cannot perform private for standard image")
|
||||
}
|
||||
return img.SSharableVirtualResourceBase.PerformPrivate(ctx, userCred, query, input)
|
||||
}
|
||||
|
||||
func (img *SImage) PerformPrivate(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input apis.PerformPrivateInput) (jsonutils.JSONObject, error) {
|
||||
if img.IsGuestImage.IsTrue() {
|
||||
return nil, errors.Wrap(httperrors.ErrForbidden, "cannot perform private for guest image")
|
||||
}
|
||||
return img.SSharableVirtualResourceBase.PerformPrivate(ctx, userCred, query, input)
|
||||
return img.performPrivate(ctx, userCred, query, input)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user