From ed7b43f93f3bf329f245f7e6c82859c43e98190e Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 18 Aug 2017 16:44:03 -0400 Subject: [PATCH] Satellite-populate nailgun entity examples for issue #64 (#91) --- Makefile | 5 +- .../abstract_compute_resource_docker.yaml | 35 ++++++++++ .../abstract_compute_resource_libvirt.yaml | 34 ++++++++++ examples/satellite/activation_key.yaml | 61 ++++++++++++++++++ examples/satellite/architecture.yaml | 37 +++++++++++ examples/satellite/bookmark.yaml | 38 +++++++++++ examples/satellite/common_parameter.yaml | 37 +++++++++++ examples/satellite/config_group.yaml | 36 +++++++++++ examples/satellite/config_template.yaml | 43 +++++++++++++ examples/satellite/content_view.yaml | 37 +++++++++++ examples/satellite/discovery_rule.yaml | 39 +++++++++++ .../satellite/docker_compute_resource.yaml | 37 +++++++++++ examples/satellite/domain.yaml | 34 ++++++++++ examples/satellite/environment.yaml | 32 ++++++++++ examples/satellite/gpg_key.yaml | 52 +++++++++++++++ examples/satellite/host_collection.yaml | 36 +++++++++++ examples/satellite/host_group.yaml | 34 ++++++++++ examples/satellite/lifecycle_environment.yaml | 35 ++++++++++ examples/satellite/location.yaml | 34 ++++++++++ examples/satellite/media.yaml | 34 ++++++++++ examples/satellite/operating_system.yaml | 39 +++++++++++ examples/satellite/organization.yaml | 36 +++++++++++ examples/satellite/partition_table.yaml | 35 ++++++++++ examples/satellite/provisioning_template.yaml | 48 ++++++++++++++ examples/satellite/puppet_class.yaml | 32 ++++++++++ examples/satellite/repository.yaml | 40 ++++++++++++ examples/satellite/role.yaml | 32 ++++++++++ examples/satellite/smart_variable.yaml | 44 +++++++++++++ examples/satellite/subnet.yaml | 37 +++++++++++ examples/satellite/sync_plan.yaml | 54 ++++++++++++++++ examples/satellite/user.yaml | 38 +++++++++++ satellite_populate/constants.py | 64 ++++++++++++++++++- 32 files changed, 1226 insertions(+), 3 deletions(-) create mode 100644 examples/satellite/abstract_compute_resource_docker.yaml create mode 100644 examples/satellite/abstract_compute_resource_libvirt.yaml create mode 100644 examples/satellite/activation_key.yaml create mode 100644 examples/satellite/architecture.yaml create mode 100644 examples/satellite/bookmark.yaml create mode 100644 examples/satellite/common_parameter.yaml create mode 100644 examples/satellite/config_group.yaml create mode 100644 examples/satellite/config_template.yaml create mode 100644 examples/satellite/content_view.yaml create mode 100644 examples/satellite/discovery_rule.yaml create mode 100644 examples/satellite/docker_compute_resource.yaml create mode 100644 examples/satellite/domain.yaml create mode 100644 examples/satellite/environment.yaml create mode 100644 examples/satellite/gpg_key.yaml create mode 100644 examples/satellite/host_collection.yaml create mode 100644 examples/satellite/host_group.yaml create mode 100644 examples/satellite/lifecycle_environment.yaml create mode 100644 examples/satellite/location.yaml create mode 100644 examples/satellite/media.yaml create mode 100644 examples/satellite/operating_system.yaml create mode 100644 examples/satellite/organization.yaml create mode 100644 examples/satellite/partition_table.yaml create mode 100644 examples/satellite/provisioning_template.yaml create mode 100644 examples/satellite/puppet_class.yaml create mode 100644 examples/satellite/repository.yaml create mode 100644 examples/satellite/role.yaml create mode 100644 examples/satellite/smart_variable.yaml create mode 100644 examples/satellite/subnet.yaml create mode 100644 examples/satellite/sync_plan.yaml create mode 100644 examples/satellite/user.yaml diff --git a/Makefile b/Makefile index 72595ec..35eb5fd 100644 --- a/Makefile +++ b/Makefile @@ -53,10 +53,12 @@ lint: ## check style with flake8 test: lint ## run tests quickly with the default Python py.test - test-all: ## run tests on every Python version with tox tox +test-entities: ## run satellite-populate examples for nailgun entities + for f in examples/satellite/*.yaml; do satellite-populate $$f; done + coverage: ## check code coverage quickly with the default Python coverage run --source satellite_populate -m pytest @@ -89,3 +91,4 @@ install: clean ## install the package to the active Python's site-packages bump: test bumpversion patch --config-file=setup.cfg + diff --git a/examples/satellite/abstract_compute_resource_docker.yaml b/examples/satellite/abstract_compute_resource_docker.yaml new file mode 100644 index 0000000..48e1561 --- /dev/null +++ b/examples/satellite/abstract_compute_resource_docker.yaml @@ -0,0 +1,35 @@ +# Testing nailgun entities + +vars: + name: AbsCompResDock + desc: Nailgun test + update_desc: Updated + +actions: + + - model: AbstractComputeResource + register: test_entity + data: + name: "{{ name }}" + description: "{{ desc }}" + provider: Docker + + - action: update + register: test_entity + model: AbstractComputeResource + data: + description: "{{ update_desc }}" + search_query: + name: "{{ entity_name }}" + + - action: assertion + operation: eq + data: + - from_registry: test_entity.description + - "{{ update_desc }}" + + - action: delete + model: AbstractComputeResource + search_query: + name: "{{ entity_name }}" + diff --git a/examples/satellite/abstract_compute_resource_libvirt.yaml b/examples/satellite/abstract_compute_resource_libvirt.yaml new file mode 100644 index 0000000..d73a7b5 --- /dev/null +++ b/examples/satellite/abstract_compute_resource_libvirt.yaml @@ -0,0 +1,34 @@ +# Testing nailgun entities + +vars: + name: AbsCompResLib + desc: Nailgun test + update_desc: Updated + +actions: + + - model: AbstractComputeResource + register: test_entity + data: + name: "{{ name }}" + description: "{{ desc }}" + provider: Libvirt + + - action: update + register: test_entity + model: AbstractComputeResource + data: + description: "{{ update_desc }}" + search_query: + name: "{{ entity_name }}" + + - action: assertion + operation: eq + data: + - from_registry: test_entity.description + - "{{ update_desc }}" + + - action: delete + model: AbstractComputeResource + search_query: + name: "{{ entity_name }}" diff --git a/examples/satellite/activation_key.yaml b/examples/satellite/activation_key.yaml new file mode 100644 index 0000000..95f2ee4 --- /dev/null +++ b/examples/satellite/activation_key.yaml @@ -0,0 +1,61 @@ +# Testing nailgun entities + +vars: + org_name: Activation Key Org + key_name: activate + update_name: Activate Key + +actions: + +# Setup + - model: Organization + register: key_org + data: + name: "{{ org_name }}" + label: label + description: Organization for testing activation keys + +# Create + - model: ActivationKey + register: test_key + data: + name: "{{ key_name }}" + max_hosts: 10 + auto_attach: True + unlimited_hosts: False + description: Test activation key + organization: + from_registry: key_org + +# Update + - action: update + register: test_key + model: ActivationKey + data: + name: "{{ update_name }}" + search_query: + name: "{{ key_name }}" + organization: + from_registry: key_org + +# Assert + - action: assertion + log: Checking that Activation Key name was updated + operation: eq + data: + - from_registry: test_key.name + - "{{ update_name }}" + +# Delete + - action: delete + model: ActivationKey + search_query: + name: "{{ update_name }}" + organization: + from_registry: key_org + +# Cleanup + - action: delete + model: Organization + search_query: + name: "{{ org_name }}" diff --git a/examples/satellite/architecture.yaml b/examples/satellite/architecture.yaml new file mode 100644 index 0000000..2739933 --- /dev/null +++ b/examples/satellite/architecture.yaml @@ -0,0 +1,37 @@ +# Testing nailtun entities + +vars: + arch_name: x172-128 + update_name: x43-32 + +actions: + +# Create + - model: Architecture + register: default_arch + data: + name: "{{ arch_name }}" + +# Update + - action: update + register: default_arch + model: Architecture + data: + name: "{{ update_name }}" + search_query: + name: "{{ arch_name }}" + +# Assert + - action: assertion + log: Checking that Architecture name was updated + operation: eq + data: + - from_registry: default_arch.name + - "{{ update_name }}" + +# Delete + - action: delete + model: Architecture + search_query: + name: "{{ update_name }}" + diff --git a/examples/satellite/bookmark.yaml b/examples/satellite/bookmark.yaml new file mode 100644 index 0000000..de03d68 --- /dev/null +++ b/examples/satellite/bookmark.yaml @@ -0,0 +1,38 @@ +# Testing nailgun entities + +vars: + book_name: Mark + book_query: last_report and status.enabled = true + +actions: + +# Create + - model: Bookmark + register: test_book + data: + name: "{{ book_name }}" + public: True + query: last_report + controller: job_invocations + +# Update + - action: update + register: test_book + model: Bookmark + data: + query: "{{ book_query }}" + search_query: + name: "{{ book_name }}" + +# Assert + - action: assertion + operation: eq + data: + - from_registry: test_book.query + - "{{ book_query }}" + +# Delete + - action: delete + model: Bookmark + search_query: + name: "{{ book_name }}" diff --git a/examples/satellite/common_parameter.yaml b/examples/satellite/common_parameter.yaml new file mode 100644 index 0000000..83247db --- /dev/null +++ b/examples/satellite/common_parameter.yaml @@ -0,0 +1,37 @@ +# Testing nailgun entities + +vars: + param_name: parameter + value: test_value + new_value: 100 + +actions: + +# Create + - model: CommonParameter + register: test_comm_param + data: + name: "{{ param_name }}" + value: "{{ value }}" + +# Update + - action: update + register: test_comm_param + model: CommonParameter + data: + value: "{{ new_value }}" + search_query: + name: "{{ param_name }}" + +# Assert + - action: assertion + operation: eq + data: + - from_registry: test_comm_param.value + - "{{ new_value }}" + +# Delete + - action: delete + model: CommonParameter + search_query: + name: "{{ param_name }}" diff --git a/examples/satellite/config_group.yaml b/examples/satellite/config_group.yaml new file mode 100644 index 0000000..12a0f86 --- /dev/null +++ b/examples/satellite/config_group.yaml @@ -0,0 +1,36 @@ +# Testing nailgun entities + +vars: + name: config_grp + new_name: config_grp2 + +actions: + +# Create + - model: ConfigGroup + register: test_group + data: + name: "{{ name }}" + +# Update + - action: update + register: test_group + model: ConfigGroup + data: + name: "{{ new_name }}" + search_query: + name: "{{ name }}" + +# Assert + - action: assertion + operation: eq + data: + - from_registry: test_group.name + - "{{ new_name }}" + +# Delete + # No attribute delete + # - action: delete + # model: ConfigGroup + # search_query: + # name: "{{ new_name }}" diff --git a/examples/satellite/config_template.yaml b/examples/satellite/config_template.yaml new file mode 100644 index 0000000..a43a728 --- /dev/null +++ b/examples/satellite/config_template.yaml @@ -0,0 +1,43 @@ +# Testing nailgun entities + +vars: + name: config_temp + comment: auditing + new_comment: audit done + +actions: + +# Create + - model: ConfigTemplate + register: test_cfg_tmp + data: + name: "{{ name }}" + audit_comment: "{{ comment }}" + snippet: 'true' + template: temp + template_combinations: + - 1 + - 2 + - 3 + +# Update + - action: update + register: test_cfg_tmp + model: ConfigTemplate + data: + audit_comment: "{{ new_comment }}" + search_query: + name: "{{ name }}" + +# Assert + - action: assertion + operation: eq + data: + - from_registry: test_cfg_tmp.audit_comment + - audit done + +# Delete + - action: delete + model: ConfigTemplate + search_query: + name: "{{ name }}" diff --git a/examples/satellite/content_view.yaml b/examples/satellite/content_view.yaml new file mode 100644 index 0000000..5cb36f3 --- /dev/null +++ b/examples/satellite/content_view.yaml @@ -0,0 +1,37 @@ +# Testing nailgun entities + +vars: + name: test content view + composite_name: composite content view + +actions: + + - model: ContentView + register: test_view + data: + name: "{{ name }}" + composite: False + description: satellite-populate content view test + label: test + next_version: 2 + content_host_count: 0 + last_published: 07/28/2017 + + - action: update + register: test_view + model: ContentView + data: + composite: True + search_query: + name: "{{ name }}" + + - action: assertion + operation: eq + data: + - from_registry: test_view.composite + - True + + - action: delete + model: ContentView + search_query: + name: "{{ name }}" diff --git a/examples/satellite/discovery_rule.yaml b/examples/satellite/discovery_rule.yaml new file mode 100644 index 0000000..5655f9e --- /dev/null +++ b/examples/satellite/discovery_rule.yaml @@ -0,0 +1,39 @@ +# Testing nailgun entities + +vars: + rule_name: discovery + +actions: + +# Create + - model: DiscoveryRule + register: test_drule + data: + name: "{{ rule_name }}" + priority: 1 + max_count: 100 + enabled: True + hostname: localhost + search_: search + +# Update + - action: update + register: test_drule + model: DiscoveryRule + data: + enabled: False + search_query: + name: "{{ rule_name }}" + +# Assert + - action: assertion + operation: eq + data: + - from_registry: test_drule.enabled + - False + +# Delete + - action: delete + model: DiscoveryRule + search_query: + name: "{{ rule_name }}" diff --git a/examples/satellite/docker_compute_resource.yaml b/examples/satellite/docker_compute_resource.yaml new file mode 100644 index 0000000..0d863cb --- /dev/null +++ b/examples/satellite/docker_compute_resource.yaml @@ -0,0 +1,37 @@ +# Testing nailgun entities + +vars: + name: DockerCompRe + desc: Nailgun test + update_desc: Updated Description + +actions: + + - model: DockerComputeResource + register: test_entity + data: + name: "{ entity_name }" + email: email@test.com + user: username + password: pass + description: "{ desc }" + + - action: update + register: test_entity + model: DockerComputeResource + data: + description: "{ update_desc }" + search_query: + name: "{ entity_name }" + + - action: assertion + operation: eq + data: + - from_registry: test_entity.description + - "{ update_desc }" + + - action: delete + model: DockerComputeResource + search_query: + name: "{ entity_name }" + diff --git a/examples/satellite/domain.yaml b/examples/satellite/domain.yaml new file mode 100644 index 0000000..a886080 --- /dev/null +++ b/examples/satellite/domain.yaml @@ -0,0 +1,34 @@ +# Test nailgun entities + +vars: + name: domain_name + fullname: domain_name.example.com + update_full: test.domain_name.example.com + +actions: + + - model: Domain + register: test_entity + data: + name: "{{ name }}" + fullname: "{{ fullname }}" + + - action: update + register: test_entity + model: Domain + data: + fullname: "{{ update_full }}" + search_query: + name: "{{ name }}" + + - action: assertion + operation: eq + data: + - from_registry: test_entity.fullname + - "{{ update_full }}" + + # - action: delete + # model: Domain + # search_query: + # name: "{{ name }}" + diff --git a/examples/satellite/environment.yaml b/examples/satellite/environment.yaml new file mode 100644 index 0000000..5ea07a0 --- /dev/null +++ b/examples/satellite/environment.yaml @@ -0,0 +1,32 @@ +# Testing nailgun entities + +vars: + name: env + new_name: testenvironment + +actions: + + - model: Environment + register: test_env + data: + name: "{{ name }}" + + - action: update + register: test_env + model: Environment + data: + name: "{{ new_name }}" + search_query: + name: "{{ name }}" + + - action: assertion + operation: eq + data: + - from_registry: test_env.name + - "{{ new_name }}" + + # - action: delete + # model: Environment + # search_query: + # name: "{{ new_name }}" + diff --git a/examples/satellite/gpg_key.yaml b/examples/satellite/gpg_key.yaml new file mode 100644 index 0000000..d2306e6 --- /dev/null +++ b/examples/satellite/gpg_key.yaml @@ -0,0 +1,52 @@ +# Testing satellite-populate actions on GPGKey entities + +vars: + name: GPGKey + org_name: Org + new_content: content + +actions: + + - model: Organization + register: org + data: + name: "{{ org_name }}" + label: test_organization + description: GPG Keys require an Organization + + - model: GPGKey + register: test_gpg + data: + name: "{{ name }}" + content: None + organization: + from_registry: org + + - action: update + register: test_gpg + model: GPGKey + data: + content: "{{ new_content }}" + organization: + from_registry: org + search_query: + name: "{{ name }}" + organization: + from_registry: org + + - action: assertion + operation: eq + data: + - from_registry: test_gpg.content + - "{{ new_content }}" + + # - action: delete + # model: GPGKey + # search_query: + # name: "{{ name }}" + + # Cleanup + - action: delete + model: Organization + search_query: + name: "{{ org_name }}" diff --git a/examples/satellite/host_collection.yaml b/examples/satellite/host_collection.yaml new file mode 100644 index 0000000..4447d0b --- /dev/null +++ b/examples/satellite/host_collection.yaml @@ -0,0 +1,36 @@ +# Testing nailgun entities + +vars: + name: host-collection + desc: Nailgun test + update_desc: Updated + +actions: + + - model: HostCollection + register: test_entity + data: + name: "{{ name }}" + description: "{{ desc }}" + max_hosts: 10 + unlimited_hosts: False + + - action: update + register: test_entity + model: HostCollection + data: + description: "{{ update_desc }}" + search_query: + name: "{{ name }}" + + - action: assertion + operation: eq + data: + - from_registry: test_entity.description + - "{{ update_desc }}" + + - action: delete + model: HostCollection + search_query: + name: "{{ name }}" + diff --git a/examples/satellite/host_group.yaml b/examples/satellite/host_group.yaml new file mode 100644 index 0000000..d4aae3f --- /dev/null +++ b/examples/satellite/host_group.yaml @@ -0,0 +1,34 @@ +# Test nailgun entities + +vars: + name: Host Group + password: password + new_password: rootroot + +actions: + + - model: HostGroup + register: test_entity + data: + name: "{{ name }}" + root_pass: "{{ password }}" + + - action: update + register: test_entity + model: HostGroup + data: + root_pass: "{{ new_password }}" + search_query: + name: "{{ name }}" + + - action: assertion + operation: eq + data: + - from_registry: test_entity.root_pass + - "{{ new_password }}" + + # - action: delete + # model: HostGroup + # search_query: + # name: "{{ name }}" + diff --git a/examples/satellite/lifecycle_environment.yaml b/examples/satellite/lifecycle_environment.yaml new file mode 100644 index 0000000..c8704f9 --- /dev/null +++ b/examples/satellite/lifecycle_environment.yaml @@ -0,0 +1,35 @@ +# Testing nailgun entities + +vars: + name: Life + desc: Nailgun test + update_desc: Updated description + +actions: + + - model: LifecycleEnvironment + register: test_entity + data: + name: "{{ name }}" + description: "{{ desc }}" + label: lifecycle_label + + - action: update + register: test_entity + model: LifecycleEnvironment + data: + description: "{{ update_desc }}" + search_query: + name: "{{ name }}" + + - action: assertion + operation: eq + data: + - from_registry: test_entity.description + - "{{ update_desc }}" + + - action: delete + model: LifecycleEnvironment + search_query: + name: "{{ name }}" + diff --git a/examples/satellite/location.yaml b/examples/satellite/location.yaml new file mode 100644 index 0000000..2556775 --- /dev/null +++ b/examples/satellite/location.yaml @@ -0,0 +1,34 @@ +# Testing nailgun entities + +vars: + name: Location + desc: Raleigh, NC + update_desc: RDU + +actions: + + - model: Location + register: test_entity + data: + name: "{{ name }}" + description: "{{ desc }}" + + - action: update + register: test_entity + model: Location + data: + description: "{{ update_desc }}" + search_query: + name: "{{ name }}" + + - action: assertion + operation: eq + data: + - from_registry: test_entity.description + - "{{ update_desc }}" + + - action: delete + model: Location + search_query: + name: "{{ name }}" + diff --git a/examples/satellite/media.yaml b/examples/satellite/media.yaml new file mode 100644 index 0000000..08afee7 --- /dev/null +++ b/examples/satellite/media.yaml @@ -0,0 +1,34 @@ +# Testing nailgun entities + +vars: + name: My Media + os: Redhat + update_os: Windows + +actions: + + - model: Media + register: test_entity + data: + name: "{{ name }}" + os_family: "{{ os }}" + + - action: update + register: test_entity + model: Media + data: + os_family: "{{ update_os }}" + search_query: + name: "{{ name }}" + + - action: assertion + operation: eq + data: + - from_registry: test_entity.os_family + - "{{ update_os }}" + + - action: delete + model: Media + search_query: + name: "{{ name }}" + diff --git a/examples/satellite/operating_system.yaml b/examples/satellite/operating_system.yaml new file mode 100644 index 0000000..7dc1b51 --- /dev/null +++ b/examples/satellite/operating_system.yaml @@ -0,0 +1,39 @@ +# Test nailgun entities + +vars: + name: Fedora + release: F25 + update_rel: F26 + +actions: + + - model: OperatingSystem + register: test_entity + data: + name: "{{ name }}" + family: Redhat + release_name: "{{ release }}" + major: 26 + minor: 25 + title: Fedora Workstation + description: Fedora linux + + - action: update + register: test_entity + model: OperatingSystem + data: + release_name: "{{ update_rel }}" + search_query: + name: "{{ name }}" + + - action: assertion + operation: eq + data: + - from_registry: test_entity.release_name + - "{{ update_rel }}" + + - action: delete + model: OperatingSystem + search_query: + name: "{{ name }}" + diff --git a/examples/satellite/organization.yaml b/examples/satellite/organization.yaml new file mode 100644 index 0000000..83aa127 --- /dev/null +++ b/examples/satellite/organization.yaml @@ -0,0 +1,36 @@ +# Testing nailgun entities + +vars: + name: Red Hat + desc: RHEL + update_desc: Red Hat Enterprise Linux + +actions: + + - model: Organization + register: test_entity + data: + name: "{{ name }}" + description: "{{ desc }}" + label: RHT + title: REDHAT + + - action: update + register: test_entity + model: Organization + data: + description: "{{ update_desc }}" + search_query: + name: "{{ name }}" + + - action: assertion + operation: eq + data: + - from_registry: test_entity.description + - "{{ update_desc }}" + + - action: delete + model: Organization + search_query: + name: "{{ name }}" + diff --git a/examples/satellite/partition_table.yaml b/examples/satellite/partition_table.yaml new file mode 100644 index 0000000..57bd337 --- /dev/null +++ b/examples/satellite/partition_table.yaml @@ -0,0 +1,35 @@ +# Testing nailgun entities + +vars: + name: entity_name + os: Debian + update_os: Redhat + +actions: + + - model: PartitionTable + register: test_entity + data: + name: "{{ name }}" + layout: table + os_family: "{{ os }}" + + - action: update + register: test_entity + model: PartitionTable + data: + os_family: "{{ update_os }}" + search_query: + name: "{{ name }}" + + - action: assertion + operation: eq + data: + - from_registry: test_entity.os_family + - "{{ update_os }}" + + - action: delete + model: PartitionTable + search_query: + name: "{{ name }}" + diff --git a/examples/satellite/provisioning_template.yaml b/examples/satellite/provisioning_template.yaml new file mode 100644 index 0000000..fe69116 --- /dev/null +++ b/examples/satellite/provisioning_template.yaml @@ -0,0 +1,48 @@ +# Testing nailgun entities + +vars: + name: provision + combinations: + - a + - b + - c + new_combinations: + - x + - y + - z + +actions: + +# Create + - model: ProvisioningTemplate + register: test_prov_tmp + data: + name: "{{ name }}" + locked: False + audit_comment: comment + snippet: True + template: temp + template_combinations: "{{ combinations }}" + +# Update + - action: update + register: test_prov_tmp + model: ProvisioningTemplate + data: + template_combinations: "{{ new_combinations }}" + search_query: + name: "{{ name }}" + +# Assert + - action: assertion + log: Checking that ProvisioningTemplate name was updated + operation: eq + data: + - from_registry: test_prov_tmp.template_combinations + - "{{ new_combinations }}" + +# Delete + - action: delete + model: ProvisioningTemplate + search_query: + name: "{{ name }}" diff --git a/examples/satellite/puppet_class.yaml b/examples/satellite/puppet_class.yaml new file mode 100644 index 0000000..e27b495 --- /dev/null +++ b/examples/satellite/puppet_class.yaml @@ -0,0 +1,32 @@ +# Test nailgun entities + +vars: + name: Puppet + update_name: puppet_class + +actions: + + - model: PuppetClass + register: test_entity + data: + name: "{{ name }}" + + # - action: update + # register: test_entity + # model: PuppetClass + # data: + # name: "{{ update_name }}" + # search_query: + # name: "{{ name }}" + + - action: assertion + operation: eq + data: + - from_registry: test_entity.name + - "{{ name }}" + + - action: delete + model: PuppetClass + search_query: + name: "{{ name }}" + diff --git a/examples/satellite/repository.yaml b/examples/satellite/repository.yaml new file mode 100644 index 0000000..a985334 --- /dev/null +++ b/examples/satellite/repository.yaml @@ -0,0 +1,40 @@ +# Testing nailgun entities + +vars: + name: Repo + +actions: + + - model: Repository + register: test_entity + data: + name: "{{ name }}" + content_type: yum + checksum_type: 'sha256' + container_repository_name: container + docker_upstream_name: busybox + download_policy: on_demand + label: test + mirror_on_sync: False + unprotected: False + url: http://inecas.fedorapeople.org/fakerepos/zoo3/ + + - action: update + register: test_entity + model: Repository + data: + content_type: docker + search_query: + name: "{{ name }}" + + - action: assertion + operation: eq + data: + - from_registry: test_entity.content_type + - docker + + - action: delete + model: Repository + search_query: + name: "{{ name }}" + diff --git a/examples/satellite/role.yaml b/examples/satellite/role.yaml new file mode 100644 index 0000000..d288a48 --- /dev/null +++ b/examples/satellite/role.yaml @@ -0,0 +1,32 @@ +# Testing nailgun entities + +vars: + name: Role + update_name: NewRole + +actions: + + - model: Role + register: test_entity + data: + name: "{{ name }}" + + - action: update + register: test_entity + model: Role + data: + name: "{{ update_name }}" + search_query: + name: "{{ name }}" + + - action: assertion + operation: eq + data: + - from_registry: test_entity.name + - "{{ update_name }}" + + - action: delete + model: Role + search_query: + name: "{{ update_name }}" + diff --git a/examples/satellite/smart_variable.yaml b/examples/satellite/smart_variable.yaml new file mode 100644 index 0000000..b52e3f4 --- /dev/null +++ b/examples/satellite/smart_variable.yaml @@ -0,0 +1,44 @@ +# Testing nailgun entities + +vars: + var: SmartVar + default_value: default + update_default: test + +actions: + + - model: PuppetClass + register: puppet + data: + name: Puppet + + - model: SmartVariable + register: test_entity + data: + default_value: "{{ default_value }}" + description: satellite-populate test + variable: "{{ var }}" + hidden_value: False + variable_type: string + puppetclass: + from_registry: puppet + + - action: update + register: test_entity + model: SmartVariable + data: + default_value: "{{ update_default }}" + search_query: + variable: "{{ var }}" + + - action: assertion + operation: eq + data: + - from_registry: test_entity.default_value + - "{{ update_default }}" + + - action: delete + model: SmartVariable + search_query: + variable: "{{ var }}" + diff --git a/examples/satellite/subnet.yaml b/examples/satellite/subnet.yaml new file mode 100644 index 0000000..52a5467 --- /dev/null +++ b/examples/satellite/subnet.yaml @@ -0,0 +1,37 @@ +# Testing nailgun entities + +vars: + name: SubNet + to: 127.0.0.1 + update_to: 127.0.1.1 + + +actions: + + - model: Subnet + register: test_entity + data: + name: "{{ name }}" + network: 127.0.0.1 + from: 127.0.0.1 + to: "{{ to }}" + + - action: update + register: test_entity + model: Subnet + data: + to: "{{ update_to }}" + search_query: + name: "{{ name }}" + + - action: assertion + operation: eq + data: + - from_registry: test_entity.to + - "{{ update_to }}" + + - action: delete + model: Subnet + search_query: + name: "{{ name }}" + diff --git a/examples/satellite/sync_plan.yaml b/examples/satellite/sync_plan.yaml new file mode 100644 index 0000000..e208ed4 --- /dev/null +++ b/examples/satellite/sync_plan.yaml @@ -0,0 +1,54 @@ +# Testing nailgun entities + +vars: + name: SyncPlan + desc: Nailgun test + update_desc: Updated description + +actions: + + - model: Organization + register: org + data: + name: My Org + + - model: SyncPlan + register: test_entity + data: + name: "{{ name }}" + description: satellite-populate test + interval: daily + enabled: True + organization: + from_registry: org + + - action: update + register: test_entity + model: SyncPlan + data: + description: "{{ update_desc }}" + organization: + from_registry: org + search_query: + name: "{{ name }}" + organization: + from_registry: org + + - action: assertion + operation: eq + data: + - from_registry: test_entity.description + - "{{ update_desc }}" + + # - action: delete + # model: SyncPlan + # search_query: + # name: "{{ name }}" + # organization: + # from_registry: org + + - action: delete + model: Organization + search_query: + name: My Org + diff --git a/examples/satellite/user.yaml b/examples/satellite/user.yaml new file mode 100644 index 0000000..92b649e --- /dev/null +++ b/examples/satellite/user.yaml @@ -0,0 +1,38 @@ +# Testing nailgun entities + +vars: + login: dbrownjr + pass: redhat + update_pass: password + +actions: + + - model: User + register: test_entity + data: + admin: True + firstname: Chris + lastname: Brown + login: "{{ login }}" + mail: dbrownjr@redhat.com + password: "{{ pass }}" + + - action: update + register: test_entity + model: User + data: + password: "{{ update_pass }}" + search_query: + login: "{{ login }}" + + - action: assertion + operation: eq + data: + - from_registry: test_entity.password + - "{{ update_pass }}" + + - action: delete + model: User + search_query: + login: "{{ login }}" + diff --git a/satellite_populate/constants.py b/satellite_populate/constants.py index fc4e01d..0393da6 100644 --- a/satellite_populate/constants.py +++ b/satellite_populate/constants.py @@ -30,8 +30,68 @@ 'repository': { 'url': {'remove': True}, }, - # force Architecture to always perform raw_search - 'architecture': {'_force_raw': True} + 'architecture': {'_force_raw': True}, + 'bookmark': { + '_force_raw': True, + 'query': {'remove': True}, + 'public': {'remove': True} + }, + 'configtemplate': { + '_force_raw': True, + 'template_combinations': {'remove': True}, + 'audit_comment': {'remove': True}, + 'locked': {'remove': True}, + 'organization': {'remove': True}, + 'template': {'remove': True}, + 'template_kind': {'remove': True}, + 'snippet': {'remove': True}, + 'operatingsystem': {'remove': True}, + }, + 'interface': {'_force_raw': True}, + 'location': {'_force_raw': True}, + 'media': { + '_force_raw': True, + 'os_family': {'remove': True}, + 'path': {'remove': True}, + 'location': {'remove': True}, + 'operatingsystem': {'remove': True}, + 'organization': {'remove': True}, + }, + 'operatingsystem': { + '_force_raw': True, + 'release_name': {'remove': True}, + 'description': {'remove': True}, + 'architecture': {'remove': True}, + 'family': {'remove': True}, + 'major': {'remove': True}, + 'minor': {'remove': True}, + 'medium': {'remove': True}, + 'ptable': {'remove': True}, + 'config_template': {'remove': True}, + 'provisioning_template': {'remove': True}, + 'password_hash': {'remove': True}, + 'title': {'remove': True}, + }, + 'partitiontable': { + '_force_raw': True, + 'layout': {'remove': True}, + 'location': {'remove': True}, + 'organization': {'remove': True}, + 'os_family': {'remove': True}, + }, + 'provisioningtemplate': { + '_force_raw': True, + 'audit_comment': {'remove': True}, + 'locked': {'remove': True}, + 'organization': {'remove': True}, + 'location': {'remove': True}, + 'template': {'remove': True}, + 'template_combinations': {'remove': True}, + 'template_kind': {'remove': True}, + 'snippet': {'remove': True}, + 'operatingsystem': {'remove': True}, + }, + 'role': {'_force_raw': True}, } DEFAULT_CONFIG = SmartDict({