예제 #1
0
 def get_vcenter_connection(self, hostname, username, password):
     vc = dynamic_map()
     vc.hostname = hostname
     vc.username = username
     vc.password = password
     from stackone.core.platforms.vmw.ESXiProxy import vCenterConnectionCache
     return vCenterConnectionCache.get_connection(vc)
예제 #2
0
파일: Groups.py 프로젝트: smarkm/ovm
 def get_allocation_candidate(self, auth, dom, node=None, exclude_ids=[]):
     ex_ids = [id for id in exclude_ids]
     policy_ctx = dynamic_map()
     policy_ctx.dom = dom
     policy_ctx.exclude_ids = ex_ids
     if node is not None:
         policy_ctx.node_id = node.id
     new_node = self.getDomAllocationCandidate(auth, policy_ctx)
     return new_node
예제 #3
0
파일: VMWNode.py 프로젝트: smarkm/ovm
 def get_external_manager(self):
     if self.external_manager_id:
         vcenter = DBSession.query(VCenter).filter(VCenter.id == self.external_manager_id).first()
         if vcenter:
             credential = vcenter.credential
             vc_cred = dynamic_map()
             vc_cred.hostname = vcenter.host
             vc_cred.username = credential.cred_details['username']
             vc_cred.password = credential.cred_details['password']
             return vc_cred
예제 #4
0
파일: Maintenance.py 프로젝트: smarkm/ovm
 def find_standby_node(self, auth, dom, node=None, grp=None, exclude_ids=[]):
     LOGGER.debug('In find_standby_node: \ndom, node, grp, exclude_ids\n%s, %s, %s, %s' % (dom, node, grp, exclude_ids))
     group = self.get_group(dom, node, grp)
     policy_ctx = dynamic_map()
     policy_ctx.dom = dom
     policy_ctx.exclude_ids = exclude_ids
     if node is not None:
         policy_ctx.node_id = node.id
     new_node = group.getStandByNode(auth, policy_ctx)
     return new_node
예제 #5
0
파일: Maintenance.py 프로젝트: smarkm/ovm
    def get_allocation_candidate(self, auth, dom, node=None, grp=None, exclude_ids=[]):
        LOGGER.debug('In get_allocation_candidate: \ndom, node, grp, exclude_ids\n%s, %s, %s, %s' % (dom, node, grp, exclude_ids))

        ex_ids = [ ids for ids in exclude_ids]
        group = self.get_group(dom,node,grp)
        policy_ctx = dynamic_map()
        policy_ctx.dom = dom
        policy_ctx.exclude_ids = ex_ids
        if node is not None:
            policy_ctx.node_id = node.id
        new_node = group.getDomAllocationCandidate(auth,policy_ctx)
        return new_node
예제 #6
0
파일: VMWVMM.py 프로젝트: smarkm/ovm
 def _to_vmInfo(self, vm_mo):
     vm_info = dynamic_map()
     try:
         config = vm_mo.config
         vm_info.name = config.name
         vm_info.id = config.name
         vm_info.uuid = config.instanceUuid
         vm_info.memory = config.hardware.memoryMB
         vm_info.vcpus = config.hardware.numCPU
         vm_info.config_filename = config.files.vmPathName
         vm_info.external_id = vm_mo._mo_ref.value
         vm_info.platform = 'vmw'
         vm_info.state = vm_mo.runtime.powerState
         vm_info.overall_cpu_usage = 0
         vm_info.guest_memory_usage = 0
     except Exception as ex:
         msg = 'ERROR:===_to_vmInfo===VMName:%s' % vm_mo.name
         print msg
         raise ex
     return vm_info
예제 #7
0
파일: ESXiProxy.py 프로젝트: smarkm/ovm
 def get_config(self, mob):
     print '\n\n\n-------vvvvv---------\n\n\n'
     vm_info = dynamic_map()
     config = mob.config
     vm_info.name = config.name
     vm_info.mob_name = config.name
     vm_info.uuid = config.instanceUuid
     vm_info.memory = config.hardware.memoryMB
     vm_info.vcpus = config.hardware.numCPU
     vm_info.config_filename = config.files.vmPathName
     vm_info.external_id = mob._mo_ref.value
     vm_info.platform = 'vmw'
     vm_info.on_reboot = config.defaultPowerOps.resetType
     vm_info.on_shutdown = config.defaultPowerOps.powerOffType
     vm_info.on_crash = config.defaultPowerOps.resetType
     devices = config.hardware.device
     vm_info.datacenter = None
     dc_mob = self.get_config_datacenter(mob)
     if dc_mob:
         vm_info.datacenter = dc_mob.name
     vm_info.vmfolder = None
     vmfolder_mob = self.get_config_vmfolder(dc_mob)
     if vmfolder_mob:
         vm_info.vmfolder = vmfolder_mob.name
     vm_info.host = None
     host_mob = self.get_hs()
     if host_mob:
         vm_info.host = host_mob.name
         
     vm_info.disk = [str(disk) for disk in self.get_config_disks(mob)]
     nw_devices =[n for n in devices if str(n.__class__.__name__) in ('VirtualE1000', 'VirtualVmxnet2', 'VirtualVmxnet3')]
     vifs = []
     for k,n in enumerate(nw_devices):
         vif = 'mac=%s,bridge=%s' %(n.macAddress,n.backing.deviceName)
         vifs.append(vif)
     vm_info.vif = vifs
     vm_info.os_name = config.guestFullName
     vm_info.guestId = config.guestId
     vm_info.os_version = config.version
     return vm_info
예제 #8
0
    def refresh(self, id, pid_filename=None):
        pid = id
        pid_string = to_str(pid)
        cmd_line_file = os.path.join('/proc',pid_string,'cmdline')
        
        if pid_filename is not None:
            if self.node_proxy.file_exists(cmd_line_file)==False:                
                self.node_proxy.remove(pid_filename)
                return None

        cmd = None
        cmd = self._get_file_content(cmd_line_file, 2048)

        if cmd is None or cmd.strip() == '':
            return None

        if cmd.split(chr(0),1)[0].endswith("qemu"):
            type = "qemu"
        elif cmd.find("kvm") > -1 or cmd.find("qemu-system-x86") > -1:
            #later look at fds and see if /dev/kvm used
            type = "kvm"
        else:
            return None

        info = dynamic_map()
        info.type = type
        info.cmdline= cmd.strip().replace(chr(0), " ")
        info.pid = to_str(pid)
        info.domid = to_str(pid)
        self.populate_info_from_cmdline(info, cmd)
        if info.name is None:
            info.name = info.pid
        info.id = info.name # will need to change once the client changes
                                  # to use proper id

        return info