Package: satellite_populate
Satellite-PopulatePopulate and Validate the System using YAMLFree software: GNU General Public License v3Documentation:https://satellite-populate.readthedocs.io.InstallationTo install latest released version:pip install satellite-populateTo install from github master branch:pip install https://github.com/SatelliteQE/satellite-populate/tarball/masterFor development:# fork https://github.com/SatelliteQE/satellite-populate/ to YOUR_GITHUB
# clone your repo locally
git clone git@github.com:YOUR_GITHUB/satellite-populate.git
cd satellite-populate

# add upstream remote
git remote add upstream git@github.com:SatelliteQE/satellite-populate.git

# create a virtualenv
mkvirtualenv satellite-populate
workon satellite-populate

# install for development (editable)
pip install -r requirements.txtTesting if installation is good:$ satellite-populate --test
satellite_populate.base - INFO - ECHO: Hello, if you can see this it means that I am working!!!FeaturesYAML based actionsData population definition goes to YAML file e.goffice.yamlin the following
example we are going to create 2 organizations and 2 admin users using lists:vars:

  org_names:
    - Dunder Mifflin
    - Wernham Hogg

  user_list:
    - firstname: Michael
      lastname: Scott

    - firstname: David
      lastname: Brent

actions:

  - model: Organization
    with_items: org_names
    register: default_orgs
    data:
      name: "{{ item }}"
      label: org{{ item.replace(' ', '') }}
      description: This is a satellite organization named {{ item }}

  - model: User
    with_items: user_list
    data:
      admin: true
      firstname: "{{ item.firstname }}"
      lastname: "{{ item.lastname }}"
      login: "{{ '{0}{1}'.format(item.firstname[0], item.lastname) | lower }}"
      password:
        from_factory: alpha
      organization:
        from_registry: default_orgs
      default_organization:
        from_registry: default_orgs[loop_index]On the populate file you can define CRUD actions such ascreate,delete,updateifaction:is not defined, the default will becreate.And also there isspecial actionsandcustom actionsexplained later.Populate Satellite With EntitiesConsideringoffice.yamlfile above you can populate satellite system with the
command line:$ satellite-populate office.yaml -h yourserver.com --output=office.yaml -vIn the above command line-hstands for--hostname,--outputis the
output file which will be written to be used to validate the system, and-vis
the verbose level.To see the list of available arguments please run:# satellite-populate --helpValidate if system have entitiesOnce you runsatellite-populateyou can use the outputted file to validate the system.
as all the output files are named asvalidation_<name>.yamlin office example you can run:$ satellite-populate validation_office.yaml -vUsing that validation file the system will be checked for entities existence, read-only.
The Validation file exists because during the population dynamic data is generated such as
passwords and stringsfrom_factoryand also some entities can be deleted or updated
so validation file takes care of it.Special actionsSome builtin special actions are:assertionechoregisterunregisterIn the following example we are going to run a complete test case using
actions defined in YAML file, if validation fails system returns status 0
which can be used to automate tests:# A TEST CASE USING SPECIAL ACTIONS
# Create a plain vanilla activation key
# Check that activation key is created and its "unlimited_hosts"
# attribute defaults to true

- action: create
  log: Create a plain vanilla activation key
  model: ActivationKey
  register: vanilla_key
  data:
     name: vanilla
     organization:
       from_registry: default_orgs[0]

- action: assertion
  log: >
    Check that activation key is created and its "unlimited_hosts"
    attribute defaults to true
  operation: eq
  register: vanilla_key_unlimited_hosts
  data:
    - from_registry: vanilla_key.unlimited_hosts
    - true

- action: echo
  log: Vanilla Key Unlimited Host is False!!!!
  level: error
  print: true
  when: vanilla_key_unlimited_hosts == False

- action: echo
  log: Vanilla Key Unlimited Host is True!!!!
  level: info
  print: true
  when: vanilla_key_unlimited_hosts

- action: register
  data:
    you_must_update_vanilla_key: true
  when: vanilla_key_unlimited_hosts == FalseCustom actionsAnd you can also have special actions defined in a custom populator.Lets say you have this python module in your project, properly available on
PYTHONPATH:from satellite_populate.api import APIPopulator

class MyPopulator(APIPopulator):
    def action_writeinfile(self, rendered_data, action_data):
        with open(rendered_data['path'], 'w') as output:
            output.write(rendered_data['content'])Now go to yourtest.yamland write:config:
  populator: mine
  populators:
    mine:
      module: mypath.mymodule.MyPopulator

actions:

  - action: writeinfile
    path: /tmp/test.txt
    text: Hello World!!!and run:$ satellite-populate test.yaml -vDecorator for test casesHaving a data_file like:actions:
  - model: Organization
    register: organization_1
    data:
      name: My OrgThen you can use in decorators:@populate_with('file.yaml')
def test_case_(self):
    'My Org exists in system test anything here'And getting the populated entities inside the test_case:@populate_with('file.yaml', context_name='my_context')
def test_case_(self, my_context=None):
    assert my_context.organization_1.name == 'My Org'

You can also set a customized context wrapper to the
context_wrapper argument::

    def my_custom_context_wrapper(result):
        # create an object using result
        my_context = MyResultContext(result)
        return my_context

    @populate_with('file.yaml', context_name='my_context',
                   content_wrapper=my_custom_context_wrapper)
    def test_case_(self, my_context=None):
        # assert with some expression using my_context object returned
        # my_custom_context_wrapper
        assert some_expressionNOTE:That is important that ``context`` argument always be declared using
either a default value ``my_context=None`` or handle in ``**kwargs``
Otherwise ``py.test`` may try to use this as a fixture placeholder.

if context_wrapper is set to None, my_context will be the pure unmodified
result of populate function.Satellite versionsThis code is by default prepared to run against Satellitelatestversion
which means the use of thelatestmaster fromnailgunrepository.If you need to run this tool in older versions e.g: to tun upgrade tests, you
have to setupnailgunversion.You have 2 options:Manuallybefore installing satellite-populate install specific nailgun version as
the following list.Satellite 6.1.x:pip install -e git+https://github.com/SatelliteQE/nailgun.git@0.28.0#egg=nailgun
pip install satellite-populateSatellite 6.2.x:pip install -e git+https://github.com/SatelliteQE/nailgun.git@6.2.z#egg=nailgun
pip install satellite-populateSatellite 6.3.x (latest):pip install -e git+https://github.com/SatelliteQE/nailgun.git#egg=nailgun
pip install satellite-populateDockerIf you need to runsatellite-populatein older Satellite versions you can
use thedocker imagesso it will manage the correct nailgun version to
be used with that specific system version.https://hub.docker.com/r/satelliteqe/satellite-populate/First pull image from Docker Hub:docker pull satelliteqe/satellite-populate:latestChange:latestto specific tag. e.g::6.1or:6.2Test it:docker run satelliteqe/satellite-populate --testThen run:docker run -v $PWD:/datafiles satelliteqe/satellite-populate /datafiles/theoffice.yaml -v -h server.comYou must map your local folder containing datafilesCreditsThis package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.History0.1.3 (2017-01-13)Docker support0.1.2 (2017-01-12)Fix decorators.0.1.0 (2017-01-10)First release on PyPI.