示例#1
0
def get_client_node_data(node_type, node_name, vpc_name):
    log_service("get client node data() "+ node_type + node_name + vpc_name)
    file_path = ""
    if (node_type == "spine"):
        if not client_exists_spine(vpc_name, node_name):
            log_service("Spine does not exists")
            return False
        else:
            file_path = "var/vpc/" + vpc_name + "/spines/" + node_name
    elif (node_type == "l1_transit"):
        if not client_exists_l1_transit(node_name):
            log_service("l1_transit does not exists "+ node_name)
            return False
        else:
            file_path = "var/l1_transits/" + node_name
    elif (node_type == "l2_transit"):
        if not client_exists_l2_transit(node_name):
            log_service("l2_transit does not exists")
            return False
        else:
            file_path = "var/l2_transits/" + node_name
    else:
        log_service("Wrong node type")
        return False
    
    return do_json.json_read(file_path + ".json") 
示例#2
0
def write_spine_ip(vpc, spine, spine_ip):
    file_path = constants.var_vpc + vpc + \
            constants.vpc_spines + spine + ".json"

    spine_data = do_json.json_read(file_path)
    spine_data["ip"] = spine_ip
    do_json.json_write(spine_data, file_path)
示例#3
0
def client_add_leaf_pc(vpc_name, pc_name, leaf_name):
    file_path = constants.var_vpc + vpc_name + \
            constants.vpc_pcs + pc_name + ".json"

    pc_data = do_json.json_read(file_path) 
    leafs = pc_data["leafs"]
    leafs.append(leaf_name)
    pc_data["leafs"] = leafs
    do_json.json_write(pc_data, file_path) 
示例#4
0
import constants
import ipaddress
"""@params:
    param1 = connection config name (required)
"""

if __name__ == "__main__":
    if (len(sys.argv) < 2):
        raas_utils.log_service("Please give connection config file")
        exit(1)

    connection_config_file = sys.argv[1]
    connection_name = connection_config_file.split('/')[-1].split('.')[0]
    cid = hyp_utils.get_client_id()

    connection_data = do_json.json_read(connection_config_file)
    raas_utils.log_service(connection_data)
    vpc_name = connection_data["vpc_name"]
    pc_name = connection_data["pc_name"]
    leaf_name = connection_data["leaf_name"]

    if not raas_utils.client_exists_pc(vpc_name, pc_name):
        raas_utils.log_service("pc does not exists " + pc_name)
        exit(1)

    if not raas_utils.client_exists_leaf(vpc_name, leaf_name):
        raas_utils.log_service("leaf does not exist " + leaf_name)
        exit(1)

    pc_hypervisor_name = connection_data["pc_hypervisor_name"]
    leaf_hypervisor_name = connection_data["leaf_hypervisor_name"]
示例#5
0
"""@params:
    param1 = vpc config file (required)
"""

if __name__=="__main__":
    if (len(sys.argv) < 2):
        raas_utils.log_client("VPC config not provided")
        raas_utils.log_service("Please give vpc config file")
        exit(1)

    spine_config_file = sys.argv[1]

    spine_name = spine_config_file.split('/')[-1].split('.')[0]

    #Assumed customer always gives correct config file
    spine_data = do_json.json_read(spine_config_file)

    hypervisor = spine_data["hypervisor_name"]
    hypervisor_arg = "hypervisor="+hypervisor

    hypervisors_data = hyp_utils.get_hypervisors_data()

    hypervisor_ip = hyp_utils.get_hyp_ip(hypervisor)

    vpc_name = spine_data["vpc_name"]

    if not raas_utils.client_exists_vpc(vpc_name):
        raas_utils.log_client("VPC does not exist")
        raas_utils.log_service("VPC does not exist")
        exit(1)
示例#6
0
def update_veth_subnet(subnet_name,new_subnet):
    file_path = "var/reserved_subnets.json"
    subnet_data = do_json.json_read(file_path)
    subnet_data[subnet_name]=new_subnet
    do_json.json_write(subnet_data, file_path)
示例#7
0
def get_new_veth_subnet(subnet_name):
    file_path = "var/reserved_subnets.json"
    subnet_data = do_json.json_read(file_path)
    return subnet_data[subnet_name]
示例#8
0
"""@params:
    param1 = l1_transit config file (required)
"""

if __name__=="__main__":
    if (len(sys.argv) < 2):
        raas_utils.log_client("Please give l1_transit config file.....aborting")
        raas_utils.log_service("Please give l1_transit config file......aborting")
        exit(1)

    l1_transit_config_file = sys.argv[1]

    l1_transit_name = l1_transit_config_file.split('/')[-1].split('.')[0]

    #Assumed customer always gives correct config file
    l1_transit_data = do_json.json_read(l1_transit_config_file)

    hypervisor = l1_transit_data["hypervisor_name"]
    hypervisor_arg = "hypervisor="+hypervisor

    hypervisors_data = hyp_utils.get_hypervisors_data()

    hypervisor_ip = hyp_utils.get_hyp_ip(hypervisor)

    if raas_utils.client_exists_l1_transit(l1_transit_name):
        raas_utils.log_service("l1_transit already exists "+ l1_transit_name +".....aborting")
        raas_utils.log_client("l1_transit already exists "+ l1_transit_name+".....aborting")
        exit(1)
    
    #All prereq checks done at this point
    l1_transit_capacity = l1_transit_data["capacity"]
示例#9
0
def get_mgmt_nid():
    json_data = do_json.json_read(constants.mgmt_net_file)
    return json_data["network_id"]
示例#10
0
"""@params:
    param1 = vpc config file (required)
"""

if __name__=="__main__":
    if (len(sys.argv) < 2):
        print("Please give vpc config file")
        exit(1)

    peer_config_file = sys.argv[1]

    leaf_name = leaf_config_file.split('/')[-1].split('.')[0]

    #Assumed customer always gives correct config file
    peering_data = do_json.json_read(leaf_config_file)

    hypervisor = leaf_data["hypervisor_name"]
    hypervisor_arg = "hypervisor="+hypervisor
    hypervisors_data = hyp_utils.get_hypervisors_data()
    hypervisor_ip = hyp_utils.get_hyp_ip(hypervisor)

    vpc_name = leaf_data["vpc_name"]
    if not raas_utils.client_exists_vpc(vpc_name):
      print(vpc_name+ " VPC does not exist")
      exit(1)
    vpc_id=hyp_utils.get_hyp_vpc_name(hypervisor,vpc_name)
    
    
    spine_name = leaf_data["spine_name"]
    if not raas_utils.client_exists_spine(vpc_name,spine_name):
示例#11
0
import ipaddress
"""@params:
    param1 = bgp config file (required)
"""

if __name__ == "__main__":
    if (len(sys.argv) < 2):
        raas_utils.log_service("Please give bgp config file")
        exit(1)

    weight_file = sys.argv[1]

    #pc_name = pc_config_file.split('/')[-1].split('.')[0]

    #Assumed customer always gives correct config file
    weight_data = do_json.json_read(weight_file)

    hypervisor = weight_data["hypervisor_name"]
    hypervisor_arg = "hypervisor=" + hypervisor

    hypervisors_data = hyp_utils.get_hypervisors_data()
    hypervisor_ip = hyp_utils.get_hyp_ip(hypervisor)

    node_type = weight_data["node_type"]
    path_choice_type = weight_data["path_choice_type"]

    vpc_name = ""
    #check if vpc exists for spine
    if (node_type == "spine"):
        vpc_name = weight_data["vpc_name"]
        if not raas_utils.client_exists_vpc(vpc_name):
示例#12
0
def get_client_id():
    hypervisors_data = do_json.json_read(constants.hypervisors_file)
    return hypervisors_data["customer_id"]
示例#13
0
def get_hypervisors_data():
    hypervisors_data = do_json.json_read(constants.hypervisors_file)
    return hypervisors_data
示例#14
0
"""@params:
    param1 = vpc config file (required)
"""

if __name__=="__main__":
    if (len(sys.argv) < 2):
        raas_utils.log_client("Config not provided.........aborting")
        raas_utils.log_service("Please give vpc config file")
        exit(1)

    pc_config_file = sys.argv[1]

    pc_name = pc_config_file.split('/')[-1].split('.')[0]

    #Assumed customer always gives correct config file
    pc_data = do_json.json_read(pc_config_file)

    hypervisor = pc_data["hypervisor_name"]
    hypervisor_arg = "hypervisor="+hypervisor

    hypervisors_data = hyp_utils.get_hypervisors_data()

    hypervisor_ip = hyp_utils.get_hyp_ip(hypervisor)

    vpc_name = pc_data["vpc_name"]

    if not raas_utils.client_exists_vpc(vpc_name):
        raas_utils.log_service("VPC does not exist")
        exit(1)

    if raas_utils.client_exists_pc(vpc_name, pc_name):
示例#15
0
import ipaddress
"""@params:
    param1 = bgp config file (required)
"""

if __name__ == "__main__":
    if (len(sys.argv) < 2):
        raas_utils.log_service("Please give bgp config file")
        exit(1)

    multipath_file = sys.argv[1]

    #pc_name = pc_config_file.split('/')[-1].split('.')[0]

    #Assumed customer always gives correct config file
    multipath_data = do_json.json_read(multipath_file)

    hypervisor = multipath_data["hypervisor_name"]
    hypervisor_arg = "hypervisor=" + hypervisor

    hypervisors_data = hyp_utils.get_hypervisors_data()
    hypervisor_ip = hyp_utils.get_hyp_ip(hypervisor)

    node_type = multipath_data["node_type"]

    vpc_name = ""
    #check if vpc exists for spine
    if (node_type == "spine"):
        vpc_name = multipath_data["vpc_name"]
        if not raas_utils.client_exists_vpc(vpc_name):
            raas_utils.log_service("VPC does not exist")
示例#16
0
def get_spine_ip(vpc, spine):
    file_path = constants.var_vpc + vpc + \
            constants.vpc_spines + spine + ".json"
    spine_data = do_json.json_read(file_path)
    spine_ip = spine_data["ip"]
    return spine_ip
示例#17
0
#logging.basicConfig(filename='raas.log', filemode='a', format='%(asctime)s %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
"""@params:
    param1 = bgp config file (required)
"""

if __name__ == "__main__":
    if (len(sys.argv) < 2):
        raas_utils.log_service("Please give bgp config file")
        exit(1)

    advertise_file = sys.argv[1]

    #pc_name = pc_config_file.split('/')[-1].split('.')[0]

    #Assumed customer always gives correct config file
    advertise_data = do_json.json_read(advertise_file)

    hypervisor = advertise_data["hypervisor_name"]
    hypervisor_arg = "hypervisor=" + hypervisor

    hypervisors_data = hyp_utils.get_hypervisors_data()
    hypervisor_ip = hyp_utils.get_hyp_ip(hypervisor)

    vpc_name = advertise_data["vpc_name"]
    if not raas_utils.client_exists_vpc(vpc_name):
        raas_utils.log_service("VPC does not exist")
        exit(1)

    spine_name = advertise_data["spine_name"]
    l1_transit_name = advertise_data["l1_transit_name"]
示例#18
0
"""@params:
    param1 = config file (required)
"""

if __name__=="__main__":
    if (len(sys.argv) < 2):
        raas_utils.log_service("Please give peering config file")
        exit(1)

    peer_config_file = sys.argv[1]

    leaf_name = peer_config_file.split('/')[-1].split('.')[0]

    #Assumed customer always gives correct config file
    peering_data = do_json.json_read(peer_config_file)

    hypervisor = peering_data["hypervisor_name"]
    hypervisor_arg = "hypervisor="+hypervisor
    hypervisors_data = hyp_utils.get_hypervisors_data()
    hypervisor_ip = hyp_utils.get_hyp_ip(hypervisor)

    vpc_name = peering_data["vpc_name"]
    if not raas_utils.client_exists_vpc(vpc_name):
      raas_utils.log_service(vpc_name+ " VPC does not exist")
      exit(1)
    vpc_id=hyp_utils.get_hyp_vpc_name(hypervisor,vpc_name)
    
    
    spine_name = peering_data["spine_name"]
    if not raas_utils.client_exists_spine(vpc_name,spine_name):