Esempio n. 1
0
    def check(verbose_level=1, hostnames=[], servicenames=[]):
        # type: (int, List[str], List[str]) -> Job
        """Do post-deployment smoke tests.

        :param hostnames: host names
        :type hostnames: list
        :param verbose_level: the higher the number, the more verbose
        :type verbose_level: integer
        :param servicenames: services to check. If empty, then check all.
        :type servicenames: list of strings
        :return: Job object
        :rtype: Job
        """
        check_arg(verbose_level, u._('Verbose level'), int)
        check_arg(hostnames,
                  u._('Host names'),
                  list,
                  empty_ok=True,
                  none_ok=True)
        check_arg(servicenames,
                  u._('Service names'),
                  list,
                  empty_ok=True,
                  none_ok=True)

        check_kolla_args(servicenames=servicenames)

        hostnames = safe_decode(hostnames)
        servicenames = safe_decode(servicenames)
        action = KollaAction(verbose_level=verbose_level,
                             playbook_name='site.yml')
        ansible_job = action.check(hostnames, servicenames)
        return Job(ansible_job)
Esempio n. 2
0
    def stop(verbose_level=1, hostnames=[], servicenames=[]):
        # type: (int, List[str], List[str]) -> Job
        """Stop Hosts.

        Stops all kolla related docker containers on the specified hosts.

        :param hostnames: host names
        :type hostnames: list
        :param verbose_level: the higher the number, the more verbose
        :type verbose_level: integer
        :param servicenames: services to stop. If empty, then stop all.
        :type servicenames: list of strings
        :return: Job object
        :rtype: Job
        """
        check_arg(verbose_level, u._('Verbose level'), int)
        check_arg(hostnames,
                  u._('Host names'),
                  list,
                  empty_ok=True,
                  none_ok=True)
        check_arg(servicenames,
                  u._('Service names'),
                  list,
                  empty_ok=True,
                  none_ok=True)

        check_kolla_args(hostnames=hostnames, servicenames=servicenames)

        hostnames = safe_decode(hostnames)
        servicenames = safe_decode(servicenames)
        action = KollaAction(verbose_level=verbose_level,
                             playbook_name='site.yml')
        ansible_job = action.stop(hostnames, servicenames)
        return Job(ansible_job)
Esempio n. 3
0
    def pull(verbose_level=1, hostnames=[], servicenames=[]):
        """Pull.

        Pull all images for containers (only pulls, no running container).

        :param verbose_level: the higher the number, the more verbose
        :param hostnames: hosts to pull to. If empty, then pull to all.
        :type hostnames: list of strings
        :type verbose_level: integer
        :param servicenames: services to pull. If empty, then pull all.
        :return: Job object
        :rtype: Job
        """
        check_arg(hostnames,
                  u._('Host names'),
                  list,
                  empty_ok=True,
                  none_ok=True)
        check_arg(verbose_level, u._('Verbose level'), int)
        check_arg(servicenames,
                  u._('Service names'),
                  list,
                  empty_ok=True,
                  none_ok=True)

        check_kolla_args(hostnames=hostnames, servicenames=servicenames)

        hostnames = safe_decode(hostnames)
        servicenames = safe_decode(servicenames)
        action = KollaAction(verbose_level=verbose_level,
                             playbook_name='site.yml')
        ansible_job = action.pull(hostnames, servicenames)
        return Job(ansible_job)
Esempio n. 4
0
    def pull(verbose_level=1):
        """Pull.

        Pull container images onto appropriate hosts.

        :param verbose_level: the higher the number, the more verbose
        :type verbose_level: integer
        :return: Job object
        :rtype: Job
        """
        check_arg(verbose_level, u._('Verbose level'), int)
        ansible_job = actions.pull(verbose_level)
        return Job(ansible_job)
Esempio n. 5
0
    def reconfigure(verbose_level=1):
        # type: (int) -> Job
        """Reconfigure.

        Reconfigure containers on hosts.

        :param verbose_level: the higher the number, the more verbose
        :type verbose_level: integer
        :return: Job object
        :rtype: Job
        """
        check_arg(verbose_level, u._('Verbose level'), int)

        ansible_job = actions.reconfigure(verbose_level)
        return Job(ansible_job)
Esempio n. 6
0
    def certificate_init(verbose_level=1):
        """Certificate Init.

        Creates a self-signed certificate for secure TLS communication.

        :param verbose_level: the higher the number, the more verbose
        :type verbose_level: integer
        :return: Job object
        :rtype: Job
        """
        check_arg(verbose_level, u._('Verbose level'), int)
        action = KollaAction(verbose_level=verbose_level,
                             playbook_name='certificates.yml')
        ansible_job = action.certificate_init()
        return Job(ansible_job)
Esempio n. 7
0
    def postdeploy(verbose_level=1):
        """Post-Deploy.

        Do post deploy on deploy node.

        :param verbose_level: the higher the number, the more verbose
        :type verbose_level: integer
        :return: Job object
        :rtype: Job
        """
        check_arg(verbose_level, u._('Verbose level'), int)

        action = KollaAction(verbose_level=verbose_level,
                             playbook_name='post-deploy.yml')
        ansible_job = action.postdeploy()
        return Job(ansible_job)
Esempio n. 8
0
    def host_destroy(hostnames,
                     destroy_type,
                     verbose_level=1,
                     include_data=False,
                     remove_images=False):
        # type: (List[str], str, int, bool, bool) -> Job
        """Destroy Hosts.

        Stops and removes all kolla related docker containers on the
        specified hosts.

        :param hostnames: host names
        :type hostnames: list
        :param destroy_type: either 'kill' or 'stop'
        :type destroy_type: string
        :param verbose_level: the higher the number, the more verbose
        :type verbose_level: integer
        :param include_data: if true, destroy data containers too.
        :type include_data: boolean
        :param remove_images: if true, destroy will remove the docker images
        :type remove_images: boolean
        :return: Job object
        :rtype: Job
        """
        check_arg(hostnames, u._('Host names'), list)
        check_arg(destroy_type, u._('Destroy type'), str)
        check_arg(verbose_level, u._('Verbose level'), int)
        check_arg(include_data, u._('Include data'), bool)
        check_arg(remove_images, u._('Remove images'), bool)
        if destroy_type not in ['stop', 'kill']:
            raise InvalidArgument(
                u._('Invalid destroy type ({type}). Must be either '
                    '"stop" or "kill".').format(type=destroy_type))

        hostnames = safe_decode(hostnames)
        inventory = Inventory.load()
        inventory.validate_hostnames(hostnames)

        action = KollaAction(verbose_level=verbose_level,
                             playbook_name='destroy.yml')
        ansible_job = action.destroy_hosts(hostnames, destroy_type,
                                           include_data, remove_images)
        return Job(ansible_job)
Esempio n. 9
0
    def deploy(hostnames=[],
               serial_flag=False,
               verbose_level=1,
               servicenames=[]):
        # type: (List[str], bool, int, List[str]) -> Job
        """Deploy.

        Deploy and start all kolla containers.

        :param hostnames: hosts to deploy to. If empty, then deploy to all.
        :type hostnames: list of strings
        :param serial_flag: if true, deploy will be done one host at a time
        :type serial_flag: boolean
        :param verbose_level: the higher the number, the more verbose
        :type verbose_level: integer
        :param servicenames: services to deploy. If empty, then deploy all.
        :type servicenames: list of strings
        :return: Job object
        :rtype: Job
        """
        check_arg(hostnames,
                  u._('Host names'),
                  list,
                  empty_ok=True,
                  none_ok=True)
        check_arg(serial_flag, u._('Serial flag'), bool)
        check_arg(verbose_level, u._('Verbose level'), int)
        check_arg(servicenames,
                  u._('Service names'),
                  list,
                  empty_ok=True,
                  none_ok=True)

        check_kolla_args(hostnames=hostnames, servicenames=servicenames)

        hostnames = safe_decode(hostnames)
        servicenames = safe_decode(servicenames)
        action = KollaAction(verbose_level=verbose_level,
                             playbook_name='site.yml')
        ansible_job = action.deploy(hostnames, serial_flag, servicenames)
        return Job(ansible_job)
Esempio n. 10
0
    def host_stop(hostnames, verbose_level=1):
        # type: (List[str], int) -> Job
        """Stop Hosts.

        Stops all kolla related docker containers on the specified hosts.

        :param hostnames: host names
        :type hostnames: list
        :param verbose_level: the higher the number, the more verbose
        :type verbose_level: integer
        :return: Job object
        :rtype: Job
        """
        check_arg(hostnames, u._('Host names'), list)
        check_arg(verbose_level, u._('Verbose level'), int)

        hostnames = safe_decode(hostnames)
        inventory = Inventory.load()
        inventory.validate_hostnames(hostnames)

        ansible_job = actions.stop_hosts(hostnames, verbose_level)
        return Job(ansible_job)
Esempio n. 11
0
    def host_precheck(hostnames, verbose_level=1):
        # type: (List[str], int) -> Job
        """Check pre-deployment configuration of hosts.

        Check if host is ready for a new deployment. This will fail if
        any of the hosts are not configured correctly or if they have
        already been deployed to.
        :param hostnames: host names
        :type hostnames: list
        :param verbose_level: the higher the number, the more verbose
        :type verbose_level: integer
        :return: Job object
        :rtype: Job
        """
        check_arg(hostnames, u._('Host names'), list)
        check_arg(verbose_level, u._('Verbose level'), int)
        hostnames = safe_decode(hostnames)
        inventory = Inventory.load()
        inventory.validate_hostnames(hostnames)

        ansible_job = actions.precheck(hostnames, verbose_level)
        return Job(ansible_job)
Esempio n. 12
0
    def reconfigure(verbose_level=1, hostnames=[], servicenames=[]):
        # type: (int, List[str], List[str]) -> Job
        """Reconfigure.

        Reconfigure OpenStack service.

        :param hostnames: host names
        :type hostnames: list
        :param verbose_level: the higher the number, the more verbose
        :type verbose_level: integer
        :param servicenames: services to prechecks.
        :type servicenames: list of strings
        :return: Job object
        :rtype: Job
        """
        check_arg(hostnames,
                  u._('Host names'),
                  list,
                  empty_ok=True,
                  none_ok=True)
        check_arg(verbose_level, u._('Verbose level'), int)
        check_arg(servicenames,
                  u._('Service names'),
                  list,
                  empty_ok=True,
                  none_ok=True)

        check_kolla_args(hostnames=hostnames, servicenames=servicenames)

        hostnames = safe_decode(hostnames)
        servicenames = safe_decode(servicenames)

        check_kolla_args(hostnames=hostnames, servicenames=servicenames)

        action = KollaAction(verbose_level=verbose_level,
                             playbook_name='site.yml')
        ansible_job = action.reconfigure(hostnames, servicenames)
        return Job(ansible_job)
Esempio n. 13
0
    def upgrade(verbose_level=1, hostnames=[], servicenames=[]):
        # type: (int, List[str], List[str]) -> Job
        """Upgrade.

        Upgrades existing OpenStack Environment.

        :param verbose_level: the higher the number, the more verbose
        :type verbose_level: integer
        :param hostnames: hostnames to upgrade.
        :type hostnames: list of strings.
        :param servicenames: services to upgrade. If empty, then upgrade all.
        :type servicenames: list of strings
        :return: Job object
        :rtype: Job

        Upgrade containers to new version specified by the property
        "openstack_release."
        """
        check_arg(verbose_level, u._('Verbose level'), int)
        check_arg(hostnames,
                  u._('Host names'),
                  list,
                  empty_ok=True,
                  none_ok=True)
        check_arg(servicenames,
                  u._('Service names'),
                  list,
                  empty_ok=True,
                  none_ok=True)

        check_kolla_args(servicenames=servicenames)

        hostnames = safe_decode(hostnames)
        servicenames = safe_decode(servicenames)
        action = KollaAction(verbose_level=verbose_level,
                             playbook_name='site.yml')
        ansible_job = action.upgrade(hostnames, servicenames)
        return Job(ansible_job)
Esempio n. 14
0
    def upgrade(verbose_level=1, servicenames=[]):
        # type: (int, List[str]) -> Job
        """Upgrade.

        :param verbose_level: the higher the number, the more verbose
        :type verbose_level: integer
        :param servicenames: services to upgrade. If empty, then upgrade all.
        :type servicenames: list of strings
        :return: Job object
        :rtype: Job

        Upgrade containers to new version specified by the property
        "openstack_release."
        """
        check_arg(verbose_level, u._('Verbose level'), int)
        check_arg(servicenames,
                  u._('Service names'),
                  list,
                  empty_ok=True,
                  none_ok=True)
        servicenames = safe_decode(servicenames)

        ansible_job = actions.upgrade(verbose_level, servicenames)
        return Job(ansible_job)
Esempio n. 15
0
    def prechecks(verbose_level=1, hostnames=[], servicenames=[]):
        # type: (int, List[str], List[str]) -> Job
        """Check pre-deployment configuration of hosts.

        Check if host is ready for a new deployment. This will fail if
        any of the hosts are not configured correctly or if they have
        already been deployed to.
        :param hostnames: host names
        :type hostnames: list
        :param verbose_level: the higher the number, the more verbose
        :type verbose_level: integer
        :param servicenames: services to prechecks.
        :type servicenames: list of strings
        :return: Job object
        :rtype: Job
        """
        check_arg(hostnames,
                  u._('Host names'),
                  list,
                  empty_ok=True,
                  none_ok=True)
        check_arg(verbose_level, u._('Verbose level'), int)
        check_arg(servicenames,
                  u._('Service names'),
                  list,
                  empty_ok=True,
                  none_ok=True)

        check_kolla_args(hostnames=hostnames, servicenames=servicenames)

        hostnames = safe_decode(hostnames)
        servicenames = safe_decode(servicenames)
        action = KollaAction(verbose_level=verbose_level,
                             playbook_name='site.yml')
        ansible_job = action.precheck(hostnames, servicenames)
        return Job(ansible_job)