Example #1
0
def main(actions=None):
    # NOTE(agordeev): get its own process group by calling setpgrp.
    # Process group is used to distribute signals to subprocesses.
    # The main application is already a process group leader,
    # then there's no need to call os.setpgrp
    #当前进程id与当前进程组id不相等,设置当前进程为组长
    if os.getpid() != os.getpgrp():
        os.setpgrp()
    #收到sigterm信号,杀掉整个进程组
    signal.signal(signal.SIGTERM, handle_sigterm)

    # Setup logging and process configuration options
    logging.register_options(CONF)
    CONF.register_cli_opts(cli_opts)
    CONF(sys.argv[1:], project=PROJECT,
         version=version.version_info.release_string())
    logging.setup(CONF, PROJECT)

    try:
        if CONF.input_data:
            data = yaml.safe_load(CONF.input_data)
        else:
            with open(CONF.input_data_file) as f:
                data = yaml.safe_load(f)
        LOG.debug('Input data: %s', data)

        #调用nailgun = fuel_agent.drivers.nailgun:Nailgun
        # 函数中的字符串,例如do_partitioning
        mgr = manager.Manager(data)
        if actions:
            for action in actions:
                getattr(mgr, action)()
    except Exception as exc:
        handle_exception(exc)
Example #2
0
def main(actions=None):
    # NOTE(agordeev): get its own process group by calling setpgrp.
    # Process group is used to distribute signals to subprocesses.
    # The main application is already a process group leader,
    # then there's no need to call os.setpgrp
    if os.getpid() != os.getpgrp():
        os.setpgrp()
    signal.signal(signal.SIGTERM, handle_sigterm)
    CONF(sys.argv[1:],
         project='fuel-agent',
         version=version.version_info.release_string())

    logging.setup('fuel-agent')
    LOG = logging.getLogger(__name__)

    try:
        if CONF.input_data:
            data = yaml.safe_load(CONF.input_data)
        else:
            with open(CONF.input_data_file) as f:
                data = yaml.safe_load(f)
        LOG.debug('Input data: %s', data)

        mgr = manager.Manager(data)
        if actions:
            for action in actions:
                getattr(mgr, action)()
    except Exception as exc:
        handle_exception(exc)
Example #3
0
    def setUp(self):
        super(BaseFuelAgentCITest, self).setUp()
        with open(FUEL_AGENT_CI_ENVIRONMENT_FILE) as f:
            ENV_DATA = (yaml.load(f.read()))
        self.env = environment.Environment.new(**ENV_DATA)
        self.env.start()
        self.name = ENV_DATA['vm'][0]['name']
        repo_obj = self.env.repo_by_name(FUEL_AGENT_REPO_NAME)
        tgz_name = '%s.tar.gz' % repo_obj.name
        utils.execute('tar czf %s %s' %
                      (tgz_name, os.path.join(self.env.envdir, repo_obj.path)))
        self.env.ssh_by_name(self.name).wait()
        self.env.ssh_by_name(self.name).put_file(
            tgz_name, os.path.join('/tmp', tgz_name))

        self.env.ssh_by_name(self.name).run(
            'tar xf %s' % os.path.join('/tmp', tgz_name),
            command_timeout=SSH_COMMAND_TIMEOUT)
        self.env.ssh_by_name(self.name).run(
            'pip install setuptools --upgrade',
            command_timeout=SSH_COMMAND_TIMEOUT)
        self.env.ssh_by_name(self.name).run(
            'cd /root/var/tmp/fuel_agent_ci/fuel_agent/fuel_agent; '
            #FIXME(agordeev): ^ don't hardcode path
            'python setup.py install',
            command_timeout=SSH_COMMAND_TIMEOUT)
        self.http_obj = self.env.http_by_name(FUEL_AGENT_HTTP_NAME)
        self.dhcp_hosts = self.env.dhcp_by_name(FUEL_AGENT_DHCP_NAME).hosts
        self.net = self.env.net_by_name(FUEL_AGENT_NET_NAME)
        p_data = get_filled_provision_data(self.dhcp_hosts[0]['ip'],
                                           self.dhcp_hosts[0]['mac'],
                                           self.net.ip, self.http_obj.port)
        self.env.ssh_by_name(self.name).put_content(
            json.dumps(p_data), os.path.join('/tmp', 'provision.json'))
        self.mgr = fa_manager.Manager(p_data)
Example #4
0
def main():
    CONF(sys.argv[1:], project='fuel-agent',
         version=version.version_info.release_string())
    log.setup('fuel-agent')

    with open(CONF.provision_data_file) as f:
        data = json.load(f)

    provision_manager = manager.Manager(data)
    provision_manager.do_provisioning()
Example #5
0
def main(actions=None):
    CONF(sys.argv[1:], project='fuel-agent',
         version=version.version_info.release_string())
    log.setup('fuel-agent')

    with open(CONF.provision_data_file) as f:
        data = json.load(f)

    mgr = manager.Manager(data)
    if actions:
        for action in actions:
            getattr(mgr, action)()
Example #6
0
def main(actions=None):
    try:
        if CONF.input_data:
            data = json.loads(CONF.input_data)
        else:
            with open(CONF.input_data_file) as f:
                data = json.load(f)
        LOG.debug('Input data: %s', data)

        mgr = manager.Manager(data)
        if actions:
            for action in actions:
                getattr(mgr, action)()
    except Exception as exc:
        handle_exception(exc)
Example #7
0
def make_bootstrap(data):
    bootdata_builder = data_util.BootstrapDataBuilder(data)
    bootdata = bootdata_builder.build()

    LOG.info("Try to build image with data:\n%s", yaml.safe_dump(bootdata))

    opts = ['--data_driver', 'bootstrap_build_image']
    if data.get('image_build_dir'):
        opts.extend(['--image_build_dir', data['image_build_dir']])

    OSLO_CONF = cfg.CONF
    OSLO_CONF(opts, project='fuel-agent')
    mngr = manager.Manager(bootdata)
    LOG.info("Build process is in progress. Usually it takes 15-20 minutes."
             " It depends on your internet connection and hardware"
             " performance.")
    mngr.do_mkbootstrap()

    return bootdata['bootstrap']['uuid'], bootdata['output']
Example #8
0
def main(actions=None):
    CONF(sys.argv[1:],
         project='fuel-agent',
         version=version.version_info.release_string())

    logging.setup('fuel-agent')
    LOG = logging.getLogger(__name__)

    try:
        if CONF.input_data:
            data = yaml.safe_load(CONF.input_data)
        else:
            with open(CONF.input_data_file) as f:
                data = yaml.safe_load(f)
        LOG.debug('Input data: %s', data)

        mgr = manager.Manager(data)
        if actions:
            for action in actions:
                getattr(mgr, action)()
    except Exception as exc:
        handle_exception(exc)
Example #9
0
 def setUp(self, mock_lbd, mock_http, mock_yaml):
     super(TestManager, self).setUp()
     mock_lbd.return_value = test_nailgun.LIST_BLOCK_DEVICES_SAMPLE
     self.mgr = manager.Manager(test_nailgun.PROVISION_SAMPLE_DATA)
Example #10
0
 def setUp(self):
     super(TestManager, self).setUp()
     self.mgr = manager.Manager(test_nailgun.PROVISION_SAMPLE_DATA)