Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

schema: add json defs for modules scripts-timezone (SC-801) #1365

Merged
merged 7 commits into from
Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions cloudinit/config/cc_scripts_per_boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,34 @@
# Author: Juerg Haefliger <juerg.haefliger@hp.com>
#
# This file is part of cloud-init. See LICENSE file for license information.
"""Scripts Per Boot: Run per boot scripts"""

"""
Scripts Per Boot
----------------
**Summary:** run per boot scripts
import os

from cloudinit import subp
from cloudinit.config.schema import MetaSchema, get_meta_doc
from cloudinit.distros import ALL_DISTROS
from cloudinit.settings import PER_ALWAYS

frequency = PER_ALWAYS
MODULE_DESCRIPTION = """\
Any scripts in the ``scripts/per-boot`` directory on the datasource will be run
every time the system boots. Scripts will be run in alphabetical order. This
module does not accept any config keys.

**Internal name:** ``cc_scripts_per_boot``

**Module frequency:** always

**Supported distros:** all
"""

import os

from cloudinit import subp
from cloudinit.settings import PER_ALWAYS
meta: MetaSchema = {
"id": "cc_scripts_per_boot",
"name": "Scripts Per Boot",
"title": "Run per boot scripts",
"description": MODULE_DESCRIPTION,
"distros": [ALL_DISTROS],
"frequency": frequency,
"examples": [],
}

frequency = PER_ALWAYS
__doc__ = get_meta_doc(meta)

SCRIPT_SUBDIR = "per-boot"

Expand Down
32 changes: 18 additions & 14 deletions cloudinit/config/cc_scripts_per_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,36 @@
# Author: Juerg Haefliger <juerg.haefliger@hp.com>
#
# This file is part of cloud-init. See LICENSE file for license information.
"""Scripts Per Instance: Run per instance scripts"""

"""
Scripts Per Instance
--------------------
**Summary:** run per instance scripts
import os

from cloudinit import subp
from cloudinit.config.schema import MetaSchema, get_meta_doc
from cloudinit.distros import ALL_DISTROS
from cloudinit.settings import PER_INSTANCE

MODULE_DESCRIPTION = """\
Any scripts in the ``scripts/per-instance`` directory on the datasource will
be run when a new instance is first booted. Scripts will be run in alphabetical
order. This module does not accept any config keys.

Some cloud platforms change instance-id if a significant change was made to
the system. As a result per-instance scripts will run again.

**Internal name:** ``cc_scripts_per_instance``

**Module frequency:** per instance

**Supported distros:** all
"""

import os
meta: MetaSchema = {
"id": "cc_scripts_per_instance",
"name": "Scripts Per Instance",
"title": "Run per instance scripts",
"description": MODULE_DESCRIPTION,
"distros": [ALL_DISTROS],
"frequency": PER_INSTANCE,
"examples": [],
}

from cloudinit import subp
from cloudinit.settings import PER_INSTANCE
__doc__ = get_meta_doc(meta)

frequency = PER_INSTANCE

SCRIPT_SUBDIR = "per-instance"

Expand Down
36 changes: 20 additions & 16 deletions cloudinit/config/cc_scripts_per_once.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,34 @@
# Author: Juerg Haefliger <juerg.haefliger@hp.com>
#
# This file is part of cloud-init. See LICENSE file for license information.
"""Scripts Per Once: Run one time scripts"""

"""
Scripts Per Once
----------------
**Summary:** run one time scripts
import os

from cloudinit import subp
from cloudinit.config.schema import MetaSchema, get_meta_doc
from cloudinit.distros import ALL_DISTROS
from cloudinit.settings import PER_ONCE

frequency = PER_ONCE
MODULE_DESCRIPTION = """\
Any scripts in the ``scripts/per-once`` directory on the datasource will be run
only once. Changes to the instance will not force a re-run. The only way to
re-run these scripts is to run the clean subcommand and reboot. Scripts will
be run in alphabetical order. This module does not accept any config keys.

**Internal name:** ``cc_scripts_per_once``

**Module frequency:** per once

**Supported distros:** all
"""

import os

from cloudinit import subp
from cloudinit.settings import PER_ONCE

frequency = PER_ONCE
meta: MetaSchema = {
"id": "cc_scripts_per_once",
"name": "Scripts Per Once",
"title": "Run one time scripts",
"description": MODULE_DESCRIPTION,
"distros": [ALL_DISTROS],
TheRealFalcon marked this conversation as resolved.
Show resolved Hide resolved
"frequency": frequency,
"examples": [],
}

__doc__ = get_meta_doc(meta)

SCRIPT_SUBDIR = "per-once"

Expand Down
32 changes: 18 additions & 14 deletions cloudinit/config/cc_scripts_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,36 @@
# Author: Juerg Haefliger <juerg.haefliger@hp.com>
#
# This file is part of cloud-init. See LICENSE file for license information.
"""Scripts User: Run user scripts"""

"""
Scripts User
------------
**Summary:** run user scripts
import os

from cloudinit import subp
from cloudinit.config.schema import MetaSchema, get_meta_doc
from cloudinit.distros import ALL_DISTROS
from cloudinit.settings import PER_INSTANCE

MODULE_DESCRIPTION = """\
This module runs all user scripts. User scripts are not specified in the
``scripts`` directory in the datasource, but rather are present in the
``scripts`` dir in the instance configuration. Any cloud-config parts with a
``#!`` will be treated as a script and run. Scripts specified as cloud-config
parts will be run in the order they are specified in the configuration.
This module does not accept any config keys.

**Internal name:** ``cc_scripts_user``

**Module frequency:** per instance

**Supported distros:** all
"""

import os
meta: MetaSchema = {
"id": "cc_scripts_user",
"name": "Scripts User",
"title": "Run user scripts",
"description": MODULE_DESCRIPTION,
"distros": [ALL_DISTROS],
"frequency": PER_INSTANCE,
"examples": [],
}

from cloudinit import subp
from cloudinit.settings import PER_INSTANCE
__doc__ = get_meta_doc(meta)

frequency = PER_INSTANCE

SCRIPT_SUBDIR = "scripts"

Expand Down
70 changes: 47 additions & 23 deletions cloudinit/config/cc_scripts_vendor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,59 @@
# Author: Ben Howard <ben.howard@canonical.com>
#
# This file is part of cloud-init. See LICENSE file for license information.

"""
Scripts Vendor
--------------
**Summary:** run vendor scripts

Any scripts in the ``scripts/vendor`` directory in the datasource will be run
when a new instance is first booted. Scripts will be run in alphabetical order.
Vendor scripts can be run with an optional prefix specified in the ``prefix``
entry under the ``vendor_data`` config key.

**Internal name:** ``cc_scripts_vendor``

**Module frequency:** per instance

**Supported distros:** all

**Config keys**::

vendor_data:
prefix: <vendor data prefix>
"""
"""Scripts Vendor: Run vendor scripts"""

import os
from textwrap import dedent

from cloudinit import subp, util
from cloudinit.config.schema import MetaSchema, get_meta_doc
from cloudinit.distros import ALL_DISTROS
from cloudinit.settings import PER_INSTANCE

frequency = PER_INSTANCE
MODULE_DESCRIPTION = """\
On select Datasources, vendors have a channel for the consumption
of all supported user data types via a special channel called
vendor data. Any scripts in the ``scripts/vendor`` directory in the datasource
will be run when a new instance is first booted. Scripts will be run in
alphabetical order. This module allows control over the execution of
vendor data.
"""

meta: MetaSchema = {
"id": "cc_scripts_vendor",
"name": "Scripts Vendor",
"title": "Run vendor scripts",
"description": MODULE_DESCRIPTION,
"distros": [ALL_DISTROS],
"frequency": PER_INSTANCE,
"examples": [
dedent(
"""\
vendor_data:
enabled: true
prefix: /usr/bin/ltrace
blackboxsw marked this conversation as resolved.
Show resolved Hide resolved
"""
),
dedent(
"""\
vendor_data:
enabled: true
prefix: [timeout, 30]
"""
),
dedent(
"""\
# Vendor data will not be processed
vendor_data:
enabled: false
"""
),
],
}

__doc__ = get_meta_doc(meta)


SCRIPT_SUBDIR = "vendor"

Expand Down
Loading