usr/src/lib/libict_pymod/ict.py
branchoi_151a
changeset 1447 f7571d01f887
parent 1433 8c642698bcb5
equal deleted inserted replaced
1446:280969bf3321 1447:f7571d01f887
  2230         return return_status
  2230         return return_status
  2231 
  2231 
  2232     def reset_image_uuid(self):
  2232     def reset_image_uuid(self):
  2233         '''ICT - reset pkg(1) image UUID for preferred publisher
  2233         '''ICT - reset pkg(1) image UUID for preferred publisher
  2234 
  2234 
  2235         Obtain name of preferred publisher by parsing output of following
  2235         Obtain name of all publishers by parsing output of the following
  2236         command: pkg -R basedir property -H preferred-publisher
  2236         command: pkg -R basedir property -H publisher-search-order
  2237 
  2237 
  2238         launch pkg -R basedir set-publisher --reset-uuid --no-refresh \
  2238         launch pkg -R basedir set-publisher --reset-uuid --no-refresh \
  2239             <preferred_publisher>
  2239             <preferred_publisher>
  2240 
  2240 
  2241         launch pkg -R basedir pkg set-property send-uuid True
  2241         launch pkg -R basedir pkg set-property send-uuid True
  2242 
  2242 
  2243         return 0 for success, otherwise error code
  2243         return 0 for success, otherwise error code
  2244         '''
  2244         '''
  2245         _register_task(inspect.currentframe())
  2245         _register_task(inspect.currentframe())
  2246         cmd = '/usr/bin/pkg -R ' + self.basedir + \
  2246         cmd = '/usr/bin/pkg -R ' + self.basedir + ' property -H ' + \
  2247             ' property -H preferred-publisher'
  2247             'publisher-search-order'
  2248         status, co = _cmd_out(cmd)
  2248         status, co = _cmd_out(cmd)
  2249         if status != 0:
  2249         if status != 0:
  2250             prerror('pkg(1) failed to obtain name of preferred publisher - '
  2250             prerror('pkg(1) failed to obtain list of publishers - '
  2251                     'exit status = ' + str(status) + ', command was ' + cmd)
  2251                     'exit status = ' + str(status) + ', command was ' + cmd)
  2252             prerror('Failure. Returning: ICT_PKG_RESET_UUID_FAILED')
  2252             prerror('Failure. Returning: ICT_PKG_RESET_UUID_FAILED')
  2253             return ICT_PKG_RESET_UUID_FAILED
  2253             return ICT_PKG_RESET_UUID_FAILED
  2254 
  2254 
  2255         try:
  2255         publisher_search_order = co[0].strip().split(None, 1)
  2256             preferred_publisher = co[0].split()[1]
  2256         # strip off the leading '[' and trailing ']' characters
  2257 
  2257         for publisher in publisher_search_order[1:-1]:
  2258         except IndexError:
  2258             # strip off any ' or , characters
  2259             prerror('Could not determine name of preferred publisher from '
  2259             publisher = publisher.strip("',")
  2260                     'following input : ' + repr(co))
  2260 
  2261             prerror('Failure. Returning: ICT_PKG_RESET_UUID_FAILED')
  2261             cmd = 'pkg -R ' + self.basedir + \
  2262             return ICT_PKG_RESET_UUID_FAILED
  2262                 ' set-publisher --reset-uuid --no-refresh ' + publisher
  2263 
  2263             status = _cmd_status(cmd)
  2264         _dbg_msg('Preferred publisher: ' + preferred_publisher)
  2264             if status != 0:
  2265 
  2265                 prerror('Reset uuid failed for publisher:  ' + publisher +
  2266         cmd = 'pkg -R ' + self.basedir + \
  2266                         '- exit status = ' + str(status) +
  2267             ' set-publisher --reset-uuid --no-refresh ' + preferred_publisher
  2267                         ', command was ' + cmd)
  2268         status = _cmd_status(cmd)
  2268                 prerror('Failure. Returning: ICT_PKG_RESET_UUID_FAILED')
  2269         if status != 0:
  2269                 return ICT_PKG_RESET_UUID_FAILED
  2270             prerror('Reset uuid failed - exit status = ' + str(status) +
       
  2271                 ', command was ' + cmd)
       
  2272             prerror('Failure. Returning: ICT_PKG_RESET_UUID_FAILED')
       
  2273             return ICT_PKG_RESET_UUID_FAILED
       
  2274 
  2270 
  2275         cmd = 'pkg -R ' + self.basedir + ' set-property send-uuid True'
  2271         cmd = 'pkg -R ' + self.basedir + ' set-property send-uuid True'
  2276         status = _cmd_status(cmd)
  2272         status = _cmd_status(cmd)
  2277         if status != 0:
  2273         if status != 0:
  2278             prerror('Set property send uuid - exit status = ' + str(status) +
  2274             prerror('Set property send uuid - exit status = ' + str(status) +