#!/usr/bin/env python3
import subprocess
import os
import sys
import json
sys.path.append("../lib/")
sys.path.append("../array/")

import json_parser
import ibofos
import cli
import test_result
import ibofos_constant
import CREATE_VOL_BASIC_8

VOL_NAME_PREFIX = "vol"
VOL_SIZE = ibofos_constant.SIZE_1MB * 100
VOL_IOPS = 10
VOL_BW = 10

def clear_result():
    if os.path.exists( __file__ + ".result"):
        os.remove( __file__ + ".result")

def set_result(detail):
    code = json_parser.get_response_code(detail)
    result = test_result.expect_false(code)
    with open(__file__ + ".result", "w") as result_file:
        result_file.write(result + " (" + str(code) + ")" + "\n" + detail)

def execute():
    clear_result()
    CREATE_VOL_BASIC_8.execute()
    out = cli.create_volume(VOL_NAME_PREFIX + str(257), str(VOL_SIZE), str(VOL_IOPS), str(VOL_BW), "")
    return out

if __name__ == "__main__":
    out = execute()
    set_result(out)
    ibofos.kill_ibofos()