def save_ospf(vmid, params):
	'''
	{
		'parameters_router-id' : '127.0.0.1',
		'auto-cost_reference-bandwidth' : 100,
		'default-methric' : 1
	}
	'''
	diff = PyUtils.diff_vyatta_conf(params['before'], params['after'])
	
	
	if len(diff) == 0:
		logger.debug("firewall 수정사항이 없습니다.")
		return {"success": "fail", "errmsg": "수정 사항이 없습니다."}
	
	vm = get_vm(vmid)
	addr = vm['mgraddr']
	
	env.hosts = [ addr ]
	env.user = vm['sshid']
	env.password = vm['sshpw']
	env.shell = '/bin/vbash -ic'
	results = execute(save_ospf_task, hosts=[addr], ospf = diff)
	
	return results[addr]
def update_firewall(vmid, params):

    diff = PyUtils.diff_vyatta_conf(params['before'], params['after'])

    diff['rule'] = params['before']['rule']  # rule number
    diff['before_eth'] = params['before']['ethernet']
    diff['before_inout'] = params['before']['inout']

    if len(diff) == 0:
        logger.debug("firewall 수정사항이 없습니다.")
        return {"success": "fail", "errmsg": "수정 사항이 없습니다."}

    vm = get_vm(vmid)
    addr = vm['mgraddr']

    env.hosts = [addr]
    env.user = vm['sshid']
    env.password = vm['sshpw']
    env.shell = '/bin/vbash -ic'
    results = execute(update_firewall_task,
                      hosts=[addr],
                      fwname=params['name'],
                      fwinfo=diff)

    return results[addr]
Пример #3
0
def update_nic(vmid, params):
	
	pdiff = PyUtils.diff_vyatta_conf(params['before'], params['after'])
	
	if len(pdiff) == 0:
		logger.debug("NIC 수정사항이 없습니다.")
		return {"success": "success", "msg": "수정 사항이 없습니다."}
	
	vms = read_repository("vms")
	
	for vm in vms:
		print vm['_id'] + " : " + vmid
		if '_id' in vm and vmid == vm['_id']:
			break
	if vm == None:
		raise ValueError("get_vm not found: " + vmid)

	pEthName = params['after']['ethName']
	addr = vm['mgraddr']
	
	env.hosts = [ addr ]
	env.user = vm['sshid']
	env.password = vm['sshpw']
	env.shell = '/bin/vbash -ic'
	results = execute(update_nic_task, hosts=[addr], ethName = pEthName, diff=pdiff)
	
	
	# vms.json 파일도 변경해주기.
	modified = False
	for key in pdiff:
		if "disable" == key:
			vm["interfaces"][pEthName]["disable"] = pdiff[key]
			modified = True
		if "hw-id" == key:
			vm["interfaces"][pEthName]["macaddr"] = pdiff[key]
			modified = True
		if "address" == key:
			modified = True
			if pdiff[key] == "dhcp":
				nicinfo = FabricUtilNFV.getIfConfig(addr, vm['sshid'], vm['sshpw'], pEthName)
				vm["interfaces"][pEthName]["ipaddr"] = nicinfo[pEthName]
			else:
				vm["interfaces"][pEthName]["ipaddr"] = pdiff[key]
	
	if modified:
		write_repository('vms', vms)
	
	return results[addr]
Пример #4
0
def update_firewall(vmid, params):

    diff = PyUtils.diff_vyatta_conf(params["before"], params["after"])

    diff["rule"] = params["before"]["rule"]  # rule number
    diff["before_eth"] = params["before"]["ethernet"]
    diff["before_inout"] = params["before"]["inout"]

    if len(diff) == 0:
        logger.debug("firewall 수정사항이 없습니다.")
        return {"success": "fail", "errmsg": "수정 사항이 없습니다."}

    vm = get_vm(vmid)
    addr = vm["mgraddr"]

    env.hosts = [addr]
    env.user = vm["sshid"]
    env.password = vm["sshpw"]
    env.shell = "/bin/vbash -ic"
    results = execute(update_firewall_task, hosts=[addr], fwname=params["name"], fwinfo=diff)

    return results[addr]
Пример #5
0
def update_bonding(vmid, params):
	
	logger.debug("update call!!")
	
	diff = PyUtils.diff_vyatta_conf(params['before'], params['after'])
	
	diff['before_eths'] = params['before']['ethernets']
	
	if len(diff) == 0:
		logger.debug("bondging 수정사항이 없습니다.")
		return {"success": "success", "msg": "수정 사항이 없습니다."}
	
	vm = get_vm(vmid)
	
	addr = vm['mgraddr']
	
	env.hosts = [ addr ]
	env.user = vm['sshid']
	env.password = vm['sshpw']
	env.shell = '/bin/vbash -ic'
	results = execute(update_bonding_task, hosts=[addr], bondid=params['bondid'], bondinfo = diff)
	
	return results[addr]
Пример #6
0
def save_ospf(vmid, params):
    '''
	{
		'parameters_router-id' : '127.0.0.1',
		'auto-cost_reference-bandwidth' : 100,
		'default-methric' : 1
	}
	'''
    diff = PyUtils.diff_vyatta_conf(params['before'], params['after'])

    if len(diff) == 0:
        logger.debug("firewall 수정사항이 없습니다.")
        return {"success": "fail", "errmsg": "수정 사항이 없습니다."}

    vm = get_vm(vmid)
    addr = vm['mgraddr']

    env.hosts = [addr]
    env.user = vm['sshid']
    env.password = vm['sshpw']
    env.shell = '/bin/vbash -ic'
    results = execute(save_ospf_task, hosts=[addr], ospf=diff)

    return results[addr]