'Returns the NodeState and the NonManifestDatasets of the local state.
These are the only parts of the state that need to be sent to the
control service.'

def shared_state_changes(self):

    manifestations = {}
    paths = {}
    devices = {}
    nonmanifest_datasets = {}
    for dataset in self.datasets.values():
        dataset_id = dataset.dataset_id
        if (dataset.state == DatasetStates.MOUNTED):
            manifestations[unicode(dataset_id)] = Manifestation(dataset=Dataset(dataset_id=dataset_id, maximum_size=dataset.maximum_size), primary=True)
            paths[unicode(dataset_id)] = dataset.mount_point
        elif (dataset.state in (DatasetStates.NON_MANIFEST, DatasetStates.ATTACHED, DatasetStates.ATTACHED_NO_FILESYSTEM, DatasetStates.ATTACHED_TO_DEAD_NODE)):
            nonmanifest_datasets[unicode(dataset_id)] = Dataset(dataset_id=dataset_id, maximum_size=dataset.maximum_size)
        if (dataset.state in (DatasetStates.MOUNTED, DatasetStates.ATTACHED, DatasetStates.ATTACHED_NO_FILESYSTEM)):
            devices[dataset_id] = dataset.device_path
    return (NodeState(uuid=self.node_uuid, hostname=self.hostname, manifestations=manifestations, paths=paths, devices=devices, applications=None), NonManifestDatasets(datasets=nonmanifest_datasets))
