def main(args):
    client = Reseller2Client(domain=args.domain)

    client.client_login(email=args.admin,
                        password=args.password,
                        source="edt-reseller2.0-tokendump")

    writer = csv.DictWriter(open(args.out, 'wb'),
                            fieldnames=[
                                'domain',
                                'token',
                                'expiry',
                                'edition',
                                'maximumNumberOfUsers',
                                'countryCode',
                                'creationTime',
                                'isSuspended'
                            ])
    writer.writeheader()

    for entry in client.get_all_domains():
        # pull out the domainName
        domainName = entry._other_elements[1]._other_attributes['value']
        print "Fetching info for %s ..." % domainName

        # fetch the transfer tokens
        token_entry = client.get_transfer_token(domain=domainName)

        # pull out the values of interest.
        expiry = token_entry._other_elements[1]._other_attributes['value']
        token = token_entry._other_elements[2]._other_attributes['value']

        # fetch information about a domain
        domain_entry = client.get_domain(domain=domainName)

        # see if the domain is in a suspended state.
        suspend_entry = client.get_suspend_status(domainName)
        isSuspended = suspend_entry._other_elements[1]._other_attributes['value']

        # pull out values of interest.
        edition = domain_entry._other_elements[1]._other_attributes['value']
        maximumNumberOfUsers = domain_entry._other_elements[2]._other_attributes['value']
        countryCode = domain_entry._other_elements[3]._other_attributes['value']
        creationTime = domain_entry._other_elements[5]._other_attributes['value']

        writer.writerow({
            'domain': domainName.encode('ascii', 'ignore'),
            'token': token,
            'expiry': expiry,
            'edition': edition,
            'maximumNumberOfUsers': maximumNumberOfUsers,
            'countryCode': countryCode.encode('ascii', 'ignore'),
            'creationTime': creationTime,
            'isSuspended': isSuspended
        })

        # keep the QPS something reasonable.
        time.sleep(1)
예제 #2
0
def main(args):
    client = Reseller2Client(domain=args.domain)

    auth_token = client.client_login(email=args.admin,
                                     password=args.password,
                                     source="edt-reseller2.0-tokendump")

    prov_client = MultiDomainProvisioningClient(domain=args.domain)
    prov_client.auth_token = auth_token

    writer = csv.DictWriter(open(args.out, 'wb'),
                            fieldnames=[
                                'domain', 'token', 'expiry', 'edition',
                                'maximumNumberOfUsers', 'countryCode',
                                'creationTime', 'isSuspended', 'userCount'
                            ])
    writer.writeheader()

    for entry in client.get_all_domains():
        # pull out the domainName
        domainName = entry._other_elements[1]._other_attributes['value']
        print "Fetching info for %s ..." % domainName

        # fetch the transfer tokens
        token_entry = client.get_transfer_token(domain=domainName)

        # pull out the values of interest.
        expiry = token_entry._other_elements[1]._other_attributes['value']
        token = token_entry._other_elements[2]._other_attributes['value']

        # fetch information about a domain
        domain_entry = client.get_domain(domain=domainName)

        # see if the domain is in a suspended state.
        isSuspended = "UNKNOWN"
        for n in range(0, 5):
            try:
                suspend_entry = client.get_suspend_status(domainName)
                isSuspended = suspend_entry._other_elements[
                    1]._other_attributes['value']
                break
            except RequestError:
                time.sleep((2**n) + random.random())

        # pull out values of interest.
        edition = domain_entry._other_elements[1]._other_attributes['value']
        maximumNumberOfUsers = domain_entry._other_elements[
            2]._other_attributes['value']
        countryCode = domain_entry._other_elements[3]._other_attributes[
            'value']
        creationTime = domain_entry._other_elements[5]._other_attributes[
            'value']

        # attempt to find the current user count of the entire instance.
        prov_client.domain = domainName
        userCount = "UNKNOWN"

        for n in range(0, 5):
            try:
                userCount = len(prov_client.retrieve_all_users().entry)
                break
            except RequestError:
                time.sleep((2**n) + random.random())

        writer.writerow({
            'domain': domainName.encode('ascii', 'ignore'),
            'token': token,
            'expiry': expiry,
            'edition': edition,
            'maximumNumberOfUsers': maximumNumberOfUsers,
            'countryCode': countryCode.encode('ascii', 'ignore'),
            'creationTime': creationTime,
            'isSuspended': isSuspended,
            'userCount': userCount
        })

        # keep the QPS something reasonable.
        time.sleep(1)
def main(args):
    client = Reseller2Client(domain=args.domain)

    auth_token = client.client_login(email=args.admin,
                                     password=args.password,
                                     source="edt-reseller2.0-tokendump")

    prov_client = MultiDomainProvisioningClient(domain=args.domain)
    prov_client.auth_token = auth_token

    writer = csv.DictWriter(open(args.out, 'wb'),
                            fieldnames=[
                                'domain',
                                'token',
                                'expiry',
                                'edition',
                                'maximumNumberOfUsers',
                                'countryCode',
                                'creationTime',
                                'isSuspended',
                                'userCount'
                            ])
    writer.writeheader()

    for entry in client.get_all_domains():
        # pull out the domainName
        domainName = entry._other_elements[1]._other_attributes['value']
        print "Fetching info for %s ..." % domainName

        # fetch the transfer tokens
        token_entry = client.get_transfer_token(domain=domainName)

        # pull out the values of interest.
        expiry = token_entry._other_elements[1]._other_attributes['value']
        token = token_entry._other_elements[2]._other_attributes['value']

        # fetch information about a domain
        domain_entry = client.get_domain(domain=domainName)

        # see if the domain is in a suspended state.
        isSuspended = "UNKNOWN"
        for n in range(0, 5):
            try:
                suspend_entry = client.get_suspend_status(domainName)
                isSuspended = suspend_entry._other_elements[1]._other_attributes['value']
                break
            except RequestError:
                time.sleep((2 ** n) + random.random())

        # pull out values of interest.
        edition = domain_entry._other_elements[1]._other_attributes['value']
        maximumNumberOfUsers = domain_entry._other_elements[2]._other_attributes['value']
        countryCode = domain_entry._other_elements[3]._other_attributes['value']
        creationTime = domain_entry._other_elements[5]._other_attributes['value']

        # attempt to find the current user count of the entire instance.
        prov_client.domain = domainName
        userCount = "UNKNOWN"

        for n in range(0, 5):
            try:
                userCount = len(prov_client.retrieve_all_users().entry)
                break
            except RequestError:
                time.sleep((2 ** n) + random.random())

        writer.writerow({
            'domain': domainName.encode('ascii', 'ignore'),
            'token': token,
            'expiry': expiry,
            'edition': edition,
            'maximumNumberOfUsers': maximumNumberOfUsers,
            'countryCode': countryCode.encode('ascii', 'ignore'),
            'creationTime': creationTime,
            'isSuspended': isSuspended,
            'userCount': userCount
        })

        # keep the QPS something reasonable.
        time.sleep(1)