本文整理汇总了Python中pritunl.organization.Organization.iter_orgs方法的典型用法代码示例。如果您正苦于以下问题:Python Organization.iter_orgs方法的具体用法?Python Organization.iter_orgs怎么用?Python Organization.iter_orgs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pritunl.organization.Organization
的用法示例。
在下文中一共展示了Organization.iter_orgs方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: status_get
# 需要导入模块: from pritunl.organization import Organization [as 别名]
# 或者: from pritunl.organization.Organization import iter_orgs [as 别名]
def status_get():
orgs_count = 0
servers_count = 0
servers_online_count = 0
clients_count = 0
for server in Server.iter_servers():
servers_count += 1
if server.status:
servers_online_count += 1
clients_count += len(server.clients)
user_count = 0
for org in Organization.iter_orgs():
orgs_count += 1
user_count += org.user_count
local_networks = utils.get_local_networks()
return utils.jsonify({
'org_count': orgs_count,
'users_online': clients_count,
'user_count': user_count,
'servers_online': servers_online_count,
'server_count': servers_count,
'server_version': __version__,
'public_ip': app_server.public_ip,
'local_networks': local_networks,
})
示例2: org_get
# 需要导入模块: from pritunl.organization import Organization [as 别名]
# 或者: from pritunl.organization.Organization import iter_orgs [as 别名]
def org_get(org_id=None):
if org_id:
return utils.jsonify(Organization.get_org(id=org_id).dict())
else:
orgs = []
for org in Organization.iter_orgs():
orgs.append(org.dict())
return utils.jsonify(orgs)
示例3: status_get
# 需要导入模块: from pritunl.organization import Organization [as 别名]
# 或者: from pritunl.organization.Organization import iter_orgs [as 别名]
def status_get():
orgs_count = 0
servers_count = 0
servers_online_count = 0
clients_count = 0
for server in Server.iter_servers():
servers_count += 1
if server.status:
servers_online_count += 1
clients_count += len(server.clients)
user_count = 0
for org in Organization.iter_orgs():
orgs_count += 1
user_count += org.user_count
local_networks = utils.get_local_networks()
if app_server.openssl_heartbleed:
notification = 'You are running an outdated version of openssl ' + \
'containting the heartbleed bug. This could allow an attacker ' + \
'to compromise your server. Please upgrade your openssl ' + \
'package and restart the pritunl service.'
else:
notification = app_server.notification
return utils.jsonify({
'org_count': orgs_count,
'users_online': clients_count,
'user_count': user_count,
'servers_online': servers_online_count,
'server_count': servers_count,
'server_version': __version__,
'public_ip': app_server.public_ip,
'local_networks': local_networks,
'notification': notification,
})
示例4: export_get
# 需要导入模块: from pritunl.organization import Organization [as 别名]
# 或者: from pritunl.organization.Organization import iter_orgs [as 别名]
def export_get():
data_path = app_server.data_path
temp_path = os.path.join(data_path, TEMP_DIR)
empty_temp_path = os.path.join(temp_path, EMPTY_TEMP_DIR)
data_archive_name = '%s_%s.tar' % (APP_NAME,
time.strftime('%Y_%m_%d_%H_%M_%S', time.localtime()))
data_archive_path = os.path.join(temp_path, data_archive_name)
# Create empty temp directory to recreate temp dirs in tarfile
if not os.path.exists(empty_temp_path):
os.makedirs(empty_temp_path)
tar_file = tarfile.open(data_archive_path, 'w')
try:
tar_add(tar_file, os.path.join(data_path, AUTH_LOG_NAME))
tar_add(tar_file, os.path.join(data_path, 'pritunl.db'))
tar_add(tar_file, os.path.join(data_path, SERVER_CERT_NAME))
tar_add(tar_file, os.path.join(data_path, SERVER_KEY_NAME))
tar_add(tar_file, os.path.join(data_path, VERSION_NAME))
for org in Organization.iter_orgs():
tar_add(tar_file, org.get_path())
tar_file.add(empty_temp_path,
arcname=os.path.relpath(os.path.join(org.path, TEMP_DIR),
data_path))
for user in org.iter_users():
tar_add(tar_file, user.reqs_path)
tar_add(tar_file, user.key_path)
tar_add(tar_file, user.cert_path)
tar_add(tar_file, user.get_path())
tar_add(tar_file, org.ca_cert.reqs_path)
tar_add(tar_file, org.ca_cert.key_path)
tar_add(tar_file, org.ca_cert.cert_path)
tar_add(tar_file, org.ca_cert.get_path())
for server in Server.iter_servers():
tar_add(tar_file, server.dh_param_path)
tar_add(tar_file, server.ip_pool_path)
tar_add(tar_file, server.get_path())
tar_add(tar_file, os.path.join(server.path, NODE_SERVER))
tar_file.add(empty_temp_path,
arcname=os.path.relpath(os.path.join(server.path, TEMP_DIR),
data_path))
tar_file.close()
with open(data_archive_path, 'r') as archive_file:
response = flask.Response(response=archive_file.read(),
mimetype='application/octet-stream')
response.headers.add('Content-Disposition',
'attachment; filename="%s"' % data_archive_name)
return response
finally:
try:
tar_file.close()
except OSError:
pass
try:
os.remove(data_archive_path)
except OSError:
pass