-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
110 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
0.3.3 (2016-??-??) | ||
================== | ||
|
||
- ?? | ||
|
||
0.3.2 (2016-02-07) | ||
================== | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Usage | ||
----- | ||
|
||
Simple admin web interface with CRUD operation for docker container | ||
and images. You can delete create and edit it. In example uses default | ||
crud templates from ``pyramid_sacrud/templates/sacrud/crud/``. | ||
|
||
.. code-block:: bash | ||
$ cd examples/docker-crud/ | ||
$ python main.py | ||
and goto http://localhost:6543/admin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from zope.interface import implementer | ||
from docker import Client | ||
|
||
from pyramid.view import view_config | ||
from pyramid.config import Configurator | ||
from pyramid_sacrud import PYRAMID_SACRUD_VIEW | ||
from pyramid_sacrud.interfaces import ISacrudResource | ||
from paginate import Page | ||
|
||
|
||
@implementer(ISacrudResource) | ||
class Docker(object): | ||
|
||
breadcrumb = True | ||
|
||
def __init__(self): | ||
self.cli = Client(base_url='unix://var/run/docker.sock') | ||
|
||
@property | ||
def verbose_name(self): | ||
return self.__class__.__name__ + "'s" | ||
|
||
@property | ||
def __name__(self): | ||
return self.verbose_name | ||
|
||
|
||
class Container(Docker): | ||
|
||
def get_id(self, row): | ||
return row['Id'] | ||
|
||
@property | ||
def all(self): | ||
return self.cli.images() | ||
|
||
|
||
@view_config( | ||
context=Docker, | ||
renderer='sacrud/crud/list.jinja2', | ||
route_name=PYRAMID_SACRUD_VIEW | ||
) | ||
def admin_docker_list_view(context, request): | ||
return { | ||
'paginator': Page( | ||
context.all, | ||
url_maker=lambda p: request.path_url + "?page=%s" % p, | ||
page=int(request.params.get('page', 1)), | ||
items_per_page=6 | ||
) | ||
} | ||
|
||
if __name__ == '__main__': | ||
config = Configurator() | ||
|
||
# Setting up pyramid_sacrud | ||
config.include('pyramid_sacrud', route_prefix='admin') | ||
settings = config.get_settings() | ||
settings['pyramid_sacrud.models'] = ( | ||
('Docker', [Container(), ]), | ||
) | ||
|
||
# Make app | ||
config.scan('.') | ||
app = config.make_wsgi_app() | ||
|
||
# Start app | ||
from wsgiref.simple_server import make_server | ||
server = make_server('0.0.0.0', 6543, app) | ||
server.serve_forever() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
docker-py | ||
pyramid | ||
pyramid_sacrud |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters