示例#1
0
文件: run.py 项目: mikemrm/osie
    tinkerbell = parse.urlparse(
        util.value_from_kopt(cmdline_content, "tinkerbell"))
    facility = util.value_from_kopt(cmdline_content, "facility")

phone_home = phone_homer(parse.urljoin(tinkerbell.geturl(), "phone-home"))
fail = failer()

statedir = os.getenv("STATEDIR_HOST")
if not statedir:
    fail("STATEDIR_HOST env var is missing, unable to proceed")

watch, resp = connect_hegel(facility)

# TODO decide to keep or remove? means we'd ignore a failed deprov
log.info("wiping disk partitions")
handlers = handlers.Handler(phone_home, log, tinkerbell, statedir)
handlers.wipe(json.loads(resp.JSON))

log.info("running subscribe loop")
while True:
    j = json.loads(resp.JSON)
    # note: do not try to ignore pushes with out state changes, network
    # sometimes comes in after state:provisioning for example
    state = j["state"]
    i = j.get("instance", {"state": ""})
    log.info("context updated", state=state, instance_state=i.get("state", ""))

    handler = handlers.handler(state)
    if handler:
        try:
            exit = handler(j)
示例#2
0
def handler_keep_wipe(phone_home, log, tmpdir):
    reset_helpers()
    host_state_dir = os.path.dirname(fake.file_path(depth=5))
    h = handlers.Handler(phone_home, log, tinkerbell, host_state_dir, tmpdir)
    h.run_osie = MagicMock()
    return h