コード例 #1
0
def main():
    """
    Main show Process routine
    :return: None
    """
    description = 'Simple application that logs on to the APIC and check cluster information for a fabric'
    creds = Credentials('apic', description)

    args = creds.get()

    session = ACI.Session(args.url, args.login, args.password)
    resp = session.login()
    if not resp.ok:
        print '%% Could not login to APIC'
        sys.exit(0)

    cluster = ACI.Cluster('Cluster')
    configured_size = cluster.get_config_size(session)
    cluster_size = cluster.get_cluster_size(session)
    cluster_info = cluster.get_cluster_info(session)

    if configured_size != cluster_size:
        print("*******************************************************")
        sys.stdout.write("WARNING, configured cluster size ")
        sys.stdout.write(configured_size)
        sys.stdout.write(" :not equal to the actual size ")
        print cluster_size
        print "WARNING, desired stats collection might be lost"
        print("*******************************************************")
        print("APICs in the cluster are:")
        for apic in cluster_info:
            print json.dumps(apic['infraCont']['attributes']['dn'], indent=4, sort_keys=True)
    else:
        print("PASS")
コード例 #2
0
def main():
    """
    Main show Process routine
    :return: None
    """
    description = 'Simple application that logs on to the APIC and displays process information for a switch'
    creds = Credentials('apic', description)

    creds.add_argument('-s', '--switch',
                       type=str,
                       default=None,
                       help='Specify a particular switch id, e.g. "102"')
    args = creds.get()

    session = ACI.Session(args.url, args.login, args.password)
    resp = session.login()
    if not resp.ok:
        print '%% Could not login to APIC'
        sys.exit(0)

    switches = ACI.Node.get(session, '1', args.switch)
    for switch in switches:
        if switch.role != 'controller':
            processes = ACI.Process.get(session, switch)
            tables = ACI.Process.get_table(processes, 'Process list for Switch ' + switch.name + '::')
            for table in tables:
                print table.get_text(tablefmt='fancy_grid') + '\n'
コード例 #3
0
def main():
    """
    Main show Process routine
    :return: None
    """
    description = 'Simple application that logs on to the APIC and check cluster information for a fabric'
    creds = Credentials('apic', description)

    args = creds.get()

    session = ACI.Session(args.url, args.login, args.password)
    resp = session.login()
    if not resp.ok:
        print '%% Could not login to APIC'
        sys.exit(0)

    
    cluster = ACI_PHYS.Cluster('Cluster')
    cluster_info = cluster.get(session)

    if (cluster.config_size != cluster.cluster_size):
        print("*******************************************************")
        print ("WARNING, configured cluster size "), cluster.config_size
        print (":   not equal to the actual size "), cluster.cluster_size
        print "WARNING, desired stats collection might be lost"
        print("*******************************************************")
        print("APICs in the cluster"), cluster.name, (":")
        for apic in cluster.apics:
            print json.dumps(apic,indent=4, sort_keys = True)
    else:
        print("PASS")
コード例 #4
0
def main():
    """
    Main execution path when run from the command line
    """
    # Get all the arguments
    description = "Search tool for APIC."
    creds = Credentials("apic", description)
    creds.add_argument(
        "-s", "--switch", type=str, default=None, help='Specify a particular switch id to perform search on, e.g. "102"'
    )
    creds.add_argument("-f", "--find", type=str, help="search string")
    creds.add_argument("--force", action="store_true", default=False, help="Force a rebuild of the search index")

    args = creds.get()
    print args
    try:
        sdb = SearchDb.load_db(args)
    except (LoginError, Timeout, ConnectionError):
        print "%% Could not login to APIC"
        sys.exit(0)

    results = sdb.search(args.find)
    count = 0
    for res in results:
        count += 1
        print res
コード例 #5
0
 def test_create_apic_list_only(self):
     """
     Basic test for only APIC Credentials qualifiers
     passed as a single string in a list
     """
     creds = Credentials(['apic'])
     self.assertTrue(isinstance(creds, Credentials))
コード例 #6
0
ファイル: aciSearchDb.py プロジェクト: yk21com/acitoolkit
def main():
    """
    Main execution path when run from the command line
    """
    # Get all the arguments
    description = 'Search tool for APIC.'
    creds = Credentials('apic', description)
    creds.add_argument(
        '-s',
        '--switch',
        type=str,
        default=None,
        help='Specify a particular switch id to perform search on, e.g. "102"')
    creds.add_argument('-f', '--find', type=str, help='search string')
    creds.add_argument('--force',
                       action="store_true",
                       default=False,
                       help='Force a rebuild of the search index')

    args = creds.get()
    print args
    sdb = SearchDb()
    sdb.set_login_credentials(args)
    try:
        sdb.load_db(args.force)
    except (LoginError, Timeout, ConnectionError):
        print '%% Could not login to APIC'
        sys.exit(0)

    results = sdb.search(args.find)
    count = 0
    for res in results:
        count += 1
        print 'score', res['pscore'], res['sscore'], res['terms'], res[
            'title'], res['path']
        tables = res['primary'].get_table([
            res['primary'],
        ])
        for table in tables:
            if table.data:
                print table.get_text()
        if count > 10:
            print 'Showing 10 of', len(results), 'results'
            break
コード例 #7
0
    def test_create_all(self):
        """
        Basic test for all Credentials qualifiers
        """
        creds = Credentials(['apic', 'mysql'])

        def return_empty_string(disp):
            """ Return an empty string """
            return ''

        creds._get_from_user = return_empty_string
        creds._get_password = return_empty_string
        self.assertTrue(isinstance(creds, Credentials))
        creds.get()
        creds.verify()
コード例 #8
0
ファイル: aciSearchDb.py プロジェクト: JMSrulez/acitoolkit
def main():
    """
    Main execution path when run from the command line
    """
    # Get all the arguments
    description = 'Search tool for APIC.'
    creds = Credentials('apic', description)
    creds.add_argument('--force',
                       action="store_true",
                       default=False,
                       help='Force a rebuild of the search index')

    args = creds.get()
    print args
    # load all objects
    session = SearchSession(args)
    try:
        fabric = Fabric.get(session.session)[0]
    except (LoginError, Timeout, ConnectionError):
        print '%% Could not login to APIC'
        sys.exit(0)

    fabric.populate_children(deep=True, include_concrete=True)

    index = SearchIndexLookup()
    store = SearchObjectStore()

    index.add_atk_objects(fabric)
    store.add_atk_objects(fabric)

    uids = index.search(args.find)
    result = store.get_by_uids_short(uids)

    count = 0
    for res in result:
        count += 1
        print res
コード例 #9
0
def main():
    """
    Main execution path when run from the command line
    """
    # Get all the arguments
    description = 'Search tool for APIC.'
    creds = Credentials('apic', description)
    creds.add_argument('--force',
                       action="store_true",
                       default=False,
                       help='Force a rebuild of the search index')

    args = creds.get()
    print(args)
    # load all objects
    session = SearchSession(args)
    try:
        fabric = Fabric.get(session.session)[0]
    except (LoginError, Timeout, ConnectionError):
        print('%% Could not login to APIC')
        sys.exit(0)

    fabric.populate_children(deep=True, include_concrete=True)

    index = SearchIndexLookup()
    store = SearchObjectStore()

    index.add_atk_objects(fabric)
    store.add_atk_objects(fabric)

    uids = index.search(args.find)
    result = store.get_by_uids_short(uids)

    count = 0
    for res in result:
        count += 1
        print(res)
コード例 #10
0
def main():
    """
    Main show Process routine
    :return: None
    """
    description = 'Simple application that logs on to the APIC and check cluster information for a fabric'
    creds = Credentials('apic', description)

    args = creds.get()

    session = ACI.Session(args.url, args.login, args.password)
    resp = session.login()
    if not resp.ok:
        print '%% Could not login to APIC'
        sys.exit(0)

    cluster = ACI.Cluster('Cluster')
    configured_size = cluster.get_config_size(session)
    cluster_size = cluster.get_cluster_size(session)
    cluster_info = cluster.get_cluster_info(session)

    if configured_size != cluster_size:
        print("*******************************************************")
        sys.stdout.write("WARNING, configured cluster size ")
        sys.stdout.write(configured_size)
        sys.stdout.write(" :not equal to the actual size ")
        print cluster_size
        print "WARNING, desired stats collection might be lost"
        print("*******************************************************")
        print("APICs in the cluster are:")
        for apic in cluster_info:
            print json.dumps(apic['infraCont']['attributes']['dn'],
                             indent=4,
                             sort_keys=True)
    else:
        print("PASS")
コード例 #11
0
ファイル: aciSearchDb.py プロジェクト: calvinha/acitoolkit
def main():
    """
    Main execution path when run from the command line
    """
    # Get all the arguments
    description = 'Search tool for APIC.'
    creds = Credentials('apic', description)
    creds.add_argument('-s', '--switch',
                       type=str,
                       default=None,
                       help='Specify a particular switch id to perform search on, e.g. "102"')
    creds.add_argument('-f', '--find',
                       type=str,
                       help='search string')
    creds.add_argument('--force',
                       action="store_true",
                       default=False,
                       help='Force a rebuild of the search index')

    args = creds.get()
    print args
    sdb = SearchDb()
    sdb.set_login_credentials(args)
    try:
        sdb.load_db(args.force)
    except (LoginError, Timeout, ConnectionError):
        print '%% Could not login to APIC'
        sys.exit(0)

    results = sdb.search(args.find)
    count = 0
    for res in results:
        count += 1
        print 'score', res['pscore'], res['sscore'], res['terms'], res['title'], res['path']
        tables = res['primary'].get_table([res['primary'], ])
        for table in tables:
            if table.data != []:
                print table.get_text()
        if count > 10:
            print 'Showing 10 of', len(results), 'results'
            break
コード例 #12
0
#    under the License.                                                        #
#                                                                              #
################################################################################
"""
Simple application that logs on to the APIC and displays all
of the Interfaces.
"""
from operator import attrgetter
import sys
import acitoolkit.acitoolkit as ACI
from acitoolkit.acitoolkitlib import Credentials

# Take login credentials from the command line if provided
# Otherwise, take them from your environment variables file ~/.profile
description = 'Simple application that logs on to the APIC and displays reports for the logical model.'
creds = Credentials('apic', description)
creds.add_argument('-t', '--tenant',
                   type=str,
                   default=None,
                   help='Specify a particular tenant name')
creds.add_argument('-all', action="store_true",
                   help='Show all detailed information')
creds.add_argument('-basic', action="store_true", help='Show basic tenant info')
creds.add_argument('-context', action="store_true", help='Show Context info')
creds.add_argument('-bridgedomain', action="store_true", help='Show Bridge Domain info')
creds.add_argument('-contract', action="store_true", help='Show Contract info')
creds.add_argument('-taboo', action="store_true", help='Show Taboo (Deny) info')
creds.add_argument('-filter', action="store_true", help='Show Filter info')
creds.add_argument('-app_profile', action="store_true", help='Show Application Profile info')
creds.add_argument('-epg', action="store_true", help='Show Endpoint Group info')
# creds.add_argument('-svi', action="store_true", help='Show SVI info')
コード例 #13
0
import flask
import mysql.connector
from acitoolkitvisualizationslib import *
from acitoolkit.acitoolkitlib import Credentials

description = 'Simple set of visualization examples.'
creds = Credentials(('mysql'), description)
args = creds.get()

app = flask.Flask(__name__)


@app.route('/')
def index():
    """ Displays the index page accessible at '/'
    """
    return flask.render_template('index.html')


@app.route('/pie')
def endpoint_tracker_pie():
    regenerate_pie_data(args.mysqllogin, args.mysqlpassword, args.mysqlip)
    return flask.render_template('endpoint-tracker-pie.html',
                                 filename='endpoint_tracker_pie.csv')


@app.route('/force')
def endpoint_location_force():
    return flask.render_template('endpoint-force.html')

コード例 #14
0
ファイル: aciConSearch.py プロジェクト: bischatt78/acitoolkit
def main():
    """
    Main execution path when run from the command line
    """
    # Get all the arguments
    description = 'Connection Search tool for APIC.'
    creds = Credentials('apic', description)

    creds.add_argument('-tenant', type=str, default='*', help='Tenant name (wildcards, "*", accepted), default "*"')
    creds.add_argument('-context', type=str, default='*', help='Tenant name (wildcards, "*", accepted), default "*"')
    creds.add_argument('-sip', type=str, default='0/0', help='Source IP or subnet - e.g. 1.2.3.4/24, default: "0/0"')
    creds.add_argument('-dip', type=str, default='0/0',
                       help='Destination IP or subnet - e.g. 1.2.3.4/24, default: "0/0"')
    creds.add_argument('-dport', type=str, default='any',
                       help='Destination L4 Port value or range, e.g. 20-25 or 80. Default: "any"')
    creds.add_argument('-sport', type=str, default='any',
                       help='Source L4 Port value or range, e.g. 20-25 or 80. Default: "any"')
    creds.add_argument('-etherT', type=str, default='any', help='EtherType, e.g. "ip", "arp", "icmp". Default: "any"')
    creds.add_argument('-prot', type=str, default='any', help='Protocol, e.g. "tcp", "udp". Default: "any"')
    creds.add_argument('-arpOpc', type=str, default='any', help='ARP Opcode, e.g. "req", "ack". Default: "any"')
    creds.add_argument('-applyToFrag', type=str, default='any',
                       help='Apply to fragment, e.g. "yes", "no". Default: "any"')
    creds.add_argument('-tcpRules', type=str, default='any', help='TCP rules, e.g. "syn", "fin". Default: "any"')

    args = creds.get()

    flow_spec = build_flow_spec_from_args(args)
    # todo: verify that a dash can be used in port range.

    # Login to APIC
    session = Session(args.url, args.login, args.password)
    resp = session.login()
    if not resp.ok:
        print '%% Could not login to APIC'
        sys.exit(0)

    sdb = SearchDb(session)
    sdb.build()
    results = sorted(sdb.search(flow_spec))
    for result in results:
        print result
コード例 #15
0
"""
Simple application that logs on to the APIC and displays all
of the Interfaces.
"""
import sys
from acitoolkit.aciConcreteLib import *
import acitoolkit.acitoolkit as ACI
import acitoolkit.aciphysobject as ACI_PHYS
from acitoolkit.acitoolkitlib import Credentials

#from SwitchJson import SwitchJson

# Take login credentials from the command line if provided
# Otherwise, take them from your environment variables file ~/.profile
description = 'Simple application that logs on to the APIC and displays reports for the switches.'
creds = Credentials('apic', description)
creds.add_argument('-s', '--switch',
                   type=str,
                   default=None,
                   help='Specify a particular switch id, e.g. "102"')
creds.add_argument('-all', action="store_true",
                   help='Show all detailed information')
creds.add_argument('-basic', action="store_true", help='Show basic switch info')
creds.add_argument('-linecard', action="store_true", help='Show Lincard info')
creds.add_argument('-supervisor', action="store_true", help='Show Supervisor Card info')
creds.add_argument('-fantray', action="store_true", help='Show Fantray info')
creds.add_argument('-powersupply', action="store_true", help='Show Power Supply info')
creds.add_argument('-arp', action="store_true", help='Show ARP info')
creds.add_argument('-context', action="store_true", help='Show Context (VRF) info')
creds.add_argument('-bridgedomain', action="store_true", help='Show Bridge Domain info')
creds.add_argument('-svi', action="store_true", help='Show SVI info')
コード例 #16
0
# all the imports
from flask import Flask, request, redirect, url_for, render_template

import acitoolkit.acitoolkit as ACI
from acitoolkit.acitoolkitlib import Credentials


# create our little application :)
app = Flask(__name__)
app.config.from_object(__name__)
description = 'Simple application that logs on to the APIC and displays stats for all of the Interfaces.'
creds = Credentials('apic', description)
args = creds.get()

# Login to APIC
session = ACI.Session(args.url, args.login, args.password)

object_type = 'mo'
mo = 'topology'
aciClass = 'fabricTopology'
history_list = []


def login(session):
    """
    Does login and reports result
    :param session:
    """
    resp = session.login()
    if not resp.ok:
        print '%% Could not login to APIC'
コード例 #17
0
ファイル: aciSearchGui.py プロジェクト: rtrentin73/acitoolkit
admin.add_view(About(name='About', endpoint='about'))
admin.add_view(Feedback(name='Feedback'))
admin.add_view(AciToolkitSearchView(name='Search'))
# admin.add_view(ShowObjectView(name='Object View', endpoint='atk_object'))


@app.route("/search/<search_terms>")
def search_result_page(search_terms='1/101/1/49'):
    """
    URL to request information about a specific port
    :param search_terms:
    """
    terms = str(request.args['first'])
    print 'search terms', terms

    result, total_hits = sdb.search(terms)
    return jsonify(result=result, total_hits=total_hits)

if __name__ == '__main__':
    description = 'ACI Search Tool.'
    creds = Credentials('server', description)
    creds.add_argument('--force',
                       action="store_true",
                       default=False,
                       help='Force a rebuild of the search index')
    args = creds.get()

    # Start app
    # app.run(debug=True, host=args.ip, port=int(args.port))
    app.run(debug=True, host=args.ip, port=5001)
コード例 #18
0
"""
Simple application that logs on to the APIC and displays all
of the Interfaces.
"""
import datetime
from operator import attrgetter
import sys

import acitoolkit as ACI
from acitoolkit.acitoolkitlib import Credentials


# Take login credentials from the command line if provided
# Otherwise, take them from your environment variables file ~/.profile
description = "Simple application that logs on to the APIC and displays reports for the switches."
creds = Credentials("apic", description)
creds.add_argument("-s", "--switch", type=str, default=None, help='Specify a particular switch id, e.g. "102"')
creds.add_argument("-all", action="store_true", help="Show all detailed information")
creds.add_argument("-basic", action="store_true", help="Show basic switch info")
creds.add_argument("-linecard", action="store_true", help="Show Lincard info")
creds.add_argument("-supervisor", action="store_true", help="Show Supervisor Card info")
creds.add_argument("-fantray", action="store_true", help="Show Fantray info")
creds.add_argument("-powersupply", action="store_true", help="Show Power Supply info")
creds.add_argument("-arp", action="store_true", help="Show ARP info")
creds.add_argument("-context", action="store_true", help="Show Context (VRF) info")
creds.add_argument("-bridgedomain", action="store_true", help="Show Bridge Domain info")
creds.add_argument("-svi", action="store_true", help="Show SVI info")
creds.add_argument("-accessrule", action="store_true", help="Show Access Rule and Filter info")
creds.add_argument("-endpoint", action="store_true", help="Show End Point info")
creds.add_argument("-portchannel", action="store_true", help="Show Port Channel and Virtual Port Channel info")
creds.add_argument("-overlay", action="store_true", help="Show Overlay info")
コード例 #19
0
#         http://www.apache.org/licenses/LICENSE-2.0                           #
#                                                                              #
#    Unless required by applicable law or agreed to in writing, software       #
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT #
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the  #
#    License for the specific language governing permissions and limitations   #
#    under the License.                                                        #
#                                                                              #
################################################################################
import flask
from acitoolkitvisualizationslib import *
from acitoolkit.acitoolkitlib import Credentials

description = 'Simple set of visualization examples.'
#creds = Credentials(('mysql'), description)
creds = Credentials(['mysql', 'server'], description)
args = creds.get()

app = flask.Flask(__name__)


@app.route('/')
def index():
    """ Displays the index page accessible at '/'
    """
    return flask.render_template('index.html')


@app.route('/pie')
def endpoint_tracker_pie():
    regenerate_pie_data(args.mysqllogin, args.mysqlpassword, args.mysqlip)
コード例 #20
0
ファイル: aciSearchGui.py プロジェクト: yk21com/acitoolkit
#     list_template = 'list.html'

# Create admin with custom base template
homepage_view = AdminIndexView(name='Home',
                               template='admin/index.html',
                               url='/')
admin = admin.Admin(app,
                    name='Search Tom View',
                    index_view=homepage_view,
                    base_template='layout.html')

# Add views
admin.add_view(CredentialsView(name='Credentials'))
admin.add_view(About(name='About', endpoint='test1', category='Test'))
admin.add_view(About(name='About', endpoint='test2', category='Test'))
admin.add_view(About(name='About 3', endpoint='test3', category='Test'))
admin.add_view(Feedback(name='Feedback'))
admin.add_view(SelectSwitchView(name='Switch Search'))

if __name__ == '__main__':
    description = 'ACI Search Viewer Tool.'
    creds = Credentials('server', description)
    creds.add_argument('--force',
                       action="store_true",
                       default=False,
                       help='Force a rebuild of the search index')
    args = creds.get()
    #sdb.load_db(args.force)
    # Start app
    app.run(debug=True, host=args.ip, port=int(args.port))
コード例 #21
0
"""
Simple application that logs on to the APIC and displays all
of the Interfaces.
"""
import sys
from acitoolkit.aciConcreteLib import *
import acitoolkit.acitoolkit as ACI
import acitoolkit.aciphysobject as ACI_PHYS
from acitoolkit.acitoolkitlib import Credentials

#from SwitchJson import SwitchJson

# Take login credentials from the command line if provided
# Otherwise, take them from your environment variables file ~/.profile
description = 'Simple application that logs on to the APIC and displays stats for all of the Interfaces.'
creds = Credentials('apic', description)
creds.add_argument('-s',
                   '--switch',
                   type=str,
                   default=None,
                   help='Specify a particular switch id, e.g. "102"')
creds.add_argument('-all',
                   action="store_true",
                   help='Show all detailed information')
creds.add_argument('-basic',
                   action="store_true",
                   help='Show basic switch info')
creds.add_argument('-linecard', action="store_true", help='Show Lincard info')
creds.add_argument('-supervisor',
                   action="store_true",
                   help='Show Supervisor Card info')
コード例 #22
0
ファイル: object_browser.py プロジェクト: lumean/acitoolkit
# all the imports
from flask import Flask, request, redirect, url_for, render_template

import acitoolkit.acitoolkit as ACI
from acitoolkit.acitoolkitlib import Credentials

# create our little application :)
app = Flask(__name__)
app.config.from_object(__name__)
description = 'Simple application that logs on to the APIC and displays stats for all of the Interfaces.'
creds = Credentials('apic', description)
args = creds.get()

# Login to APIC
session = ACI.Session(args.url, args.login, args.password)

object_type = 'mo'
mo = 'topology'
aciClass = 'fabricTopology'
history_list = []


def login(session):
    """
    Does login and reports result
    :param session:
    """
    resp = session.login()
    if not resp.ok:
        print('%% Could not login to APIC')
    else:
コード例 #23
0
    result = sdb.search(flow_spec)
    t2 = datetime.datetime.now()
    print "Search time:", t2 - t1
    return jsonify(result=prep_results(result))


@app.route("/load_data")
def load_data():
    if BaseConnSearchView.load_db():
        return jsonify(result='done')
    else:
        return jsonify(result='fail')

        # return redirect(url_for('credentialsview.index'))

        # return jsonify(result='done')


def initialize_db():
    sdb.build()


if __name__ == '__main__':
    description = 'ACI Connection Search Tool.'
    creds = Credentials('server', description)
    args = creds.get()

    # Start app
    # app.run(debug=True, host=args.ip, port=int(args.port))
    app.run(debug=True, use_reloader=False, host=args.ip, port=5001)
コード例 #24
0
#    License for the specific language governing permissions and limitations   #
#    under the License.                                                        #
#                                                                              #
################################################################################
"""
Simple application that logs on to the APIC and displays all
of the Interfaces.
"""
import sys
import acitoolkit.acitoolkit as ACI
from acitoolkit.acitoolkitlib import Credentials

# Take login credentials from the command line if provided
# Otherwise, take them from your environment variables file ~/.profile
description = 'Simple application that logs on to the APIC and displays reports for the logical model.'
creds = Credentials('apic', description)
creds.add_argument('-t',
                   '--tenant',
                   type=str,
                   default=None,
                   help='Specify a particular tenant name')
creds.add_argument('-all',
                   action="store_true",
                   help='Show all detailed information')
creds.add_argument('-basic',
                   action="store_true",
                   help='Show basic tenant info')
creds.add_argument('-context', action="store_true", help='Show Context info')
creds.add_argument('-bridgedomain',
                   action="store_true",
                   help='Show Bridge Domain info')