本文整理汇总了Python中organization.Organization.get_user方法的典型用法代码示例。如果您正苦于以下问题:Python Organization.get_user方法的具体用法?Python Organization.get_user怎么用?Python Organization.get_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类organization.Organization
的用法示例。
在下文中一共展示了Organization.get_user方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _generate_ovpn_conf
# 需要导入模块: from organization import Organization [as 别名]
# 或者: from organization.Organization import get_user [as 别名]
def _generate_ovpn_conf(self):
if not self.get_orgs():
raise ValueError("Ovpn conf cannot be generated without " + "any organizations")
logger.debug("Generating server ovpn conf. %r" % {"server_id": self.id})
if not self.primary_organization or not self.primary_user:
self._create_primary_user()
if not os.path.isfile(self.dh_param_path):
self._generate_dh_param()
primary_org = Organization(self.primary_organization)
primary_user = primary_org.get_user(self.primary_user)
self.generate_ca_cert()
self._generate_tls_verify()
self._generate_user_pass_verify()
if self.local_network:
push = "route %s %s" % self._parse_network(self.local_network)
else:
push = "redirect-gateway"
server_conf = OVPN_SERVER_CONF % (
self.port,
self.protocol,
self.interface,
self.ca_cert_path,
primary_user.cert_path,
primary_user.key_path,
self.tls_verify_path,
self.dh_param_path,
"%s %s" % self._parse_network(self.network),
self.ifc_pool_path,
push,
self.ovpn_status_path,
4 if self.debug else 1,
8 if self.debug else 3,
)
if self.otp_auth:
server_conf += "auth-user-pass-verify %s via-file\n" % (self.user_pass_verify_path)
if self.lzo_compression:
server_conf += 'comp-lzo\npush "comp-lzo"\n'
if self.local_network:
server_conf += "client-to-client\n"
with open(self.ovpn_conf_path, "w") as ovpn_conf:
ovpn_conf.write(server_conf)
示例2: _generate_ovpn_conf
# 需要导入模块: from organization import Organization [as 别名]
# 或者: from organization.Organization import get_user [as 别名]
def _generate_ovpn_conf(self):
if not self.get_orgs():
raise ValueError('Ovpn conf cannot be generated without ' + \
'any organizations')
logger.debug('Generating server ovpn conf. %r' % {
'server_id': self.id,
})
if not self.primary_organization or not self.primary_user:
self._create_primary_user()
if not os.path.isfile(self.dh_param_path):
self._generate_dh_param()
primary_org = Organization(self.primary_organization)
primary_user = primary_org.get_user(self.primary_user)
self.generate_ca_cert()
self._generate_tls_verify()
if self.local_network:
push = 'route %s %s' % self._parse_network(
self.local_network)
else:
push = 'redirect-gateway'
with open(self.ovpn_conf_path, 'w') as ovpn_conf:
ovpn_conf.write(OVPN_SERVER_CONF % (
self.port,
self.protocol,
self.interface,
self.ca_cert_path,
primary_user.cert_path,
primary_user.key_path,
self.tls_verify_path,
self.dh_param_path,
'%s %s' % self._parse_network(self.network),
self.ifc_pool_path,
push,
self.ovpn_status_path,
4 if self.debug else 1,
8 if self.debug else 3,
))
示例3: _remove_primary_user
# 需要导入模块: from organization import Organization [as 别名]
# 或者: from organization.Organization import get_user [as 别名]
def _remove_primary_user(self):
logger.debug("Removing primary user. %r" % {"server_id": self.id})
primary_organization = self.primary_organization
primary_user = self.primary_user
self.primary_organization = None
self.primary_user = None
if not primary_organization or not primary_user:
return
org = Organization(primary_organization)
user = org.get_user(primary_user)
if not user:
logger.debug(
"Primary user not found, skipping remove. %r"
% {"server_id": self.id, "org_id": org.id, "user_id": user.id}
)
return
if user:
user.remove()
示例4: _remove_primary_user
# 需要导入模块: from organization import Organization [as 别名]
# 或者: from organization.Organization import get_user [as 别名]
def _remove_primary_user(self):
logger.debug('Removing primary user. %r' % {
'server_id': self.id,
})
primary_organization = self.primary_organization
primary_user = self.primary_user
self.primary_organization = None
self.primary_user = None
if not primary_organization or not primary_user:
return
org = Organization(primary_organization)
user = org.get_user(primary_user)
if not user:
logger.debug('Primary user not found, skipping remove. %r' % {
'server_id': self.id,
'org_id': org.id,
'user_id': user.id,
})
return
if user:
user.remove()