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


Python org_utils.org_get函数代码示例

本文整理汇总了Python中uforgecli.utils.org_utils.org_get函数的典型用法代码示例。如果您正苦于以下问题:Python org_get函数的具体用法?Python org_get怎么用?Python org_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了org_get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: do_list

        def do_list(self, args):
                try:
                        doParser = self.arg_list()
                        doArgs = doParser.parse_args(shlex.split(args))
                        org = org_get(self.api, doArgs.org)

                        allUsergrp = self.api.Usergroups.Getall(Name=org.name)

                        if allUsergrp is None:
                                printer.out("No user groups found.")
                                return 0

                        allUsergrp = allUsergrp.userGroups.userGroup

                        table = Texttable(200)
                        table.set_cols_align(["l", "r"])
                        table.header(["Name", "# Members"])
                        for item in allUsergrp:
                                table.add_row([item.admin.name, str(len(item.members.member))])
                        print table.draw() + "\n"

                        printer.out("Found " + str(len(allUsergrp)) + " user group in [" + org.name + "].")

                        return 0

                except ArgumentParserError as e:
                        printer.out("ERROR: In Arguments: " + str(e), printer.ERROR)
                        self.help_list()
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:uforge-cli,代码行数:30,代码来源:usergrp.py

示例2: do_delete

        def do_delete(self, args):
                try:
                        doParser = self.arg_delete()
                        doArgs = doParser.parse_args(shlex.split(args))

                        org = org_utils.org_get(self.api, doArgs.org)
                        if org is None:
                                printer.out("There is no organization matching ["+doArgs.org+"].", printer.OK)
                                return 0

                        printer.out("Getting target platform with id ["+doArgs.id+"] for ["+org.name+"] . . .")
                        targetPlatform = self.api.Orgs(org.dbId).Targetplatforms(doArgs.id).Get()
                        if targetPlatform is None:
                                printer.out("targetPlatform with id "+ doArgs.id +" does not exist", printer.ERROR)
                                return 2
                        else:
                                result = self.api.Orgs(org.dbId).Targetplatforms(doArgs.id).Delete()
                                printer.out("Target Platform ["+targetPlatform.name+"] has successfully been deleted.", printer.OK)

                        return 0

                except ArgumentParserError as e:
                        printer.out("In Arguments: "+str(e), printer.ERROR)
                        self.help_delete()
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:uforge-cli,代码行数:26,代码来源:org_targetPlatform.py

示例3: do_create

        def do_create(self, args):
                try:
                        doParser = self.arg_create()
                        doArgs = doParser.parse_args(shlex.split(args))
                        org = org_get(self.api, doArgs.org)

                        newUsergrp = userGroup()
                        newUser = user()
                        newUser.loginName = doArgs.name
                        newUser.email = doArgs.email
                        newUser.password = doArgs.usergrpPassword
                        newUsergrp.admin = newUser

                        newUsergrp.members = pyxb.BIND()
                        if doArgs.accounts is not None:
                                for item in doArgs.accounts:
                                        addNewUser = user()
                                        addNewUser.loginName = item
                                        newUsergrp.members.append(addNewUser)
                                        printer.out("[" + addNewUser.loginName + "] has been added to user group.")

                        result = self.api.Usergroups.Create(Org=org.name,body=newUsergrp)
                        printer.out("User group [" + newUser.loginName + "] has been successfully created", printer.OK)
                        return 0

                except ArgumentParserError as e:
                        printer.out("ERROR: In Arguments: " + str(e), printer.ERROR)
                        self.help_create()
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:uforge-cli,代码行数:30,代码来源:usergrp.py

示例4: do_delete

        def do_delete(self, args):
                try:
                        doParser = self.arg_delete()
                        doArgs = doParser.parse_args(shlex.split(args))
                        org = org_get(self.api, doArgs.org)

                        allUsergrp = self.api.Usergroups.Getall(Name=org.name)

                        if allUsergrp is None:
                                printer.out("No user groups found in [" + org.name + "].")
                                return 0

                        allUsergrp = allUsergrp.userGroups.userGroup
                        for item in allUsergrp:
                                if item.admin.name == doArgs.name:
                                        result = self.api.Usergroups(item.dbId).Delete()
                                        printer.out("[" + item.admin.name + "] has been successfully deleted.", printer.OK)
                                        return 0

                        printer.out("[" + doArgs.name + "] was not found in [" + org.name + "].")

                        return 0

                except ArgumentParserError as e:
                        printer.out("ERROR: In Arguments: " + str(e), printer.ERROR)
                        self.help_delete()
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:uforge-cli,代码行数:28,代码来源:usergrp.py

示例5: do_create

        def do_create(self, args):
                try:
                        doParser = self.arg_create()
                        doArgs = doParser.parse_args(shlex.split(args))

                        org = org_utils.org_get(self.api, doArgs.org)
                        allRepo = self.api.Orgs(org.dbId).Repositories.Getall()
                        allRepo = allRepo.repositories.repository

                        for item in allRepo:
                                if doArgs.repoUrl == item.url:
                                        printer.out("The repository with URL [" + item.url + "] already exist in [" + org.name + "].", printer.ERROR)
                                        return 0

                        newRepository = repository()
                        newRepository.url = doArgs.repoUrl
                        newRepository.packagingType = doArgs.type
                        newRepository.name = doArgs.name
                        newRepository.officiallySupported = doArgs.officiallySupported

                        result = self.api.Orgs(org.dbId).Repositories.Create(body=newRepository)
                        printer.out("Successfully created repository with URL [" + doArgs.repoUrl + "] in [" + org.name + "].", printer.OK)
                        return 0

                except ArgumentParserError as e:
                        printer.out("In Arguments: "+str(e), printer.ERROR)
                        self.help_create()
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:uforge-cli,代码行数:29,代码来源:org_repo.py

示例6: do_disable

        def do_disable(self, args):
                try:
                        doParser = self.arg_enable()
                        doArgs = doParser.parse_args(shlex.split(args))

                        printer.out("Getting subscription profile with name [" + doArgs.name + "]...")
                        org = org_utils.org_get(self.api, doArgs.org)
                        subscriptions = self.api.Orgs(org.dbId).Subscriptions().Getall(Search=doArgs.name)

                        exist = False
                        for item in subscriptions.subscriptionProfiles.subscriptionProfile:
                                if item.name == doArgs.name:
                                        exist = True
                                        updated_subscription = subscriptionProfile()
                                        updated_subscription.name = item.name
                                        updated_subscription.code = item.code
                                        if item.active:
                                                updated_subscription.active = False
                                                printer.out("Disabling subscription profile with name [" + doArgs.name + "] ...")
                                                # call UForge API
                                                self.api.Orgs(org.dbId).Subscriptions(item.dbId).Update(updated_subscription)
                                                printer.out("Subscription [" + doArgs.name + "] is disabled.", printer.OK)
                                        else:
                                                printer.out("Subscription [" + doArgs.name + "] is already disabled", printer.WARNING)
                        if not exist:
                                printer.out("Subscription profile requested don't exist in [" + org.name + "]")
                                return 0
                        return 0

                except ArgumentParserError as e:
                        printer.out("ERROR: In Arguments: " + str(e), printer.ERROR)
                        self.help_enable()
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:uforge-cli,代码行数:34,代码来源:subscription.py

示例7: do_create

        def do_create(self, args):
                try:
                        doParser = self.arg_create()
                        doArgs = doParser.parse_args(shlex.split(args))

                        org = org_utils.org_get(self.api, doArgs.org)
                        allCategory = self.api.Orgs(org.dbId).Categories.Getall()
                        allCategory = allCategory.categories.category

                        Exist = False
                        for item in allCategory:
                                if doArgs.name == item.name:
                                        Exist = True
                                        printer.out("A category already have the name ["+doArgs.name+"].", printer.ERROR)
                                        return 0

                        if not Exist:
                                newCategory = category()
                                newCategory.name = doArgs.name
                                newCategory.type = doArgs.type

                                result = self.api.Orgs(org.dbId).Categories.Create(body=newCategory)
                                printer.out("Category ["+newCategory.name+"] has successfully been created.", printer.OK)

                        return 0

                except ArgumentParserError as e:
                        printer.out("In Arguments: "+str(e), printer.ERROR)
                        self.help_create()
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:uforge-cli,代码行数:31,代码来源:org_category.py

示例8: do_list

        def do_list(self, args):
                try:
                        doParser = self.arg_list()
                        doArgs = doParser.parse_args(shlex.split(args))
                        org = org_utils.org_get(self.api, doArgs.org)

                        # call UForge API
                        printer.out("Getting all the subscription profiles for organization ...")
                        subscriptions = self.api.Orgs(org.dbId).Subscriptions().Getall(Search=None)
                        subscriptions = generics_utils.order_list_object_by(subscriptions.subscriptionProfiles.subscriptionProfile, "name")
                        if subscriptions is None or len(subscriptions) == 0:
                                printer.out("There is no subscriptions in [" + org.name + "] ")
                                return 0
                        printer.out("List of subscription profiles in [" + org.name + "] :")
                        table = Texttable(200)
                        table.set_cols_align(["c", "c", "c", "c"])
                        table.header(["Name", "Code", "Active", "description"])
                        for subscription in subscriptions:
                                if subscription.active:
                                        active = "X"
                                else:
                                        active = ""
                                table.add_row([subscription.name, subscription.code, active, subscription.description])
                        print table.draw() + "\n"
                        printer.out("Foumd " + str(len(subscriptions)) + " subscription profile(s).")
                        return 0

                except ArgumentParserError as e:
                        printer.out("ERROR: In Arguments: " + str(e), printer.ERROR)
                        self.help_list()
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:uforge-cli,代码行数:32,代码来源:subscription.py

示例9: do_delete

        def do_delete(self, args):
                try:
                        doParser = self.arg_delete()
                        doArgs = doParser.parse_args(shlex.split(args))

                        org = org_utils.org_get(self.api, doArgs.org)
                        allCategory = self.api.Orgs(org.dbId).Categories.Getall()
                        allCategory = allCategory.categories.category

                        deleteList = []
                        if doArgs.name is not None:
                                for arg1 in doArgs.name:
                                        for item in allCategory:
                                                if arg1 == item.name:
                                                        deleteList.append(item)
                                                        break
                        if doArgs.ids is not None:
                                for arg2 in doArgs.ids:
                                        for item2 in allCategory:
                                                if long(arg2) == item2.dbId:
                                                        deleteList.append(item2)
                                                        break

                        for item3 in deleteList:
                                result = self.api.Orgs(org.dbId).Categories.Delete(Id=item3.dbId)
                                printer.out("Category ["+item3.name+"] has been deleted.", printer.OK)
                        return 0

                except ArgumentParserError as e:
                        printer.out("In Arguments: "+str(e), printer.ERROR)
                        self.help_delete()
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:uforge-cli,代码行数:33,代码来源:org_category.py

示例10: do_list

        def do_list(self, args):
                try:
                        doParser = self.arg_list()
                        doArgs = doParser.parse_args(shlex.split(args))

                        org = org_utils.org_get(self.api, doArgs.org)
                        printer.out("Getting category list for ["+org.name+"] . . .")
                        allCategory = self.api.Orgs(org.dbId).Categories.Getall()
                        allCategory = order_list_object_by(allCategory.categories.category, "name")

                        if len(allCategory) is 0:
                                printer.out("["+org.name+"] has no categories.")
                                return 0

                        table = Texttable(200)
                        table.set_cols_align(["l", "l", "l"])
                        table.header(["Id", "Category", "type"])

                        for item in allCategory:
                                table.add_row([item.dbId, item.name, item.type])
                        print table.draw() + "\n"
                        printer.out("Found " + str(len(allCategory)) + " categories.")
                        return 0

                except ArgumentParserError as e:
                        printer.out("In Arguments: "+str(e), printer.ERROR)
                        self.help_list()
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:uforge-cli,代码行数:29,代码来源:org_category.py

示例11: do_create

        def do_create(self, args):
                try:
                        # add arguments
                        doParser = self.arg_create()
                        doArgs = doParser.parse_args(shlex.split(args))

                        printer.out("Creating role [" + doArgs.name + "] ...")
                        org = org_utils.org_get(self.api, doArgs.org)

                        new_role = role()
                        new_role.name = doArgs.name
                        if doArgs.description:
                                new_role.description = doArgs.description
                        if doArgs.entitlements:
                                if doArgs.entitlements is not None:
                                        new_role.entitlements = pyxb.BIND()
                                        entList = self.api.Entitlements.Getall()
                                        entList = entList.entitlements.entitlement
                                        entList = compare(entList, doArgs.entitlements, "name")
                                        for ent in entList:
                                                add_entitlement = entitlement()
                                                add_entitlement.name = ent.name
                                                add_entitlement.description = ent.description
                                                new_role.entitlements.append(add_entitlement)
                                                printer.out("Entitlement " + ent.name + " added to the role")

                        self.api.Orgs(org.dbId).Roles().Create(new_role)
                        printer.out("Role [" + new_role.name + "] was correctly created", printer.OK)
                        return 0
                except ArgumentParserError as e:
                        printer.out("ERROR: In Arguments: " + str(e), printer.ERROR)
                        self.help_create()
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:uforge-cli,代码行数:34,代码来源:role.py

示例12: do_list

        def do_list(self, args):
                try:
                        doParser = self.arg_list()
                        doArgs = doParser.parse_args(shlex.split(args))

                        org = org_utils.org_get(self.api, doArgs.org)
                        printer.out("Getting user list for ["+org.name+"] . . .")
                        allUsers = self.api.Orgs(org.dbId).Members.Getall()
                        allUsers = order_list_object_by(allUsers.users.user, "loginName")

                        table = Texttable(200)
                        table.set_cols_align(["l", "l", "c"])
                        table.header(["Login", "Email", "Active"])

                        for item in allUsers:
                                if item.active:
                                        active = "X"
                                else:
                                        active = ""
                                table.add_row([item.loginName, item.email, active])

                        print table.draw() + "\n"
                        return 0

                except ArgumentParserError as e:
                        printer.out("In Arguments: "+str(e), printer.ERROR)
                        self.help_list()
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:uforge-cli,代码行数:29,代码来源:org_user.py

示例13: do_create

        def do_create(self, args):
                try:
                        doParser = self.arg_create()
                        doArgs = doParser.parse_args(shlex.split(args))

                        org = org_utils.org_get(self.api, doArgs.org)
                        allDist = self.api.Orgs(org.dbId).Distributions.Getall()
                        allDist = allDist.distributions.distribution

                        goldenId = None
                        for distrib in allDist:
                                if distrib.name == doArgs.name and distrib.version == doArgs.version and distrib.arch == doArgs.arch:
                                        goldenId = distrib.dbId

                        if goldenId is None:
                                printer.out("No distributions found with the arguments entered.")
                                return 0

                        result = self.api.Orgs(org.dbId).Distributions(goldenId).Goldens.Create(Language=doArgs.language, Edition=doArgs.edition, Type=doArgs.type, Goldendate=doArgs.goldenDate, Filename=doArgs.goldenName, body=None)
                        printer.out("Golden image [" + result.name + "] has been created", printer.OK)
                        return 0

                except ArgumentParserError as e:
                        printer.out("In Arguments: "+str(e), printer.ERROR)
                        self.help_create()
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:uforge-cli,代码行数:27,代码来源:org_golden.py

示例14: do_delete

        def do_delete(self, args):
                try:
                        # add arguments
                        doParser = self.arg_delete()
                        doArgs = doParser.parse_args(shlex.split(args))

                        printer.out("Deleting subscription profile [" + doArgs.name + "] ...")
                        org = org_utils.org_get(self.api, doArgs.org)

                        # call UForge API
                        subscriptions = self.api.Orgs(org.dbId).Subscriptions().Getall(Search=None)

                        exist = False
                        for item in subscriptions.subscriptionProfiles.subscriptionProfile:
                                if item.name == doArgs.name:
                                        exist = True
                                        subscription = subscriptions.subscriptionProfiles.subscriptionProfile[0]
                                        self.api.Orgs(org.dbId).Subscriptions(subscription.dbId).Remove(None)
                                        printer.out("Subscription profile [" + doArgs.name + "] deleted", printer.OK)

                        if not exist:
                                printer.out("Subscription profile requested don't exist in [" + org.name + "]")
                                return 0
                        return 0

                except ArgumentParserError as e:
                        printer.out("ERROR: In Arguments: " + str(e), printer.ERROR)
                        self.help_delete()
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:uforge-cli,代码行数:30,代码来源:subscription.py

示例15: do_enable

        def do_enable(self, args):
                try:
                        doParser = self.arg_enable()
                        doArgs = doParser.parse_args(shlex.split(args))
                        org = org_utils.org_get(self.api, doArgs.org)
                        if org is None:
                                printer.out("There is no organization matching ["+doArgs.org+"].", printer.OK)
                                return 0

                        targetPlatformsOrg = self.api.Orgs(org.dbId).Targetplatforms.Getall()
                        if targetPlatformsOrg is None or len(targetPlatformsOrg.targetPlatforms.targetPlatform) == 0:
                                printer.out("There is no target platform for the user \""+doArgs.account+"\" in [" + org.name + "].")
                                return 0
                        else:
                                targetPlatformsOrg = targetPlatformsOrg.targetPlatforms.targetPlatform

                                targetPlatformsList = targetPlatforms()
                                targetPlatformsList.targetPlatforms = pyxb.BIND()

                                targetPlatformsOrg = compare(targetPlatformsOrg, doArgs.targetPlatforms, "name")

                                if len(targetPlatformsOrg) == 0:
                                        listName = ""
                                        for tpname in doArgs.targetPlatforms:
                                                listName = listName + tpname + " "
                                        printer.out("There is no target platforms matching ["+listName+"].")
                                        return 0

                                for item in targetPlatformsOrg:
                                        targetPlatformToEnable = targetPlatform()
                                        targetPlatformToEnable = item
                                        targetPlatformToEnable.active = True
                                        targetPlatformToEnable.access = True
                                        printer.out("Enabling ["+item.name+"].")
                                        targetPlatformsList.targetPlatforms.append(targetPlatformToEnable)

                                result = self.api.Users(doArgs.account).Targetplatforms.Update(Org=org.name,body=targetPlatformsList)
                                result =generics_utils.order_list_object_by(result.targetPlatforms.targetPlatform, "name")

                                table = Texttable(200)
                                table.set_cols_align(["c", "c", "c", "c"])
                                table.header(["Id", "Name", "Type", "Access"])

                                for item in result:
                                        if item.access:
                                                access = "X"
                                        else:
                                                access = ""
                                        table.add_row([item.dbId, item.name, item.type, access])

                                printer.out("Target Platform list for user \""+doArgs.account+"\" :")
                                print table.draw() + "\n"
                        return 0

                except ArgumentParserError as e:
                        printer.out("In Arguments: "+str(e), printer.ERROR)
                        self.help_enable()
                except Exception as e:
                        return handle_uforge_exception(e)
开发者ID:DimitriSCOLE,项目名称:uforge-cli,代码行数:59,代码来源:user_targetPlatform.py


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