Beispiel #1
0
 def delete_route_from_app(self,app,route):
     logging.info("Removing route {} to app {}".format(route.host,app.name))
     assert isinstance(app,CloudFoundryApp)
     assert isinstance(route,CloudFoundryRoute)
     response = self._delete_or_exception("v2/apps/{}/routes/{}".format(app.guid,route.guid))
     self._apps[app.guid] = CloudFoundryApp.from_dict(response['metadata'],response['entity'])
     self._routes = self._update_routes()
Beispiel #2
0
    def create_app(self, name, space):
        """
        Creates an application

        :param name: Name of the application
        :type name: str
        :param space: space in which to create the app
        :type space: CloudFoundrySpace
        :return: The CloudFoundryApp object corresponding to the new app
        :rtype: CloudFoundryApp
        """
        assert isinstance(space, CloudFoundrySpace)
        logging.warn("Creating new app in space {}".format(space.guid))

        if self.get_app_by_name(name) is not None:
            return self.get_app_by_name(name)

        response = self._post_or_exception("v2/apps",
                                           data={
                                               'name': name,
                                               'space_guid': space.guid
                                           })
        metadata = response['metadata']
        app_data = response['entity']
        app = CloudFoundryApp.from_dict(metadata, app_data)
        self._apps[app.guid] = app

        return app
Beispiel #3
0
    def create_app(self,name, space_guid):
        logging.warn("Creating new app in space {}".format(space_guid))

        response = self._post_or_exception("v2/apps",data={'name':name, 'space_guid':space_guid})
        metadata = response['metadata']
        app_data = response['entity']
        app = CloudFoundryApp.from_dict(metadata,app_data)
        self._apps[app.guid] = app
        return app
Beispiel #4
0
 def _update_apps(self):
     logging.info("Updating all app as user {}".format(self._username))
     raw = self._get_or_exception("v2/apps")['resources']
     apps = {}
     for app in raw:
         app_data = app['entity']
         metadata = app['metadata']
         current_app = CloudFoundryApp.from_dict(metadata,app_data)
         apps[current_app.guid] = current_app
     self._apps = apps
Beispiel #5
0
 def add_route_to_app(self,app,route):
     self._update_apps()
     self._update_routes.delete()
     self._update_routes()
     assert isinstance(app, CloudFoundryApp)
     assert isinstance(route, CloudFoundryRoute)
     logging.info("Adding route {} to app {}".format(route.host,app.name))
     response = self._put_or_exception("v2/apps/{}/routes/{}".format(app.guid,route.guid))
     self._apps[app.guid] = CloudFoundryApp.from_dict(response['metadata'],response['entity'])
     self._update_routes.delete()
    def create_app(self,name, space):
        """
        Creates an application

        :param name: Name of the application
        :type name: str
        :param space: space in which to create the app
        :type space: CloudFoundrySpace
        :return: The CloudFoundryApp object corresponding to the new app
        :rtype: CloudFoundryApp
        """
        assert isinstance(space,CloudFoundrySpace)
        logging.warn("Creating new app in space {}".format(space.guid))

        if self.get_app_by_name(name) is not None:
            return self.get_app_by_name(name)

        response = self._post_or_exception("v2/apps",data={'name':name, 'space_guid':space.guid})
        metadata = response['metadata']
        app_data = response['entity']
        app = CloudFoundryApp.from_dict(metadata,app_data)
        self._apps[app.guid] = app

        return app
 def get_app(self, name):
     return CloudFoundryApp.from_dict(self._get_json_or_exception("apps/%s" % name), self)
 def get_apps(self):
     return [CloudFoundryApp.from_dict(app, self) for app in self._get_json_or_exception("apps/")]
Beispiel #9
0
 def get_app(self, name):
     return CloudFoundryApp.from_dict(self._get_json_or_exception("apps/%s" % name), self)
Beispiel #10
0
 def get_apps(self):
     return [CloudFoundryApp.from_dict(app, self) for app in self._get_json_or_exception("apps/")]