-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit 0849e5b43eb8fdb0bb888a0c62b7b4281b1eadae Author: remi.pauchet <remi.pauchet@stormshield.eu> Date: Thu May 9 17:07:07 2019 +0200 fix cmd.complete new path commit 18303e74fc38ba6a517686083c7cdfcd4777c3e8 Author: remi.pauchet <remi.pauchet@stormshield.eu> Date: Thu May 9 15:43:44 2019 +0200 Fix socks install and version handling commit 5fb3610ab08685abf0cbd9b782a6172c43123d67 Author: remi.pauchet <remi.pauchet@stormshield.eu> Date: Tue Apr 30 17:44:57 2019 +0200 fix http proxy commit 73ea82b3f4490531215f727e048f9b04b31e25f6 Author: remi.pauchet <remi.pauchet@stormshield.eu> Date: Tue Apr 30 17:19:23 2019 +0200 fix commit 5b8e34dea77768f7614c2af5a431345c3b534bef Author: remi.pauchet <remi.pauchet@stormshield.eu> Date: Tue Apr 30 17:07:47 2019 +0200 Add socks/http proxy option, fix log file, use entry-points for windows snscli compatibility commit 07f485be81d952be99788a2849d08ca51da024c7 Author: remi.pauchet <remi.pauchet@stormshield.eu> Date: Mon Apr 29 14:35:47 2019 +0200 Add socks/http proxy support
- Loading branch information
Showing
9 changed files
with
497 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/usr/bin/env python3 | ||
|
||
""" | ||
Script to create a VLAN interface on a SNS appliance | ||
""" | ||
|
||
import sys | ||
import getpass | ||
|
||
from stormshield.sns.sslclient import SSLClient | ||
|
||
# user input | ||
host = input("Appliance ip address: ") | ||
user = input("User:") | ||
password = getpass.getpass("Password: ") | ||
vlanname = input("VLAN name: ") | ||
vlanphy = input("Physical interface: ") | ||
vlantag = input("VLAN tag: ") | ||
vlanaddr = input("Address: ") | ||
vlanmask = input("Mask: ") | ||
|
||
#host = "10.0.0.0.254" | ||
#user = "admin" | ||
#password = "mypassword" | ||
#vlanname = "myvlan3" | ||
#vlanphy = "Ethernet0" | ||
#vlantag = 103 | ||
#vlanaddr = "192.168.103.1" | ||
#vlanmask = "255.255.255.0" | ||
|
||
MAXVLAN=60 | ||
|
||
# connect to the appliance | ||
client = SSLClient( | ||
host=host, port=443, | ||
user=user, password=password, | ||
sslverifyhost=False) | ||
|
||
def error(msg): | ||
global client | ||
|
||
print("ERROR: {}".format(msg)) | ||
client.disconnect() | ||
sys.exit(1) | ||
|
||
def command(cmd): | ||
global client | ||
|
||
response = client.send_command(cmd) | ||
if not response: | ||
error("command failed:\n{}".format(response.output)) | ||
|
||
return response | ||
|
||
|
||
# get vlan list & extract first available vlanX interface | ||
response = command("config network interface show filter=vlan") | ||
if len(response.data.keys()) == 0: | ||
vlanid = 0 | ||
else: | ||
vlanid = -1 | ||
for i in range(MAXVLAN): | ||
if "vlan{}".format(i) not in response.data: | ||
vlanid = i | ||
break | ||
if vlanid == -1: | ||
error("all available VLAN already created") | ||
|
||
|
||
response = command("CONFIG NETWORK INTERFACE CREATE state=1 protected=0 mtu=1500 physical={} name={} tag={} priority=0 keepVlanPriority=1 maxThroughput=0 ifname=vlan{} address={} mask={}".format(vlanphy, vlanname, vlantag, vlanid, vlanaddr, vlanmask)) | ||
if response.code: | ||
print("VLAN vlan{} created".format(vlanid)) | ||
else: | ||
error("VLAN vlan{} can't be created:\n{}".format(vlanid, response.output)) | ||
|
||
response = command("CONFIG NETWORK ACTIVATE") | ||
if response.code: | ||
print("Configuration activated") | ||
else: | ||
error("Can't activate network:\n{}".format(response.output)) | ||
|
||
client.disconnect() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +0,0 @@ | ||
__version__ = "1.0.0.beta1" | ||
|
||
# major.minor.patch | ||
# major: breaking API change | ||
# minor: new functionality | ||
# patch: bugfix | ||
Oops, something went wrong.