Ejemplo n.º 1
0
    def __init__(self, module):
        super(VMwareDvSwitchInfoManager, self).__init__(module)
        self.folder = self.params['folder']
        self.switch_name = self.params['switch_name']

        folder_obj = None
        if self.folder:
            folder_obj = self.content.searchIndex.FindByInventoryPath(
                self.folder)
            if not folder_obj:
                self.module.fail_json(
                    msg="Failed to find folder specified by %s" % self.folder)

        if self.switch_name:
            self.switch_objs = [
                find_object_by_name(self.content, self.switch_name,
                                    vim.DistributedVirtualSwitch, folder_obj)
            ]
            if None in self.switch_objs:
                self.switch_objs = None
        else:
            self.switch_objs = find_obj(self.content,
                                        [vim.DistributedVirtualSwitch],
                                        '',
                                        first=False)
Ejemplo n.º 2
0
    def __init__(self, module):
        super(VMwareResourcePool, self).__init__(module)
        self.datacenter = module.params['datacenter']
        self.resource_pool = module.params['resource_pool']
        self.hostname = module.params['hostname']
        self.username = module.params['username']
        self.password = module.params['password']
        self.state = module.params['state']
        self.mem_shares = module.params['mem_shares']
        self.mem_allocation_shares = module.params['mem_allocation_shares']
        self.mem_limit = module.params['mem_limit']
        self.mem_reservation = module.params['mem_reservation']
        self.mem_expandable_reservations = module.params[
            'mem_expandable_reservations']
        self.cpu_shares = module.params['cpu_shares']
        self.cpu_allocation_shares = module.params['cpu_allocation_shares']
        self.cpu_limit = module.params['cpu_limit']
        self.cpu_reservation = module.params['cpu_reservation']
        self.cpu_expandable_reservations = module.params[
            'cpu_expandable_reservations']
        self.resource_pool_obj = None

        self.dc_obj = find_datacenter_by_name(self.content, self.datacenter)
        if self.dc_obj is None:
            self.module.fail_json(msg="Unable to find datacenter with name %s" % self.datacenter)

        if module.params['cluster']:
            self.compute_resource_obj = find_cluster_by_name(self.content, module.params['cluster'], datacenter=self.dc_obj)
            if self.compute_resource_obj is None:
                self.module.fail_json(msg="Unable to find cluster with name %s" % module.params['cluster'])

        if module.params['esxi_hostname']:
            self.compute_resource_obj = find_object_by_name(self.content, module.params['esxi_hostname'], [vim.ComputeResource], folder=self.dc_obj.hostFolder)
            if self.compute_resource_obj is None:
                self.module.fail_json(msg="Unable to find host with name %s" % module.params['esxi_hostname'])
 def get_dist_switch_by_name(self, switch_name):
     switch_objs = find_object_by_name(self.content, switch_name,
                                       vim.DistributedVirtualSwitch, None)
     if switch_objs:
         return switch_objs.uuid
     else:
         self.module.fail_json(
             msg="Distributed Switch with name [%s] not found" %
             switch_name)