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


Python core.handle_request函数代码示例

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


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

示例1: modify

    def modify(self, name=None, data=None, ttl=None):
        """Modify this Record's properties.

        :param name: Modify the Record's name.
        :type ttl: str
        :param data: Modify the Record's data.
        :type data: str
        :param ttl: Modify the Record's time-to-live (TTL).
        :type ttl: int
        :returns: A list of Records.
        :rtype: A list of :class:`Record`

        .. versionadded:: 0.1
        """
        assert 'id' in self
        assert 'domain_id' in self
        data = {}
        if name is not None:
            data['name'] = name
        if data is not None:
            data['data'] = data
        if ttl is not None:
            data['ttl'] = int(ttl)
        data = json.dumps(data)
        url = '/'.join([get_url('clouddns'), 'domains', str(self['domain_id']),
                        'records', str(self['id'])])
        handle_request('put', url, data)
        if name is not None:
            self['name'] = name
        if data is not None:
            self['data'] = data
        if ttl is not None:
            self['ttl'] = int(ttl)
        return self
开发者ID:abg,项目名称:vaporize,代码行数:34,代码来源:domains.py

示例2: resize

    def resize(self, flavor=None, size=None):
        """Resize the memory and/or volume of the instance.

        This operation changes the memory and/or volume size of the instance,
        assuming a valid Flavor is provided. Restarts MySQL in the process.

        :param flavor: New Flavor (memory size) ofr the Instance.
        :type flavor: :class:`Flavor`
        :param size: New volume size Iin GBs) for Instance, 1 to 25.
        :type size: int

        .. versionadded:: 0.2
        """
        assert 'id' in self, "Missing Instance ID"
        if isinstance(flavor, Flavor):
            flavor = flavor.ref
        data = {'resize': {}}
        if flavor is not None:
            data['resize']['flavorRef'] = flavor
        if size is not None:
            data['resize']['volume'] = {'size': int(size)}
        data = json.dumps(data)
        url = '/'.join([get_url('clouddatabases'), 'instances',
                        str(self['id']), 'action'])
        handle_request('post', url, data)
开发者ID:rvoicilas,项目名称:vaporize,代码行数:25,代码来源:databases.py

示例3: volume_detach

    def volume_detach(self, volumeId):
        """Detach the volume specified by volume_id from this NextGenServer.

        """
        assert 'id' in self
        url = '/'.join([get_url('cloudserversopenstack'), 'servers',
            str(self['id']), 'os-volume_attachments', str(volumeId)])
        handle_request('delete', url)
开发者ID:kolanos,项目名称:vaporize,代码行数:8,代码来源:nextgen_servers.py

示例4: delete

    def delete(self):
        """Delete this Shared IP Group.

        .. versionadded:: 0.1
        """
        assert 'id' in self
        url = '/'.join([get_url('cloudservers'), 'shared_ip_groups',
                        str(self['id'])])
        handle_request('delete', url)
开发者ID:mihait,项目名称:vaporize,代码行数:9,代码来源:servers.py

示例5: unshare_ip

    def unshare_ip(self, address):
        """Unshare this Server's IP

        .. versionadded:: 0.1
        """
        assert 'id' in self
        url = '/'.join([get_url('cloudservers'), 'servers', str(self['id']),
                        'ips', 'public', address])
        handle_request('delete', url)
开发者ID:mihait,项目名称:vaporize,代码行数:9,代码来源:servers.py

示例6: revert_resize

    def revert_resize(self):
        """Revert an unsuccessful resize operation

        .. versionadded:: 0.3
        """
        assert 'id' in self
        data = json.dumps({'revertResize': None})
        url = '/'.join([get_url('cloudserversopenstack'), 'servers',
                        str(self['id']), 'action'])
        handle_request('post', url, data)
开发者ID:kolanos,项目名称:vaporize,代码行数:10,代码来源:nextgen_servers.py

示例7: confirm_resize

    def confirm_resize(self):
        """Confirm a successful resize operation

        .. versionadded:: 0.1
        """
        assert 'id' in self
        data = json.dumps({'confirmResize': None})
        url = '/'.join([get_url('cloudservers'), 'servers',
                        str(self['id']), 'action'])
        handle_request('post', url, data)
开发者ID:mihait,项目名称:vaporize,代码行数:10,代码来源:servers.py

示例8: remove_record

    def remove_record(self, record):
        """Remove a Record from this Domain.

        :param record: A Record or ``id`` for the Record to remove.
        :type record: int or :class:`REcord`

        .. versionadded:: 0.1
        """
        assert 'id' in self
        record = record.id if isinstance(record, Record) else int(record)
        url = '/'.join([get_url('clouddns'), 'domains', str(self['id']),
                        'records', str(record)])
        handle_request('delete', url)
开发者ID:abg,项目名称:vaporize,代码行数:13,代码来源:domains.py

示例9: backup_schedule

    def backup_schedule(self):
        """Disable a backup schedule for this Server

            >>> server = vaporize.servers.Server.get(...)
            >>> del server.backup_schedule

        .. versionadded:: 0.1
        """
        assert 'id' in self
        url = '/'.join([get_url('cloudservers'), 'servers', str(self['id']),
                        'backup_schedule'])
        handle_request('delete', url)
        del self['backup_schedule']
开发者ID:mihait,项目名称:vaporize,代码行数:13,代码来源:servers.py

示例10: rebuild

    def rebuild(self, name, image, flavor, adminpass, accessIPv4=None,
            accessIPv6=None, metadata={}, files={}, diskConfig='AUTO'):
        """Rebuild this NextGenServer using a specified NextGenImage

        :param image: The NextGenImage or ``id``
        :type image: int or :class:`NextGenImage`
        :param flavor: The NextGenFlavor or  ``id``
        :type image: int or :class:`NextGenFlavor`
        :param adminpass: Admin Password.
        :param accessIPv4: IPv4 access address
        :type type: str
        :param accessIPv6: IPv6 access address
        :type type: str
        :param metadata: key/value pairs
        :type type: dict
        :param files: path,contents dict
        :type type: dict
        :param diskConfig: OS-DCF:diskConfig AUTO or MANUAL
        :type type: str

        .. versionadded:: 0.3
        """
        assert 'id' in self, "id is missing"
        assert 'name' in self or len(name) > 0, "name is missing"
        assert len(adminpass) >= 8, "Admin password must be >= 8 chars long"
        assert diskConfig in ['AUTO', 'MANUAL'], ("diskConfig must be"
        "'AUTO' or 'MANUAL'")
        if name:
            self['name'] = name
        if isinstance(image, NextGenImage):
            image = image.id
        if isinstance(flavor, NextGenFlavor):
            flavor = flavor.id
        data = {'rebuild':{
                    'name': str(self['name']),
                    'imageRef': str(image),
                    'flavorRef': str(flavor),
                    'adminPass': str(adminpass),
                    'OS-DCF:diskConfig': str(diskConfig)
                    }}
        if accessIPv4 is not None:
            data['rebuild']['accessIPv4'] = str(accessIPv4)
        if accessIPv6 is not None:
            data['rebuild']['accessIPv6'] = str(accessIPv6)
        if isinstance(files, dict):
            for path, contents in list(files.items()):
                data['rebuild']['personality'].append({'path': path, 'contents': contents})
        data = json.dumps(data)
        url = '/'.join([get_url('cloudserversopenstack'), 'servers',
                        str(self['id']), 'action'])
        handle_request('post', url, data)
开发者ID:kolanos,项目名称:vaporize,代码行数:51,代码来源:nextgen_servers.py

示例11: reboot

    def reboot(self, type='SOFT'):
        """Perform a soft/hard reboot on this NextGenServer.

        :param type: A reboot type (``SOFT`` or ``HARD``).
        :type type: str

        .. versionadded:: 0.3
        """
        assert 'id' in self, "Missing NextGenServer ID"
        assert type in ['SOFT', 'HARD'], "Reboot type must be 'SOFT' or 'HARD'"
        data = json.dumps({'reboot': {'type': type}})
        url = '/'.join([get_url('cloudserversopenstack'), 'servers',
                        str(self['id']), 'action'])
        handle_request('post', url, data)
开发者ID:kolanos,项目名称:vaporize,代码行数:14,代码来源:nextgen_servers.py

示例12: restart

    def restart(self):
        """Restart the database service on the instance.

        The restart operation will restart only the MySQL Instance. Restarting
        MySQL will erase any dynamic configuration settings that you have made
        within MySQL.

        .. versionadded:: 0.2
        """
        assert 'id' in self
        data = json.dumps({'restart': {}})
        url = '/'.join([get_url('clouddatabases'), 'instances',
                        str(self['id']), 'action'])
        handle_request('post', url, dataa)
开发者ID:rvoicilas,项目名称:vaporize,代码行数:14,代码来源:databases.py

示例13: change_admin_pass

    def change_admin_pass(self, password):
        """Change admin password.

        :param password: Admin Password.
        :type type: str

        """
        assert len(password) >= 8, "Admin password must be >= 8 chars long"

        assert 'id' in self
        url = '/'.join([get_url('cloudserversopenstack'), 'servers',
            str(self['id']), 'action'])
        data = json.dumps({ "changePassword": { "adminPass" : str(password)}})
        handle_request('post', url, data)
开发者ID:kolanos,项目名称:vaporize,代码行数:14,代码来源:nextgen_servers.py

示例14: delete

    def delete(self):
        """Delete this NextGenServer.

        .. warning::

            There is no confirmation step for this operation. When you delete a
            server it is permanent. If in doubt, create a backup image
            (:func:`vaporize.images.create`) first before deleting.

        .. versionadded:: 0.1
        """
        assert 'id' in self
        url = '/'.join([get_url('cloudserversopenstack'), 'servers', str(self['id'])])
        handle_request('delete', url)
开发者ID:kolanos,项目名称:vaporize,代码行数:14,代码来源:nextgen_servers.py

示例15: update_server

    def update_server(self, name=None, accessIPv4=None, accessIPv6=None):
        """Update this NextGenServer's name or ip addresses.

        :param name: Change the NextGenServer's name
        :type name: str
        :param accessIPv4: IPv4 access address
        :type name: str
        :param accessIPv6: IPv6 access address
        :type name: str
        :returns: A modified CloudNextGenServers NextGenServer.
        :rtype: :class:`NextGenServer`

        .. versionadded:: 0.3
        """
        assert 'id' in self
        data = {'server': {}}
        if name is not None:
            data['server']['name'] = name
        if addressIPv4 is not None:
            data['server']['addressIPv4'] = addressIPv4
        if addressIPv6 is not None:
            data['server']['addressIPv6'] = addressIPv6
        data = json.dumps(data)
        url = '/'.join([get_url('cloudserversopenstack'), 'servers', str(self['id'])])
        response = handle_request('put', url, data=data)
        if response:
            if name is not None:
                self['name'] = name
        return self
开发者ID:kolanos,项目名称:vaporize,代码行数:29,代码来源:nextgen_servers.py


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