コード例 #1
0
import sys

from pfsense_api import PfSenseAPI
from pfsense_cmdline import PfSenseOptionParser
from datetime import datetime
from HTMLParser import HTMLParser

import email.mime.text

validAreas = [ 'all', 'aliases', 'captiveportal', 'voucher', 'dnsmasq', 'dhcpd', 'dhcpdv6',
     'filter', 'interfaces', 'ipsec', 'nat', 'openvpn', 'installedpackages', 'pptpd', 'rrddata', 'cron', 'syslog', 'system',
     'staticroutes', 'sysctl', 'snmpd', 'shaper', 'vlans', 'wol' ]
validAreasList = ', '.join( validAreas ) 

parser = PfSenseOptionParser()
parser.add_option("--area", dest="area",
                  help="Restore Area: %s" % ( validAreasList ), default='all')

parser.add_option('-i', '--input', dest='input', help='Input file (default: stdin)' )

(options, args) = parser.parse_args()

parser.checkOptions( options )

if not  options.area in validAreas:
    print '%s is not a valid area for restore. Options are: %s' % ( options.area, validAreasList )

api = PfSenseAPI.fromConfig( options.config )

コード例 #2
0
from pfsense_api import PfSenseAPI
from pfsense_cmdline import PfSenseOptionParser
from datetime import datetime
from HTMLParser import HTMLParser

import email.mime.text

validAreas = [
    'all', 'aliases', 'captiveportal', 'voucher', 'dnsmasq', 'dhcpd',
    'dhcpdv6', 'filter', 'interfaces', 'ipsec', 'nat', 'openvpn',
    'installedpackages', 'pptpd', 'rrddata', 'cron', 'syslog', 'system',
    'staticroutes', 'sysctl', 'snmpd', 'shaper', 'vlans', 'wol'
]
validAreasList = ', '.join(validAreas)

parser = PfSenseOptionParser()
parser.add_option("--area",
                  dest="area",
                  help="Restore Area: %s" % (validAreasList),
                  default='all')

parser.add_option('-i',
                  '--input',
                  dest='input',
                  help='Input file (default: stdin)')

(options, args) = parser.parse_args()

parser.checkOptions(options)

if not options.area in validAreas:
コード例 #3
0
#!/usr/bin/env python

import sys

from pfsense_api import PfSenseAPI
from datetime import datetime

from pfsense_cmdline import PfSenseOptionParser

parser = PfSenseOptionParser()
parser.add_option("--id", dest="crlID", help="ID of the CRL to update")
parser.add_option("--name", dest="name", help="Descriptive name of the CRL", default="Imported CRL")
parser.add_option("--crl", dest="crl", help="File containing CRL in PEM format")

(options, args) = parser.parse_args()

parser.checkOptions(options)

if options.crlID is None or options.crl is None:
    print "pfsense-updateCRL: options --id and --crl are required (see help: pfsense-updateCRL --help)"
    sys.exit(1)

crlFile = open(options.crl, "rU")
crl = crlFile.read()
crlFile.close()

api = PfSenseAPI.fromConfig(options.config)

(rc, data, contentType) = api.call(
    "/system_crlmanager.php",
    "POST",
コード例 #4
0
#!/usr/bin/env python

import sys

from pfsense_api import PfSenseAPI
from pfsense_cmdline import PfSenseOptionParser
from datetime import datetime
from ConfigParser import ConfigParser
from pfsense_logger import PfSenseLogger as logging

validAreas = [ 'all', 'dnsmasq', 'filter', 'interfaces', 'pptpd', 'rrddata', 'cron', 'system', 'sysctl', 'snmpd' ]
validAreasList = ', '.join(validAreas ) 

parser = PfSenseOptionParser()
parser.add_option("--area", dest="area",
                  help="Backup Area: %s" % (validAreasList ), default='all')
parser.add_option('--no-rrd', dest='noRRD', action='store_true', help='Do not backup RRD (will result in large XML file). Only applicable if --area=all.' )
parser.add_option('--no-packages', dest='noPackages', action='store_true', help='Do not backup package info. Only applicable if --area=all.' )
parser.add_option("--ssl_verification", dest="ssl_verification", help="Whether SSL should be verified or not, valid values are yes/no, true/false, 1/0", default=True, metavar="yes/no")
parser.add_option("--overwrite", dest="overwrite", default=False, help="Command line options will overwrite same settings in config file", action="store_true")
parser.add_option('-o', '--output', dest='output', help='Output file (default: stdout)' )
parser.add_option('--output-dir', dest='output_dir', help='Directory to store backup files')

(options, args) = parser.parse_args()

logger = logging.setupLogger(options.logging)
parser.check_cmd_options( options )

required_items = ['host', 'username', 'password']

options_cmdline = vars(options).copy()
コード例 #5
0
#!/usr/bin/env python

import sys

from pfsense_api import PfSenseAPI
from datetime import datetime

from pfsense_cmdline import PfSenseOptionParser

parser = PfSenseOptionParser()
parser.add_option("--id", dest="crlID", help="ID of the CRL to update")
parser.add_option("--name", dest="name", help="Descriptive name of the CRL", default="Imported CRL")
parser.add_option("--crl", dest="crl", help="File containing CRL in PEM format" )

(options, args) = parser.parse_args()

parser.checkOptions( options )

if options.crlID is None or options.crl is None:
	print 'pfsense-updateCRL: options --id and --crl are required (see help: pfsense-updateCRL --help)'
	sys.exit( 1 )

crlFile = open( options.crl, 'rU' )
crl = crlFile.read()
crlFile.close()

api = PfSenseAPI.fromConfig( options.config )

(rc, data, contentType) = api.call( '/system_crlmanager.php', 'POST',
	apiData = { 
	  'method': 'existing',
コード例 #6
0
#!/usr/bin/env python

import sys

from pfsense_api import PfSenseAPI
from pfsense_cmdline import PfSenseOptionParser
from datetime import datetime


validAreas = [ 'all', 'dnsmasq', 'filter', 'interfaces', 'pptpd', 'rrddata', 'cron', 'system', 'sysctl', 'snmpd' ]
validAreasList = ', '.join( validAreas ) 

parser = PfSenseOptionParser()
parser.add_option("--area", dest="area",
                  help="Backup Area: %s" % ( validAreasList ), default='all')
parser.add_option('--no-rrd', dest='noRRD', action='store_true', help='Do not backup RRD (will result in large XML file). Only applicable if --area=all.' )
parser.add_option('--no-packages', dest='noPackages', action='store_true', help='Do not backup package info. Only applicable if --area=all.' )

parser.add_option('-o', '--output', dest='output', help='Output file (default: stdout)' )

(options, args) = parser.parse_args()

parser.checkOptions( options )

if not  options.area in validAreas:
	print '%s is not a valid area for backup. Options are: %s' % ( options.area, validAreasList )

if options.area != 'all' and (options.noRRD or options.noPackages):
	print '--no-rrd and --no-packages only make sense when combined with --area=all'
	sys.exit( 1 )
コード例 #7
0
#!/usr/bin/env python

import sys

from pfsense_api import PfSenseAPI
from pfsense_cmdline import PfSenseOptionParser
from datetime import datetime

validAreas = [
    'all', 'dnsmasq', 'filter', 'interfaces', 'pptpd', 'rrddata', 'cron',
    'system', 'sysctl', 'snmpd'
]
validAreasList = ', '.join(validAreas)

parser = PfSenseOptionParser()
parser.add_option("--area",
                  dest="area",
                  help="Backup Area: %s" % (validAreasList),
                  default='all')
parser.add_option(
    '--no-rrd',
    dest='noRRD',
    action='store_true',
    help=
    'Do not backup RRD (will result in large XML file). Only applicable if --area=all.'
)
parser.add_option(
    '--no-packages',
    dest='noPackages',
    action='store_true',
    help='Do not backup package info. Only applicable if --area=all.')