Beispiel #1
0
def login_flow_rc():
    API_ENDPOINT = "https://marla.cisco.com"
    #API_KEY      = "76ad0edabbba46e29e997305afe2b42e"
    #API_SECRET   = "2b117acf13440cdc07236c4d77260959be220611"
    API_KEY = "655fa22032ca4a7ba0f56f0c9106f7e6"
    API_SECRET = "fb91bbc9633ee2c8513a7abb227e85fad75dd8ac"
    rc = RestClient(API_ENDPOINT, API_KEY, API_SECRET, verify=False)
    return rc
Beispiel #2
0
from pprint import pprint
from datetime import datetime

try:
    from credentials import API_ENDPOINT, API_KEY, API_SECRET
except ImportError:
    sys.exit("Error: please verify credentials file format.")

# Import Tetration client
from tetration import RestClient
import json
import requests.packages.urllib3

requests.packages.urllib3.disable_warnings()

rc = RestClient(API_ENDPOINT, API_KEY, API_SECRET, verify=False)

################ GET Sensors
print 'Retrieving all sensors, excluding sensors in Tetration VRF'
print '-' * 40
resp = rc.get('/sensors')
if resp:
    sensors = resp.json()
    for i in sensors['results']:
        if i['interfaces'][0]['vrf'] == 'Tetration':
            continue
        hostname = i['host_name']
        agentmode = i['agent_type']
        print('Sensor {} is running {}').format(hostname, agentmode)
else:
    sys.exit("No data returned! HTTP {}".format(resp.status_code))
Beispiel #3
0
def login_sw_rc():
    API_ENDPOINT = "https://marla.cisco.com"
    API_KEY = "ace132ddef784667944f683cae6db28c"
    API_SECRET = "0efcf4e825c8b899c5d93c625a7cd237014f1bb0"
    rc = RestClient(API_ENDPOINT, API_KEY, API_SECRET, verify=False)
    return rc
Beispiel #4
0
def login_hw_rc():
    API_ENDPOINT = "https://marla.cisco.com"
    API_KEY = "6f30e0e3dc3549e5b00ffcd2f9fdb6d6"
    API_SECRET = "9aa5181e9c3b91aa84b5413d0a2a5b0504579287"
    rc = RestClient(API_ENDPOINT, API_KEY, API_SECRET, verify=False)
    return rc
Beispiel #5
0
from tetration import RestClient
import json
import requests.packages.urllib3
import csv

with open('plx_users.csv', 'rb') as fp:
    reader = csv.reader(fp)
    for row in reader:
        print row

sys.exit(666)

requests.packages.urllib3.disable_warnings()

email = '*****@*****.**'
rc = RestClient(API_ENDPOINT, API_KEY, API_SECRET, verify=False)

role_dict = {}
print 'Indexing roles from system'
resp = rc.get('/roles')
if resp.status_code == 200:
    parsed_resp = json.loads(resp.content)
    for role in parsed_resp:
        role_dict[role['name']] = role['id']
        print '\t{} is {}'.format(role['name'], role['id'])
else:
    sys.exit('Unable to enumerate roles - are you authorized? HTTP {}'.format(
        resp.status_code))

print 'Retrieving list of users from system'
resp = rc.get('/users')
Beispiel #6
0
from datetime import datetime
import json

try:
    from credentials import API_ENDPOINT, API_KEY, API_SECRET
except ImportError:
    sys.exit("Error: please verify credentials file format.")

# Import Tetration client
from tetration import RestClient
import json
import requests.packages.urllib3

requests.packages.urllib3.disable_warnings()

rc = RestClient(API_ENDPOINT, API_KEY, API_SECRET, verify=False)

################ GET Sensors
print 'Retrieving all filters'
print '-' * 40
resp = rc.get('/filters/inventories')
if resp:
    filters = resp.json()
    for filter in filters:
        print("Filter {} has ID {}. It is in scope ID {}. The query is {}"
              ).format(filter["id"], filter["name"], filter["app_scope_id"],
                       filter["query"])
        print '-' * 40
else:
    sys.exit("No data returned! HTTP {}".format(resp.status_code))
Beispiel #7
0
from pprint import pprint
from datetime import datetime

try:
    from credentials import API_ENDPOINT, API_KEY, API_SECRET
except ImportError:
    sys.exit("Error: please verify credentials file format.")

# Import Tetration client
from tetration import RestClient
import json
import requests.packages.urllib3

requests.packages.urllib3.disable_warnings()

rc = RestClient(API_ENDPOINT, API_KEY, API_SECRET, verify=False)

# you can specify a filter in flow_req
# this GET returns values for filter options
#
# resp = rc.get('/flowsearch/dimensions')
# print json.dumps(resp.json())
#

flow_req = {
    "t0": "2017-05-30T17:00:00-0700", 
    "t1": "2017-05-31T10:00:00-0700",
    "scopeName": "Prod:Opencart",
    "limit": 100,
    "filter": {"type": "and",
        "filters": [
Beispiel #8
0
from pprint import pprint
from datetime import datetime

try:
    from credentials import API_ENDPOINT, API_KEY, API_SECRET
except ImportError:
    sys.exit("Error: please verify credentials file format.")

# Import Tetration client
from tetration import RestClient
import json
import requests.packages.urllib3
import csv

requests.packages.urllib3.disable_warnings()
rc = RestClient(API_ENDPOINT, API_KEY, API_SECRET, verify=False)
if rc:
    print("Connected to TA cluster!")
else:
    print("Failed to connect to TA cluster!")
    sys.exit(1)

start_ip="10.48.58.{}"
numOfPods=6
pod_array = {}
for i in range(1,numOfPods):
    for j in range(0, 4):
        lastByte=25 + i*4 + j
        pod_array[j]=start_ip.format(lastByte)

    pod_query_string_array = {u'type': u'or', u'filters': [{u'field': u'ip', u'type': u'eq', u'value': pod_array[0]}, {u'field': u'ip', u'type': u'eq', u'value': pod_array[1]}, {u'field': u'ip', u'type': u'eq', u'value': pod_array[2]}, {u'field': u'ip', u'type': u'eq', u'value': pod_array[3]}]}
Beispiel #9
0
from pprint import pprint
from datetime import datetime

try:
    from credentials import API_ENDPOINT, API_KEY, API_SECRET
except ImportError:
    sys.exit("Error: please verify credentials file format.")

# Import Tetration client
from tetration import RestClient
import json
import requests.packages.urllib3

requests.packages.urllib3.disable_warnings()

rc = RestClient(API_ENDPOINT, API_KEY, API_SECRET, verify=False)

role_dict = {}
print 'Indexing roles from system'
resp = rc.get('/roles')
if resp.status_code == 200:
    parsed_resp = json.loads(resp.content)
    for role in parsed_resp:
        role_dict[role['id']] = role['name']
        print '\t{} is {}'.format(role['id'], role['name'])
else:
    sys.exit('Unable to enumerate roles - are you authorized? HTTP {}'.format(
        resp.status_code))

print 'Retrieving users from system'
resp = rc.get('/users')