'Create a new ``FlockerClient`` instance pointing at a running control
service REST API.
:return: ``FlockerClient`` instance.'

@skipUnless(platform.isLinux(), 'flocker-node-era    currently    requires    Linux.')
@skipUnless(which('flocker-node-era'), 'flocker-node-era    needs    to    be    in    $PATH.')
def create_client(self):

    clock = Clock()
    (_, self.port) = find_free_port()
    self.persistence_service = ConfigurationPersistenceService(clock, FilePath(self.mktemp()))
    self.persistence_service.startService()
    self.cluster_state_service = ClusterStateService(reactor)
    self.cluster_state_service.startService()
    source = ChangeSource()
    source.set_last_activity(reactor.seconds())
    self.era = UUID(check_output(['flocker-node-era']))
    self.cluster_state_service.apply_changes_from_source(source=source, changes=([UpdateNodeStateEra(era=self.era, uuid=self.node_1.uuid)] + [NodeState(uuid=node.uuid, hostname=node.public_address) for node in [self.node_1, self.node_2]]))
    self.addCleanup(self.cluster_state_service.stopService)
    self.addCleanup(self.persistence_service.stopService)
    (credential_set, _) = get_credential_sets()
    credentials_path = FilePath(self.mktemp())
    credentials_path.makedirs()
    api_service = create_api_service(self.persistence_service, self.cluster_state_service, TCP4ServerEndpoint(reactor, self.port, interface='127.0.0.1'), rest_api_context_factory(credential_set.root.credential.certificate, credential_set.control), clock)
    api_service.startService()
    self.addCleanup(api_service.stopService)
    credential_set.copy_to(credentials_path, user=True)
    return FlockerClient(reactor, '127.0.0.1', self.port, credentials_path.child('cluster.crt'), credentials_path.child('user.crt'), credentials_path.child('user.key'))
