Changeset b4b19c7 for fedd/federation/proxy_emulab_segment.py
- Timestamp:
- Apr 21, 2010 5:31:03 AM (14 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
- Children:
- f7a54c6
- Parents:
- f54e8e4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/proxy_emulab_segment.py
rf54e8e4 rb4b19c7 25 25 $ns run 26 26 """ 27 self.node = { } 27 28 28 29 def get_state(self, user, host, pid, eid): … … 78 79 79 80 81 def get_mapping(self, pid, eid): 82 # command to test experiment state 83 expinfo_exec = "/usr/testbed/bin/expinfo" 84 # The expinfo ssh command. Note the identity restriction to use 85 # only the identity provided in the pubkey given. 86 cmd = [self.ssh_exec, '-o', 'IdentitiesOnly yes', '-o', 87 'StrictHostKeyChecking no', '-i', 88 self.ssh_privkey_file, "%s@%s" % (user, host), 89 expinfo_exec, '-m', pid, eid] 90 91 dev_null = None 92 try: 93 dev_null = open("/dev/null", "a") 94 except IOError, e: 95 self.log.error("[get_state]: can't open /dev/null: %s" %e) 96 97 if self.debug: 98 rv = 0 99 else: 100 self.log.debug("Getting mapping for %s %s" % (pid, eid)) 101 phys_start = re.compile('^Physical\s+Node\s+Mapping') 102 phys_line = re.compile('(\S+)\s+\S+\s+\S+\s+(.*)') 103 phys_end = re.compile('^$') 104 status = subprocess.Popen(cmd, stdout=subprocess.PIPE, 105 stderr=dev_null, close_fds=True) 106 107 # Parse the info output. Format: 108 # 109 # stuff 110 # Physical Node Mapping: 111 # ID Type OS Physical 112 # --------------- ------------ --------------- ------------ 113 # virtual dummy dummy physical 114 # 115 foundit = False 116 skip = 0 117 for line in status.stdout: 118 if phys_start.match(line): 119 skip = 2 120 foundit = True 121 elif not foundit: 122 continue 123 elif skip > 0: 124 skip -= 1 125 elif phys_end.match(line): 126 break 127 else: 128 m = phys_line.match(line.strip()) 129 if m: self.node[m.group(1)] = m.group(2) 130 else: self.log.warn( 131 "Matching failed while parsing node mapping") 132 rv = status.wait() 133 134 # If the experiment is not present the subcommand returns a 135 # non-zero return value. If we successfully parsed a "none" 136 # outcome, ignore the return code. 137 if rv != 0 : 138 raise service_error(service_error.internal, 139 "Cannot get node mapping of segment:%s/%s" % (pid, eid)) 140 else: 141 return True 142 143 80 144 def __call__(self, parent, eid, pid, user, tclfile, tmpdir, timeout=0): 81 145 """
Note: See TracChangeset
for help on using the changeset viewer.