Esempio n. 1
0
 def test_parse_no_file(self):
     """
     Test to ensure an IOError is raised when reading in a non-existent
     file
     :return:
     """
     with self.assertRaises(IOError):
         file_utils.read_yaml('foo')
Esempio n. 2
0
def main(arguments):
    """
     This will launch the provisioning of Bare metat & IaaS.
     There is pxe based configuration defined to provision the bare metal.
     For IaaS provisioning different deployment models are supported.
     Relevant conf files related to PXE based Hw provisioning & Openstack based
     IaaS must be present in ./conf folder.
     :param arguments: This expects command line options to be entered by user
                       for relavant operations.
     :return: To the OS
    """

    log_level = logging.INFO
    if arguments.log_level != 'INFO':
        log_level = logging.DEBUG
    logging.basicConfig(level=log_level)

    logger.info('Launching Operation Starts ........')

    dir_path = os.path.dirname(os.path.realpath(__file__))
    export_path = dir_path + "/"
    os.environ['CWD_IAAS'] = export_path
    print '===========================Current Exported Relevant Path' \
          '=================================='
    logger.info('export CWD_IAAS=%s', export_path)

    config = file_utils.read_yaml(arguments.config)
    logger.info('Read configuration file - ' + arguments.config)
    if arguments.hardware is not ARG_NOT_SET:
        __read_hw_config(config, "hardware")

    if arguments.provisionClean is not ARG_NOT_SET:
        __read_hw_config(config, "provisionClean")

    if arguments.staticIPCleanup is not ARG_NOT_SET:
        __read_hw_config(config, "staticIPCleanup")

    if arguments.staticIPConfigure is not ARG_NOT_SET:
        __read_hw_config(config, "staticIPConfigure")

    if arguments.boot is not ARG_NOT_SET:
        if arguments.boot == "ubuntu":
           __read_hw_config(config, "ubuntu")
        elif arguments.boot == "centos":
           __read_hw_config(config, "centos")
        else:
           __read_hw_config(config, "boot")

    if arguments.bootd is not ARG_NOT_SET:
        __read_hw_config(config, "bootd")
    if arguments.setIsolCpus is not ARG_NOT_SET:
        __read_hw_config(config, "setIsolCpus")
    if arguments.delIsolCpus is not ARG_NOT_SET:
        __read_hw_config(config, "delIsolCpus")
    logger.info('Completed operation successfully')
Esempio n. 3
0
    def test_parse_text_file(self):
        """
        Tests attempting to parse a text file. The utility returns the contents
        of the text file back as a str, not a dict
        :return:
        """
        text_filepath = pkg_resources.resource_filename(
            'tests.unit.common.utils', 'test.txt')

        out = file_utils.read_yaml(text_filepath)
        self.assertTrue(isinstance(out, str))
Esempio n. 4
0
    def test_parse_yaml(self):
        """
        Test to ensure a YAML file is properly parsed
        :return:
        """
        yaml_filepath = pkg_resources.resource_filename(
            'tests.unit.common.utils', 'test.yaml')
        parsed_dict = file_utils.read_yaml(yaml_filepath)
        self.assertEqual(2, len(parsed_dict))
        self.assertTrue('foo' in parsed_dict)
        self.assertTrue('hello' in parsed_dict)

        hello_dict = parsed_dict['hello']
        self.assertEqual(1, len(hello_dict))
        self.assertTrue('world' in hello_dict)
        self.assertTrue('earth', hello_dict['world'])