当前位置: 首页>>代码示例>>Python>>正文


Python Organization.get_user方法代码示例

本文整理汇总了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)
开发者ID:CorbettBaker-Company,项目名称:pritunl,代码行数:54,代码来源:server.py

示例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,
            ))
开发者ID:cDoru,项目名称:pritunl,代码行数:46,代码来源:server.py

示例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()
开发者ID:CorbettBaker-Company,项目名称:pritunl,代码行数:23,代码来源:server.py

示例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()
开发者ID:cDoru,项目名称:pritunl,代码行数:26,代码来源:server.py


注:本文中的organization.Organization.get_user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。