~hazmat/pyjuju/rapi-delta

« back to all changes in this revision

Viewing changes to juju/providers/local/files.py

  • Committer: Kapil Thangavelu
  • Date: 2012-09-19 20:38:44 UTC
  • mfrom: (573.1.6 rest-context)
  • Revision ID: kapil@canonical.com-20120919203844-dc2pf82ttm7xj3xs
Merged rest-context into rapi-delta.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from getpass import getuser
2
1
import os
3
2
from StringIO import StringIO
4
 
import yaml
5
3
 
6
4
from twisted.internet.defer import inlineCallbacks, returnValue
7
5
from twisted.internet.error import ConnectionRefusedError
8
6
from twisted.web.client import getPage
9
7
 
10
8
from juju.errors import ProviderError, FileNotFound
 
9
from juju.lib import serializer
11
10
from juju.lib.upstart import UpstartService
12
11
from juju.providers.common.files import FileStorage
13
12
 
78
77
        storage = LocalStorage(self._storage_dir)
79
78
        yield storage.put(
80
79
            SERVER_URL_KEY,
81
 
            StringIO(yaml.safe_dump(
 
80
            StringIO(serializer.dump(
82
81
                {"storage-url": "http://%s:%s/" % (self._host, self._port)})))
83
82
 
84
83
        self._service.set_command(" ".join(self._service_args))
111
110
 
112
111
        if not storage_data or not "storage-url" in storage_data:
113
112
            raise ProviderError("Storage not initialized")
114
 
        url = yaml.load(storage_data)["storage-url"]
 
113
        url = serializer.load(storage_data)["storage-url"]
115
114
        returnValue(url + key)