github.com/jbking/gohan@v0.0.0-20151217002006-b41ccf1c2a96/docs/source/config.rst (about) 1 ============== 2 Configuration 3 ============== 4 5 In this section we will describe how to configure 6 gohan server cli. 7 8 gohan server command takes "--config-file" parameter to specify 9 configuraion file. 10 11 12 .. code-block:: shell 13 14 gohan server --config-file etc/gohan.yaml 15 16 17 Note that there are some example configuraions in the etc directory. 18 Gohan server configuration is written in YAML format. 19 (For YAML specification, see http://yaml.org/) 20 21 .. code-block:: yaml 22 23 ####################################################### 24 # Gohan API Server example configuraion 25 ###################################################### 26 27 include: gohan.d 28 # database connection configuraion 29 database: 30 # sqlite3 and mysql supported 31 type: "sqlite3" 32 # connection string 33 # it is file path for yaml, json and sqlite3 backend 34 connection: "./etc/test.db" 35 initial_data: 36 - type: "yaml" 37 connection: "./etc/examples/heat_template.yaml" 38 # schema path 39 schemas: 40 - "./etc/schema/gohan.json" 41 # listen address for gohan 42 address: ":9090" 43 tls: 44 enabled: true 45 cert_file: "./etc/cert.pem" 46 key_file: "./etc/key.pem" 47 # document root of gohan API server 48 # Note: only static and schema directoriy will be served 49 document_root: "./etc" 50 # list of etcd backend servers 51 etcd: 52 - "http://127.0.0.1:4001" 53 # keystone configuraion 54 keystone: 55 use_keystone: false 56 fake: true 57 auth_url: "http://localhost:35357/v2.0" 58 user_name: "admin" 59 tenant_name: "admin" 60 password: "gohan" 61 # CORS (Cross-origin resource sharing (CORS)) configuraion for javascript based client 62 cors: "*" 63 64 # allowed levels "CRITICAL", "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG", 65 logging: 66 stderr: 67 enabled: true 68 level: DEBUG 69 file: 70 enabled: true 71 level: INFO 72 filename: ./gohan.log 73 74 75 Include 76 -------------------- 77 78 You can include config yaml files from specified dirs 79 Note that overwrapped configuraion will be overrides by configuration loaded 80 later, so we don't recommend to have duplicated config file key in multiple files. 81 82 .. code-block:: yaml 83 84 include: gohan.d 85 86 Environment Value 87 -------------------- 88 89 You can use Environemnt value in the configuraion. 90 91 .. code-block:: yaml 92 93 address: {{ .GOHAN_IP}}:{{ .GOHAN_PORT}} 94 95 96 Note you need to use {{ and }}, and you need to put . before 97 your env key. 98 We are using golang text template package, so please take a 99 look more at https://golang.org/pkg/text/template/ 100 101 Database 102 -------------------- 103 104 database is backend database configuraion. 105 You can select from sqlite3 and mysql. 106 Note that yaml and json is only for development purpose. 107 108 This is a sample database configuraion for sqlite3. 109 110 .. code-block:: yaml 111 112 # database connection configuraion 113 database: 114 type: "sqlite3" 115 connection: "./sqlite3.db" 116 117 Note that you need to initialize database using gohan init-db CLI. 118 119 gohan init-db takes following parameters. 120 121 - --database_type, --dt 'sqlite3' Backend datebase type 122 - --database, -d 'gohan.db' DB Connection String 123 - --schema, -s '../schema/gohan.json' Schema Def 124 - --delete-on-create If selected, existing database will be dropped 125 - --cascade If selected, FOREIGN KEYs will be created with CASCADE ON DELETE 126 127 128 This is example init database command for sqlite3 database 129 130 .. code-block:: yaml 131 132 gohan init-db -s schema/gohan.json -d sqlite3.db 133 134 135 This is a sample database configuraion for mysql. 136 137 .. code-block:: yaml 138 139 # database connection configuraion 140 database: 141 type: "mysql" 142 connection: "root:gohan@127.0.0.1/gohan" 143 144 This is example init database command for sqlite3 database 145 146 .. code-block:: yaml 147 148 gohan init-db -s schema/gohan.json -dt mysql -d "root:gohan/gohan" 149 150 151 You can also specify initial_data for static configs. 152 gohan server registers content of data on startup time. 153 154 .. code-block:: yaml 155 156 database: 157 type: "yaml" 158 connection: "./etc/example.yaml" 159 initial_data: 160 - type: "yaml" 161 connection: "./etc/examples/initial_datayaml" 162 163 Gohan policy determining what to do when there is existing database, can be specified 164 with drop_on_create option. If it's set to true, database will be dropped before 165 initialization. 166 167 .. code-block:: yaml 168 169 database: 170 type: "yaml" 171 connection: "./etc/example.yaml" 172 drop_on_create: true 173 174 Cascade deletion, i.e. creating FOREING KEYs with CASCADE ON DELETE, can be 175 activated with cascade switch. 176 177 .. code-block:: yaml 178 179 database: 180 type: "yaml" 181 connection: "./etc/example.yaml" 182 cascade: true 183 184 Schema 185 ----------- 186 187 Gohan works based on schema definitions. 188 You should specify list of schema file in the configuraion. 189 190 .. code-block:: yaml 191 192 schemas: 193 - "./etc/schema/gohan.json" 194 195 196 You can specify your own schema here. You can also use gohan meta-schema. 197 Meta-schema defines gohan schema itself. 198 You can see it on etc/schema/gohan.json. 199 When you have meta-schema in the schema configuraion, you can use gohan 200 meta-schema API and schema editor in webui. 201 202 Keystone 203 -------------- 204 205 Gohan support OpenStack keystone authentication backend. 206 (see http://docs.openstack.org/developer/keystone/ ) 207 208 - use_keystone: boolean 209 210 use keystone or not 211 212 - fake: boolean 213 214 use fake keystone server for testing or not 215 216 - auth_url 217 218 keytone admin URL 219 220 - user_name 221 222 service user name 223 224 - tenant_name 225 226 service tenant_name (needed for keystone v2.0 api) 227 228 - domain 229 230 service domain name (needed for keystone v3.0 api) 231 232 - password 233 234 password for service user 235 236 - version 237 238 v2.0 or v3 is suppoted 239 240 .. code-block:: yaml 241 242 keystone: 243 use_keystone: false 244 fake: true 245 auth_url: "http://localhost:35357/v2.0" 246 user_name: "admin" 247 tenant_name: "admin" 248 password: "gohan" 249 250 CORS 251 -------------- 252 253 Gohan supports Cross-Origin Resource Sharing (CORS) for supporting 254 javascript webui without proxy server. 255 You need to specify allowd domain pattern in cors parameter. 256 Note: DO NOT USE * configuraion in production deployment. 257 258 .. code-block:: yaml 259 260 cors: "*" 261 262 Logging 263 -------------- 264 265 You can define logging output in logging configuraion. 266 267 Logging level can be specified per log and per module in log. If module is not specified 268 in "modules", value from "level" is applied. 269 270 Allowed log levels: "CRITICAL", "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG", 271 272 273 .. code-block:: yaml 274 275 logging: 276 stderr: 277 enabled: true 278 level: DEBUG 279 file: 280 enabled: true 281 level: INFO 282 modules: 283 - name: gohan.db.sql 284 level: DEBUG 285 - name: gohan.sync.etcd 286 level: CRITICAL 287 filename: ./gohan.log 288 289 HTTPS 290 -------------- 291 292 - enabled 293 294 You can enable HTTPS support by setting this flag to ``true``. 295 Disabling this option will cause Gohan to fallback to HTTP. 296 297 - cert_file 298 299 Location of X509 certificate file. 300 e.g. ``"./etc/cert.pem"`` 301 302 - key_file 303 304 Location of key file matching with certificate. 305 e.g. ``"./etc/key.pem"`` 306 307 .. code-block:: yaml 308 309 tls: 310 enabled: true 311 cert_file: "./etc/cert.pem" 312 key_file: "./etc/key.pem" 313 314 315 Misc 316 -------------- 317 318 - address 319 320 address to bind gohan-sever. 321 eg. 127.0.0.1:9090, 0.0.0.0:9090 or just :9090 322 323 - document_root 324 325 Clients such as webui needs gohan-meta-schema file. We will serve the file from 326 configured document_root. 327 328 - etcd 329 330 list of etcd backend. 331 332 333 .. code-block:: yaml 334 335 etcd: 336 - "http://192.0.0.1:4001" 337 - "http://192.0.0.2:4001" 338 339 - run job on update from etcd 340 341 You can run extension on update event on etcd using 342 sync://{{etcd_path}}. 343 344 This is a sample configuraion. 345 346 - watch/keys list of watched keys in etcd. This will be done recursively. 347 - events list of event we invoke extension 348 - worker_count: number of concurrent execution tasks 349 350 .. code-block:: yaml 351 352 watch: 353 keys: 354 - v2.0 355 events: 356 - v2.0/servers/ 357 worker_count: 4 358 359 WARNING: The value of watched etcd keys must be a JSON dictionary. 360 361 - amqp 362 363 You can listen notification event from openstack components using 364 amqp. You need to specify listen queues and events. 365 366 You can also run extension for amqp based event specifying path for 367 amqp://{{event_type}}. 368 369 .. code-block:: yaml 370 371 amqp: 372 connection: amqp://guest:guest@172.16.25.130:5672/ 373 queues: 374 - notifications.info 375 - notifications.error 376 events: 377 - orchestration.stack 378 379 - snmp 380 381 You can listen snmp trap, and execute extesion for that trap. 382 extension path should be snmp:// 383 384 .. code-block:: yaml 385 386 snmp: 387 address: "localhost:8888" 388 389 - cron 390 391 You can pediorically execute cron job using configuraion. 392 extension path should be specified in the path. 393 394 .. code-block:: yaml 395 396 cron: 397 - path: cron://cron_job_sample 398 timing: "*/5 * * * * *" 399 400 - schema editor 401 402 You can use gohan server as a schema editor if you specify editable_schema yaml file. 403 Gohan updates this file based on scheam REST API call. 404 405 406 .. code-block:: yaml 407 408 editable_schema: ./example_schema.yaml