Skip to content

Instantly share code, notes, and snippets.

@akutz
Last active April 21, 2016 01:38
Show Gist options
  • Save akutz/e1e56e30a73a6260d60e1cd87af46fe2 to your computer and use it in GitHub Desktop.
Save akutz/e1e56e30a73a6260d60e1cd87af46fe2 to your computer and use it in GitHub Desktop.
libStorage embedded C client & server
$ libstor-c /Users/akutz/.libstorage/config.yaml
service: mock
- volume: vol-001
name: Volume 1
iops: 0
size: 40960
type: gold
zone: zone-001
status:
netnam:
- volume: vol-002
name: Volume 2
iops: 0
size: 163840
type: gold
zone: zone-002
status:
netnam:
- volume: vol-000
name: Volume 0
iops: 0
size: 10240
type: gold
zone: zone-000
status:
netnam:
$ env LIBSTORAGE_DEBUG=true LIBSTORAGE_RUN_HOST="tcp://127.0.0.1:7979" DYLD_LIBRARY_PATH=$GOPATH/pkg/darwin_amd64/github.com/emccode/libstorage/c libstor-s mock
INFO[0000] parsed gostr gostr=mock x=0
INFO[0000] serving args=[mock] host= tls=false
DEBU[0000] initializing configuration
DEBU[0000] adding flag defaultValue= envVar=VFS_ROOT flagName=vfsRoot keyName=vfs.root keyType=0 usage=/var/folders/48/52fjq9r10zx3gnm7j57th0500000gn/T//libstorage-vfs
DEBU[0000] adding flag defaultValue= envVar=LIBSTORAGE_HOST flagName=libstorageHost keyName=libstorage.host keyType=0 usage=
DEBU[0000] adding flag defaultValue= envVar=LIBSTORAGE_SERVICE flagName=libstorageService keyName=libstorage.service keyType=0 usage=
DEBU[0000] adding flag defaultValue= envVar=LIBSTORAGE_DRIVER flagName=libstorageDriver keyName=libstorage.driver keyType=0 usage=
DEBU[0000] adding flag defaultValue=false envVar=LIBSTORAGE_PROFILES_ENABLED flagName=libstorageProfilesEnabled keyName=libstorage.profiles.enabled keyType=2 usage=
DEBU[0000] adding flag defaultValue=false envVar=LIBSTORAGE_PROFILES_CLIENT flagName=libstorageProfilesClient keyName=libstorage.profiles.client keyType=2 usage=
DEBU[0000] adding flag defaultValue=local=127.0.0.1 envVar=LIBSTORAGE_PROFILES_GROUPS flagName=libstorageProfilesGroups keyName=libstorage.profiles.groups keyType=0 usage=
DEBU[0000] adding flag defaultValue=/proc/partitions envVar=LIBSTORAGE_CLIENT_LOCALDEVICESFILE flagName=libstorageClientLocaldevicesfile keyName=libstorage.client.localdevicesfile keyType=0 usage=
DEBU[0000] adding flag defaultValue=/usr/local/bin envVar=LIBSTORAGE_CLIENT_TOOLDIR flagName=libstorageClientTooldir keyName=libstorage.client.tooldir keyType=0 usage=
DEBU[0000] adding flag defaultValue=false envVar=LIBSTORAGE_CLIENT_HTTP_LOGGING_ENABLED flagName=libstorageClientHttpLoggingEnabled keyName=libstorage.client.http.logging.enabled keyType=2 usage=
DEBU[0000] adding flag defaultValue= envVar=LIBSTORAGE_CLIENT_HTTP_LOGGING_OUT flagName=libstorageClientHttpLoggingOut keyName=libstorage.client.http.logging.out keyType=0 usage=
DEBU[0000] adding flag defaultValue= envVar=LIBSTORAGE_CLIENT_HTTP_LOGGING_ERR flagName=libstorageClientHttpLoggingErr keyName=libstorage.client.http.logging.err keyType=0 usage=
DEBU[0000] adding flag defaultValue=false envVar=LIBSTORAGE_CLIENT_HTTP_LOGGING_LOGREQUEST flagName=libstorageClientHttpLoggingLogrequest keyName=libstorage.client.http.logging.logrequest keyType=2 usage=
DEBU[0000] adding flag defaultValue=false envVar=LIBSTORAGE_CLIENT_HTTP_LOGGING_LOGRESPONSE flagName=libstorageClientHttpLoggingLogresponse keyName=libstorage.client.http.logging.logresponse keyType=2 usage=
DEBU[0000] adding flag defaultValue=60 envVar=LIBSTORAGE_SERVER_READTIMEOUT flagName=libstorageServerReadtimeout keyName=libstorage.server.readtimeout keyType=1 usage=
DEBU[0000] adding flag defaultValue=60 envVar=LIBSTORAGE_SERVER_WRITETIMEOUT flagName=libstorageServerWritetimeout keyName=libstorage.server.writetimeout keyType=1 usage=
DEBU[0000] adding flag defaultValue=false envVar=LIBSTORAGE_SERVER_HTTP_LOGGING_ENABLED flagName=libstorageServerHttpLoggingEnabled keyName=libstorage.server.http.logging.enabled keyType=2 usage=
DEBU[0000] adding flag defaultValue= envVar=LIBSTORAGE_SERVER_HTTP_LOGGING_OUT flagName=libstorageServerHttpLoggingOut keyName=libstorage.server.http.logging.out keyType=0 usage=
DEBU[0000] adding flag defaultValue= envVar=LIBSTORAGE_SERVER_HTTP_LOGGING_ERR flagName=libstorageServerHttpLoggingErr keyName=libstorage.server.http.logging.err keyType=0 usage=
DEBU[0000] adding flag defaultValue=false envVar=LIBSTORAGE_SERVER_HTTP_LOGGING_LOGREQUEST flagName=libstorageServerHttpLoggingLogrequest keyName=libstorage.server.http.logging.logrequest keyType=2 usage=
DEBU[0000] adding flag defaultValue=false envVar=LIBSTORAGE_SERVER_HTTP_LOGGING_LOGRESPONSE flagName=libstorageServerHttpLoggingLogresponse keyName=libstorage.server.http.logging.logresponse keyType=2 usage=
DEBU[0000]
libstorage:
host: tcp://127.0.0.1:7979
profiles:
enabled: true
groups:
- local=127.0.0.1
server:
endpoints:
localhost:
address: tcp://127.0.0.1:7979
services:
mock:
libstorage:
driver: mock
DEBU[0000] initializing server server=oil-shirt-id
INFO[0000] configured endpoint address=tcp://127.0.0.1:7979 endpoint=localhost
INFO[0000] server created host=tcp://127.0.0.1:7979 server=oil-shirt-id tls=false
DEBU[0000] initialized endpoints server=oil-shirt-id
DEBU[0000] got services map count=1
DEBU[0000] processing service config service=mock
DEBU[0000] getting scoped config for service scope=libstorage.server.services.mock
INFO[0000] created new service driver=mock service=mock
DEBU[0000] initialized services server=oil-shirt-id
INFO[0000] initialized router len(routes)=3 router=executor-router
INFO[0000] initialized router len(routes)=1 router=root-router
INFO[0000] initialized router len(routes)=2 router=service-router
INFO[0000] initialized router len(routes)=6 router=snapshot-router
INFO[0000] initialized router len(routes)=2 router=tasks-router
INFO[0000] initialized router len(routes)=14 router=volume-router
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=0 method=GET path=/executors queries=[] server=oil-shirt-id tls=false
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=0 method=GET path=/executors/{executor} queries=[] server=oil-shirt-id tls=false
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=0 method=HEAD path=/executors/{executor} queries=[] server=oil-shirt-id tls=false
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=0 method=GET path=/ queries=[] server=oil-shirt-id tls=false
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=0 method=GET path=/services queries=[] server=oil-shirt-id tls=false
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=0 method=GET path=/services/{service} queries=[] server=oil-shirt-id tls=false
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=0 method=GET path=/snapshots queries=[] server=oil-shirt-id tls=false
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=0 method=GET path=/snapshots/{service} queries=[] server=oil-shirt-id tls=false
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=0 method=GET path=/snapshots/{service}/{snapshotID} queries=[] server=oil-shirt-id tls=false
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=2 method=POST path=/snapshots/{service}/{snapshotID} queries=[create ] server=oil-shirt-id tls=false
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=2 method=POST path=/snapshots/{service}/{snapshotID} queries=[copy ] server=oil-shirt-id tls=false
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=0 method=DELETE path=/snapshots/{service}/{snapshotID} queries=[] server=oil-shirt-id tls=false
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=0 method=GET path=/tasks queries=[] server=oil-shirt-id tls=false
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=0 method=GET path=/tasks/{taskID} queries=[] server=oil-shirt-id tls=false
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=2 method=GET path=/volumes queries=[attachments ] server=oil-shirt-id tls=false
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=0 method=GET path=/volumes queries=[] server=oil-shirt-id tls=false
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=2 method=GET path=/volumes/{service} queries=[attachments ] server=oil-shirt-id tls=false
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=0 method=GET path=/volumes/{service} queries=[] server=oil-shirt-id tls=false
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=2 method=GET path=/volumes/{service}/{volumeID} queries=[attachments ] server=oil-shirt-id tls=false
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=0 method=GET path=/volumes/{service}/{volumeID} queries=[] server=oil-shirt-id tls=false
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=2 method=POST path=/volumes/{service} queries=[detach ] server=oil-shirt-id tls=false
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=0 method=POST path=/volumes/{service} queries=[] server=oil-shirt-id tls=false
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=2 method=POST path=/volumes/{service}/{volumeID} queries=[copy ] server=oil-shirt-id tls=false
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=2 method=POST path=/volumes/{service}/{volumeID} queries=[snapshot ] server=oil-shirt-id tls=false
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=2 method=POST path=/volumes/{service}/{volumeID} queries=[attach ] server=oil-shirt-id tls=false
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=2 method=POST path=/volumes queries=[detach ] server=oil-shirt-id tls=false
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=2 method=POST path=/volumes/{service}/{volumeID} queries=[detach ] server=oil-shirt-id tls=false
DEBU[0000] registered route host=tcp://127.0.0.1:7979 len(queries)=0 method=DELETE path=/volumes/{service}/{volumeID} queries=[] server=oil-shirt-id tls=false
INFO[0000] api listening host=tcp://127.0.0.1:7979 server=oil-shirt-id tls=false
DEBU[0000] waiting for err or close signal server=oil-shirt-id
INFO[0001] server started server=oil-shirt-id
DEBU[0005] http request host=tcp://127.0.0.1:7979 route=volumes server=oil-shirt-id tls=false
DEBU[0005] added route middlware host=tcp://127.0.0.1:7979 middleware=schmea-validator route=volumes server=oil-shirt-id tls=false
DEBU[0005] added global middlware host=tcp://127.0.0.1:7979 middleware=instanceIDs-handler route=volumes server=oil-shirt-id tls=false
DEBU[0005] added global middlware host=tcp://127.0.0.1:7979 middleware=error-handler route=volumes server=oil-shirt-id tls=false
DEBU[0005] added global middlware host=tcp://127.0.0.1:7979 middleware=logging-handler route=volumes server=oil-shirt-id tls=false
DEBU[0005] added global middlware host=tcp://127.0.0.1:7979 middleware=query-params-handler route=volumes server=oil-shirt-id tls=false
DEBU[0005] http header host=tcp://127.0.0.1:7979 libstorage-instanceid= route=volumes server=oil-shirt-id tls=false
INFO[0005] executing task host=tcp://127.0.0.1:7979 route=volumes server=oil-shirt-id task=0 tls=false
INFO[0005] executing task host=tcp://127.0.0.1:7979 route=volumes server=oil-shirt-id task=1 tls=false
DEBU[0005] validating schema body={"vol-000":{"availabilityZone":"zone-000","name":"Volume 0","size":10240,"id":"vol-000","type":"gold"},"vol-001":{"availabilityZone":"zone-001","name":"Volume 1","size":40960,"id":"vol-001","type":"gold"},"vol-002":{"availabilityZone":"zone-002","name":"Volume 2","size":163840,"id":"vol-002","type":"gold"}} host=tcp://127.0.0.1:7979 route=volumes schema={
"$schema": "http://json-schema.org/draft-04/schema#",
"$ref": "https://github.com/emccode/libstorage#/definitions/volumeMap"
} server=oil-shirt-id task=0 tls=false
DEBU[0005] task completed host=tcp://127.0.0.1:7979 route=volumes server=oil-shirt-id task=0 tls=false
DEBU[0005] validating schema body={"mock":{"vol-000":{"availabilityZone":"zone-000","name":"Volume 0","size":10240,"id":"vol-000","type":"gold"},"vol-001":{"availabilityZone":"zone-001","name":"Volume 1","size":40960,"id":"vol-001","type":"gold"},"vol-002":{"availabilityZone":"zone-002","name":"Volume 2","size":163840,"id":"vol-002","type":"gold"}}} host=tcp://127.0.0.1:7979 route=volumes schema={
"$schema": "http://json-schema.org/draft-04/schema#",
"$ref": "https://github.com/emccode/libstorage#/definitions/serviceVolumeMap"
} server=oil-shirt-id task=1 tls=false
DEBU[0005] task completed host=tcp://127.0.0.1:7979 route=volumes server=oil-shirt-id task=1 tls=false
INFO[0005] 127.0.0.1 - - [20/Apr/2016:20:37:58 -0500] "GET /volumes HTTP/1.1" 200 478
INFO[0005]
INFO[0005] -------------------------- HTTP REQUEST (SERVER) --------------------------
INFO[0005] GET /volumes HTTP/1.1
INFO[0005] Host: 127.0.0.1:7979
INFO[0005] Accept-Encoding: gzip
INFO[0005] User-Agent: Go-http-client/1.1
INFO[0005]
INFO[0005] -------------------------- HTTP RESPONSE (SERVER) -------------------------
INFO[0005] Content-Type=application/json
INFO[0005]
INFO[0005] {
INFO[0005] "mock": {
INFO[0005] "vol-000": {
INFO[0005] "availabilityZone": "zone-000",
INFO[0005] "name": "Volume 0",
INFO[0005] "size": 10240,
INFO[0005] "id": "vol-000",
INFO[0005] "type": "gold"
INFO[0005] },
INFO[0005] "vol-001": {
INFO[0005] "availabilityZone": "zone-001",
INFO[0005] "name": "Volume 1",
INFO[0005] "size": 40960,
INFO[0005] "id": "vol-001",
INFO[0005] "type": "gold"
INFO[0005] },
INFO[0005] "vol-002": {
INFO[0005] "availabilityZone": "zone-002",
INFO[0005] "name": "Volume 2",
INFO[0005] "size": 163840,
INFO[0005] "id": "vol-002",
INFO[0005] "type": "gold"
INFO[0005] }
INFO[0005] }
INFO[0005] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment