def render_app_from_etcd_value(cls, etcd_value): try: app_info = json.loads(etcd_value) appname = app_info.get('appname', '') giturl = app_info.get('giturl', '') meta_version = app_info.get('meta_version', '') meta = app_info.get('meta', '') default_image = app_info.get('default_image', '') running_state = app_info.get('running_state', None) app_type = app_info.get('app_type', None) last_update = app_info.get('last_update', '') last_error = app_info.get('last_error', '') if appname == '': raise InvalidStoreData("appname should not be empty") app = cls() app.appname = appname app.giturl = giturl app.meta_version = meta_version app.meta = meta app.default_image = default_image app.running_state = running_state app.app_type = app_type app.last_update = last_update app.last_error = last_error app._registry_tags = [] app._latest_meta_version = '' app._app_spec = None app._lain_config = None return app except ValueError, e: raise InvalidStoreData(e)
def get(cls, appname): try: etcd_r = read_from_etcd(cls.etcd_app_key(appname)) if etcd_r.dir: raise InvalidStoreData("Store Data should not be dir") except EtcdKeyNotFound, e: raise DoesNotExist(e)