add openvswitch support

This commit is contained in:
arcan1s 2014-08-10 21:21:18 +04:00
parent 43ed28de52
commit 501b43002e
10 changed files with 212 additions and 5 deletions

View File

@ -13,7 +13,7 @@ license=('GPL3')
makedepends=('automoc4' 'cmake' 'kdelibs' 'qt5-base' 'qt5-tools')
source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${pkgbase}-${pkgver}-src.tar.xz")
install="${pkgbase}.install"
md5sums=('9a47346e890e7c4458602d47751adf17')
md5sums=('d0a279f99cbb9a33b283def9fe053594')
prepare() {

View File

@ -64,7 +64,6 @@ Additional information
TODO (wish list)
----------------
* add support of **openvswitch** (netctl-auto-1.9)
* plasmoid helper integration
* remove suid from helper (polkit integration or run through sudo)
* security notes / project architecture

View File

@ -162,7 +162,9 @@ int GeneralWidget::isOk()
// bind interfaces is not set
if ((ui->comboBox_connection->currentText() == QString("bond")) ||
(ui->comboBox_connection->currentText() == QString("bridge")) ||
(ui->comboBox_connection->currentText() == QString("vlan")))
(ui->comboBox_connection->currentText() == QString("vlan")) ||
(ui->comboBox_connection->currentText() == QString("macvlan")) ||
(ui->comboBox_connection->currentText() == QString("openvswitch")))
if (ui->listWidget_bindto->count() == 0)
return 1;
// empty description

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>429</width>
<height>535</height>
<width>427</width>
<height>533</height>
</rect>
</property>
<property name="windowTitle">
@ -123,6 +123,11 @@
<string notr="true">macvlan</string>
</property>
</item>
<item>
<property name="text">
<string>openvswitch</string>
</property>
</item>
</widget>
</item>
</layout>

View File

@ -36,6 +36,7 @@
#include "mobilewidget.h"
#include "netctlautowindow.h"
#include "netctlguiadaptor.h"
#include "openvswitchwidget.h"
#include "passwdwidget.h"
#include "pppoewidget.h"
#include "settingswindow.h"
@ -645,6 +646,7 @@ void MainWindow::profileTabChangeState(const QString current)
ethernetWid->setShown(true);
macvlanWid->setShown(false);
mobileWid->setShown(false);
openvWid->setShown(false);
pppoeWid->setShown(false);
tunnelWid->setShown(false);
tuntapWid->setShown(false);
@ -658,6 +660,7 @@ void MainWindow::profileTabChangeState(const QString current)
ethernetWid->setShown(false);
macvlanWid->setShown(false);
mobileWid->setShown(false);
openvWid->setShown(false);
pppoeWid->setShown(false);
tunnelWid->setShown(false);
tuntapWid->setShown(false);
@ -672,6 +675,7 @@ void MainWindow::profileTabChangeState(const QString current)
ethernetWid->setShown(false);
macvlanWid->setShown(false);
mobileWid->setShown(false);
openvWid->setShown(false);
pppoeWid->setShown(false);
tunnelWid->setShown(false);
tuntapWid->setShown(false);
@ -685,6 +689,7 @@ void MainWindow::profileTabChangeState(const QString current)
ethernetWid->setShown(false);
macvlanWid->setShown(false);
mobileWid->setShown(false);
openvWid->setShown(false);
pppoeWid->setShown(false);
tunnelWid->setShown(false);
tuntapWid->setShown(false);
@ -698,6 +703,7 @@ void MainWindow::profileTabChangeState(const QString current)
ethernetWid->setShown(false);
macvlanWid->setShown(false);
mobileWid->setShown(false);
openvWid->setShown(false);
pppoeWid->setShown(true);
tunnelWid->setShown(false);
tuntapWid->setShown(false);
@ -711,6 +717,7 @@ void MainWindow::profileTabChangeState(const QString current)
ethernetWid->setShown(false);
macvlanWid->setShown(false);
mobileWid->setShown(true);
openvWid->setShown(false);
pppoeWid->setShown(false);
tunnelWid->setShown(false);
tuntapWid->setShown(false);
@ -724,6 +731,7 @@ void MainWindow::profileTabChangeState(const QString current)
ethernetWid->setShown(false);
macvlanWid->setShown(false);
mobileWid->setShown(false);
openvWid->setShown(false);
pppoeWid->setShown(false);
tunnelWid->setShown(true);
tuntapWid->setShown(false);
@ -737,6 +745,7 @@ void MainWindow::profileTabChangeState(const QString current)
ethernetWid->setShown(false);
macvlanWid->setShown(false);
mobileWid->setShown(false);
openvWid->setShown(false);
pppoeWid->setShown(false);
tunnelWid->setShown(false);
tuntapWid->setShown(true);
@ -750,6 +759,7 @@ void MainWindow::profileTabChangeState(const QString current)
ethernetWid->setShown(true);
macvlanWid->setShown(false);
mobileWid->setShown(false);
openvWid->setShown(false);
pppoeWid->setShown(false);
tunnelWid->setShown(false);
tuntapWid->setShown(false);
@ -763,6 +773,21 @@ void MainWindow::profileTabChangeState(const QString current)
ethernetWid->setShown(true);
macvlanWid->setShown(true);
mobileWid->setShown(false);
openvWid->setShown(false);
pppoeWid->setShown(false);
tunnelWid->setShown(false);
tuntapWid->setShown(false);
vlanWid->setShown(false);
wirelessWid->setShown(false);
}
else if (current == QString("openvswitch")) {
generalWid->setShown(true);
ipWid->setShown(true);
bridgeWid->setShown(false);
ethernetWid->setShown(false);
macvlanWid->setShown(false);
mobileWid->setShown(false);
openvWid->setShown(true);
pppoeWid->setShown(false);
tunnelWid->setShown(false);
tuntapWid->setShown(false);
@ -794,6 +819,7 @@ void MainWindow::profileTabClear()
ethernetWid->clear();
macvlanWid->clear();
mobileWid->clear();
openvWid->clear();
pppoeWid->clear();
tunnelWid->clear();
tuntapWid->clear();
@ -879,6 +905,8 @@ void MainWindow::profileTabCreateProfile()
if (ethernetWid->isOk() == 1)
return errorWin->showWindow(7, QString("[MainWindow] : [profileTabCreateProfile]"));
}
else if (generalWid->connectionType->currentText() == QString("openvswitch")) {
}
ui->tabWidget->setDisabled(true);
// read settings
@ -963,6 +991,14 @@ void MainWindow::profileTabCreateProfile()
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
}
else if (generalWid->connectionType->currentText() == QString("openvswitch")) {
QMap<QString, QString> addSettings = ipWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
addSettings = openvWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
}
// call netctlprofile
bool status = false;
@ -1060,6 +1096,10 @@ void MainWindow::profileTabLoadProfile()
ethernetWid->setSettings(settings);
macvlanWid->setSettings(settings);
}
else if (generalWid->connectionType->currentText() == QString("openvswitch")) {
ipWid->setSettings(settings);
openvWid->setSettings(settings);
}
}

View File

@ -35,6 +35,7 @@
#include "mobilewidget.h"
#include "netctlautowindow.h"
#include "netctlguiadaptor.h"
#include "openvswitchwidget.h"
#include "passwdwidget.h"
#include "pppoewidget.h"
#include "settingswindow.h"
@ -407,6 +408,8 @@ void MainWindow::createObjects()
ui->scrollAreaWidgetContents->layout()->addWidget(macvlanWid);
mobileWid = new MobileWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(mobileWid);
openvWid = new OpenvswitchWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(openvWid);
pppoeWid = new PppoeWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(pppoeWid);
tunnelWid = new TunnelWidget(this);
@ -436,6 +439,7 @@ void MainWindow::deleteObjects()
if (ipWid != nullptr) delete ipWid;
if (macvlanWid != nullptr) delete macvlanWid;
if (mobileWid != nullptr) delete mobileWid;
if (openvWid != nullptr) delete openvWid;
if (pppoeWid != nullptr) delete pppoeWid;
if (tunnelWid != nullptr) delete tunnelWid;
if (tuntapWid != nullptr) delete tuntapWid;

View File

@ -34,6 +34,7 @@ class IpWidget;
class MacvlanWidget;
class MobileWidget;
class NetctlAutoWindow;
class OpenvswitchWidget;
class PasswdWidget;
class PppoeWidget;
class SettingsWindow;
@ -140,6 +141,7 @@ private:
IpWidget *ipWid = nullptr;
MacvlanWidget *macvlanWid = nullptr;
MobileWidget *mobileWid = nullptr;
OpenvswitchWidget *openvWid = nullptr;
PppoeWidget *pppoeWid = nullptr;
TunnelWidget *tunnelWid = nullptr;
TuntapWidget *tuntapWid = nullptr;

View File

@ -0,0 +1,73 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "openvswitchwidget.h"
#include "ui_openvswitchwidget.h"
OpenvswitchWidget::OpenvswitchWidget(QWidget *parent)
: QWidget(parent),
ui(new Ui::OpenvswitchWidget)
{
ui->setupUi(this);
clear();
}
OpenvswitchWidget::~OpenvswitchWidget()
{
delete ui;
}
void OpenvswitchWidget::clear()
{
}
void OpenvswitchWidget::setShown(const bool state)
{
if (state)
show();
else
hide();
}
QMap<QString, QString> OpenvswitchWidget::getSettings()
{
QMap<QString, QString> openvswitchSettings;
if (isOk() != 0)
return openvswitchSettings;
return openvswitchSettings;
}
int OpenvswitchWidget::isOk()
{
// all fine
return 0;
}
void OpenvswitchWidget::setSettings(const QMap<QString, QString> settings)
{
clear();
QMap<QString, QString> OpenvswitchWidget = settings;
}

View File

@ -0,0 +1,48 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef OPENVSWITCHWIDGET_H
#define OPENVSWITCHWIDGET_H
#include <QWidget>
namespace Ui {
class OpenvswitchWidget;
}
class OpenvswitchWidget : public QWidget
{
Q_OBJECT
public:
explicit OpenvswitchWidget(QWidget *parent = 0);
~OpenvswitchWidget();
QMap<QString, QString> getSettings();
int isOk();
void setSettings(const QMap<QString, QString> settings);
public slots:
void clear();
void setShown(const bool state);
private:
Ui::OpenvswitchWidget *ui;
};
#endif /* OPENVSWITCHWIDGET_H */

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OpenvswitchWidget</class>
<widget class="QWidget" name="OpenvswitchWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>391</width>
<height>79</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QDockWidget" name="dockWidget_openvswitch">
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>openvswitch settings</string>
</property>
<widget class="QWidget" name="dockWidgetContents_openvswitch">
<layout class="QVBoxLayout" name="verticalLayout_2"/>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>