def image_update(call=None, kwargs=None):
 if (call != 'function'):
  raise SaltCloudSystemExit('The image_allocate function must be called with -f or --function.')
 if (kwargs is None):
  kwargs = {}
 image_id = kwargs.get('image_id', None)
 image_name = kwargs.get('image_name', None)
 path = kwargs.get('path', None)
 data = kwargs.get('data', None)
 update_type = kwargs.get('update_type', None)
 update_args = ['replace', 'merge']
 if (update_type is None):
  raise SaltCloudSystemExit("The image_update function requires an 'update_type' to be provided.")
 if (update_type == update_args[0]):
  update_number = 0
 elif (update_type == update_args[1]):
  update_number = 1
 else:
  raise SaltCloudSystemExit('The update_type argument must be either {0} or {1}.'.format(update_args[0], update_args[1]))
 if image_id:
  if image_name:
   log.warning("Both the 'image_id' and 'image_name' arguments were provided. 'image_id' will take precedence.")
 elif image_name:
  image_id = get_image_id(kwargs={'name': image_name})
 else:
  raise SaltCloudSystemExit("The image_update function requires either an 'image_id' or an 'image_name' to be provided.")
 if data:
  if path:
   log.warning("Both the 'data' and 'path' arguments were provided. 'data' will take precedence.")
 elif path:
  data = salt.utils.fopen(path, mode='r').read()
 else:
  raise SaltCloudSystemExit("The image_update function requires either 'data' or a file 'path' to be provided.")
 (server, user, password) = _get_xml_rpc()
 auth = ':'.join([user, password])
 response = server.one.image.update(auth, int(image_id), data, int(update_number))
 ret = {'action': 'image.update', 'updated': response[0], 'image_id': response[1], 'error_code': response[2]}
 return ret

def image_update ( call = None , kwargs = None ) : if ( call != 'function' ) : raise SaltCloudSystemExit ( 'The image_allocate function must be called with -f or --function.' ) if ( kwargs is None ) : kwargs = { } image_id = kwargs . get ( 'image_id' , None ) image_name = kwargs . get ( 'image_name' , None ) path = kwargs . get ( 'path' , None ) data = kwargs . get ( 'data' , None ) update_type = kwargs . get ( 'update_type' , None ) update_args = [ 'replace' , 'merge' ] if ( update_type is None ) : raise SaltCloudSystemExit ( "The image_update function requires an 'update_type' to be provided." ) if ( update_type == update_args [ 0 ] ) : update_number = 0 elif ( update_type == update_args [ 1 ] ) : update_number = 1 else : raise SaltCloudSystemExit ( 'The update_type argument must be either {0} or {1}.' . format ( update_args [ 0 ] , update_args [ 1 ] ) ) if image_id : if image_name : log . warning ( "Both the 'image_id' and 'image_name' arguments were provided. 'image_id' will take precedence." ) elif image_name : image_id = get_image_id ( kwargs = { 'name' : image_name } ) else : raise SaltCloudSystemExit ( "The image_update function requires either an 'image_id' or an 'image_name' to be provided." ) if data : if path : log . warning ( "Both the 'data' and 'path' arguments were provided. 'data' will take precedence." ) elif path : data = salt . utils . fopen ( path , mode = 'r' ) . read ( ) else : raise SaltCloudSystemExit ( "The image_update function requires either 'data' or a file 'path' to be provided." ) ( server , user , password ) = _get_xml_rpc ( ) auth = ':' . join ( [ user , password ] ) response = server . one . image . update ( auth , int ( image_id ) , data , int ( update_number ) ) ret = { 'action' : 'image.update' , 'updated' : response [ 0 ] , 'image_id' : response [ 1 ] , 'error_code' : response [ 2 ] } return ret
set the given properties on an image and update it .