def import_elements(self, import_file): """ Import elements into SMC. Specify the fully qualified path to the import file. :param str import_file: system level path to file :raises: ActionCommandFailed :return: None """ import_follower = Task( self.make_request( method="create", resource="import_elements", files={"import_file": open(import_file, "rb")}, )) in_progress = import_follower.data.in_progress progress = import_follower.progress while in_progress is True: time.sleep(1) logger.info("[{}] XML Import task => {}%".format( "{:%H:%M:%S.%f}".format(datetime.now())[:-3], progress)) in_progress = import_follower.update_status().data.in_progress progress = import_follower.update_status().progress succeed = import_follower.update_status().success last_message = import_follower.update_status().last_message if not succeed: logger.info("[{}] XML Import task failed:{}".format( "{:%H:%M:%S.%f}".format(datetime.now())[:-3], last_message)) raise ActionCommandFailed(last_message) logger.info("[{}] XML Import task succeed".format( "{:%H:%M:%S.%f}".format(datetime.now())[:-3]))
def import_elements(self, import_file): """ Import elements into SMC. Specify the fully qualified path to the import file. :param str import_file: system level path to file :raises: ActionCommandFailed :return: None """ import_follower = Task( self.make_request(method='create', resource='import_elements', files={'import_file': open(import_file, 'rb')})) in_progress = import_follower.data.in_progress progress = import_follower.progress while in_progress is True: time.sleep(1) logger.info("[{}] XML Import task => {}%".format( '{:%H:%M:%S.%f}'.format(datetime.now())[:-3], progress)) in_progress = import_follower.update_status().data.in_progress progress = import_follower.update_status().progress logger.info("[{}] XML Import task finished".format( '{:%H:%M:%S.%f}'.format(datetime.now())[:-3]))