Override method for one in resource.py to check partition

        The partition cannot be included as a parameter to load a guest.
        Raise an exception if a consumer gives the partition parameter.

        :raises: DisallowedReadParameter
428026
def _check_load_parameters(self, **kwargs):
        

        if 'partition' in kwargs:
            msg = "'partition' is not allowed as a load parameter. Vcmp " \
                "guests are accessed by name."
            raise DisallowedReadParameter(msg)
        super(Virtual_Disk, self)._check_load_parameters(**kwargs)
877122
def remove_partition(self, partition):
        """"""
        if partition in self._partitions:
            # Remove partition from set
            self._partitions.remove(partition)
            # Remove broker from replica list of partition
            partition.replicas.remove(self)
        else:
            raise ValueError(
                'Partition: {topic_id}:{partition_id} not found in broker '
                '{broker_id}'.format(
                    topic_id=partition.topic.id,
                    partition_id=partition.partition_id,
                    broker_id=self._id,
                )
            )
1260012
def build_resource_params
        parameters = permitted_params || params
        rparams = [parameters[resource_request_name] || parameters[resource_instance_name] || {}]
        if without_protection_given?
          rparams << without_protection
        else
          rparams << as_role if role_given?
        end

        rparams
      end
293304
def handle_not_allowed(environ, start_response):
    
    _methods = util.wsgi_path_item(environ, '_methods')
    headers = {}
    if _methods:
        headers['allow'] = str(_methods)
    raise webob.exc.HTTPMethodNotAllowed(
        ('The method specified is not allowed for this resource.'),
        headers=headers, json_formatter=util.json_error_formatter)
271105
def allowed_entries(self, capability):
        
        index = re.match(r'(.+)index$', capability)
        archive = re.match(r'(.+)\-archive$', capability)
        if (capability == 'capabilitylistindex'):
            return([])  # not allowed so no valid references
        elif (index):
            return([index.group(1)])  # name without index ending
        elif (archive):
            return([archive.group(1)])  # name without -archive ending
        elif (capability == 'description'):
            return(['capabilitylist'])
        elif (capability == 'capabilitylist'):
            return(['resourcelist', 'resourcedump',
                    'changelist', 'changedump',
                    'resourcelist-archive', 'resourcedump-archive',
                    'changelist-archive', 'changedump-archive'])
        return([])
899622
def _exclusively_used(self, context, hosting_device, tenant_id):
        """"""
        return (context.session.query(hd_models.SlotAllocation).filter(
            hd_models.SlotAllocation.hosting_device_id == hosting_device['id'],
            hd_models.SlotAllocation.logical_resource_owner != tenant_id).
            first() is None)
1307561
def get_partition_owner(self, partition_id):
        
        if partition_id not in self.partitions:
            self._do_refresh()
        return self.partitions.get(partition_id, None)
657542
private void handleDrainedSource() throws IOException {
         if (!inCatalog() && m_committedBuffers.isEmpty()) {
             //Returning null indicates end of stream
             try {
                 if (m_pollTask != null) {
                     m_pollTask.setFuture(null);
                 }
             } catch (RejectedExecutionException reex) {
                 // Ignore, {@code GuestProcessor} was closed
             }
             m_pollTask = null;
             m_generation.onSourceDrained(m_partitionId, m_tableName);
             return;
         }
     }
1256901
def validate_host_parameters(self, host_list, remote_user):
        '''
        
        '''
        if host_list is None:
            host_list = self.host_list

        if remote_user is None:
            remote_user = self.remote_user

        if host_list is None or remote_user is None:
            print "Host list [%s], remote user [%s] are required" % \
                  (host_list, remote_user)
            return (None, None)

        return (host_list, remote_user)
1356568
private void checkUri(AlluxioURI uri) {
    Preconditions.checkNotNull(uri, "uri");
    if (uri.hasScheme()) {
      String warnMsg = "The URI scheme \"{}\" is ignored and not required in URIs passed to"
          + " the Alluxio Filesystem client.";
      switch (uri.getScheme()) {
        case Constants.SCHEME:
          LOG.warn(warnMsg, Constants.SCHEME);
          break;
        case Constants.SCHEME_FT:
          LOG.warn(warnMsg, Constants.SCHEME_FT);
          break;
        default:
          throw new IllegalArgumentException(
              String.format("Scheme %s:// in AlluxioURI is invalid. Schemes in filesystem"
                  + " operations are ignored. \"alluxio://\" or no scheme at all is valid.",
                  uri.getScheme()));
      }
    }

    if (uri.hasAuthority()) {
      LOG.warn("The URI authority (hostname and port) is ignored and not required in URIs passed "
          + "to the Alluxio Filesystem client.");
      /* Even if we choose to log the warning, check if the Configuration host matches what the
       * user passes. If not, throw an exception letting the user know they don't match.
       */
      Authority configured =
          MasterInquireClient.Factory.create(mFsContext.getClusterConf())
              .getConnectDetails().toAuthority();
      if (!configured.equals(uri.getAuthority())) {
        throw new IllegalArgumentException(
            String.format("The URI authority %s does not match the configured " + "value of %s.",
                uri.getAuthority(), configured));
      }
    }
    return;
  }
224433
def post(method, hmc, uri, uri_parms, body, logon_required,
             wait_for_completion):
        """"""
        assert wait_for_completion is True  # async not supported yet
        partition_oid = uri_parms[0]
        partition_uri = '/api/partitions/' + partition_oid
        try:
            partition = hmc.lookup_by_uri(partition_uri)
        except KeyError:
            raise InvalidResourceError(method, uri)
        cpc = partition.manager.parent
        assert cpc.dpm_enabled
        check_valid_cpc_status(method, uri, cpc)
        check_partition_status(method, uri, partition,
                               valid_statuses=['stopped'])

        # Reflect the result of starting the partition
        partition.properties['status'] = 'active'
        return {}
332565
def _check_create_parameters(self, **kwargs):
        

        if 'partition' in kwargs:
            msg = "'partition' is not allowed as a create parameter. Vcmp " \
                "guests are created with the 'name' at least."
            raise DisallowedCreationParameter(msg)
        super(Guest, self)._check_create_parameters(**kwargs)
289243
PartitionReplica checkAndGetPrimaryReplicaOwner(int partitionId, int replicaIndex) {
        InternalPartitionImpl partition = partitionStateManager.getPartitionImpl(partitionId);
        PartitionReplica owner = partition.getOwnerReplicaOrNull();
        if (owner == null) {
            logger.info("Sync replica target is null, no need to sync -> partitionId=" + partitionId + ", replicaIndex="
                    + replicaIndex);
            return null;
        }

        PartitionReplica localReplica = PartitionReplica.from(nodeEngine.getLocalMember());
        if (owner.equals(localReplica)) {
            if (logger.isFinestEnabled()) {
                logger.finest("This node is now owner of partition, cannot sync replica -> partitionId=" + partitionId
                        + ", replicaIndex=" + replicaIndex + ", partition-info="
                        + partitionStateManager.getPartitionImpl(partitionId));
            }
            return null;
        }

        if (!partition.isOwnerOrBackup(localReplica)) {
            if (logger.isFinestEnabled()) {
                logger.finest("This node is not backup replica of partitionId=" + partitionId
                        + ", replicaIndex=" + replicaIndex + " anymore.");
            }
            return null;
        }
        return owner;
    }
659668
def container_permitted(self, name):
        
        white = self._container_whitelist
        black = self._container_blacklist
        return name not in black and (not white or name in white)
1277442
def post(method, hmc, uri, uri_parms, body, logon_required,
             wait_for_completion):
        """"""
        assert wait_for_completion is True  # async not supported yet
        partition_oid = uri_parms[0]
        partition_uri = '/api/partitions/' + partition_oid
        try:
            partition = hmc.lookup_by_uri(partition_uri)
        except KeyError:
            raise InvalidResourceError(method, uri)
        cpc = partition.manager.parent
        assert cpc.dpm_enabled
        check_valid_cpc_status(method, uri, cpc)
        check_partition_status(method, uri, partition,
                               invalid_statuses=['starting', 'stopping'])
        check_required_fields(method, uri, body, [])  # check just body

        adapter_uris, domain_configs = ensure_crypto_config(partition)

        remove_adapter_uris = body.get('crypto-adapter-uris', [])
        remove_domain_indexes = body.get('crypto-domain-indexes', [])

        # We don't support finding errors in this simple-minded mock support,
        # so we assume that the input is fine (e.g. no invalid adapters) and
        # we just remove it.

        for uri in remove_adapter_uris:
            if uri in adapter_uris:
                adapter_uris.remove(uri)
        for remove_di in remove_domain_indexes:
            for i, dc in enumerate(domain_configs):
                if dc['domain-index'] == remove_di:
                    del domain_configs[i]
730108
def _check_load_parameters(self, **kwargs):
        
        rset = self._meta_data['required_load_parameters']
        check = _missing_required_parameters(rset, **kwargs)
        if check:
            check.sort()
            error_message = 'Missing required params: %s' % check
            raise MissingRequiredReadParameter(error_message)
559257
private static VirtualNetworkAdapterType validateNicType(GuestOsDescriptor[] guestOsDescriptorList,
                                                             String guestId, VirtualNetworkAdapterType adapterType) throws DeviceNotSupported {
        VirtualNetworkAdapterType result = adapterType;

        GuestOsDescriptor guestOsInfo = null;

        for (GuestOsDescriptor desc : guestOsDescriptorList) {
            if (desc.getId().equalsIgnoreCase(guestId)) {
                guestOsInfo = desc;
                break;
            }
        }

        if (adapterType == VirtualNetworkAdapterType.Unknown) {
            result = TryGetNetworkAdapterType(guestOsInfo);
        }
        else {
            if (guestOsInfo.getSupportedEthernetCard() != null) {
                boolean supported = false;
                List<String> supportedTypeList = new ArrayList<String>();

                for (String supportedAdapterName : guestOsInfo.getSupportedEthernetCard()) {
                    VirtualNetworkAdapterType supportedAdapterType = GetNetworkAdapterTypeByApiType(supportedAdapterName);
                    supportedTypeList.add(supportedAdapterType.toString());

                    if (supportedAdapterType == adapterType) {
                        supported = true;
                        break;
                    }
                }

                if (!supported) {
                    DeviceNotSupported dns = new DeviceNotSupported();
                    dns.setDevice("Virtual NIC");
                    dns.setReason("The requested NIC is not supported in this OS.");
                    throw dns;
                }
            }
        }
        return result;
    }