Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 3a446ec3 authored by SIMONIN Matthieu's avatar SIMONIN Matthieu
Browse files

Add programmable firewall interface

parent f0325f9a
No related branches found
No related tags found
No related merge requests found
Pipeline #310230 failed
......@@ -156,7 +156,7 @@ class CreateMixin(object):
class DeleteMixin(object):
@exc.on_http_error(exc.Grid5000DeleteError)
def delete(self, id, **kwargs):
def delete(self, id=None, **kwargs):
"""Delete an object on the server.
Args:
......
......@@ -2,6 +2,9 @@ from .base import * # noqa
from .mixins import * # noqa
class FirewallPort(RESTObject):
_id_attr = None
class NetworkEquipment(RESTObject):
pass
......@@ -72,6 +75,11 @@ class Cluster(RESTObject):
class Job(RESTObject, RefreshMixin, ObjectDeleteMixin):
_create_attrs = (("command"),)
_managers=(
("firewall", "SiteJobFirewallManager"),
)
def __repr__(self):
keys = ["uid", "site", "state", "user"]
try:
......@@ -134,8 +142,6 @@ class JobManager(NoUpdateMixin, BracketMixin, RESTManager):
_path = "/sites/%(site)s/jobs"
_obj_cls = Job
_from_parent_attrs = {"site": "uid"}
class ClusterManager(RetrieveMixin, BracketMixin, RESTManager):
_path = "/sites/%(site)s/clusters"
_obj_cls = Cluster
......@@ -376,3 +382,18 @@ class SiteNetworkEquipmentManager(BracketMixin, RetrieveMixin, RESTManager):
_path = "/sites/%(site)s/network_equipments"
_obj_cls = NetworkEquipment
_from_parent_attrs = {"site": "uid"}
class SiteJobFirewallManager(ListMixin, DeleteMixin, CreateMixin, RESTManager):
_path = "/sites/%(site)s/firewall/%(jobid)s"
_obj_cls = FirewallPort
_from_parent_attrs = {"site": "site", "jobid": "uid"}
@exc.on_http_error(exc.Grid5000CreateError)
def create(self, data, **kwargs):
# The api answer with a list of firewall rules
self._check_missing_create_attrs(data)
# Handle specific URL for creation
server_data = self.grid5000.http_post(self.path, post_data=data, **kwargs)
return [self._obj_cls(self, s) for s in server_data]
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment