Beispiel #1
0
def start(context, network_id, gateway_ip):
    """
    Start DHCP server(s) in isolated network.
    :param network_id: Isolated network, which should be connected with new VPN server
    :param gateway_ip: Gateway ip for isolated network.
    """

    network = Subnet.get(context.user_id, network_id)

    if network.network_pool.mode != 'isolated':
        raise CoreException('network_not_isolated')

    network.set_prop('gateway', gateway_ip)
    network.save()

    if network.get_prop('dhcp_running', False):
        task = Task()
        task.type = 'dhcp'
        task.action = 'stop_dhcp'
        task.append_to([network], broadcast=True)

    task = Task()
    task.type = 'dhcp'
    task.action = 'start_dhcp'
    task.append_to([network])
Beispiel #2
0
def stop(context, network_id):
    """
    Stop DHCP servers in network
    """
    network = Subnet.get(context.user_id, network_id)
    if network.network_pool.mode != 'isolated':
        raise CoreException('network_not_isolated')

    task = Task()
    task.type = 'dhcp'
    task.action = 'stop_dhcp'
    task.append_to([network], broadcast=True)
Beispiel #3
0
def stop(context, network_id):
    """
    Stop DHCP servers in network
    """
    network = Subnet.get(context.user_id, network_id)
    if network.network_pool.mode != 'isolated':
        raise CoreException('network_not_isolated')

    task = Task()
    task.type = 'dhcp'
    task.action = 'stop_dhcp'
    task.append_to([network], broadcast=True)
Beispiel #4
0
def create(context, name, network_id):
    """
    Create new vpn server attached to isolated network. There is no dhcp
    :param name: Network name
    :param network_id: Isolated network, which should be connected with new VPN server
    """

    network = Subnet.get(context.user_id, network_id)
    if network.network_pool.mode != 'isolated':
        raise CoreException('network_not_isolated')

    vpn = VPN()
    vpn.state = 'init'
    vpn.name = name
    vpn.network = Subnet.get(context.user_id, network_id)
    vpn.user_id = context.user_id
    vpn.save()

    task = Task()
    task.type = 'vpn'
    task.action = 'create'
    task.append_to([vpn, network])

    return vpn.to_dict
Beispiel #5
0
def start(context, network_id, gateway_ip):
    """
    Start DHCP server(s) in isolated network.
    :param network_id: Isolated network, which should be connected with new VPN server
    :param gateway_ip: Gateway ip for isolated network.
    """

    network = Subnet.get(context.user_id, network_id)
    if network.network_pool.mode != 'isolated':
        raise CoreException('network_not_isolated')

    network.set_prop('gateway', gateway_ip)
    network.save()

    if network.get_prop('dhcp_running', False):
        task = Task()
        task.type = 'dhcp'
        task.action = 'stop_dhcp'
        task.append_to([network], broadcast=True)

    task = Task()
    task.type = 'dhcp'
    task.action = 'start_dhcp'
    task.append_to([network])