def take_action(self, parsed_args):
     self.log.debug('take_action({})'.format(parsed_args))
     self.log.warning('This command is deprecated. Please use "openstack '
                      'overcloud roles list" instead.')
     roles_path = os.path.realpath(parsed_args.roles_path)
     roles = rolesutils.get_roles_list_from_directory(roles_path)
     print('\n'.join(roles))
Ejemplo n.º 2
0
    def take_action(self, parsed_args):
        """Generate roles_data.yaml from imputed roles

        From the provided roles, validate that we have yaml files for the each
        role in our roles path and print them out concatenated together in the
        order they were provided.
        """
        self.log.debug('take_action({})'.format(parsed_args))
        roles_path = os.path.realpath(parsed_args.roles_path)
        # eliminate any dupes from the command line with an OrderedDict
        requested_roles = collections.OrderedDict.fromkeys(parsed_args.roles)
        available_roles = rolesutils.get_roles_list_from_directory(roles_path)
        rolesutils.check_role_exists(available_roles,
                                     list(requested_roles.keys()))
        self._capture_output(parsed_args.output_file)
        roles_data = rolesutils.generate_roles_data_from_directory(
            roles_path, list(requested_roles.keys()),
            parsed_args.skip_validate)
        sys.stdout.write(roles_data)
Ejemplo n.º 3
0
 def test_get_roles_from_directory(self, exists_mock, listdir_mock):
     exists_mock.return_value = True
     listdir_mock.return_value = ['b.yaml', 'a.yaml']
     self.assertEqual(rolesutils.get_roles_list_from_directory('/foo'),
                      ['a', 'b'])
Ejemplo n.º 4
0
 def test_get_roles_from_directory(self, exists_mock, listdir_mock):
     exists_mock.return_value = True
     listdir_mock.return_value = ['b.yaml', 'a.yaml']
     self.assertEqual(rolesutils.get_roles_list_from_directory('/foo'),
                      ['a', 'b'])
Ejemplo n.º 5
0
 def take_action(self, parsed_args):
     self.log.debug('take_action({})'.format(parsed_args))
     roles_path = os.path.realpath(parsed_args.roles_path)
     roles = rolesutils.get_roles_list_from_directory(roles_path)
     print('\n'.join(roles))