def getOldTenant(): tenants_list = [] tenants = Tenant.get(session) for tenant in tenants: if tenant.name != 'mgmt' and tenant.name != 'infra' and tenant.name != 'common': tenants_list.append((tenant)) print('\nTenants on the system') print('=====================') for a in range(len(tenants_list)): print str(a) + ': ' + tenants_list[a].name tenant_in = 99999 while tenant_in > 99998: error = False input = raw_input( '\nPlease enter the Tenant # where the application is you want to duplicate: ' ) try: tenant_in = int(input) except: error = True if tenant_in > len(tenants_list) - 1: error = True if error: tenant_in = 99999 print('Please select a Tenant number from the list.') return tenants_list[tenant_in]
def getOldTenant(): tenants_list = [] tenants = Tenant.get(session) for tenant in tenants: if tenant.name != 'mgmt' and tenant.name != 'infra' and tenant.name != 'common': tenants_list.append((tenant)) print ('\nTenants on the system') print ('=====================') for a in range(len(tenants_list)): print str(a) + ': ' + tenants_list[a].name tenant_in = 99999 while tenant_in > 99998: error = False input = raw_input('\nPlease enter the Tenant # where the application is you want to duplicate: ') try: tenant_in = int(input) except: error = True if tenant_in > len(tenants_list)-1: error = True if error: tenant_in = 99999 print ('Please select a Tenant number from the list.') return tenants_list[tenant_in]
def delete_tenant_for_scalabilityTest(self, session): tenants = Tenant.get(session) for tenant in tenants: if re.match("FVT_TenantScale_Test\d+", str(tenant)): tenant.mark_as_deleted() resp = session.push_to_apic(tenant.get_url(), tenant.get_json()) if resp.ok: print('***{} Tenant Deleted'.format(str(tenant)))
def main(): with open(CONFFILE, 'r') as r: conf = json.loads(r.read()) #login to apic session = Session(conf['url'], conf['login'], conf['password']) resp = session.login() if not resp.ok: print('%% Could not login to APIC') return sys.exit(0) tenants = Tenant.get(session) for tenant in tenants: print(tenant.name)
# Process all relevant command-line parameters and print our welcome banner if args.debug is not None: debug_enable() print_banner() # Now, we log into the APIC session = Session(args.url, args.login, args.password) response = session.login() if response.ok is False: fatal(response.content) else: output("Successfully connected to %s" % args.url) # Retrieve the list of existing tenants tenants = Tenant.get(session) # Subscribe to each one urls=[] for tn in tenants: url = "/api/mo/uni/tn-%s.json?query-target=subtree&subscription=yes" % tn.name try: debug("Subscribing to '%s'" % url) session.subscribe(url, only_new=True) urls.append(url) except: error("Error creating subscription for tenant '%s'" % tn.name) # Also, subscribe to the Tenant class so we can create new subscriptions # if new tenants get created. tn_url = "/api/class/fvTenant.json?subscription=yes"
from acitoolkit.acitoolkit import Session, Credentials, Tenant creds = Credentials('apic', 'Opis co skrypt robi.') args = creds.get() session = Session(args.url, args.login, args.password) resp = session.login() if not resp.ok: print 'Could not login to APIC' tenant = Tenant('mytenat') resp = session.push_to_apic(tenant.get_url(), tenant.get_json()) if not resp.ok: print 'Could not push configuration to APIC' print resp.text tenants = Tenant.get(session) for tenant in tenants: print tenant.name session.close()
import credentials as cred def get_tenant(tenant, tenant_list): for tenant_entry in tenant_list: if tenant_entry.name == tenant: return tenant_entry return None session = Session(cred.URL, cred.LOGIN, cred.PASSWORD) resp = session.login() if not resp.ok: print 'Login to ACI was not successful' common_tenant = get_tenant('common', Tenant.get(session)) if common_tenant is None: print 'Common tenant not found!' exit() data = pd.read_csv('resources/filter_entries.csv') filterObj = dict() for f in data.filterName.unique(): filterObj[f] = Filter(f, common_tenant) for index, row in data.iterrows(): FilterEntry(str(row['filterEntryName']), applyToFrag=str(row['applyToFrag']), arpOpc=str(row['arpOpc']), stateful=str(row['stateful']),