diff --git a/backend/app/classes/SettingsManager.py b/backend/app/classes/SettingsManager.py
index f5af4fa87..ea025ea46 100644
--- a/backend/app/classes/SettingsManager.py
+++ b/backend/app/classes/SettingsManager.py
@@ -40,6 +40,7 @@ class SettingsManager(metaclass=Singleton):
"connection_type": "DHCP",
"ip": "",
"gateway": "",
+ "netmask": "",
"hostname": "",
"curr_camera": "",
"curr_pipeline": ""
@@ -188,8 +189,6 @@ class SettingsManager(metaclass=Singleton):
for key in dic['change_general_settings_values']:
if self.default_general_settings[key]:
self.general_settings[key] = dic['change_general_settings_values'][key]
- if key == "hostname":
- subprocess.call(['hostnamectl set-hostname', str(self.general_settings['hostname'])])
self.settings_manager.save_settings()
#after all values has been set change settings
self.change_general_settings()
diff --git a/backend/app/handlers/IPHandler.py b/backend/app/handlers/IPHandler.py
new file mode 100644
index 000000000..d25ba0321
--- /dev/null
+++ b/backend/app/handlers/IPHandler.py
@@ -0,0 +1,42 @@
+import subprocess
+import netifaces
+
+
+class ChangeIP:
+ def __init__(self, ip_type, ip, netmask, gateway, hostname):
+
+ adapter = self.find_adapter()
+
+ if ip_type == "DHCP":
+ self.change_to_dhcp(adapter=adapter)
+ elif ip_type == "Static":
+ self.change_to_static(adapter=adapter, ip=ip, netmask=netmask, gateway=gateway)
+
+ self.change_hostname(hostname=hostname)
+ self.restart_adapter(adapter=adapter)
+
+ @staticmethod
+ def change_to_dhcp(adapter):
+ subprocess.call(['dhclient -r', adapter])
+
+ @staticmethod
+ def change_to_static(adapter, ip, netmask, gateway):
+ subprocess.call(['ifconfig', adapter, ip, 'netmask', netmask])
+ subprocess.call(['route add default gw', gateway, adapter])
+
+ @staticmethod
+ def restart_adapter(adapter):
+ subprocess.call(['ifconfig', adapter, 'down'])
+ subprocess.call(['ifconfig', adapter, 'up'])
+
+ @staticmethod
+ def find_adapter():
+ for i_name in netifaces.interfaces():
+ interface = netifaces.ifaddresses(i_name)[netifaces.AF_INET][0]
+ address = interface['addr'].split('.')[0]
+ if address == "10":
+ return str(i_name)
+
+ @staticmethod
+ def change_hostname(hostname):
+ subprocess.call(['hostnamectl set-hostname', "Chameleon-Vision-{}".format(hostname)])
\ No newline at end of file
diff --git a/chameleon-client/src/components/SystemTab.vue b/chameleon-client/src/components/SystemTab.vue
index c08ed1918..47a2334fc 100644
--- a/chameleon-client/src/components/SystemTab.vue
+++ b/chameleon-client/src/components/SystemTab.vue
@@ -25,6 +25,14 @@
+
+
+ Netmask:
+
+
+
+
+
Gateway:
@@ -103,6 +111,14 @@
this.$store.commit('ip',value);
}
},
+ netmask:{
+ get: function(){
+ return this.$store.state.netmask;
+ },
+ set: function(){
+ this.$store.commit('netmask',value);
+ }
+ },
gateway:{
get: function(){
return this.$store.state.gateway;
diff --git a/chameleon-client/src/store.js b/chameleon-client/src/store.js
index e42e35de3..ddca1e933 100644
--- a/chameleon-client/src/store.js
+++ b/chameleon-client/src/store.js
@@ -30,14 +30,15 @@ export const store = new Vuex.Store({
area:[0,100],
ratio:[0,20],
extent:[0,100],
- sort_mode:'Largest', //
- target_group:'Single', //
- target_intersection:'Up', //
+ sort_mode:'Largest',
+ target_group:'Single',
+ target_intersection:'Up',
//Settings
team_number:0,
connection_type:"DHCP",
- ip:0,
- gateWay:0,
+ ip:"",
+ gateWay:"",
+ netmask:"",
hostname:"",
//live info
port:1181,
@@ -68,6 +69,7 @@ export const store = new Vuex.Store({
team_number: set('team_number'),
connection_type: set('connection_type'),
ip: set('ip'),
+ netmask: set('netmask'),
gateWay : set('gateway'),
hostname : set('hostname'),
is_binary: set('is_binary'),
@@ -99,6 +101,7 @@ export const store = new Vuex.Store({
team_number: state => state.teamValue,
connection_type: state => state.connectionType,
ip: state => state.ip,
+ netmask: state => state.netmask,
gateWay: state => state.gateWay,
hostname: state => state.hostName,
is_binary: state => state.is_binary,