code: def check_valid_cpc_status(method, uri, cpc):
      
      status = cpc.properties.get('status', None)
      if status is None:
          # Do nothing if no status is set on the faked CPC
          return
      valid_statuses = ['active', 'service-required', 'degraded', 'exceptions']
      if status not in valid_statuses:
          if uri.startswith(cpc.uri):
              # The uri targets the CPC (either is the CPC uri or some
              # multiplicity under the CPC uri)
              raise ConflictError(method, uri, reason=1,
                                  message="The operation cannot be performed "
                                  "because the targeted CPC {} has a status "
                                  "that is not valid for the operation: {}".
                                  format(cpc.name, status))
          else:
              # The uri targets a resource hosted by the CPC
              raise ConflictError(method, uri, reason=6,
                                  message="The operation cannot be performed "
                                  "because CPC {} hosting the targeted resource "
                                  "has a status that is not valid for the "
                                  "operation: {}".
                                  format(cpc.name, status))
docs: Check that the CPC is in a valid status, as indicated by its 'status'
      property.
  
      If the Cpc object does not have a 'status' property set, this function does
      nothing (in order to make the mock support easy to use).
  
      Raises:
        ConflictError with reason 1: The CPC itself has been targeted by the
          operation.
        ConflictError with reason 6: The CPC is hosting the resource targeted by
          the operation.