def generate_volume_pattern(volume_template, volume_id): try: return volume_template % volume_id except TypeError: msg = "Invalid volume name template '%s' specified in config." LOG.error(msg) raise exception.InvalidConfigException(msg)
def check_bbcp(self): msg = "Invalid path '{path}' specified in [bbcp] {name} config option" messages = [] for name in ('path', 'src_path', 'dst_path'): path = self.cfg.bbcp.get(name) if not os.path.isfile(path): messages.append(msg.format(path=path, name=name)) if messages: raise exception.InvalidConfigException('\n'.join(messages))
def from_context(cls, context): vmax_ip = context.cloud_config.storage.vmax_ip vmax_port = context.cloud_config.storage.vmax_port vmax_user = context.cloud_config.storage.vmax_user vmax_password = context.cloud_config.storage.vmax_password vmax_port_groups = context.cloud_config.storage.vmax_port_groups vmax_fast_policy = context.cloud_config.storage.vmax_fast_policy vmax_pool_name = context.cloud_config.storage.vmax_pool_name vmax_iscsi_my_ip = context.cloud_config.storage.iscsi_my_ip vmax_initiator_name = context.cloud_config.storage.initiator_name volume_name_template = context.cloud_config.storage.\ volume_name_template backend_timeout = context.cloud_config.migrate.storage_backend_timeout vmax_config_opts = [opt for opt in list(locals().keys()) if opt.startswith('vmax_')] missing_opts = [opt for opt in vmax_config_opts if opt is None] if any(missing_opts): msg = ("Invalid configuration specified for EMC storage backend, " "following options must be specified: {}") msg = msg.format(', '.join(missing_opts)) LOG.error(msg) raise exception.InvalidConfigException(msg) cinder = context.resources[utils.STORAGE_RESOURCE] vmax_connector = EMCConnector(vmax_ip, vmax_port, vmax_user, vmax_password, vmax_port_groups, vmax_fast_policy, vmax_pool_name, backend_timeout, volume_name_template, vmax_initiator_name) num_retries = context.cloud_config.migrate.retry sudo_pass = context.cloud_config.migrate.local_sudo_password timeout = context.cloud_config.migrate.storage_backend_timeout iscsi_connector = iscsi.ISCSIConnector(num_retries=num_retries, local_sudo_password=sudo_pass, storage_backend_timeout=timeout) db = cinder_db.CinderDBBroker(cinder.mysql_connector) return cls(vmax_connector, db, iscsi_connector, vmax_iscsi_my_ip)
def _is_nfs_shared(self): src_shared_nfs = isinstance(self.src_cinder_backend, generic.SharedNFSPlugin) dst_shared_nfs = isinstance(self.dst_cinder_backend, generic.SharedNFSPlugin) if src_shared_nfs and dst_shared_nfs: return True elif src_shared_nfs or dst_shared_nfs: msg = ("Invalid configuration of src or dst storage backends. " "In case of shared-nfs both options of the backends must " "be set to have a value of shared-nfs. Source storage " "backend has '{src}' and destination storage backend has " "'{dst}'") raise exception.InvalidConfigException( msg, src=self.cfg.src_storage.backend, dst=self.cfg.dst_storage.backend) else: return False