def get_parser(self, prog_name): parser = super(CreateDatabaseBackup, self).get_parser(prog_name) parser.add_argument( 'instance', metavar='<instance>', help=_('ID or name of the instance.') ) parser.add_argument( 'name', metavar='<name>', help=_('Name of the backup.') ) parser.add_argument( '--description', metavar='<description>', default=None, help=_('An optional description for the backup.') ) parser.add_argument( '--parent', metavar='<parent>', default=None, help=_('Optional ID of the parent backup to perform an' ' incremental backup from.') ) parser.add_argument( '--incremental', action='store_true', default=False, help=_('Create an incremental backup based on the last' ' full or incremental backup. It will create a' ' full backup if no existing backup found.') ) return parser
def get_parser(self, prog_name): parser = super(CreateDatabaseConfiguration, self).get_parser(prog_name) parser.add_argument( 'name', metavar='<name>', help=_('Name of the configuration group.'), ) parser.add_argument( 'values', metavar='<values>', help=_('Dictionary of the values to set.'), ) parser.add_argument( '--datastore', metavar='<datastore>', default=None, help=_('Datastore assigned to the configuration group. Required ' 'if default datastore is not configured.'), ) parser.add_argument( '--datastore_version', metavar='<datastore_version>', default=None, help=_('Datastore version ID assigned to the ' 'configuration group.'), ) parser.add_argument( '--description', metavar='<description>', default=None, help=_('An optional description for the configuration group.'), ) return parser
def get_parser(self, prog_name): parser = super(CreateDatabaseBackup, self).get_parser(prog_name) parser.add_argument('instance', metavar='<instance>', help=_('ID or name of the instance.')) parser.add_argument('name', metavar='<name>', help=_('Name of the backup.')) parser.add_argument('--description', metavar='<description>', default=None, help=_('An optional description for the backup.')) parser.add_argument( '--parent', metavar='<parent>', default=None, help=_('Optional ID of the parent backup to perform an' ' incremental backup from.')) parser.add_argument( '--incremental', action='store_true', default=False, help=_('Create an incremental backup based on the last' ' full or incremental backup. It will create a' ' full backup if no existing backup found.')) return parser
def get_parser(self, prog_name): parser = super(SetDatabaseInstanceLog, self).get_parser(prog_name) parser.add_argument('instance', metavar='<instance>', type=str, help=_('Id or Name of the instance.')) parser.add_argument('log_name', metavar='<log_name>', type=str, help=_('Name of log to operate.')) parser.add_argument( '--enable', action='store_true', help="Whether or not to enable log collection.", ) parser.add_argument( '--disable', action='store_true', help="Whether or not to disable log collection.", ) parser.add_argument( '--publish', action='store_true', help="Whether or not to publish log files to the backend storage " "for logs(Swift by default).", ) parser.add_argument( '--discard', action='store_true', help="Whether or not to discard the existing logs before publish.", ) return parser
def get_parser(self, prog_name): parser = super(GrantDatabaseUserAccess, self).get_parser(prog_name) parser.add_argument( 'instance', metavar='<instance>', help=_('ID or name of the instance.') ) parser.add_argument( 'name', metavar='<name>', help=_('Name of user.') ) parser.add_argument( '--host', metavar='<host>', default=None, help=_('Optional host of user.') ) parser.add_argument( 'databases', metavar='<databases>', nargs="+", default=[], help=_('List of databases.') ) return parser
def get_parser(self, prog_name): parser = super(ListDatabaseInstances, self).get_parser(prog_name) parser.add_argument( '--limit', dest='limit', metavar='<limit>', default=None, help=_('Limit the number of results displayed.') ) parser.add_argument( '--marker', dest='marker', metavar='<ID>', type=str, default=None, help=_('Begin displaying the results for IDs greater than the' 'specified marker. When used with :option:`--limit,` set' 'this to the last ID displayed in the previous run.') ) parser.add_argument( '--include_clustered', '--include-clustered', dest='include_clustered', action="store_true", default=False, help=_("Include instances that are part of a cluster " "(default %(default)s). --include-clustered may be " "deprecated in the future, retaining just " "--include_clustered.") ) return parser
def get_parser(self, prog_name): parser = super(ListDatabaseInstanceBackups, self).get_parser(prog_name) parser.add_argument( 'instance', metavar='<instance>', help=_('ID or name of the instance.') ) parser.add_argument( '--limit', dest='limit', metavar='<limit>', default=None, help=_('Return up to N number of the most recent bcakups.') ) parser.add_argument( '--marker', dest='marker', metavar='<ID>', type=str, default=None, help=_('Begin displaying the results for IDs greater than the' 'specified marker. When used with :option:`--limit,` set' 'this to the last ID displayed in the previous run.') ) return parser
def get_parser(self, prog_name): parser = super(CreateDatabaseUser, self).get_parser(prog_name) parser.add_argument( 'instance', metavar='<instance>', help=_('ID or name of the instance.') ) parser.add_argument( 'name', metavar='<name>', help=_('Name of user.') ) parser.add_argument( 'password', metavar='<password>', help=_('Password of user.') ) parser.add_argument( '--host', metavar='<host>', help=_('Optional host of user.') ) parser.add_argument( '--databases', metavar='<databases>', nargs='+', default=[], help=_('Optional list of databases.') ) return parser
def get_parser(self, prog_name): parser = super(ListDatabaseBackups, self).get_parser(prog_name) parser.add_argument( '--limit', dest='limit', metavar='<limit>', default=None, help=_('Return up to N number of the most recent bcakups.')) parser.add_argument( '--marker', dest='marker', metavar='<ID>', type=str, default=None, help=_('Begin displaying the results for IDs greater than the' 'specified marker. When used with ``--limit``, set ' 'this to the last ID displayed in the previous run.')) parser.add_argument( '--datastore', dest='datastore', metavar='<datastore>', default=None, help=_('ID or name of the datastore (to filter backups by).')) parser.add_argument('--instance-id', default=None, help=_('Filter backups by database instance ID.')) parser.add_argument( '--all-projects', action='store_true', help=_('Get all the backups of all the projects(Admin only).')) return parser
def get_parser(self, prog_name): parser = super(ListDatabaseInstances, self).get_parser(prog_name) parser.add_argument('--limit', dest='limit', metavar='<limit>', default=None, help=_('Limit the number of results displayed.')) parser.add_argument( '--marker', dest='marker', metavar='<ID>', type=str, default=None, help=_('Begin displaying the results for IDs greater than the' 'specified marker. When used with ``--limit``, set ' 'this to the last ID displayed in the previous run.')) parser.add_argument( '--include_clustered', '--include-clustered', dest='include_clustered', action="store_true", default=False, help=_("Include instances that are part of a cluster " "(default %(default)s). --include-clustered may be " "deprecated in the future, retaining just " "--include_clustered.")) parser.add_argument( '--all-projects', dest='all_projects', action="store_true", default=False, help=_("Include database instances of all projects (admin only)")) return parser
def get_parser(self, prog_name): parser = super(DeleteDatabaseBackupStrategy, self).get_parser(prog_name) parser.add_argument( '--project-id', help=_('Project ID in Keystone. Only admin user is allowed to ' 'delete backup strategy for other projects.')) parser.add_argument('--instance-id', help=_('Database instance ID.')) return parser
def get_parser(self, prog_name): parser = super(DeleteDatabase, self).get_parser(prog_name) parser.add_argument(dest='instance', metavar='<instance>', help=_('ID or name of the instance.')) parser.add_argument(dest='database', metavar='<database>', help=_('Name of the database.')) return parser
def get_parser(self, prog_name): parser = super(DeleteDatabaseUser, self).get_parser(prog_name) parser.add_argument('instance', metavar='<instance>', help=_('ID or name of the instance.')) parser.add_argument('name', metavar='<name>', help=_('Name of user.')) parser.add_argument('--host', metavar='<host>', help=_('Optional host of user.')) return parser
def get_parser(self, prog_name): parser = super(RebuildDatabaseInstance, self).get_parser(prog_name) parser.add_argument('instance', metavar='<instance>', type=str, help=_('ID or name of the instance.')) parser.add_argument('image', metavar='<image-id>', help=_('ID of the new guest image.')) return parser
def get_parser(self, prog_name): parser = super(ResizeDatabaseInstanceFlavor, self).get_parser(prog_name) parser.add_argument('instance', metavar='<instance>', type=str, help=_('ID or name of the instance')) parser.add_argument('flavor', type=str, help=_('ID or name of the new flavor.')) return parser
def get_parser(self, prog_name): parser = super(ListDatabaseFlavors, self).get_parser(prog_name) parser.add_argument('--datastore-type', dest='datastore_type', metavar='<datastore-type>', help=_('Type of the datastore. For eg: mysql.')) parser.add_argument('--datastore-version-id', dest='datastore_version_id', metavar='<datastore-version-id>', help=_('ID of the datastore version.')) return parser
def get_parser(self, prog_name): parser = super(EnableDatabaseInstanceLog, self).get_parser(prog_name) parser.add_argument('instance', metavar='<instance>', type=str, help=_('Id or Name of the instance.')) parser.add_argument('log_name', metavar='<log_name>', type=str, help=_('Name of log to publish.')) return parser
def get_parser(self, prog_name): parser = super(SetDatabaseConfiguration, self).get_parser(prog_name) parser.add_argument( 'configuration_group_id', help=_('Configuration group ID.'), ) parser.add_argument( 'values', metavar='<values>', help=_('Dictionary of the new values to set.'), ) return parser
def get_parser(self, prog_name): parser = super(ListDatabaseBackupStrategies, self).get_parser(prog_name) parser.add_argument('--instance-id', help=_('Filter results by database instance ID.')) parser.add_argument( '--project-id', help=_('Project ID in Keystone. Only admin user is allowed to ' 'list backup strategy for other projects.')) return parser
def get_parser(self, prog_name): parser = super(UpgradeDatabaseCluster, self).get_parser(prog_name) parser.add_argument( 'cluster', metavar='<cluster>', help=_('ID or name of the cluster.'), ) parser.add_argument( 'datastore_version', metavar='<datastore_version>', help=_('A datastore version name or ID.'), ) return parser
def get_parser(self, prog_name): parser = super(ShrinkDatabaseCluster, self).get_parser(prog_name) parser.add_argument('cluster', metavar='<cluster>', help=_('ID or name of the cluster.')) parser.add_argument('instances', metavar='<instance>', nargs='+', default=[], help=_( "Drop instance(s) from the cluster. Specify " "multiple ids to drop multiple instances.")) return parser
def get_parser(self, prog_name): parser = super(EnableDatabaseRoot, self).get_parser(prog_name) parser.add_argument( 'instance_or_cluster', metavar='<instance_or_cluster>', help=_('ID or name of the instance or cluster.'), ) parser.add_argument('--root_password', metavar='<root_password>', default=None, help=_('Root password to set.')) return parser
def get_parser(self, prog_name): parser = super(DeleteDatabase, self).get_parser(prog_name) parser.add_argument( dest='instance', metavar='<instance>', help=_('ID or name of the instance.') ) parser.add_argument( dest='database', metavar='<database>', help=_('Name of the database.') ) return parser
def get_parser(self, prog_name): parser = super(UpgradeDatabaseInstance, self).get_parser(prog_name) parser.add_argument( 'instance', metavar='<instance>', type=str, help=_('ID or name of the instance.'), ) parser.add_argument( 'datastore_version', metavar='<datastore_version>', help=_('ID or name of the instance.'), ) return parser
def get_parser(self, prog_name): parser = super(RevokeDatabaseUserAccess, self).get_parser(prog_name) parser.add_argument('instance', metavar='<instance>', help=_('ID or name of the instance.')) parser.add_argument('name', metavar='<name>', help=_('Name of user.')) parser.add_argument('--host', metavar='<host>', default=None, help=_('Optional host of user.')) parser.add_argument('databases', metavar='<databases>', help=_('A single database.')) return parser
def get_parser(self, prog_name): parser = super(EnableDatabaseRoot, self).get_parser(prog_name) parser.add_argument( 'instance_or_cluster', metavar='<instance_or_cluster>', help=_('ID or name of the instance or cluster.'), ) parser.add_argument( '--root_password', metavar='<root_password>', default=None, help=_('Root password to set.')) return parser
def get_parser(self, prog_name): parser = super(ResizeDatabaseInstanceVolume, self).get_parser(prog_name) parser.add_argument('instance', metavar='<instance>', type=str, help=_('ID or name of the instance.')) parser.add_argument( 'size', metavar='<size>', type=int, default=None, help=_('New size of the instance disk volume in GB.')) return parser
def get_parser(self, prog_name): parser = super(CreateDatabaseCluster, self).get_parser(prog_name) parser.add_argument( 'name', metavar='<name>', type=str, help=_('Name of the cluster.'), ) parser.add_argument( 'datastore', metavar='<datastore>', help=_('A datastore name or ID.'), ) parser.add_argument( 'datastore_version', metavar='<datastore_version>', help=_('A datastore version name or ID.'), ) parser.add_argument( '--instance', metavar=INSTANCE_METAVAR, action='append', dest='instances', default=[], help=INSTANCE_HELP, ) parser.add_argument( '--locality', metavar='<policy>', default=None, choices=['affinity', 'anti-affinity'], help=_('Locality policy to use when creating cluster. ' 'Choose one of %(choices)s.'), ) parser.add_argument( '--extended-properties', dest='extended_properties', metavar=EXT_PROPS_METAVAR, default=None, help=EXT_PROPS_HELP, ) parser.add_argument( '--configuration', metavar='<configuration>', type=str, default=None, help=_('ID of the configuration group to attach to the cluster.'), ) return parser
def get_parser(self, prog_name): parser = super(EnableDatabaseInstanceLog, self).get_parser(prog_name) parser.add_argument( 'instance', metavar='<instance>', type=str, help=_('Id or Name of the instance.') ) parser.add_argument( 'log_name', metavar='<log_name>', type=str, help=_('Name of log to publish.') ) return parser
def get_parser(self, prog_name): parser = super(ShowDatastoreVersion, self).get_parser(prog_name) parser.add_argument( 'datastore_version', metavar='<datastore_version>', help=_('ID or name of the datastore version.'), ) parser.add_argument( '--datastore', metavar='<datastore>', default=None, help=_('ID or name of the datastore. Optional if the ID of' 'the datastore_version is provided.'), ) return parser
def get_parser(self, prog_name): parser = super(CreateDatabaseBackupStrategy, self).get_parser(prog_name) parser.add_argument( '--project-id', help=_('Project ID in Keystone. Only admin user is allowed to ' 'create backup strategy for other projects.')) parser.add_argument('--instance-id', help=_('Database instance ID.')) parser.add_argument( '--swift-container', help=_('The container name for storing the backup data when Swift ' 'is used as backup storage backend.')) return parser
def get_parser(self, prog_name): parser = super(ListDatabaseFlavors, self).get_parser(prog_name) parser.add_argument( '--datastore-type', dest='datastore_type', metavar='<datastore-type>', help=_('Type of the datastore. For eg: mysql.') ) parser.add_argument( '--datastore-version-id', dest='datastore_version_id', metavar='<datastore-version-id>', help=_('ID of the datastore version.') ) return parser
def get_parser(self, prog_name): parser = super(ListDatabaseConfigurationParameters, self).\ get_parser(prog_name) parser.add_argument('datastore_version', metavar='<datastore_version>', help=_('Datastore version name or ID assigned' 'to the configuration group.')) parser.add_argument( '--datastore', metavar='<datastore>', default=None, help=_('ID or name of the datastore to list configuration' 'parameters for. Optional if the ID of the' 'datastore_version is provided.')) return parser
def get_parser(self, prog_name): parser = super(ShrinkDatabaseCluster, self).get_parser(prog_name) parser.add_argument( 'cluster', metavar='<cluster>', help=_('ID or name of the cluster.') ) parser.add_argument( 'instances', metavar='<instance>', nargs='+', default=[], help=_("Drop instance(s) from the cluster. Specify " "multiple ids to drop multiple instances.") ) return parser
class ListDatabaseClusterModules(command.Lister): _description = _("Lists all modules for each instance of a cluster.") columns = [ 'instance_name', 'Module Name', 'Module Type', 'md5', 'created', 'updated' ] def get_parser(self, prog_name): parser = (super(ListDatabaseClusterModules, self).get_parser(prog_name)) parser.add_argument('cluster', metavar='<cluster>', help=_('ID or name of the cluster.')) return parser def take_action(self, parsed_args): database_clusters = self.app.client_manager.database.clusters database_instances = self.app.client_manager.database.instances cluster = utils.find_resource(database_clusters, parsed_args.cluster) instances = cluster._info['instances'] modules = [] for instance in instances: new_list = database_instances.modules(instance['id']) for item in new_list: item.instance_id = instance['id'] item.instance_name = instance['name'] item.module_name = item.name item.module_type = item.type modules += new_list modules = [ utils.get_item_properties(module, self.columns) for module in modules ] return self.columns, modules
class ListDatabaseClusterInstances(command.Lister): _description = _("Lists all instances of a cluster.") columns = ['ID', 'Name', 'Flavor ID', 'Size', 'Status'] def get_parser(self, prog_name): parser = (super(ListDatabaseClusterInstances, self).get_parser(prog_name)) parser.add_argument('cluster', metavar='<cluster>', help=_('ID or name of the cluster.')) return parser def take_action(self, parsed_args): database_clusters = self.app.client_manager.database.clusters cluster = utils.find_resource(database_clusters, parsed_args.cluster) instances = cluster._info['instances'] for instance in instances: instance['flavor_id'] = instance['flavor']['id'] if instance.get('volume'): instance['size'] = instance['volume']['size'] instances = [ utils.get_dict_properties(inst, self.columns) for inst in instances ] return self.columns, instances
class ForceDeleteDatabaseCluster(command.Command): _description = _("Force delete a cluster.") def get_parser(self, prog_name): parser = super(ForceDeleteDatabaseCluster, self).get_parser(prog_name) parser.add_argument( 'cluster', metavar='<cluster>', help=_('ID or name of the cluster.'), ) return parser def take_action(self, parsed_args): database_clusters = self.app.client_manager.database.clusters cluster = utils.find_resource(database_clusters, parsed_args.cluster) database_clusters.reset_status(cluster) try: database_clusters.delete(cluster) except Exception as e: msg = (_("Failed to delete cluster %(cluster)s: %(e)s") % { 'cluster': parsed_args.cluster, 'e': e }) raise exceptions.CommandError(msg)
def get_parser(self, prog_name): parser = (super(ListDatabaseClusterModules, self).get_parser(prog_name)) parser.add_argument('cluster', metavar='<cluster>', help=_('ID or name of the cluster.')) return parser
class GrowDatabaseCluster(command.Command): _description = _("Adds more instances to a cluster.") def get_parser(self, prog_name): parser = super(GrowDatabaseCluster, self).get_parser(prog_name) parser.add_argument('--instance', metavar=INSTANCE_METAVAR, action='append', dest='instances', default=[], help=INSTANCE_HELP) parser.add_argument('cluster', metavar='<cluster>', help=_('ID or name of the cluster.')) return parser def take_action(self, parsed_args): database_client_manager = self.app.client_manager.database db_clusters = database_client_manager.clusters cluster = utils.find_resource(db_clusters, parsed_args.cluster) instances = _parse_instance_options(database_client_manager, parsed_args.instances, for_grow=True) db_clusters.grow(cluster, instances=instances)
class ShrinkDatabaseCluster(command.Command): _description = _("Drops instances from a cluster.") def get_parser(self, prog_name): parser = super(ShrinkDatabaseCluster, self).get_parser(prog_name) parser.add_argument('cluster', metavar='<cluster>', help=_('ID or name of the cluster.')) parser.add_argument('instances', metavar='<instance>', nargs='+', default=[], help=_( "Drop instance(s) from the cluster. Specify " "multiple ids to drop multiple instances.")) return parser def take_action(self, parsed_args): database_client_manager = self.app.client_manager.database db_clusters = database_client_manager.clusters cluster = utils.find_resource(db_clusters, parsed_args.cluster) db_instances = database_client_manager.instances instances = [{ 'id': utils.find_resource(db_instances, instance).id } for instance in parsed_args.instances] db_clusters.shrink(cluster, instances)
def get_parser(self, prog_name): parser = super(ResizeDatabaseInstanceFlavor, self).get_parser( prog_name ) parser.add_argument( 'instance', metavar='<instance>', type=str, help=_('ID or name of the instance') ) parser.add_argument( 'flavor_id', metavar='<flavor_id>', type=str, help=_('New flavor of the instance') ) return parser
def get_parser(self, prog_name): parser = super(ShowDatastore, self).get_parser(prog_name) parser.add_argument( 'datastore', metavar='<datastore>', help=_('ID of the datastore'), ) return parser
def get_parser(self, prog_name): parser = super(ListDatastoreVersions, self).get_parser(prog_name) parser.add_argument( 'datastore', metavar='<datastore>', help=_('ID or name of the datastore'), ) return parser
def get_parser(self, prog_name): parser = (super(ListDatabaseClusterModules, self) .get_parser(prog_name)) parser.add_argument( 'cluster', metavar='<cluster>', help=_('ID or name of the cluster.')) return parser
def get_parser(self, prog_name): parser = super(ListDatabaseUsers, self).get_parser(prog_name) parser.add_argument( dest='instance', metavar='<instance>', help=_('ID or name of the instance.') ) return parser
def get_parser(self, prog_name): parser = super(ShowDatabaseCluster, self).get_parser(prog_name) parser.add_argument( 'cluster', metavar='<cluster>', help=_('ID or name of the cluster'), ) return parser
def get_parser(self, prog_name): parser = super(DeleteDatabaseBackup, self).get_parser(prog_name) parser.add_argument( 'backup', metavar='<backup>', help=_('ID or name of the backup.') ) return parser
def get_parser(self, prog_name): parser = super(ResetDatabaseInstanceStatus, self).get_parser(prog_name) parser.add_argument( 'instance', metavar='<instance>', help=_('ID or name of the instance'), ) return parser
def get_parser(self, prog_name): parser = super(ShowDatabaseFlavor, self).get_parser(prog_name) parser.add_argument( 'flavor', metavar='<flavor>', help=_('ID or name of the flavor'), ) return parser
def get_parser(self, prog_name): parser = super(ShowDatabaseInstance, self).get_parser(prog_name) parser.add_argument( 'instance', metavar='<instance>', help=_('Instance (name or ID)'), ) return parser
def get_parser(self, prog_name): parser = super(DeleteDatabaseBackupExecution, self).get_parser( prog_name) parser.add_argument( 'execution', metavar='<execution>', help=_('ID of the execution to delete.') ) return parser
def get_parser(self, prog_name): parser = super(ShowDatabaseRoot, self).get_parser(prog_name) parser.add_argument( 'instance_or_cluster', metavar='<instance_or_cluster>', help=_('ID or name of the instance or cluster.'), ) return parser
def get_parser(self, prog_name): parser = super(DisableDatabaseRoot, self).get_parser(prog_name) parser.add_argument( 'instance', metavar='<instance>', help=_('ID or name of the instance.'), ) return parser
def get_parser(self, prog_name): parser = super(ShowDatabaseUser, self).get_parser(prog_name) parser.add_argument( 'instance', metavar='<instance>', help=_('ID or name of the instance.'), ) parser.add_argument( 'name', metavar='<name>', help=_('Name of user.'), ) parser.add_argument( "--host", metavar="<host>", help=_("Optional host of user."), ) return parser
def get_parser(self, prog_name): parser = super(DeleteDatabaseUser, self).get_parser(prog_name) parser.add_argument( 'instance', metavar='<instance>', help=_('ID or name of the instance.') ) parser.add_argument( 'name', metavar='<name>', help=_('Name of user.') ) parser.add_argument( '--host', metavar='<host>', help=_('Optional host of user.') ) return parser
def main(): try: if sys.version_info >= (3, 0): OpenStackTroveShell().main(sys.argv[1:]) else: OpenStackTroveShell().main(map(encodeutils.safe_decode, sys.argv[1:])) except KeyboardInterrupt: print(_("... terminating trove client"), file=sys.stderr) sys.exit(130) except Exception as e: logger.debug(e, exc_info=1) message = six.text_type(e) if not isinstance(message, six.string_types): message = str(message) print(_("ERROR: %s") % encodeutils.safe_encode(message), file=sys.stderr) sys.exit(1)