def is_excluded_tenant_name(tenant_name): try: if not cfg.has_option('sync','excluded_tenants'): return False excluded_tenants = cfg.get('sync','excluded_tenants').split(',') if tenant_name in excluded_tenants: return True elif cfg.has_option('openstack','default_net_partition'): if cfg.get('openstack','default_net_partition') == tenant_name: return True else: return False except Exception, e: logger.error("|- ERROR getting list of excluded tenants from config file") logger.error(repr(e))
def is_excluded_tenant_name(tenant_name): try: if not cfg.has_option('sync', 'excluded_tenants'): return False excluded_tenants = cfg.get('sync', 'excluded_tenants').split(',') if tenant_name in excluded_tenants: return True elif cfg.has_option('openstack', 'default_net_partition'): if cfg.get('openstack', 'default_net_partition') == tenant_name: return True else: return False except Exception, e: logger.error( "|- ERROR getting list of excluded tenants from config file") logger.error(repr(e))
def calcL2SubnetName(nc, l2domain): if not cfg.has_option('sync', 'l2_name_format'): L2NameFormat = "$d" else: L2NameFormat = cfg.get('sync', 'l2_name_format') name = l2domain['name'] return name
def calcL2SubnetName(nc,l2domain): if not cfg.has_option('sync','l2_name_format'): L2NameFormat = "$d" else: L2NameFormat = cfg.get('sync','l2_name_format') name = l2domain['name'] return name
def is_excluded_keystone_tenant_id(tenant_id): try: if not cfg.has_option('sync','excluded_tenants'): return False excluded_tenants = cfg.get('sync','excluded_tenants').split(',') try: tenant = get_tenant_with_id(tenant_id) except Exception, e: logger.error("|- ERROR getting keystone tenant with id: %s" % tenant_id) logger.error(repr(e)) if tenant.name in excluded_tenants: return True elif cfg.has_option('openstack','default_net_partition'): if cfg.get('openstack','default_net_partition') == tenant.name: return True else: return False
def is_excluded_keystone_tenant_id(tenant_id): try: if not cfg.has_option('sync', 'excluded_tenants'): return False excluded_tenants = cfg.get('sync', 'excluded_tenants').split(',') try: tenant = get_tenant_with_id(tenant_id) except Exception, e: logger.error("|- ERROR getting keystone tenant with id: %s" % tenant_id) logger.error(repr(e)) if tenant.name in excluded_tenants: return True elif cfg.has_option('openstack', 'default_net_partition'): if cfg.get('openstack', 'default_net_partition') == tenant.name: return True else: return False
def is_excluded_netpartition_id(netpartition_id): neutron_creds = get_neutron_creds(cfg.get('openstack','admin_username'), cfg.get('openstack','admin_password'), "admin") neutron = neutronclient.Client(**neutron_creds) try: if not cfg.has_option('sync','excluded_tenants'): return False excluded_tenants = cfg.get('sync','excluded_tenants').split(',') try: tenant = neutron.list_net_partitions(id=netpartition_id)['net_partitions'][0] except Exception, e: logger.error("|- ERROR getting netpartition with id: %s" % netpartition_id) logger.error(repr(e)) if tenant['name'] in excluded_tenants: return True elif cfg.has_option('openstack','default_net_partition'): if cfg.get('openstack','default_net_partition') == tenant['name']: return True else: return False
def is_excluded_netpartition_id(netpartition_id): neutron_creds = get_neutron_creds(cfg.get('openstack', 'admin_username'), cfg.get('openstack', 'admin_password'), "admin") neutron = neutronclient.Client(**neutron_creds) try: if not cfg.has_option('sync', 'excluded_tenants'): return False excluded_tenants = cfg.get('sync', 'excluded_tenants').split(',') try: tenant = neutron.list_net_partitions( id=netpartition_id)['net_partitions'][0] except Exception, e: logger.error("|- ERROR getting netpartition with id: %s" % netpartition_id) logger.error(repr(e)) if tenant['name'] in excluded_tenants: return True elif cfg.has_option('openstack', 'default_net_partition'): if cfg.get('openstack', 'default_net_partition') == tenant['name']: return True else: return False
def get_current_subnet_mappings(): con = mdb.connect(cfg.get('neutron', 'db_hostname'), cfg.get('neutron', 'db_username'), cfg.get('neutron', 'db_password'), cfg.get('neutron', 'db_name')) cur = con.cursor(mdb.cursors.DictCursor) if not cfg.has_option('openstack', 'version'): cur.execute("SELECT * FROM nuage_subnet_l2dom_mapping") else: if cfg.get('openstack', 'version').lower() == "icehouse": cur.execute("SELECT * FROM subnet_l2dom_mapping") else: # juno, kilo and liberty cur.execute("SELECT * FROM nuage_subnet_l2dom_mapping") rows = cur.fetchall() return rows
def get_current_subnet_mappings(): con = mdb.connect(cfg.get('neutron', 'db_hostname'), cfg.get('neutron', 'db_username'), cfg.get('neutron', 'db_password'), cfg.get('neutron', 'db_name')) cur = con.cursor(mdb.cursors.DictCursor) if not cfg.has_option('openstack', 'version'): cur.execute("SELECT * FROM nuage_subnet_l2dom_mapping") else: if cfg.get('openstack', 'version').lower() == "icehouse": cur.execute("SELECT * FROM subnet_l2dom_mapping") else: # juno, kilo and liberty cur.execute("SELECT * FROM nuage_subnet_l2dom_mapping") rows = cur.fetchall() return rows
def calcL3SubnetName(nc, vsd_subnet): if not cfg.has_option('sync', 'l3_name_format'): L3NameFormat = "$d ($z) \ $s" else: L3NameFormat = cfg.get('sync', 'l3_name_format') name = L3NameFormat name = name.replace('$s', vsd_subnet['name']) if '$d' in L3NameFormat: zone = nc.get("zones/%s" % vsd_subnet['parentID']).obj()[0] domain = nc.get("domains/%s" % zone['parentID']).obj()[0] name = name.replace('$d', domain['name']) if '$z' in L3NameFormat: name = name.replace('$z', zone['name']) elif '$z' in L3NameFormat: zone = nc.get("zones/%s" % vsd_subnet['parentID']).obj()[0] name = name.replace('$z', zone['name']) return name
def calcL3SubnetName(nc,vsd_subnet): if not cfg.has_option('sync','l3_name_format'): L3NameFormat = "$d ($z) \ $s" else: L3NameFormat = cfg.get('sync','l3_name_format') name = L3NameFormat name = name.replace('$s',vsd_subnet['name']) if '$d' in L3NameFormat: zone = nc.get("zones/%s" % vsd_subnet['parentID']).obj()[0] domain = nc.get("domains/%s" % zone['parentID']).obj()[0] name = name.replace('$d',domain['name']) if '$z' in L3NameFormat: name = name.replace('$z',zone['name']) elif '$z' in L3NameFormat: zone = nc.get("zones/%s" % vsd_subnet['parentID']).obj()[0] name = name.replace('$z',zone['name']) return name