Ejemplo n.º 1
0
 def save_info_to_yaml(cls) -> dict:
     if not cls.network_information:
         cls.get_network_info()
     log.info(f"StaticIpUtils Save: {cls.network_information}")
     file_oper = YamlOperator(cls.temp_net_info_file)
     file_oper.write(cls.network_information)
     return cls.network_information
Ejemplo n.º 2
0
def case_steps_run_control(steps_list, name, *args, **kwargs):
    case_steps_file = os.path.join(get_current_dir(),
                                   "{}_case_steps.yml".format(name))
    if not os.path.exists(case_steps_file):
        list_dict = {}
        for s in steps_list:
            list_dict[s] = "norun"
        steps_yml = YamlOperator(case_steps_file)
        steps_yml.write(list_dict)

    steps_yml = YamlOperator(case_steps_file)
    for step in steps_list:
        steps_dict = steps_yml.read()
        for key, value in steps_dict.items():
            if step == key and value.lower() != "finished":
                steps_dict[key] = "finished"
                steps_yml.write(steps_dict)
                result = getattr(sys.modules[name], step)(*args, **kwargs)
                # result = eval(key)
                if result is False:
                    os.remove(case_steps_file)
                    return False
        if steps_list.index(step) == len(steps_list) - 1:
            os.remove(case_steps_file)
            return True
 def change_key_state(self, user_name, state, key="user"):
     self.ftp.download_file(self.remote_base_file('path'), self.file_path)
     time.sleep(2)
     yaml_obj = YamlOperator(self.file_path)
     total_users = yaml_obj.read()
     value = total_users.get(key).get(user_name)
     if value:
         total_users[key][user_name] = state
         yaml_obj.write(total_users)
         self.ftp.upload_file(self.file_path, self.remote_base_file('path'))
     else:
         print('invalid user')
Ejemplo n.º 4
0
 def change_key_state(self, user_name, state, key="user"):
     self.ftp.download_file(self.remote_base_file, self.file_path)
     time.sleep(2)
     yaml_obj = YamlOperator(self.file_path)
     total_users = yaml_obj.read()
     value = total_users.get(key).get(user_name)
     if value:
         total_users[key][user_name] = state
         yaml_obj.write(total_users)
         self.ftp.upload_file(self.file_path, self.remote_base_file)
     else:
         log.error('invalid user {}'.format(user_name))
         return False
     return True
Ejemplo n.º 5
0
 def __save(cls, **data) -> dict:
     log.info(f"StaticIpUtils Save: {data}")
     file_oper = YamlOperator(cls.temp_static_info_file)
     file_oper.write(data)
     return data