Beispiel #1
0
def _get_cmd_prefix():
    editor_path = os.path.join(utils.get_kollacli_home(), 'tools',
                               PWD_EDITOR_FILENAME)
    pwd_file_path = os.path.join(utils.get_kolla_etc(), PWDS_FILENAME)
    user = utils.get_admin_user()
    prefix = '/usr/bin/sudo -u %s %s -p %s ' % (user, editor_path,
                                                pwd_file_path)
    return prefix
Beispiel #2
0
    def take_action(self, parsed_args):
        try:
            hostname = ''
            hostname = parsed_args.hostname.strip()
            hostname = convert_to_unicode(hostname)

            if hostname != 'all':
                inventory = Inventory.load()
                host = inventory.get_host(hostname)
                if not host:
                    _host_not_found(self.log, hostname)

            destroy_type = 'kill'
            if parsed_args.stop:
                destroy_type = 'stop'

            self.log.info('please be patient as this may take a while.')
            ansible_properties = properties.AnsibleProperties()
            base_distro = \
                ansible_properties.get_property('kolla_base_distro')
            install_type = \
                ansible_properties.get_property('kolla_install_type')
            container_prefix = base_distro + '-' + install_type
            kollacli_home = get_kollacli_home()
            playbook = AnsiblePlaybook()
            playbook.playbook_path = os.path.join(kollacli_home,
                                                  'ansible/host_destroy.yml')
            playbook.extra_vars = 'hosts=' + hostname + \
                                  ' prefix=' + container_prefix + \
                                  ' destroy_type=' + destroy_type
            playbook.print_output = False
            playbook.verbose_level = self.app.options.verbose_level
            playbook.run()
        except CommandError as e:
            raise e
        except Exception as e:
            raise Exception(traceback.format_exc())
def _get_cmd_prefix():
    editor_path = os.path.join(utils.get_kollacli_home(), "tools", PWD_EDITOR_FILENAME)
    pwd_file_path = os.path.join(utils.get_kolla_etc(), PWDS_FILENAME)
    user = utils.get_admin_user()
    prefix = "/usr/bin/sudo -u %s %s -p %s " % (user, editor_path, pwd_file_path)
    return prefix