def attach_remote_media(self, url, user, password): proto, host, path = util.urlsplit(url) if proto == 'smb': proto = 'cifs' rq = {'Option': '', 'Domain': '', 'Write': 0} # nfs == 1, cifs == 0 if proto == 'nfs': rq['Protocol'] = 1 rq['Url'] = '{0}:{1}'.format(host, path) elif proto == 'cifs': rq['Protocol'] = 0 rq['Credential'] = '{0}:{1}'.format(user, password) rq['Url'] = '//{0}{1}'.format(host, path) elif proto in ('http', 'https'): rq['Protocol'] = 7 rq['Url'] = url else: raise Exception('TODO') rt = self.wc.grab_json_response('/api/providers/rp_vm_remote_connect', json.dumps(rq)) if 'return' not in rt or rt['return'] != 0: raise Exception('Unhandled return: ' + repr(rt)) rt = self.wc.grab_json_response('/api/providers/rp_vm_remote_mountall', '{}') if 'return' not in rt or rt['return'] != 0: raise Exception('Unhandled return: ' + repr(rt))
def attach_remote_media(self, url, username, password): if self.has_megarac: proto, host, path = util.urlsplit(url) if proto == 'smb': proto = 'cifs' domain = None path, imagename = path.rsplit('/', 1) if username is not None and '@' in username: username, domain = username.split('@', 1) elif username is not None and '\\' in username: domain, username = username.split('\\', 1) try: self._megarac_attach_media(proto, username, password, imagename, domain, path, host) except pygexc.IpmiException as ie: if ie.ipmicode in (0x92, 0x99): # if starting from scratch, this can happen... self._megarac_attach_media(proto, username, password, imagename, domain, path, host) else: raise