Reference
odooghost.config
ContextConfig
Bases: BaseModel
Context config holds configuration file
Source code in odooghost/config/app.py
6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
version: str
instance-attribute
OdooGhost version
working_dir: Path
instance-attribute
Working directory
OdooStackConfig
Bases: StackServiceConfig
Odoo stack configuration
Source code in odooghost/config/service.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
addons: t.List[_addons.AddonsConfig] = []
class-attribute
instance-attribute
Odoo addons configurations
cmdline: t.Optional[str] = None
class-attribute
instance-attribute
Odoo-bin cmdline
dependencies: dependency.DependenciesConfig = dependency.DependenciesConfig()
class-attribute
instance-attribute
Odoo dependencies configurations
version: float
instance-attribute
Odoo version
validate_versîon(v)
classmethod
Validate supported Odoo version
Raises:
Type | Description |
---|---|
ValueError
|
When provided version is not supported |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
Odoo version |
Source code in odooghost/config/service.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
PostgresStackConfig
Bases: StackServiceConfig
Postgres stack configuration holds database configuration It support both remote and local databse
Source code in odooghost/config/service.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
db: t.Optional[str] = 'postgres'
class-attribute
instance-attribute
Database template (only availible in local type)
host: t.Optional[str] = None
class-attribute
instance-attribute
Database hostname
password: t.Optional[str] = None
class-attribute
instance-attribute
Database user password
type: t.Literal['local', 'remote']
instance-attribute
Type of database config
user: t.Optional[str] = None
class-attribute
instance-attribute
Database user
version: int
instance-attribute
Database version
StackConfig
Bases: BaseModel
Stack configuration
Source code in odooghost/config/stack.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
name: str
instance-attribute
Name of stack
network: StackNetworkConfig = StackNetworkConfig()
class-attribute
instance-attribute
Network config
services: service.StackServicesConfig
instance-attribute
Services of stack
from_file(file_path)
classmethod
Return a StackConfig instance from JSON/YAML file config
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path |
Path
|
file path |
required |
Raises:
Type | Description |
---|---|
RuntimeError
|
when the file does not exists |
Returns:
Name | Type | Description |
---|---|---|
StackConfig |
StackConfig
|
StackConfig instance |
Source code in odooghost/config/stack.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
get_network_name()
Get netowkr name regarding network mode T
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Stack netowrk name |
Source code in odooghost/config/stack.py
106 107 108 109 110 111 112 113 114 |
|
get_service_hostname(service)
Get given service name regatding netowrk. We do prefix the service name with the stack name if the stack network is shared with other. This is done to allow running multiple stack's at the same time with the same network
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service |
str
|
service name |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
name of the given service |
Source code in odooghost/config/stack.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
validate_name(v)
classmethod
Validate stack name
Parameters:
Name | Type | Description | Default |
---|---|---|---|
v |
str
|
Stack name |
required |
Raises:
Type | Description |
---|---|
ValueError
|
When stack name is not valid |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Stack name |
Source code in odooghost/config/stack.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
|
StackServiceConfig
Bases: BaseModel
, ABC
Abstract config for stack services
Source code in odooghost/config/service.py
10 11 12 13 14 15 16 17 18 |
|
service_port: t.Optional[int] = None
class-attribute
instance-attribute
Map local port to container sercice port
odooghost.stack
Stack
Stack manage differents Odoo stacks regarding it's config
Source code in odooghost/stack.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 |
|
exists: bool
property
Check if stack already exists
Returns:
Type | Description |
---|---|
bool
|
bool |
name: str
property
Return name of stack
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Stack name |
state: StackState
property
__eq__(other)
Check if Stack equal other Stack
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
Stack
|
Other Stack instance |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
|
Source code in odooghost/stack.py
365 366 367 368 369 370 371 372 373 374 375 376 377 |
|
__repr__()
Stack repr
Source code in odooghost/stack.py
359 360 361 362 363 |
|
containers(filters=None, labels=None, stopped=False, one_off=OneOffFilter.exclude)
Get Stack containers
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filters |
Optional[Filters]
|
Search filters. Defaults to None. |
None
|
labels |
Optional[Labels]
|
Additionnal search labels. Defaults to None. |
None
|
stopped |
bool
|
Get stopped containers. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
List[Container]
|
t.List[Container]: Container list |
Source code in odooghost/stack.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
|
count()
classmethod
Count all stacks in context
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
stack count |
Source code in odooghost/stack.py
109 110 111 112 113 114 115 116 117 |
|
create(force=False, do_pull=True, ensure_addons=True)
Create Stack
Parameters:
Name | Type | Description | Default |
---|---|---|---|
force |
bool
|
Force recreate of dangling containers. Defaults to False. |
False
|
do_pull |
bool
|
Pull base images. Defaults to True. |
True
|
ensure_addons |
bool
|
Ensure Odoo addons. Defaults to True. |
True
|
Raises:
Type | Description |
---|---|
StackAlreadyExistsError
|
When Stack alreary exists |
Source code in odooghost/stack.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
|
drop(volumes=False)
Drop Stack
Parameters:
Name | Type | Description | Default |
---|---|---|---|
volumes |
bool
|
Drop volumes. Defaults to False. |
False
|
Raises:
Type | Description |
---|---|
StackNotFoundError
|
When Stack does not exists |
Source code in odooghost/stack.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
|
from_file(file_path)
classmethod
Instanciate Stack from file
File could be both YAML and JSON
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path |
Path
|
stack config file path |
required |
Returns:
Name | Type | Description |
---|---|---|
Stack |
Stack
|
Stack instance |
Source code in odooghost/stack.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
from_name(name)
classmethod
Instanciate Stack from name Stack config will be searched from Context
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Stack name |
required |
Returns:
Name | Type | Description |
---|---|---|
Stack |
Stack
|
Stack instance |
Source code in odooghost/stack.py
95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
labels(one_off=OneOffFilter.exclude)
Get Stack labels
Returns:
Name | Type | Description |
---|---|---|
Labels |
Labels
|
Labels as dict |
Source code in odooghost/stack.py
149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
list(running=False)
classmethod
List all stacks
Yields:
Name | Type | Description |
---|---|---|
Srack |
Stack
|
Stack instance |
Source code in odooghost/stack.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|
pull()
Pull Stack
Source code in odooghost/stack.py
244 245 246 247 248 249 250 251 252 |
|
restart(timeout=10)
Restart Stack
Parameters:
Name | Type | Description | Default |
---|---|---|---|
timeout |
int
|
timeout before sending SIGKILL. Defaults to 10. |
10
|
Raises:
Type | Description |
---|---|
StackNotFoundError
|
When stack does not exists |
Source code in odooghost/stack.py
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
|
start()
Start Stack
Raises:
Type | Description |
---|---|
StackNotFoundError
|
When Stack does not exists |
Source code in odooghost/stack.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
|
stop(timeout=10, wait=False)
Stop Stack
Parameters:
Name | Type | Description | Default |
---|---|---|---|
timeout |
int
|
timeout before sending SIGKILL. Defaults to 10. |
10
|
Raises:
Type | Description |
---|---|
StackNotFoundError
|
When stack does not exists |
Source code in odooghost/stack.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
|
update(do_pull=False)
Update Stack
Source code in odooghost/stack.py
254 255 256 257 258 259 260 261 262 263 264 265 |
|
StackState
Bases: Enum
StackState obviously holds StackState
Source code in odooghost/stack.py
21 22 23 24 25 26 27 28 |
|
odooghost.services
odooghost.context
Context
Context holds contextual data for OdooGhost
Source code in odooghost/context.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|
config: ContextConfig
property
Get context config
Raises:
Type | Description |
---|---|
RuntimeError
|
when context was not initialized |
Returns:
Name | Type | Description |
---|---|---|
ContextConfig |
ContextConfig
|
context config |
docker: docker.DockerClient
property
Lazyily return Docker client
Returns:
Type | Description |
---|---|
DockerClient
|
docker.DockerClient: Docker client instance |
check_setup_state()
Check setup status
Returns:
Type | Description |
---|---|
bool
|
bool |
Source code in odooghost/context.py
137 138 139 140 141 142 143 144 |
|
create_common_network()
Create common Docker network for stacks
Raises:
Type | Description |
---|---|
CommonNetworkEnsureError
|
When create fail |
Source code in odooghost/context.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
|
ensure_common_network()
Ensure common Docker network
Raises:
Type | Description |
---|---|
CommonNetworkEnsureError
|
When ensure fail |
Source code in odooghost/context.py
203 204 205 206 207 208 209 210 211 212 213 214 215 |
|
get_build_context_path()
Get build context path
Returns:
Name | Type | Description |
---|---|---|
Path |
Path
|
Path to build context |
Source code in odooghost/context.py
217 218 219 220 221 222 223 224 |
|
initialize()
Initialize context
Source code in odooghost/context.py
146 147 148 149 150 151 152 153 |
|
setup(version, working_dir)
Setup OdooGhost
Parameters:
Name | Type | Description | Default |
---|---|---|---|
version |
str
|
OdooGhost version |
required |
working_dir |
Path
|
working directory |
required |
Raises:
Type | Description |
---|---|
ContextAlreadySetupError
|
Already setup |
Source code in odooghost/context.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
|
StackContext
Source code in odooghost/context.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|
__contains__(stack)
Check if given stack name or StackConfig exists in context
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stack |
str | StackConfig
|
Stack to check |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
When stack exists or not |
Source code in odooghost/context.py
93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
__iter__()
Iter over StackConfig's
Yields:
Type | Description |
---|---|
Iterable[StackConfig]
|
Iterator[t.Iterable[StackConfig]]: Stack config iterable |
Source code in odooghost/context.py
107 108 109 110 111 112 113 114 115 |
|
create(config)
Create StackConfig file in context
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
StackConfig
|
Stack config |
required |
Raises:
Type | Description |
---|---|
StackAlreadyExistsError
|
When stack config file exists |
Source code in odooghost/context.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
drop(stack_name)
Drop Stack from context
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stack_name |
str
|
name of stack |
required |
Source code in odooghost/context.py
79 80 81 82 83 84 85 86 87 88 89 90 91 |
|
get(stack_name)
Get StackConfig
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stack_name |
str
|
name of stack |
required |
Returns:
Name | Type | Description |
---|---|---|
StackConfig |
StackConfig
|
Stack config instance |
Source code in odooghost/context.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
get_path(stack_name)
Get Stack config path
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stack_name |
str
|
name of stack |
required |
Returns:
Name | Type | Description |
---|---|---|
Path |
Path
|
Stack config path |
Source code in odooghost/context.py
21 22 23 24 25 26 27 28 29 30 31 |
|
update(config)
Update StackConfig file in context
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
StackConfig
|
Stack config |
required |
Raises:
Type | Description |
---|---|
StackNotFoundError
|
When stack config file does not exists |
Source code in odooghost/context.py
65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
odooghost.renderer
render_dockerfile(**kw)
Render custom dockerfile for Odoo image
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Rendered dockerfile |
Source code in odooghost/renderer.py
14 15 16 17 18 19 20 21 |
|
odooghost.logger
InterceptHandler
Bases: Handler
InterceptHandler convert default logging LogRecord to loguru format
Source code in odooghost/logger.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
setup_cli_logging()
Setup logger for CLI
Source code in odooghost/logger.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|