Example #1
0
def get_tenants(domain):
    """ Get tenants of a domain in a dict with openstack_id as key """
    logger.debug("Getting teants in %s" % domain)
    tenants = Tenant.in_domain(domain)
    for tenant in tenants:
        logger.debug(tenant)

    logger.debug("Getting managers from Keystone")
    results = []
    kclient = get_keystoneclient()
    for tenant in tenants:
        tenant["manager"] = ""
        tenant["email"] = ""
        # only get the first manager of non-personal tenant
        # personal tenant has not manager
        managers = kclient.get_tenant_manangers(tenant["openstack_id"])
        if len(managers) > 0:
            if len(managers) > 1:
                logger.warn("More than one manager found, only one set")
                print(managers)
            manager = managers[0]
            tenant["manager"] = manager["name"]
            tenant["email"] = manager["email"]
        results.append(repack(tenant, {"name": "tenant_name"}))

    return array_to_dict(results, "openstack_id")
Example #2
0
def get_tenants(domain):
    """ Get tenants of a domain in a dict with openstack_id as key """
    logger.debug("Getting teants in %s" % domain)
    tenants = Tenant.in_domain(domain)
    for tenant in tenants:
        logger.debug(tenant)

    logger.debug("Getting managers from Keystone")
    results = []
    kclient = get_keystoneclient()
    for tenant in tenants:
        tenant["manager"] = ""
        tenant["email"] = ""
        # only get the first manager of non-personal tenant
        # personal tenant has not manager
        managers = kclient.get_tenant_manangers(tenant["openstack_id"])
        if len(managers) > 0:
            if len(managers) > 1:
                logger.warn("More than one manager found, only one set")
                print(managers)
            manager = managers[0]
            tenant["manager"] = manager["name"]
            tenant["email"] = manager["email"]
        results.append(repack(tenant, {"name": "tenant_name"}))

    return array_to_dict(results, "openstack_id")
Example #3
0
def export_tenants(domain):
    logger.debug("Getting teants in %s" % domain)
    tenants = Tenant.in_domain(domain)
    results = []

    logger.debug("Getting managers from Keystone")
    kclient = get_keystoneclient()
    file_name = "%s_tenants.csv" % domain
    with open(file_name, "w", newline="") as csvfile:
        spamwriter = csv.writer(csvfile)
        for tenant in tenants:
            if not tenant['name'].startswith('pt-'):
                fields = _to_list(tenant, ["openstack_id", "allocation", "name", "description"])
                managers = kclient.get_tenant_manangers(tenant["openstack_id"])
                for manager in managers:
                    fields.extend(_to_list(manager, ["id", "name", "email", "domain"]))
                spamwriter.writerow(fields)
            else:
                print(tenant['name'])
Example #4
0
def export_tenants(domain):
    logger.debug("Getting teants in %s" % domain)
    tenants = Tenant.in_domain(domain)
    results = []

    logger.debug("Getting managers from Keystone")
    kclient = get_keystoneclient()
    file_name = "%s_tenants.csv" % domain
    with open(file_name, "w", newline="") as csvfile:
        spamwriter = csv.writer(csvfile)
        for tenant in tenants:
            if not tenant['name'].startswith('pt-'):
                fields = _to_list(
                    tenant,
                    ["openstack_id", "allocation", "name", "description"])
                managers = kclient.get_tenant_manangers(tenant["openstack_id"])
                for manager in managers:
                    fields.extend(
                        _to_list(manager, ["id", "name", "email", "domain"]))
                spamwriter.writerow(fields)
            else:
                print(tenant['name'])
Example #5
0
def test_in_domain(domain):
    tenants = Tenant.in_domain(domain)
    for tenant in tenants:
        logger.debug(tenant)
Example #6
0
def test_in_domain(domain):
    tenants = Tenant.in_domain(domain)
    for tenant in tenants:
        logger.debug(tenant)