Esempio n. 1
0
def ModifyImageSharePermission(image_id, add_accounts=[], remove_accounts=[]):
    client = get_client()
    request = ModifyImageSharePermissionRequest.ModifyImageSharePermissionRequest(
    )
    request.set_ImageId(image_id)
    request.set_AddAccounts(add_accounts),
    request.set_RemoveAccounts(remove_accounts),
    # Initiate an API request and print the response
    response = client.do_action_with_exception(request)
    data = json.loads(response)
    return data
Esempio n. 2
0
    def _share_images(self, region_image_map: dict):
        for region, image_id in region_image_map.items():
            self.acs_client.set_region_id(region)
            logger.info(f"share image ({region}/{image_id}) as a hidden image")
            req = ModifyImageSharePermissionRequest.ModifyImageSharePermissionRequest(
            )
            req.set_ImageId(image_id)
            req.set_LaunchPermission(str(ImageShareOption.SHARE))
            self.acs_client.do_action_with_exception(req)

        self.acs_client.set_region_id(self.region)
Esempio n. 3
0
 def _del_image(self, region, image_id):
     logger.warning(
         f"Delete image {self.image_name}/{image_id} in region {region}")
     self.acs_client.set_region_id(region)
     req = ModifyImageSharePermissionRequest.ModifyImageSharePermissionRequest(
     )
     req.set_ImageId(image_id)
     req.set_LaunchPermission(str(ImageShareOption.UNSHARE))
     self.acs_client.do_action_with_exception(req)
     req = DeleteImageRequest.DeleteImageRequest()
     req.set_ImageId(image_id)
     self.acs_client.do_action_with_exception(req)