Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Commit

Permalink
v0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gabstopper committed Apr 12, 2017
1 parent 4da619b commit f3c6e15
Show file tree
Hide file tree
Showing 35 changed files with 1,311 additions and 571 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Python 3.4, 3.5 (version >- 0.4)

Requests

Security Management Center version 5.10, 6.0, 6.1, 6.1.1, 6.1.2, 6.2
Security Management Center version 6.0, 6.1, 6.1.1, 6.1.2, 6.2

##### Getting Started

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def readme():
return f.read()

setup(name='smc-python',
version='0.4.12',
version='0.5.0',
description='Python based API to Stonesoft Security Management Center',
url='http://github.com/gabstopper/smc-python',
author='David LePage',
Expand Down
15 changes: 13 additions & 2 deletions smc/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ If-Match header enforced in SMC 6.1.2, required for delete operations

$version 0.4.10
remove add_vlan_to_single_node_interface; use add_ipaddress_to_vlan_interface
tunnel interface has one method (add_
tunnel interface add methods collapsed
routes are removed when a VLAN with interfaces or a physical interface with addresses is removed
remove_vlan method of physical interface

Expand All @@ -135,4 +135,15 @@ new contact address implementation (now bound to engine level and interfaces)

$version 0.4.12
rule fixes, action and options input to set deep inspection, logging, etc
documentation updates
documentation updates

$version 0.5.0
Full support for SMC 6.2
MatchExpression added for rule source/destinations
instance Cache re-implementation
add_before/add_after for rule positioning
find all references by element resource (referenced_by property of Element)
location used_on field
DNSRelayProfile
smc.core.addon module with engine helpers for enabling/disabling engine level features
remove support for SMC 5.10
2 changes: 1 addition & 1 deletion smc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from smc.api.session import Session

__author__ = 'David LePage'
__version__ = '0.4.12'
__version__ = '0.5.0'

# Default SMC Session
session = Session()
Expand Down
5 changes: 4 additions & 1 deletion smc/administration/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ def abort(self):
href=find_link_by_name('abort', self.link)).delete()

def __call__(self):
_task = search.element_by_href_as_json(self.follower)
_task = prepared_request(href=self.follower
).read().json
#_task = search.element_by_href_as_json(self.follower)
for k, v in _task.items():
setattr(self, k, v)

Expand Down Expand Up @@ -173,6 +175,7 @@ def task_handler(task, wait_for_finish=False,
engine = Engine('myfw')
for msg in engine.upload('mypolicy', wait_for_finish=True)
print msg
"""
if wait_for_finish:
#first task will not have a last_message attribute
Expand Down
8 changes: 8 additions & 0 deletions smc/api/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ class DeleteElementFailed(SMCException):
"""
pass

class UpdateElementFailed(SMCException):
"""
Failure when updating element. When failure is due to ETag
being invalid, target was modified before change was
submitted. A resubmit would be required.
"""
pass

class ModificationFailed(SMCException):
"""
Used when making generic modifications to elements.
Expand Down
21 changes: 12 additions & 9 deletions smc/api/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,10 @@ def send_request(self, method, request):
request.headers.update(Etag=request.etag)

response = self.session.put(request.href,
#data=json.dumps(request.json),
json=request.json,
params=request.params,
headers=request.headers)

logger.debug(vars(response))
counters.update(update=1)

Expand All @@ -97,10 +96,18 @@ def send_request(self, method, request):
elif method == SMCAPIConnection.DELETE:
response = self.session.delete(request.href,
headers=request.headers)
response.encoding = 'utf-8'


counters.update(delete=1)

# Conflict (409) if ETag is not current
if response.status_code in (409,):
req = self.session.get(request.href)
etag = req.headers.get('ETag')
response = self.session.delete(request.href,
headers={'if-match': etag})

response.encoding = 'utf-8'

if response.status_code not in (200, 204):
raise SMCOperationFailure(response)

Expand Down Expand Up @@ -221,8 +228,4 @@ def __str__(self):
sb.append("{key}='{value}'".format(key=key, value=self.__dict__[key]))
return ', '.join(sb)

counters = collections.Counter({'read': 0,
'create': 0,
'update': 0,
'delete': 0,
'cache': 0})
counters = collections.Counter({'read': 0, 'create': 0, 'update': 0, 'delete': 0, 'cache': 0})
Loading

0 comments on commit f3c6e15

Please sign in to comment.