本文整理汇总了Python中pyrax.manager.BaseManager.get方法的典型用法代码示例。如果您正苦于以下问题:Python BaseManager.get方法的具体用法?Python BaseManager.get怎么用?Python BaseManager.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyrax.manager.BaseManager
的用法示例。
在下文中一共展示了BaseManager.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CloudDatabaseClient
# 需要导入模块: from pyrax.manager import BaseManager [as 别名]
# 或者: from pyrax.manager.BaseManager import get [as 别名]
class CloudDatabaseClient(BaseClient):
"""
This is the primary class for interacting with Cloud Databases.
"""
def _configure_manager(self):
"""
Creates a manager to handle the instances, and another
to handle flavors.
"""
self._manager = BaseManager(self, resource_class=CloudDatabaseInstance,
response_key="instance", uri_base="instances")
self._flavor_manager = BaseManager(self,
resource_class=CloudDatabaseFlavor, response_key="flavor",
uri_base="flavors")
@assure_instance
def list_databases(self, instance):
"""Returns all databases for the specified instance."""
return instance.list_databases()
@assure_instance
def create_database(self, instance, name, character_set=None,
collate=None):
"""Creates a database with the specified name on the given instance."""
return instance.create_database(name, character_set=character_set,
collate=collate)
@assure_instance
def get_database(self, instance, name):
"""
Finds the database in the given instance with the specified name, and
returns a CloudDatabaseDatabase object. If no match is found, a
NoSuchDatabase exception is raised.
"""
return instance.get_database(name)
@assure_instance
def delete_database(self, instance, name):
"""Deletes the database by name on the given instance."""
return instance.delete_database(name)
@assure_instance
def list_users(self, instance):
"""Returns all users for the specified instance."""
return instance.list_users()
@assure_instance
def create_user(self, instance, name, password, database_names):
"""
Creates a user with the specified name and password, and gives that
user access to the specified database(s).
"""
return instance.create_user(name=name, password=password,
database_names=database_names)
@assure_instance
def get_user(self, instance, name):
"""
Finds the user in the given instance with the specified name, and
returns a CloudDatabaseUser object. If no match is found, a
NoSuchUser exception is raised.
"""
return instance.get_user(name)
@assure_instance
def delete_user(self, instance, name):
"""Deletes the user by name on the given instance."""
return instance.delete_user(name)
@assure_instance
def enable_root_user(self, instance):
"""
This enables login from any host for the root user and provides
the user with a generated root password.
"""
return instance.enable_root_user()
@assure_instance
def root_user_status(self, instance):
"""Returns True if the given instance is root-enabled."""
return instance.root_user_status()
@assure_instance
def restart(self, instance):
"""Restarts the instance."""
return instance.restart()
@assure_instance
#.........这里部分代码省略.........
示例2: CloudDatabaseClient
# 需要导入模块: from pyrax.manager import BaseManager [as 别名]
# 或者: from pyrax.manager.BaseManager import get [as 别名]
class CloudDatabaseClient(BaseClient):
"""
This is the primary class for interacting with Cloud Databases.
"""
name = "Cloud Databases"
def _configure_manager(self):
"""
Creates a manager to handle the instances, and another
to handle flavors.
"""
self._manager = CloudDatabaseManager(self,
resource_class=CloudDatabaseInstance, response_key="instance",
uri_base="instances")
self._flavor_manager = BaseManager(self,
resource_class=CloudDatabaseFlavor, response_key="flavor",
uri_base="flavors")
self._backup_manager = CloudDatabaseBackupManager(self,
resource_class=CloudDatabaseBackup, response_key="backup",
uri_base="backups")
@assure_instance
def list_databases(self, instance, limit=None, marker=None):
"""Returns all databases for the specified instance."""
return instance.list_databases(limit=limit, marker=marker)
@assure_instance
def create_database(self, instance, name, character_set=None,
collate=None):
"""Creates a database with the specified name on the given instance."""
return instance.create_database(name, character_set=character_set,
collate=collate)
@assure_instance
def get_database(self, instance, name):
"""
Finds the database in the given instance with the specified name, and
returns a CloudDatabaseDatabase object. If no match is found, a
NoSuchDatabase exception is raised.
"""
return instance.get_database(name)
@assure_instance
def delete_database(self, instance, name):
"""Deletes the database by name on the given instance."""
return instance.delete_database(name)
@assure_instance
def list_users(self, instance, limit=None, marker=None):
"""Returns all users for the specified instance."""
return instance.list_users(limit=limit, marker=marker)
@assure_instance
def create_user(self, instance, name, password, database_names, host=None):
"""
Creates a user with the specified name and password, and gives that
user access to the specified database(s).
"""
return instance.create_user(name=name, password=password,
database_names=database_names, host=host)
@assure_instance
def get_user(self, instance, name):
"""
Finds the user in the given instance with the specified name, and
returns a CloudDatabaseUser object. If no match is found, a
NoSuchUser exception is raised.
"""
return instance.get_user(name)
@assure_instance
def delete_user(self, instance, name):
"""Deletes the user by name on the given instance."""
return instance.delete_user(name)
@assure_instance
def change_user_password(self, instance, user, new_pass):
"""
Changes the password for the user of the specified instance to the
supplied value.
Returns None upon success; raises PasswordChangeFailed if the call
does not complete successfully.
"""
return instance.change_user_password(user, new_pass)
@assure_instance
def update_user(self, instance, user, name=None, password=None, host=None):
"""
Allows you to change one or more of the user's username, password, or
#.........这里部分代码省略.........
示例3: CloudMonitorClient
# 需要导入模块: from pyrax.manager import BaseManager [as 别名]
# 或者: from pyrax.manager.BaseManager import get [as 别名]
class CloudMonitorClient(BaseClient):
"""
This is the base client for creating and managing Cloud Monitoring.
"""
def __init__(self, *args, **kwargs):
super(CloudMonitorClient, self).__init__(*args, **kwargs)
self.name = "Cloud Monitoring"
def _configure_manager(self):
"""
Creates the Manager instances to handle monitoring.
"""
self._entity_manager = CloudMonitorEntityManager(self,
uri_base="entities", resource_class=CloudMonitorEntity,
response_key=None, plural_response_key=None)
self._check_type_manager = BaseManager(self,
uri_base="check_types", resource_class=CloudMonitorCheckType,
response_key=None, plural_response_key=None)
self._monitoring_zone_manager = BaseManager(self,
uri_base="monitoring_zones", resource_class=CloudMonitorZone,
response_key=None, plural_response_key=None)
self._notification_manager = CloudMonitorNotificationManager(self,
uri_base="notifications",
resource_class=CloudMonitorNotification,
response_key=None, plural_response_key=None)
self._notification_plan_manager = CloudMonitorNotificationPlanManager(
self, uri_base="notification_plans",
resource_class=CloudMonitorNotificationPlan,
response_key=None, plural_response_key=None)
self._changelog_manager = CloudMonitorChangelogManager(self,
uri_base="changelogs/alarms", resource_class=None,
response_key=None, plural_response_key=None)
self._overview_manager = CloudMonitorOverviewManager(self,
uri_base="views/overview", resource_class=None,
response_key="value", plural_response_key=None)
def get_account(self):
"""
Returns a dict with the following keys: id, webhook_token, and metadata.
"""
resp, resp_body = self.method_get("/account")
return resp_body
def get_audits(self):
"""
Every write operation performed against the API (PUT, POST or DELETE)
generates an audit record that is stored for 30 days. Audits record a
variety of information about the request including the method, URL,
headers, query string, transaction ID, the request body and the
response code. They also store information about the action performed
including a JSON list of the previous state of any modified objects.
For example, if you perform an update on an entity, this will record
the state of the entity before modification.
"""
resp, resp_body = self.method_get("/audits")
return resp_body["values"]
def list_entities(self):
return self._entity_manager.list()
def get_entity(self, entity):
return self._entity_manager.get(entity)
def create_entity(self, label=None, name=None, agent=None,
ip_addresses=None, metadata=None):
# NOTE: passing a non-None value for ip_addresses is required so that
# the _create_body() method can distinguish this as a request for a
# body dict for entities.
ip_addresses = ip_addresses or {}
resp = self._entity_manager.create(label=label, name=name, agent=agent,
ip_addresses=ip_addresses, metadata=metadata,
return_response=True)
if resp.status_code == 201:
ent_id = resp.headers["x-object-id"]
return self.get_entity(ent_id)
def update_entity(self, entity, agent=None, metadata=None):
"""
Only the agent_id and metadata are able to be updated via the API.
"""
self._entity_manager.update_entity(entity, agent=agent,
metadata=metadata)
def delete_entity(self, entity):
"""Deletes the specified entity."""
self._entity_manager.delete(entity)
def list_check_types(self):
return self._check_type_manager.list()
#.........这里部分代码省略.........
示例4: RackConnectClient
# 需要导入模块: from pyrax.manager import BaseManager [as 别名]
# 或者: from pyrax.manager.BaseManager import get [as 别名]
class RackConnectClient(BaseClient):
"""A client to interact with RackConnected resources."""
name = "RackConnect"
def _configure_manager(self):
"""Create a manager to handle RackConnect operations."""
self._network_manager = BaseManager(
self, resource_class=Network, uri_base="cloud_networks",
)
self._load_balancer_pool_manager = LoadBalancerPoolManager(
self, resource_class=LoadBalancerPool,
uri_base="load_balancer_pools"
)
self._public_ip_manager = PublicIPManager(
self, resource_class=PublicIP, uri_base="public_ips",
)
def get_network(self, network):
return self._network_manager.get(network)
def list_networks(self):
return self._network_manager.list()
def list_load_balancer_pools(self):
return self._load_balancer_pool_manager.list()
def get_load_balancer_pool(self, pool):
return self._load_balancer_pool_manager.get(pool)
def list_pool_nodes(self, pool):
return self._load_balancer_pool_manager.get_pool_nodes(pool)
def create_pool_node(self, pool, server):
return self._load_balancer_pool_manager.add_pool_node(pool, server)
def get_pool_node(self, pool, node):
return self._load_balancer_pool_manager.get_pool_node(pool, node)
def delete_pool_node(self, pool, node):
return self._load_balancer_pool_manager.delete_pool_node(pool, node)
def create_public_ip(self, public_ip):
return self._public_ip_manager.add_public_ip(public_ip)
def list_public_ips(self):
return self._public_ip_manager.list()
def get_public_ip(self, public_ip):
return self._public_ip_manager.get(public_ip)
def get_public_ips_for_server(self, server):
return self._public_ip_manager.get_ip_for_server(server)
def delete_public_ip(self, public_ip):
return self._public_ip_manager.delete_public_ip(public_ip)
#################################################################
# The following methods are defined in the generic client class,
# but don't have meaning in RackConnect, as there is not a single
# resource that defines this module.
#################################################################
def list(self, limit=None, marker=None):
"""Not applicable in RackConnect."""
raise NotImplementedError
def get(self, item):
"""Not applicable in RackConnect."""
raise NotImplementedError
def create(self, *args, **kwargs):
"""Not applicable in RackConnect."""
raise NotImplementedError
def delete(self, item):
"""Not applicable in RackConnect."""
raise NotImplementedError
def find(self, **kwargs):
"""Not applicable in RackConnect."""
raise NotImplementedError
def findall(self, **kwargs):
"""Not applicable in RackConnect."""
raise NotImplementedError