Providing a partition is not necessary on topology; causes errors
166584
def exists(self, **kwargs):
        """"""
        kwargs.pop('partition', None)
        kwargs['transform_name'] = True
        return self._exists(**kwargs)
298724
def main():
    
    arg_parse = setup_argparse()
    args = arg_parse.parse_args()

    if not args.quiet:
        print('GNS3 Topology Converter')

    if args.debug:
        logging_level = logging.DEBUG
    else:
        logging_level = logging.WARNING

    logging.basicConfig(level=logging_level,
                        format=LOG_MSG_FMT, datefmt=LOG_DATE_FMT)

    logging.getLogger(__name__)

    # Add the main topology to the list of files to convert
    if args.topology == 'topology.net':
        args.topology = os.path.join(os.getcwd(), 'topology.net')

    topology_files = [{'file': topology_abspath(args.topology),
                       'snapshot': False}]

    # Add any snapshot topologies to be converted
    topology_files.extend(get_snapshots(args.topology))

    topology_name = name(args.topology, args.name)

    # Do the conversion
    for topology in topology_files:
        do_conversion(topology, topology_name, args.output, args.debug)
1036895
def partition_t(wrap, func):
    
    return Transformation(
        'partition({0})'.format(name(func)),
        partial(partition_impl, wrap, func),
        None
    )
434294
def add_partition(self, p):
        """"""

        if not self.partitions:
            self.partitions = {}

        self.partitions[p.vid] = p
1263971
function CannotBuildDependencyGraphError(nestedError){
  this.name = 'CannotBuildDependencyGraphError';
  this.message = nestedError.message;
  this.stack = nestedError.stack;

  this.nestedError = nestedError;
}
262940
protected void cleanState(
      String topologyName,
      SchedulerStateManagerAdaptor statemgr) throws TopologyRuntimeManagementException {
    LOG.fine("Cleaning up topology state");

    Boolean result;

    result = statemgr.deleteTMasterLocation(topologyName);
    if (result == null || !result) {
      throw new TopologyRuntimeManagementException(
          "Failed to clear TMaster location. Check whether TMaster set it correctly.");
    }

    result = statemgr.deleteMetricsCacheLocation(topologyName);
    if (result == null || !result) {
      throw new TopologyRuntimeManagementException(
          "Failed to clear MetricsCache location. Check whether MetricsCache set it correctly.");
    }

    result = statemgr.deletePackingPlan(topologyName);
    if (result == null || !result) {
      throw new TopologyRuntimeManagementException(
          "Failed to clear packing plan. Check whether Launcher set it correctly.");
    }

    result = statemgr.deletePhysicalPlan(topologyName);
    if (result == null || !result) {
      throw new TopologyRuntimeManagementException(
          "Failed to clear physical plan. Check whether TMaster set it correctly.");
    }

    result = statemgr.deleteSchedulerLocation(topologyName);
    if (result == null || !result) {
      throw new TopologyRuntimeManagementException(
          "Failed to clear scheduler location. Check whether Scheduler set it correctly.");
    }

    result = statemgr.deleteLocks(topologyName);
    if (result == null || !result) {
      throw new TopologyRuntimeManagementException(
          "Failed to delete locks. It's possible that the topology never created any.");
    }

    result = statemgr.deleteExecutionState(topologyName);
    if (result == null || !result) {
      throw new TopologyRuntimeManagementException(
          "Failed to clear execution state");
    }

    // Set topology def at last since we determine whether a topology is running
    // by checking the existence of topology def
    result = statemgr.deleteTopology(topologyName);
    if (result == null || !result) {
      throw new TopologyRuntimeManagementException(
          "Failed to clear topology definition");
    }

    LOG.fine("Cleaned up topology state");
  }
40707
function Partition( buffer, start, end ) {

  if( !(this instanceof Partition) )
    return new Partition( buffer, start, end )

  if( buffer != null && !Buffer.isBuffer( buffer ) )
    throw new TypeError( 'Argument must be a Buffer' )

  /** @type {Number} Partition status */
  this.status = 0x00
  /** @type {Number} Partition type identifier */
  this.type = 0x00
  /** @type {Number} Sector count */
  this.sectors = 0x00
  /** @type {Number} LBA of first sector */
  this.firstLBA = 0x00
  /** @type {Number} CHS address of first sector */
  this.firstCHS = new CHS()
  /** @type {Number} CHS address of last sector */
  this.lastCHS = new CHS()

  if( buffer != null ) {
    this.buffer = buffer.slice( start, end )
  }

}
841826
def partition(self, ref=None, **kwargs):
        """"""
        from ambry.orm.exc import NotFoundError
        from sqlalchemy.orm.exc import NoResultFound

        if not ref and not kwargs:
            return None

        if ref:
            for p in self.partitions:
                if ref == p.name or ref == p.vname or ref == p.vid or ref == p.id:
                  p._bundle = self
                  return p

            raise NotFoundError("No partition found for '{}' (a)".format(ref))

        elif kwargs:
            from ..identity import PartitionNameQuery
            pnq = PartitionNameQuery(**kwargs)
            try:
                p = self.partitions._find_orm(pnq).one()
                if p:
                    p._bundle = self
                    return p
            except NoResultFound:
                raise NotFoundError("No partition found for '{}' (b)".format(kwargs))
313555
def acquire_partition(self, partition, source_broker):
        
        broker_dest = self._elect_dest_broker(partition)
        if not broker_dest:
            raise NotEligibleGroupError(
                "No eligible brokers to accept partition {p}".format(p=partition),
            )
        source_broker.move_partition(partition, broker_dest)
584502
public void submitTopology() throws TopologySubmissionException {
    // build primary runtime config first
    Config primaryRuntime = Config.newBuilder()
          .putAll(LauncherUtils.getInstance().createPrimaryRuntime(topology)).build();
    // call launcher directly here if in dry-run mode
    if (Context.dryRun(config)) {
      callLauncherRunner(primaryRuntime);
      return;
    }
    // 1. Do prepare work
    // create an instance of state manager
    String statemgrClass = Context.stateManagerClass(config);
    IStateManager statemgr;

    // Create an instance of the launcher class
    String launcherClass = Context.launcherClass(config);
    ILauncher launcher;

    // create an instance of the uploader class
    String uploaderClass = Context.uploaderClass(config);
    IUploader uploader;

    // create an instance of state manager
    try {
      statemgr = ReflectionUtils.newInstance(statemgrClass);
    } catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
      throw new TopologySubmissionException(
          String.format("Failed to instantiate state manager class '%s'", statemgrClass), e);
    }

    // create an instance of launcher
    try {
      launcher = ReflectionUtils.newInstance(launcherClass);
    } catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
      throw new LauncherException(
          String.format("Failed to instantiate launcher class '%s'", launcherClass), e);
    }

    // create an instance of uploader
    try {
      uploader = ReflectionUtils.newInstance(uploaderClass);
    } catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
      throw new UploaderException(
          String.format("Failed to instantiate uploader class '%s'", uploaderClass), e);
    }

    // Put it in a try block so that we can always clean resources
    try {
      // initialize the state manager
      statemgr.initialize(config);

      // initialize the uploader
      uploader.initialize(config);

      // TODO(mfu): timeout should read from config
      SchedulerStateManagerAdaptor adaptor = new SchedulerStateManagerAdaptor(statemgr, 5000);

      // Check if topology is already running
      validateSubmit(adaptor, topology.getName());

      LOG.log(Level.FINE, "Topology {0} to be submitted", topology.getName());

      Config runtimeWithoutPackageURI = Config.newBuilder()
          .putAll(primaryRuntime)
          .putAll(LauncherUtils.getInstance().createAdaptorRuntime(adaptor))
          .put(Key.LAUNCHER_CLASS_INSTANCE, launcher)
          .build();

      PackingPlan packingPlan = LauncherUtils.getInstance()
          .createPackingPlan(config, runtimeWithoutPackageURI);

      // The packing plan might call for a number of containers different than the config
      // settings. If that's the case we need to modify the configs to match.
      runtimeWithoutPackageURI =
          updateNumContainersIfNeeded(runtimeWithoutPackageURI, topology, packingPlan);

      // If the packing plan is valid we will upload necessary packages
      URI packageURI = uploadPackage(uploader);

      // Update the runtime config with the packageURI
      Config runtimeAll = Config.newBuilder()
          .putAll(runtimeWithoutPackageURI)
          .put(Key.TOPOLOGY_PACKAGE_URI, packageURI)
          .build();

      callLauncherRunner(runtimeAll);

    } catch (LauncherException | PackingException e) {
      // we undo uploading of topology package only if launcher fails to
      // launch topology, which will throw LauncherException or PackingException
      uploader.undo();
      throw e;
    } finally {
      SysUtils.closeIgnoringExceptions(uploader);
      SysUtils.closeIgnoringExceptions(launcher);
      SysUtils.closeIgnoringExceptions(statemgr);
    }
  }
301896
private void createPartitions() {

        for (Map.Entry<String, String> partitionEntry : this.partitions.entrySet()) {
            try {
                this.addPartitionInternal(partitionEntry.getKey(), partitionEntry.getValue());
            } catch (Exception e) { //NOSONAR
                throw new AssertionError("Could not create partitions " + this.partitions, e);
            }
        }
    }
730649
def _add_partition(self, connection, partition):
        
        logger.debug('Creating virtual table for partition.\n    partition: {}'.format(partition.name))
        sqlite_med.add_partition(connection, partition.datafile, partition.vid+'_vt')
921995
def detach_disk(name=None, kwargs=None, call=None):
    '''
    
    '''
    if call != 'action':
        raise SaltCloudSystemExit(
            'The detach_Disk action must be called with -a or --action.'
        )

    if not name:
        log.error(
            'Must specify an instance name.'
        )
        return False
    if not kwargs or 'disk_name' not in kwargs:
        log.error(
            'Must specify a disk_name to detach.'
        )
        return False

    node_name = name
    disk_name = kwargs['disk_name']

    conn = get_conn()
    node = conn.ex_get_node(node_name)
    disk = conn.ex_get_volume(disk_name)

    __utils__['cloud.fire_event'](
        'event',
        'detach disk',
        'salt/cloud/disk/detaching',
        args={
            'name': node_name,
            'disk_name': disk_name,
        },
        sock_dir=__opts__['sock_dir'],
        transport=__opts__['transport']
    )

    result = conn.detach_volume(disk, node)

    __utils__['cloud.fire_event'](
        'event',
        'detached disk',
        'salt/cloud/disk/detached',
        args={
            'name': node_name,
            'disk_name': disk_name,
        },
        sock_dir=__opts__['sock_dir'],
        transport=__opts__['transport']
    )
    return result
719185
def append_partition_with_environment_context(self, db_name, tbl_name, part_vals, environment_context):
    
    self.send_append_partition_with_environment_context(db_name, tbl_name, part_vals, environment_context)
    return self.recv_append_partition_with_environment_context()
427624
def as_partition(self, **kwargs):
        """"""

        return PartitionName(**dict(list(self.dict.items()) + list(kwargs.items())))
231179
def no_args(**kwargs):
    """"""
    from benchbuild.utils.cmd import uchroot as uchrt

    prefixes = CFG["container"]["prefixes"].value
    p_paths, p_libs = env(prefixes)
    uchrt = run.with_env_recursive(
        uchrt,
        LD_LIBRARY_PATH=path.list_to_path(p_libs),
        PATH=path.list_to_path(p_paths))

    return uchrt
1044733
private static Partition createRangeSubPartition(SqlgGraph sqlgGraph, Partition parentPartition, String name, String from, String to) {
        Preconditions.checkArgument(!parentPartition.getAbstractLabel().getSchema().isSqlgSchema(), "createRangeSubPartition may not be called for \"%s\"", Topology.SQLG_SCHEMA);
        Partition partition = new Partition(sqlgGraph, parentPartition, name, from, to, PartitionType.NONE, null);
        partition.createRangePartitionOnDb();
        TopologyManager.addSubPartition(sqlgGraph, partition);
        partition.committed = false;
        return partition;
    }