public function path(RequestSave $request, $id) { if (Request::isMethod('post')) { $data = $request->all(); foreach ($data['rows'] as $row) { if ($row['checkbox'] !== '0') { $conn = new Connections(); $conn->connected_id = $id; $conn->connection_id = $row['id']; $conn->colour = $row['colour']; $conn->bitrate = $row['bitrate']; $conn->save(); } } } $nodes = Node::get(); $connect = Connections::get(); return view('scripts.simulator.addpath')->with('nodes', $nodes)->with('conn', $connect)->with('self', Node::getById($id)); }
/** pole koloru zwraca ttablicę gdzie mamy wybrane kolory w kolejnosci 0 'zolty NIE', 1 'zolty TAK', 2 'zielony NIE', 3 'zielony TAK', 4 'szary NIE', 5 'szary TAK', 6 'czerwony NIE', 7 'czerwony TAK' czyli np "color" => array:4 [▼ 0 => "0" 1 => "2" 2 => "5" 3 => "7" ] **/ public function vplsView(Request $request) { if (Request::isMethod('post')) { $data = $request::all(); if (isset($data['color'])) { $affinity = $this->makeMask($data['color']); } else { $affinity = 15; } $router1 = Node::getbyID($data['ruter1']); $router2 = Node::getbyID($data['ruter2']); $interface1 = $data['interface1']; $interface2 = $data['interface2']; //Traffic eng interface $config1 = 'interface traffic-eng add name=' . $data['ruter1'] . 'to' . $data['ruter2'] . ' primary-path=dyn record-route=yes bandwidth=' . $data['bitrate'] . 'M bandwidth-limit=100 affinity-include-any=' . $affinity . ' from-address=' . $router1['name'] . ' to-address=' . $router2['name'] . ' disabled=no; '; //VPLS $config1 .= 'interface vpls add name=vpls-' . $data['ruter1'] . 'to' . $data['ruter2'] . ' remote-peer=' . $router2['name'] . ' vpls-id=' . $data['ruter1'] . ':' . $data['ruter2'] . ' disabled=no; '; //Bridge VPLS and local interface $config1 .= 'interface bridge add name=vpls-bridge-' . $interface1 . '; '; $config1 .= 'interface bridge port add bridge=vpls-bridge-' . $interface1 . ' interface=vpls-' . $data['ruter1'] . 'to' . $data['ruter2'] . '; '; $config1 .= 'interface bridge port add bridge=vpls-bridge-' . $interface1 . ' interface=' . $interface1 . '; '; $config2 = 'interface traffic-eng add name=' . $data['ruter2'] . 'to' . $data['ruter1'] . ' primary-path=dyn record-route=yes bandwidth=' . $data['bitrate'] . 'M bandwidth-limit=100 affinity-include-any=' . $affinity . ' from-address=' . $router2['name'] . ' to-address=' . $router1['name'] . ' disabled=no; '; //VPLS $config2 .= 'interface vpls add name=vpls-' . $data['ruter2'] . 'to' . $data['ruter1'] . ' remote-peer=' . $router1['name'] . ' vpls-id=' . $data['ruter1'] . ':' . $data['ruter2'] . ' disabled=no; '; //Bridge VPLS and local interface $config2 .= 'interface bridge add name=vpls-bridge-' . $interface2 . '; '; $config2 .= 'interface bridge port add bridge=vpls-bridge-' . $interface2 . ' interface=vpls-' . $data['ruter2'] . 'to' . $data['ruter1'] . '; '; $config2 .= 'interface bridge port add bridge=vpls-bridge-' . $interface2 . ' interface=' . $interface2 . '; '; $sshService1 = new SshService($router1['ip'], $router1['login'], $router1['password'], 22, '/tmp/log.txt'); $sshService1->cmd($config1); $sshService1->disconnect(); $sshService2 = new SshService($router2['ip'], $router2['login'], $router2['password'], 22, '/tmp/log.txt'); $sshService2->cmd($config2); $sshService2->disconnect(); return view('scripts.simulator.vplsConfig')->with(compact('config1', 'config2')); } $nodes = Node::get(); return view('scripts.simulator.vpls')->with('nodes', $nodes); }