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


Python Default.get_cloud方法代码示例

本文整理汇总了Python中cloudmesh_client.cloud.default.Default.get_cloud方法的典型用法代码示例。如果您正苦于以下问题:Python Default.get_cloud方法的具体用法?Python Default.get_cloud怎么用?Python Default.get_cloud使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cloudmesh_client.cloud.default.Default的用法示例。


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

示例1: do_quota

# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get_cloud [as 别名]
    def do_quota(self, args, arguments):
        """
        ::

            Usage:
                quota list [--cloud=CLOUD] [--tenant=TENANT] [--format=FORMAT]

                Prints quota limit on a current project/tenant

            Options:
               --format=FORMAT  the output format [default: table]
               --cloud=CLOUD    the cloud name
               --tenant=TENANT  the tenant id

            Examples:
                cm quota list
                cm quota list --cloud=india --format=csv

        """
        if arguments["list"]:
            cloud = arguments["--cloud"] or Default.get_cloud()

            if not cloud:
                Console.error("Default cloud doesn't exist")
                return
            tenant = arguments["--tenant"]
            output_format = arguments["--format"]
            list_quotas = Quota.list(cloud,
                                     tenant,
                                     output=output_format)
            Console.msg(list_quotas)
            return
开发者ID:atavism,项目名称:client,代码行数:34,代码来源:QuotaCommand.py

示例2: do_check

# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get_cloud [as 别名]
    def do_check(self, args, arguments):
        """
        ::

            Usage:
                check --cloud=CLOUD
                check

                checks some elementary setting for cloudmesh

            Options:
               --format=FORMAT  the output format [default: table]
               --cloud=CLOUD    the cloud name

            Examples:
                cm check
                cm check --cloud=kilo

        """
        cloud = arguments["--cloud"] or Default.get_cloud()

        if cloud is None:
            Console.error("Default cloud doesn't exist")

        print(locals())

        Console.ok("{:} ok".format(cloud))

        return ""
开发者ID:rajaramcomputers,项目名称:client,代码行数:31,代码来源:CheckCommand.py

示例3: do_cloud

# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get_cloud [as 别名]
    def do_cloud(self, args, arguments):
        """
        ::

          Usage:
              cloud list [--cloud=CLOUD] [--format=FORMAT]
              cloud activate CLOUD
              cloud deactivate CLOUD
              cloud info CLOUD

          managing the admins test test test test

          Arguments:
            KEY    the name of the admin
            VALUE  the value to set the key to

          Options:
             --cloud=CLOUD    the name of the cloud [default: general]
             --format=FORMAT  the output format [default: table]

          Description:
             Cloudmesh contains a cloudmesh.yaml file that contains
             templates for multiple clouds that you may or may not have
             access to. Hence it is useful to activate and deacivate clouds
             you like to use in other commands.

             To activate a cloud a user can simply use the activate
             command followed by the name of the cloud to be
             activated. To find out which clouds are available you can
             use the list command that will provide you with some
             basic information. As default it will print a table. Thus
             the commands::

               cloud activate india
               cloud deactivate aws

             Will result in

                +----------------------+--------+-------------------+
                | Cloud name           | Active | Type              |
                +----------------------+--------+-------------------+
                | india                | True   | Openstack         |
                +----------------------+--------+-------------------+
                | aws                  | False  | AWS               |
                +----------------------+--------+-------------------+

             To get ore information about the cloud you can use the command

                cloud info CLOUD

             It will call internally also the command uses in register

          See also:
             register
        """
        # pprint(arguments)
        cloud = arguments["--cloud"] or Default.get_cloud()
        output_format = arguments["--format"]
        Console.error("TODO: Command not yet implemented.")
        pass
开发者ID:atavism,项目名称:client,代码行数:62,代码来源:CloudCommand.py

示例4: do_limits

# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get_cloud [as 别名]
    def do_limits(self, args, arguments):
        """
        ::

            Usage:
                limits list [--cloud=CLOUD] [--tenant=TENANT] [--format=FORMAT]

                Current list data with limits on a selected project/tenant.
                The --tenant option can be used by admin only

            Options:
               --format=FORMAT  the output format [default: table]
               --cloud=CLOUD    the cloud name
               --tenant=TENANT  the tenant name

            Examples:
                cm limits list
                cm limits list --cloud=juno --format=csv

        """
        if arguments["list"]:
            cloud = arguments["--cloud"] or Default.get_cloud()

            if not cloud:
                Console.error("cloud doesn't exist")
                return ""

            output_format = arguments["--format"]
            tenant = arguments["--tenant"]
            result = Limits.list(cloud,
                                 output=output_format,
                                 tenant=tenant)
            Console.msg(result)
            return ""
开发者ID:atavism,项目名称:client,代码行数:36,代码来源:LimitsCommand.py

示例5: do_flavor

# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get_cloud [as 别名]
    def do_flavor(self, args, arguments):
        """
        ::

            Usage:
                flavor refresh [--cloud=CLOUD]
                flavor list [ID] [--cloud=CLOUD] [--format=FORMAT] [--refresh]

                This lists out the flavors present for a cloud

            Options:
               --format=FORMAT  the output format [default: table]
               --cloud=CLOUD    the cloud name
               --refresh        refreshes the data before displaying it
                                from the cloud

            Examples:
                cm flavor refresh
                cm flavor list
                cm flavor list --format=csv
                cm flavor show 58c9552c-8d93-42c0-9dea-5f48d90a3188 --refresh

        """

        cloud = arguments["--cloud"] or Default.get_cloud()
        if cloud is None:
            Console.error("Default cloud doesn't exist")
            return

        if arguments["refresh"]:
            msg = "Refresh flavor for cloud {:}.".format(cloud)
            if Flavor.refresh(cloud):
                Console.ok("{:} ok".format(msg))
            else:
                Console.error("{:} failed".format(msg))
            return ""

        if arguments["list"]:
            cluster_id = arguments['ID']
            refresh = arguments['--refresh']
            output_format = arguments["--format"]

            if cluster_id is None:
                result = Flavor.list(cloud, output_format)
            else:
                result = Flavor.details(cloud, cluster_id, refresh, output_format)

            if result is None:
                #
                # outo refresh
                #
                Console.error("No flavor(s) found. Failed")
                # Flavor.refresh(cloud)
                # Console.ok("Refreshing flavor(s). ok.")

            else:

                print(result)
            return ""
开发者ID:atavism,项目名称:client,代码行数:61,代码来源:FlavorCommand.py

示例6: test_002

# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get_cloud [as 别名]
    def test_002(self):
        """
        set default cloud
        :return:
        """
        HEADING()
        result = Default.list()
        print(result)

        name = "mycloud"
        Default.set_cloud(name)

        result = Default.list()
        print(result)

        print    ("KKK", Default.get_cloud())


        assert Default.get_cloud() == name
        self._check(name)
开发者ID:atavism,项目名称:client,代码行数:22,代码来源:test_default.py

示例7: do_image

# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get_cloud [as 别名]
    def do_image(self, args, arguments):
        """
        ::

            Usage:
                image refresh [--cloud=CLOUD]
                image list [ID] [--cloud=CLOUD] [--format=FORMAT] [--refresh]

                This lists out the images present for a cloud

            Options:
               --format=FORMAT  the output format [default: table]
               --cloud=CLOUD    the cloud name
               --refresh        live data taken from the cloud

            Examples:
                cm image refresh
                cm image list
                cm image list --format=csv
                cm image list 58c9552c-8d93-42c0-9dea-5f48d90a3188 --refresh

        """
        cloud = arguments["--cloud"] or Default.get_cloud()
        if cloud is None:
            Console.error("Default cloud doesn't exist")
            return

        if arguments["refresh"] or Default.refresh():
            msg = "Refresh image for cloud {:}.".format(cloud)
            if Image.refresh(cloud):
                Console.ok("{:} ok.".format(msg))
            else:
                Console.error("{:} failed.".format(msg))
            return ""

        if arguments["list"]:
            id = arguments['ID']
            live = arguments['--refresh']
            output_format = arguments["--format"]
            if id is None:
                result = Image.list(cloud, output_format)
            else:
                result = Image.details(cloud, id, live, output_format)
            if result is None:
                Console.error("No image(s) found. Failed.")
            # Todo:
            # if database size = 0:
            #    Console.error("No images in the database, please refresh.")
            print(result)
            return ""
开发者ID:rajaramcomputers,项目名称:client,代码行数:52,代码来源:ImageCommand.py

示例8: do_sync

# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get_cloud [as 别名]
    def do_sync(self, args, arguments):
        """
        ::
        
            Usage:
                sync put [--cloud=CLOUD] [--group=GROUP] LOCALDIR [REMOTEDIR]
                sync get [--cloud=CLOUD] [--group=GROUP] REMOTEDIR LOCALDIR
                sync put [--server=SERVER] [--group=GROUP] LOCALDIR [REMOTEDIR]
                sync get [--server=SERVER] [--group=GROUP] REMOTEDIR LOCALDIR

            A simple wrapper for the openstack nova command

            Arguments:
                LOCALDIR        A directory on local machine
                REMOTEDIR       A directory on remote machine

            Options:
                --cloud=CLOUD   Sync with cloud

        """
        cloudname = arguments["--cloud"] or Default.get_cloud()

        if cloudname is None:
            Console.error("Default cloud has not been set!"
                          "Please use the following to set it:\n"
                          "cm default cloud=CLOUDNAME\n"
                          "or provide it via the --cloud=CLOUDNAME argument.")
            return

        # Get the arguments
        group = arguments["--group"] or Default.get("group", cloudname)

        localdir = arguments["LOCALDIR"]
        remotedir = arguments["REMOTEDIR"]

        if arguments["put"]:
            # validate local directory exists
            if localdir is None:
                Console.error("Please provide the [LOCALDIR] argument.")
                return ""

            result = Sync.sync(cloudname=cloudname,
                               localdir=localdir,
                               remotedir=remotedir,
                               operation="put")

            if result is not None:
                Console.ok("Successuly synced local and remote directories.")

        elif arguments["get"]:
            # validate local directory exists
            if localdir is None:
                Console.error("Please provide the [LOCALDIR] argument.")
                return ""

            result = Sync.sync(cloudname=cloudname,
                               localdir=localdir,
                               remotedir=remotedir,
                               operation="get")

            if result is not None:
                Console.ok("Successuly synced local and remote directories.")

        return ""
开发者ID:atavism,项目名称:client,代码行数:66,代码来源:SyncCommand.py

示例9: do_secgroup

# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get_cloud [as 别名]
    def do_secgroup(self, args, arguments):
        """
        ::

            Usage:
                secgroup list [--cloud=CLOUD] [--tenant=TENANT]
                secgroup create [--cloud=CLOUD] [--tenant=TENANT] LABEL
                secgroup delete [--cloud=CLOUD] [--tenant=TENANT] LABEL
                secgroup rules-list [--cloud=CLOUD] [--tenant=TENANT] LABEL
                secgroup rules-add [--cloud=CLOUD] [--tenant=TENANT] LABEL FROMPORT TOPORT PROTOCOL CIDR
                secgroup rules-delete [--cloud=CLOUD] [--tenant=TENANT] LABEL FROMPORT TOPORT PROTOCOL CIDR
                secgroup -h | --help
                secgroup --version

            Options:
                -h                  help message
                --cloud=CLOUD       Name of the IaaS cloud e.g. india_openstack_grizzly.
                --tenant=TENANT     Name of the tenant, e.g. fg82.

            Arguments:
                LABEL         The label/name of the security group
                FROMPORT      Staring port of the rule, e.g. 22
                TOPORT        Ending port of the rule, e.g. 22
                PROTOCOL      Protocol applied, e.g. TCP,UDP,ICMP
                CIDR          IP address range in CIDR format, e.g., 129.79.0.0/16

            Description:
                security_group command provides list/add/delete
                security_groups for a tenant of a cloud, as well as
                list/add/delete of rules for a security group from a
                specified cloud and tenant.


            Examples:
                $ secgroup list --cloud india --tenant fg82
                $ secgroup rules-list --cloud india --tenant fg82 default
                $ secgroup create --cloud india --tenant fg82 webservice
                $ secgroup rules-add --cloud india --tenant fg82 webservice 8080 8088 TCP "129.79.0.0/16"

        """
        # pprint(arguments)

        cloud = arguments["--cloud"] or Default.get_cloud()

        if arguments["list"]:
            # if no arguments read default
            tenant = arguments["--tenant"] or Default.get("tenant")

            # If default not set, terminate
            if not cloud:
                Console.error("Default cloud not set!")
                return
            if not tenant:
                Console.error("Default tenant not set!")
                return ""

            result = SecGroup.list(tenant, cloud)
            if result:
                print(result)
            else:
                Console.error(
                    "No Security Groups found in the cloudmesh database!")
            return ""

        elif arguments["create"]:
            # if no arguments read default
            tenant = arguments["--tenant"] or Default.get("tenant", cloud)
            label = arguments["LABEL"]

            # If default not set, terminate
            if not cloud:
                Console.error("Default cloud not set!")
                return
            if not tenant:
                Console.error("Default tenant not set!")
                return ""

            # Create returns uuid of created sec-group
            uuid = SecGroup.create(label, cloud, tenant)

            if uuid:
                Console.ok("Created a new security group [{}] with UUID [{}]"
                           .format(label, uuid))
            else:
                Console.error("Exiting!")
            return ""

        elif arguments["delete"]:
            # if no arguments read default
            tenant = arguments["--tenant"] or Default.get("tenant", cloud)
            label = arguments["LABEL"]

            # If default not set, terminate
            if not cloud:
                Console.error("Default cloud not set!")
                return ""
            if not tenant:
                Console.error("Default tenant not set!")
                return ""

#.........这里部分代码省略.........
开发者ID:atavism,项目名称:client,代码行数:103,代码来源:SecgroupCommand.py

示例10: print

# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get_cloud [as 别名]
                print(traceback.format_exc())
                print(e)
                Console.error("Problem booting instance {:}".format(name))

        elif arguments["default"]:
            try:
                count = Counter.get()
                prefix = Username()

                if prefix is None or count is None:
                    Console.error("Prefix and Count could not be retrieved correctly.")
                    return

                vm_name = prefix + "-" + str(count).zfill(3)
                data = {"name": vm_name,
                        "cloud": arguments["--cloud"] or Default.get_cloud()}
                for attribute in ["image", "flavor", "key", "login_key", "group", "secgroup"]:
                    data[attribute] = Default.get(attribute, cloud=cloud)
                output_format = arguments["--format"] or "table"
                print (attribute_printer(data, output=output_format))
                msg = "info. OK."
                Console.ok(msg)
                ValueError("default command not implemented properly. Upon "
                           "first install the defaults should be read from yaml.")
            except Exception, e:
                import traceback
                print(traceback.format_exc())
                print(e)
                Console.error("Problem listing defaults")

        elif arguments["status"]:
开发者ID:rajaramcomputers,项目名称:client,代码行数:33,代码来源:VmCommand.py

示例11: do_select

# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get_cloud [as 别名]
    def do_select(self, args, arguments):
        """
        ::

          Usage:
              select image [CLOUD]
              select flavor [CLOUD]
              select cloud [CLOUD]
              select key [CLOUD]

          selects interactively the default values

          Arguments:

            CLOUD    the name of the cloud

          Options:

        """
        # pprint(arguments)
        cloud = arguments["CLOUD"] or Default.get_cloud()
        if arguments["image"]:
            try:
                image_dict = Image.list(cloud, format="dict")

                image_names = list()
                for image in image_dict.values():
                    image_names.append(image["name"])

                number = menu_return_num(title="Select an Image",
                                         menu_list=image_names,
                                         tries=10,
                                         with_display=True)

                if number == "q":
                    pass
                else:
                    image = image_names[number]
                    print("Selected image " + image)
                    Default.set("image", image, cloud=cloud)
            except:
                print("ERROR: could not set image.")

        elif arguments["flavor"]:
            try:
                flavor_dict = Flavor.list(cloud, format="dict")

                flavor_names = list()
                for flavor in flavor_dict.values():
                    flavor_names.append(flavor["name"])

                number = menu_return_num(title="Select a Flavor",
                                         menu_list=flavor_names,
                                         tries=10,
                                         with_display=True)

                if number == "q":
                    pass
                else:
                    flavor = flavor_names[number]
                    print("Selected flavor " + flavor)
                    Default.set("flavor", flavor, cloud=cloud)
            except:
                print("ERROR: could not set flavor.")

        elif arguments["cloud"]:
            try:
                config = ConfigDict("cloudmesh.yaml")
                clouds = config["cloudmesh"]["clouds"]

                for key in clouds.keys():
                    Console.ok("  " + key)

                number = menu_return_num(title="Select a cloud",
                                         menu_list=clouds.keys(),
                                         tries=10,
                                         with_display=True)
                if number == "q":
                    pass
                else:
                    cloud = clouds.keys()[number]
                    print("Selected cloud " + cloud)
                    Default.set("cloud", cloud, "general")
            except:
                print("ERROR: could not set cloud.")

        elif arguments["key"]:
            try:
                db = SSHKeyDBManager()

                key_dict = db.table_dict()

                key_names = list()
                for key in key_dict.values():
                    key_names.append(key["name"])

                number = menu_return_num(title="Select a Key",
                                         menu_list=key_names,
                                         tries=10,
                                         with_display=True)
#.........这里部分代码省略.........
开发者ID:rajaramcomputers,项目名称:client,代码行数:103,代码来源:SelectCommand.py

示例12: do_launcher

# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get_cloud [as 别名]
    def do_launcher(self, args, arguments):
        """
        ::

          Usage:
              launcher list [--cloud=CLOUD] [--format=FORMAT] [--all]
              launcher delete KEY [--cloud=CLOUD]
              launcher run
              launcher resume
              launcher suspend
              launcher details
              launcher clear
              launcher refresh

          Arguments:

            KEY    the name of the launcher

          Options:

             --cloud=CLOUD    the name of the cloud
             --format=FORMAT  the output format [launcher: table]
             --all            lists all the launcher values

        Description:

        Launcher is a command line tool to test the portal launch functionalities through command

        The current launcher values can by listed with --all option:(
        if you have a launcher cloud specified. You can also add a
        cloud parameter to apply the command to a specific cloud)

               launcher list

            A launcher can be deleted with

                launcher delete KEY


        Examples:
            launcher list --all
            launcher list --cloud=general
            launcher delete <KEY>
        """
        # pprint(arguments)

        cloud = arguments["--cloud"] or Default.get_cloud()
        launcher = Launcher(kind=None)

        if cloud is None:
            Console.error("Default cloud not set")
            return

        if arguments["list"]:
            result = launcher.list()
            print(result)

        elif arguments["delete"]:
            result = launcher.delete()
            print(result)

        elif arguments["run"]:
            result = launcher.run()
            print(result)

        elif arguments["resume"]:
            result = launcher.resume()
            print(result)

        elif arguments["suspend"]:
            result = launcher.suspend()
            print(result)

        elif arguments["details"]:
            result = launcher.details()
            print(result)

        elif arguments["clear"]:
            result = launcher.clear()
            print(result)

        elif arguments["refresh"]:
            result = launcher.refresh()
            print(result)
开发者ID:atavism,项目名称:client,代码行数:86,代码来源:LauncherCommand.py

示例13: do_nova

# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get_cloud [as 别名]
    def do_nova(self, args, arguments):
        """
        ::
        
            Usage:
                nova set CLOUD
                nova info [CLOUD] [--password]
                nova help
                nova [--group=GROUP] ARGUMENTS...

            A simple wrapper for the openstack nova command

            Arguments:
                GROUP           The group to add vms to
                ARGUMENTS       The arguments passed to nova
                help            Prints the nova manual
                set             reads the information from the current cloud
                                and updates the environment variables if
                                the cloud is an openstack cloud
                info            the environment values for OS

            Options:
                --group=GROUP   Add VM to GROUP group
                --password      Prints the password
                -v              verbose mode

        """
        # pprint(arguments)
        cloud = arguments['CLOUD'] or Default.get_cloud()
        if not cloud:
            Console.error("Default cloud not set!")
            return ""

        group = arguments["--group"] or Default.get("group", cloud=cloud)

        if not group:
            Console.error("Default group not set!")
            return ""

        if arguments["help"]:
            os.system("nova help")
            return ""
        elif arguments["info"]:
            set_os_environ(cloud)
            d = {}
            #
            # TODO: this naturally does not work as clouds will have
            # different parameters. ALos it does not unset previous
            # parameters from other clouds. See register
            #
            for attribute in ['OS_USERNAME',
                              'OS_TENANT_NAME',
                              'OS_AUTH_URL',
                              'OS_CACERT',
                              'OS_PASSWORD',
                              'OS_REGION']:
                try:
                    d[attribute] = os.environ[attribute]
                except:
                    Console.warning("OS environment variable {:} not found"
                                    .format(attribute))
                    d[attribute] = None
                if not arguments["--password"]:
                    d['OS_PASSWORD'] = "********"
            print(row_table(d, order=None, labels=["Variable", "Value"]))
            msg = "info. OK."
            Console.ok(msg)
            return ""
        elif arguments["set"]:
            if cloud:

                set_os_environ(cloud)

                msg = "{0} is set".format(cloud)
                Console.ok(msg)
            else:
                Console.error("CLOUD is required")

        else:  # nova ARGUMENTS...
            print("Cloud = {0}".format(cloud))
            try:
                set_os_environ(cloud)
                args = arguments["ARGUMENTS"]

                # arguments may contain multiple optional arguments
                if len(args) == 1:
                    args = args[0].split()

                result = Shell.execute("nova", args)

                print(Nova.remove_subjectAltName_warning(result))

                """
                If request for nova boot,
                add the vm to group specified,
                or else add to default group
                """
                if "boot" in args:
                    # Logic to find ID of VM in the result
                    fields = []
#.........这里部分代码省略.........
开发者ID:atavism,项目名称:client,代码行数:103,代码来源:NovaCommand.py

示例14: do_network

# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get_cloud [as 别名]
    def do_network(self, args, arguments):
        """
        ::

            Usage:
                network get fixed [ip] [--cloud=CLOUD] FIXED_IP
                network get floating [ip] [--cloud=CLOUD] FLOATING_IP_ID
                network reserve fixed [ip] [--cloud=CLOUD] FIXED_IP
                network unreserve fixed [ip] [--cloud=CLOUD] FIXED_IP
                network associate floating [ip] [--cloud=CLOUD] [--group=GROUP] [--instance=INS_ID_OR_NAME] [FLOATING_IP]
                network disassociate floating [ip] [--cloud=CLOUD] [--group=GROUP] [--instance=INS_ID_OR_NAME] [FLOATING_IP]
                network create floating [ip] [--cloud=CLOUD] [--pool=FLOATING_IP_POOL]
                network delete floating [ip] [--cloud=CLOUD] FLOATING_IP...
                network list floating pool [--cloud=CLOUD]
                network list floating [ip] [--cloud=CLOUD] [--instance=INS_ID_OR_NAME] [IP_OR_ID]
                network create cluster --group=demo_group
                network -h | --help

            Options:
                -h                          help message
                --cloud=CLOUD               Name of the IaaS cloud e.g. india_openstack_grizzly.
                --group=GROUP               Name of the group in Cloudmesh
                --pool=FLOATING_IP_POOL     Name of Floating IP Pool
                --instance=INS_ID_OR_NAME   ID or Name of the vm instance

            Arguments:
                IP_OR_ID        IP Address or ID of IP Address
                FIXED_IP        Fixed IP Address, e.g. 10.1.5.2
                FLOATING_IP     Floating IP Address, e.g. 192.1.66.8
                FLOATING_IP_ID  ID associated with Floating IP, e.g. 185c5195-e824-4e7b-8581-703abec4bc01

            Examples:
                $ network get fixed ip --cloud=india 10.1.2.5
                $ network get fixed --cloud=india 10.1.2.5
                $ network get floating ip --cloud=india 185c5195-e824-4e7b-8581-703abec4bc01
                $ network get floating --cloud=india 185c5195-e824-4e7b-8581-703abec4bc01
                $ network reserve fixed ip --cloud=india 10.1.2.5
                $ network reserve fixed --cloud=india 10.1.2.5
                $ network unreserve fixed ip --cloud=india 10.1.2.5
                $ network unreserve fixed --cloud=india 10.1.2.5
                $ network associate floating ip --cloud=india --instance=albert-001 192.1.66.8
                $ network associate floating --cloud=india --instance=albert-001
                $ network associate floating --cloud=india --group=albert_group
                $ network disassociate floating ip --cloud=india --instance=albert-001 192.1.66.8
                $ network disassociate floating --cloud=india --instance=albert-001 192.1.66.8
                $ network create floating ip --cloud=india --pool=albert-f01
                $ network create floating --cloud=india --pool=albert-f01
                $ network delete floating ip --cloud=india 192.1.66.8 192.1.66.9
                $ network delete floating --cloud=india 192.1.66.8 192.1.66.9
                $ network list floating ip --cloud=india
                $ network list floating --cloud=india
                $ network list floating --cloud=india 192.1.66.8
                $ network list floating --cloud=india --instance=323c5195-7yy34-4e7b-8581-703abec4b
                $ network list floating pool --cloud=india
                $ network create cluster --group=demo_group

        """
        # pprint(arguments)
        # Get the cloud parameter OR read default
        cloudname = arguments["--cloud"] or Default.get_cloud()

        if cloudname is None:
            Console.error("Default cloud has not been set!"
                          "Please use the following to set it:\n"
                          "cm default cloud=CLOUDNAME\n"
                          "or provide it via the --cloud=CLOUDNAME argument.")
            return ""

        # Fixed IP info
        if arguments["get"] \
                and arguments["fixed"]:
            fixed_ip = arguments["FIXED_IP"]
            result = Network.get_fixed_ip(cloudname,
                                          fixed_ip_addr=fixed_ip)
            Console.msg(result)

        # Floating IP info
        elif arguments["get"] \
                and arguments["floating"]:
            floating_ip_id = arguments["FLOATING_IP_ID"]
            result = Network.get_floating_ip(cloudname,
                                             floating_ip_or_id=floating_ip_id)
            Console.msg(result)

        # Reserve a fixed ip
        elif arguments["reserve"] \
                and arguments["fixed"]:
            fixed_ip = arguments["FIXED_IP"]
            result = Network.reserve_fixed_ip(cloudname=cloudname,
                                              fixed_ip_addr=fixed_ip)
            if result is not None:
                Console.ok("Reserve fixed ip address [{}] complete.".format(fixed_ip))

        # Un-Reserve a fixed ip
        elif arguments["unreserve"] \
                and arguments["fixed"]:
            fixed_ip = arguments["FIXED_IP"]
            result = Network.unreserve_fixed_ip(cloudname=cloudname,
                                                fixed_ip_addr=fixed_ip)
            if result is not None:
#.........这里部分代码省略.........
开发者ID:rajaramcomputers,项目名称:client,代码行数:103,代码来源:NetworkCommand.py

示例15: do_list

# 需要导入模块: from cloudmesh_client.cloud.default import Default [as 别名]
# 或者: from cloudmesh_client.cloud.default.Default import get_cloud [as 别名]
    def do_list(self, args, arguments):
        """
        ::

            Usage:
                list [--cloud=CLOUD] [--format=FORMAT] [--user=USER] [--tenant=TENANT] default
                list [--cloud=CLOUD] [--format=FORMAT] [--user=USER] [--tenant=TENANT] vm
                list [--cloud=CLOUD] [--format=FORMAT] [--user=USER] [--tenant=TENANT] flavor
                list [--cloud=CLOUD] [--format=FORMAT] [--user=USER] [--tenant=TENANT] image

            List the items stored in the database

            Options:
                --cloud=CLOUD    the name of the cloud
                --format=FORMAT  the output format
                --tenant=TENANT     Name of the tenant, e.g. fg82.

            Description:
                List command prints the values stored in the database
                for [default/vm/flavor/image].
                Result can be filtered based on the cloud, user & tenant arguments.
                If these arguments are not specified, it reads the default

            Examples:
                $ list --cloud india default
                $ list --cloud india --format table flavor
                $ list --cloud india --user albert --tenant fg82 flavor
        """
        # pprint(arguments)

        # Method to get the kind from args
        #
        # TODO: the kind are defined in the provider,
        # TODO: keep the kind lower case
        # why is there a reason to make the gind upper case
        def get_kind():
            for k in ["vm", "image", "flavor", "default"]:
                if arguments[k]:
                    # kinds are all uppercase in model.py
                    return k.upper()
            return "help"

        # Read commandline arguments
        output_format = arguments['--format']
        cloud = arguments['--cloud'] or Default.get_cloud()
        user = arguments['--user']
        tenant = arguments['--tenant']

        # If format is not specified, read default
        if output_format is None:
            output_format = Default.get("format") or "table"

        # If cloud is not specified, get default
        if cloud is None:
            cloud = Default.get("cloud") or "india"

        # If user is not specified, get default
        if user is None:
            user = Default.get("user")

        # If tenant is not specified, get default
        if tenant is None:
            tenant = Default.get("tenant")

        # Get the kind
        kind = get_kind()
        header = None
        order = None

        # print help message
        if kind == 'help':
            Console.ok("Print help!")
            return ""

        # Prepare the order & header based on kind
        # TODO: use lower case so we have a convention thats easy to follow
        # TODO: add quota
        # TODO: add limits
        # TODO: add usage
        if kind == 'FLAVOR':
            order = [
                'cm_cloud',
                'disk',
                'ephemeral_disk',
                'id',
                'name',
                'ram',
                'vcpus'
            ]
        elif kind == 'DEFAULT':
            order = ['user',
                     'cloud',
                     'name',
                     'value',
                     'created_at',
                     'updated_at'
                     ]
        elif kind == 'IMAGE':
            order = [
                'cm_cloud',
#.........这里部分代码省略.........
开发者ID:atavism,项目名称:client,代码行数:103,代码来源:ListCommand.py


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