def __init__(self, input_json): self.input_json = input_json vc = self.input_json.get('vcenter_configuration') self.si = VMwareUtils.get_vcenter_session(vc['ip_address'], vc['port'], vc['username'], vc['password']) self.content = self.si.RetrieveContent() self.dc = VMwareUtils.get_data_center(self.content, vc['datacenter']) self.vc = vc
def move_host_back_to_cluster(inputs): host_name = inputs.get('host_name') err = inputs.get('status') == constants.HOST_COMM_FAILURE si = VMwareUtils.get_vcenter_session(inputs['vcenter_host'], inputs['vcenter_https_port'], inputs['vcenter_username'], inputs['vcenter_password']) host_view = VMwareUtils.get_view_ref(si.content, si.content.rootFolder, [vim.HostSystem]) host_prop = ['name', 'vm'] host_refs = VMwareUtils.collect_properties(si.content, host_view, vim.HostSystem, host_prop, True) host = None for host_ref in host_refs: if host_ref['name'] == host_name: host = host_ref break if not host: raise OVSvAppException( "Couldn't find the commissioned host '{}'".format(host_name)) datacenter = OVSvAppUtil.get_host_parent(host['obj'], vim.Datacenter) prep_folder = OVSvAppUtil.get_host_parent(host['obj'], vim.Folder) if prep_folder.name != 'host': cluster_id = prep_folder.name cluster = VMwareUtils.get_cluster(si.content, datacenter.hostFolder, cluster_id) if not cluster: raise OVSvAppException( _("Couldn't find the Cluster from the prep " "folder name !")) OVSvAppUtil.move_host_back_to_cluster(si, host, cluster, prep_folder, err) if not err: vm_obj = get_ovsvapp_from_host(host) OVSvAppUtil.disable_ha_on_ovsvapp(si, vm_obj, cluster, host)