Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion app/api/controllers/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,22 @@ def removeProxy(name, proxy):
container = LXCContainer({'name': name})
return response.replySuccess(container.removeProxy(proxy))
except ValueError as e:
return response.replyFailed(message=e.__str__())
return response.replyFailed(message=e.__str__())

@container_api.route('/<name>/interface/<iface>/up', methods=['PUT'])
@jwt_required()
def ifaceUp(name, iface):
try:
container = LXCContainer({'name': name})
return response.replySuccess(container.interfaceUp(iface))
except ValueError as e:
return response.replyFailed(message=e.__str__())

@container_api.route('/<name>/interface/<iface>/down', methods=['PUT'])
@jwt_required()
def ifaceDown(name, iface):
try:
container = LXCContainer({'name': name})
return response.replySuccess(container.interfaceDown(iface))
except ValueError as e:
return response.replyFailed(message=e.__str__())
16 changes: 16 additions & 0 deletions app/api/models/LXCContainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,19 @@ def removeProxy(self, name):
return self.info()
except Exception as e:
raise ValueError(e)

def interfaceUp(self, iface):
try:
container = self.client.containers.get(self.data['name'])
result = container.execute(['ifconfig {} up'.format(iface)])
return result
except Exception as e:
raise ValueError(e)

def interfaceDown(self, iface):
try:
container = self.client.containers.get(self.data['name'])
result = container.execute(['ifconfig {} down'.format(iface)])
return result
except Exception as e:
raise ValueError(e)