Exemple #1
0
    def resources(self):
        """
        Resource usage information

        """
        self.dialog.infobox(title=self.title,
                            text='Retrieving information ...')

        elements = [
            pvc.widget.form.FormElement(
                label='CPU Usage',
                item='{} MHz'.format(
                    self.obj.summary.quickStats.overallCpuUsage)),
            pvc.widget.form.FormElement(
                label='Memory Usage',
                item='{} MB'.format(
                    self.obj.summary.quickStats.overallMemoryUsage)),
            pvc.widget.form.FormElement(
                label='CPU Fairness',
                item='{} MHz'.format(
                    self.obj.summary.quickStats.distributedCpuFairness)),
            pvc.widget.form.FormElement(
                label='Memory Fairness',
                item='{} MB'.format(
                    self.obj.summary.quickStats.distributedMemoryFairness)),
        ]

        form = pvc.widget.form.Form(dialog=self.dialog,
                                    form_elements=elements,
                                    title=self.title,
                                    text='Host resource usage information')

        form.display()
Exemple #2
0
    def info(self):
        """
        Display info about a service

        """
        elements = [
            pvc.widget.form.FormElement(label='Service',
                                        item=self.service.key),
            pvc.widget.form.FormElement(label='Description',
                                        item=self.service.label),
            pvc.widget.form.FormElement(label='Running',
                                        item=str(self.service.running)),
            pvc.widget.form.FormElement(label='Policy',
                                        item=self.service.policy),
            pvc.widget.form.FormElement(label='Required',
                                        item=str(self.service.required)),
            pvc.widget.form.FormElement(label='Uninstallable',
                                        item=str(self.service.uninstallable)),
        ]

        form = pvc.widget.form.Form(dialog=self.dialog,
                                    form_elements=elements,
                                    title=self.title,
                                    text='Service information')

        form.display()
Exemple #3
0
    def summary(self):
        """
        General information about the network

        """
        self.dialog.infobox(
            title=self.title,
            text='Retrieving information ...'
        )

        elements = [
            pvc.widget.form.FormElement(
                label='Name',
                item=self.obj.name
            ),
            pvc.widget.form.FormElement(
                label='Accessible',
                item=str(self.obj.summary.accessible)
            ),
            pvc.widget.form.FormElement(
                label='IP Pool',
                item=self.obj.summary.ipPoolName
            ),
        ]

        form = pvc.widget.form.Form(
            dialog=self.dialog,
            form_elements=elements,
            title=self.title,
            text='Network summary information'
        )

        form.display()
    def summary(self):
        """
        Performance provider summary information

        """
        self.dialog.infobox(title=self.title,
                            text='Retrieving information ...')

        provider_summary = self.pm.QueryPerfProviderSummary(entity=self.obj)

        elements = [
            pvc.widget.form.FormElement(
                label='Real-time statistics support',
                item=str(provider_summary.currentSupported)),
            pvc.widget.form.FormElement(
                label='Historical statistics support',
                item=str(provider_summary.summarySupported)),
            pvc.widget.form.FormElement(label='Refresh rate (seconds)',
                                        item=str(provider_summary.refreshRate))
        ]

        form = pvc.widget.form.Form(
            dialog=self.dialog,
            form_elements=elements,
            title=self.title,
            text='Performance provider summary information')

        form.display()
Exemple #5
0
    def info(self):
        """
        Datastore general information

        """
        self.dialog.infobox(title=self.title,
                            text='Retrieving information ...')

        elements = [
            pvc.widget.form.FormElement(
                label='Name',
                item=self.obj.name,
            ),
            pvc.widget.form.FormElement(label='Location',
                                        item=self.obj.summary.url),
            pvc.widget.form.FormElement(label='Type',
                                        item=self.obj.summary.type),
            pvc.widget.form.FormElement(label='Accessible',
                                        item=str(self.obj.summary.accessible)),
            pvc.widget.form.FormElement(label='Maintenance Mode',
                                        item=self.obj.summary.maintenanceMode),
            pvc.widget.form.FormElement(
                label='Multiple Host Access',
                item=str(self.obj.summary.multipleHostAccess)),
        ]

        form = pvc.widget.form.Form(dialog=self.dialog,
                                    form_elements=elements,
                                    title=self.title,
                                    text='Datastore general information')

        form.display()
Exemple #6
0
    def info(self):
        """
        General information

        """
        self.dialog.infobox(
            title=self.title,
            text='Retrieving information ...'
        )

        elements = [
            pvc.widget.form.FormElement(
                label='State',
                item=self.obj.runtime.connectionState
            ),
            pvc.widget.form.FormElement(
                label='Type',
                item=self.obj.config.product.fullName,
            ),
            pvc.widget.form.FormElement(
                label='Vendor',
                item=self.obj.hardware.systemInfo.vendor
            ),
            pvc.widget.form.FormElement(
                label='Model',
                item=self.obj.hardware.systemInfo.model
            ),
            pvc.widget.form.FormElement(
                label='Memory Size',
                item=humanize.naturalsize(self.obj.hardware.memorySize, binary=True)
            ),
            pvc.widget.form.FormElement(
                label='CPU Packages',
                item=str(self.obj.hardware.cpuInfo.numCpuPackages)
            ),
            pvc.widget.form.FormElement(
                label='CPU Cores',
                item=str(self.obj.hardware.cpuInfo.numCpuCores)
            ),
            pvc.widget.form.FormElement(
                label='CPU Threads',
                item=str(self.obj.hardware.cpuInfo.numCpuThreads)
            ),
            pvc.widget.form.FormElement(
                label='Uptime',
                item=str(datetime.timedelta(seconds=self.obj.summary.quickStats.uptime))
            ),
        ]

        form = pvc.widget.form.Form(
            dialog=self.dialog,
            form_elements=elements,
            title=self.title,
            text='Host general information'
        )

        form.display()
Exemple #7
0
    def summary(self):
        """
        Cluster general information

        """
        self.dialog.infobox(
            title=self.title,
            text='Retrieving information ...'
        )

        elements = [
            pvc.widget.form.FormElement(
                label='Hosts',
                item=str(self.obj.summary.numHosts)
            ),
            pvc.widget.form.FormElement(
                label='DRS Enabled',
                item=str(self.obj.configuration.drsConfig.enabled)
            ),
            pvc.widget.form.FormElement(
                label='DRS Mode',
                item=self.obj.configuration.drsConfig.defaultVmBehavior
            ),
            pvc.widget.form.FormElement(
                label='vMotion Migrations',
                item=str(self.obj.summary.numVmotions)
            ),
            pvc.widget.form.FormElement(
                label='Total CPU Cores',
                item=str(self.obj.summary.numCpuCores)
            ),
            pvc.widget.form.FormElement(
                label='Total CPU Threads',
                item=str(self.obj.summary.numCpuThreads)
            ),
            pvc.widget.form.FormElement(
                label='Total CPU Resources',
                item='{} MHz'.format(self.obj.summary.totalCpu)
            ),
            pvc.widget.form.FormElement(
                label='Total Memory',
                item=humanize.naturalsize(self.obj.summary.totalMemory, binary=True)
            ),
            pvc.widget.form.FormElement(
                label='Overall Status',
                item=self.obj.overallStatus
            ),
        ]

        form = pvc.widget.form.Form(
            dialog=self.dialog,
            form_elements=elements,
            title=self.title,
            text='Cluster general information'
        )

        form.display()
Exemple #8
0
    def info(self):
        """
        Display information about a counter

        """
        self.dialog.infobox(
            title=self.title,
            text='Retrieving information ...'
        )

        counter_name = '{0}.{1}.{2}'.format(
            self.counter.groupInfo.key,
            self.counter.nameInfo.key,
            self.counter.unitInfo.key
        )
        intervals = [i.name for i in self.pm.historicalInterval if self.counter.level == i.level]

        elements = [
            pvc.widget.form.FormElement(
                label='Key',
                item=str(self.counter.key)
            ),
            pvc.widget.form.FormElement(
                label='Counter',
                item=counter_name
            ),
            pvc.widget.form.FormElement(
                label='Label',
                item=self.counter.nameInfo.label
            ),
            pvc.widget.form.FormElement(
                label='Description',
                item=self.counter.nameInfo.summary
            ),
            pvc.widget.form.FormElement(
                label='Group',
                item=self.counter.groupInfo.label
            ),
            pvc.widget.form.FormElement(
                label='Unit',
                item=self.counter.unitInfo.label
            ),
            pvc.widget.form.FormElement(
                label='Intervals',
                item=', '.join(intervals)
            ),
        ]

        form = pvc.widget.form.Form(
            dialog=self.dialog,
            form_elements=elements,
            title=self.title,
            text='Performance counter information'
        )

        form.display()
Exemple #9
0
    def details(self):
        self.dialog.infobox(
            text='Retrieving information ...'
        )

        elements = [
            pvc.widget.form.FormElement(
                label='Username',
                item=self.obj.userName
            ),
            pvc.widget.form.FormElement(
                label='Full Name',
                item=self.obj.fullName
            ),
            pvc.widget.form.FormElement(
                label='Login Time',
                item=str(self.obj.loginTime)
            ),
            pvc.widget.form.FormElement(
                label='Last Active',
                item=str(self.obj.lastActiveTime)
            ),
            pvc.widget.form.FormElement(
                label='Idle',
                item=str(self.agent.si.CurrentTime() - self.obj.lastActiveTime)
            ),
            pvc.widget.form.FormElement(
                label='IP Address',
                item=self.obj.ipAddress
            ),
            pvc.widget.form.FormElement(
                label='User Agent',
                item=self.obj.userAgent
            ),
            pvc.widget.form.FormElement(
                label='API Invocations',
                item=str(self.obj.callCount)
            ),
        ]

        current_session = self.agent.si.content.sessionManager.currentSession
        if current_session.key == self.obj.key:
            title = 'Session {}@{} (This Session)'
        else:
            title = 'Session {}@{}'

        form = pvc.widget.form.Form(
            dialog=self.dialog,
            form_elements=elements,
            title=title.format(self.obj.userName, self.obj.ipAddress),
            text='Session details'
        )

        form.display()
Exemple #10
0
    def capacity(self):
        """
        Datastore Capacity Information

        """
        self.dialog.infobox(title=self.title,
                            text='Retrieving information ...')

        uncommitted = self.obj.summary.uncommitted if self.obj.summary.uncommitted else 0
        elements = [
            pvc.widget.form.FormElement(label='Capacity',
                                        item=humanize.naturalsize(
                                            self.obj.summary.capacity,
                                            binary=True)),
            pvc.widget.form.FormElement(label='Free Space',
                                        item=humanize.naturalsize(
                                            self.obj.summary.freeSpace,
                                            binary=True)),
            pvc.widget.form.FormElement(label='Uncommitted Space',
                                        item=humanize.naturalsize(
                                            uncommitted, binary=True)),
        ]

        form = pvc.widget.form.Form(dialog=self.dialog,
                                    form_elements=elements,
                                    title=self.title,
                                    text='Datastore capacity information')

        return form.display()
Exemple #11
0
    def capacity(self):
        """
        Datastore Capacity Information

        """
        self.dialog.infobox(
            title=self.title,
            text='Retrieving information ...'
        )

        uncommitted = self.obj.summary.uncommitted if self.obj.summary.uncommitted else 0
        elements = [
            pvc.widget.form.FormElement(
                label='Capacity',
                item=humanize.naturalsize(self.obj.summary.capacity, binary=True)
            ),
            pvc.widget.form.FormElement(
                label='Free Space',
                item=humanize.naturalsize(self.obj.summary.freeSpace, binary=True)
            ),
            pvc.widget.form.FormElement(
                label='Uncommitted Space',
                item=humanize.naturalsize(uncommitted, binary=True)
            ),
        ]

        form = pvc.widget.form.Form(
            dialog=self.dialog,
            form_elements=elements,
            title=self.title,
            text='Datastore capacity information'
        )

        return form.display()
Exemple #12
0
    def get_vm_specs(self):
        """
        Get Virtual Machine specs

        """
        elements = [
            pvc.widget.form.FormElement(label='Name'),
            pvc.widget.form.FormElement(label='vCPU(s)'),
            pvc.widget.form.FormElement(label='Memory Size (MB)'),
        ]

        form = pvc.widget.form.Form(
            dialog=self.dialog,
            form_elements=elements,
            title='Create New Virtual Machine',
            text='Virtual Machine details'
        )

        code, fields = form.display()

        if code in (self.dialog.CANCEL, self.dialog.ESC):
            return

        if not all(fields.values()):
            self.dialog.msgbox(
                title='Create New Virtual Machine',
                text='Invalid input provided'
            )
            return

        return fields
Exemple #13
0
    def details(self):
        self.dialog.infobox(title=self.title,
                            text='Retrieving information ...')

        elements = [
            pvc.widget.form.FormElement(label='Entity',
                                        item=self.obj.entity.name),
            pvc.widget.form.FormElement(label='Status',
                                        item=self.obj.overallStatus),
            pvc.widget.form.FormElement(label='Name',
                                        item=self.obj.alarm.info.name),
            pvc.widget.form.FormElement(label='Triggered',
                                        item=str(self.obj.time)),
            pvc.widget.form.FormElement(label='Acknowledged',
                                        item=str(self.obj.acknowledged)),
            pvc.widget.form.FormElement(label='Acknowledged At',
                                        item=str(self.obj.acknowledgedTime)
                                        if self.obj.acknowledgedTime else ''),
            pvc.widget.form.FormElement(label='Acknowledged By',
                                        item=self.obj.acknowledgedByUser
                                        if self.obj.acknowledgedByUser else '')
        ]

        form = pvc.widget.form.Form(dialog=self.dialog,
                                    form_elements=elements,
                                    title=self.title,
                                    text='Alarm details')

        return form.display()
Exemple #14
0
    def info(self):
        """
        General information

        """
        self.dialog.infobox(title=self.title,
                            text='Retrieving information ...')

        elements = [
            pvc.widget.form.FormElement(label='State',
                                        item=self.obj.runtime.connectionState),
            pvc.widget.form.FormElement(
                label='Type',
                item=self.obj.config.product.fullName,
            ),
            pvc.widget.form.FormElement(
                label='Vendor', item=self.obj.hardware.systemInfo.vendor),
            pvc.widget.form.FormElement(
                label='Model', item=self.obj.hardware.systemInfo.model),
            pvc.widget.form.FormElement(label='Memory Size',
                                        item=humanize.naturalsize(
                                            self.obj.hardware.memorySize,
                                            binary=True)),
            pvc.widget.form.FormElement(
                label='CPU Packages',
                item=str(self.obj.hardware.cpuInfo.numCpuPackages)),
            pvc.widget.form.FormElement(
                label='CPU Cores',
                item=str(self.obj.hardware.cpuInfo.numCpuCores)),
            pvc.widget.form.FormElement(
                label='CPU Threads',
                item=str(self.obj.hardware.cpuInfo.numCpuThreads)),
            pvc.widget.form.FormElement(
                label='Uptime',
                item=str(
                    datetime.timedelta(
                        seconds=self.obj.summary.quickStats.uptime))),
        ]

        form = pvc.widget.form.Form(dialog=self.dialog,
                                    form_elements=elements,
                                    title=self.title,
                                    text='Host general information')

        form.display()
Exemple #15
0
    def info(self):
        """
        Datastore general information

        """
        self.dialog.infobox(
            title=self.title,
            text='Retrieving information ...'
        )

        elements = [
            pvc.widget.form.FormElement(
                label='Name',
                item=self.obj.name,
            ),
            pvc.widget.form.FormElement(
                label='Location',
                item=self.obj.summary.url
            ),
            pvc.widget.form.FormElement(
                label='Type',
                item=self.obj.summary.type
            ),
            pvc.widget.form.FormElement(
                label='Accessible',
                item=str(self.obj.summary.accessible)
            ),
            pvc.widget.form.FormElement(
                label='Maintenance Mode',
                item=self.obj.summary.maintenanceMode
            ),
            pvc.widget.form.FormElement(
                label='Multiple Host Access',
                item=str(self.obj.summary.multipleHostAccess)
            ),
        ]

        form = pvc.widget.form.Form(
            dialog=self.dialog,
            form_elements=elements,
            title=self.title,
            text='Datastore general information'
        )

        form.display()
Exemple #16
0
    def connect_host(self):
        """
        Connect a host to the cluster and add it to the inventory

        """
        text = (
            'Enter hostname or IP address of the '
            'host to be connected to cluster {}\n'
        )

        elements = [
            pvc.widget.form.FormElement(label='Hostname'),
            pvc.widget.form.FormElement(label='SSL Thumbprint'),
            pvc.widget.form.FormElement(label='Username'),
            pvc.widget.form.FormElement(label='Password', attributes=0x1),
        ]

        form = pvc.widget.form.Form(
            dialog=self.dialog,
            form_elements=elements,
            mixed_form=True,
            title=self.title,
            text=text.format(self.obj.name)
        )

        code, fields = form.display()

        if code in (self.dialog.CANCEL, self.dialog.ESC):
            return

        if not all(fields.values()):
            self.dialog.msgbox(
                title=self.title,
                text='Invalid input provided'
            )
            return

        connect_spec = pyVmomi.vim.HostConnectSpec(
            hostName=fields['Hostname'],
            sslThumbprint=fields['SSL Thumbprint'],
            userName=fields['Username'],
            password=fields['Password']
        )

        task = self.obj.AddHost(
            spec=connect_spec,
            asConnected=True
        )

        gauge = pvc.widget.gauge.TaskGauge(
            dialog=self.dialog,
            task=task,
            title=self.title,
            text='Connecting {} to cluster ...'.format(fields['Hostname'])
        )

        gauge.display()
Exemple #17
0
    def display(self):
        elements = [
            pvc.widget.form.FormElement(label='Server'),
            pvc.widget.form.FormElement(label='Path', item='/vol0/datastore'),
            pvc.widget.form.FormElement(label='Read-Only', item='False'),
            pvc.widget.form.FormElement(label='Datastore Name'),
        ]

        form = pvc.widget.form.Form(
            dialog=self.dialog,
            form_elements=elements,
            title=self.title,
            text='Provide details of the remote NFS volume'
        )

        code, fields = form.display()

        if code in (self.dialog.CANCEL, self.dialog.ESC):
            return

        if not all(fields.values()):
            self.dialog.msgbox(
                title=self.title,
                text='Error, invalid input provided'
            )
            return

        if fields['Read-Only'].lower() in ('yes', 'true'):
            access_mode = pyVmomi.vim.HostMountMode.readOnly
        else:
            access_mode = pyVmomi.vim.HostMountMode.readWrite

        self.dialog.infobox(
            title=self.title,
            text='Creating datastore {} ...'.format(fields['Datastore Name'])
        )

        spec = pyVmomi.vim.HostNasVolumeSpec(
            accessMode=access_mode,
            localPath=fields['Datastore Name'],
            remoteHost=fields['Server'],
            remotePath=fields['Path']
        )

        try:
            self.obj.configManager.datastoreSystem.CreateNasDatastore(
                spec=spec
            )
        except pyVmomi.vim.MethodFault as e:
            self.dialog.msgbox(
                title=self.title,
                text=e.msg
            )
Exemple #18
0
    def info(self):
        """
        Datastore general information

        """
        self.dialog.infobox(title=self.title, text="Retrieving information ...")

        elements = [
            pvc.widget.form.FormElement(label="Name", item=self.obj.name),
            pvc.widget.form.FormElement(label="Location", item=self.obj.summary.url),
            pvc.widget.form.FormElement(label="Type", item=self.obj.summary.type),
            pvc.widget.form.FormElement(label="Accessible", item=str(self.obj.summary.accessible)),
            pvc.widget.form.FormElement(label="Maintenance Mode", item=self.obj.summary.maintenanceMode),
            pvc.widget.form.FormElement(label="Multiple Host Access", item=str(self.obj.summary.multipleHostAccess)),
        ]

        form = pvc.widget.form.Form(
            dialog=self.dialog, form_elements=elements, title=self.title, text="Datastore general information"
        )

        form.display()
Exemple #19
0
    def info(self):
        """
        Display info about a service

        """
        elements = [
            pvc.widget.form.FormElement(
                label='Service',
                item=self.service.key
            ),
            pvc.widget.form.FormElement(
                label='Description',
                item=self.service.label
            ),
            pvc.widget.form.FormElement(
                label='Running',
                item=str(self.service.running)
            ),
            pvc.widget.form.FormElement(
                label='Policy',
                item=self.service.policy
            ),
            pvc.widget.form.FormElement(
                label='Required',
                item=str(self.service.required)
            ),
            pvc.widget.form.FormElement(
                label='Uninstallable',
                item=str(self.service.uninstallable)
            ),
        ]

        form = pvc.widget.form.Form(
            dialog=self.dialog,
            form_elements=elements,
            title=self.title,
            text='Service information'
        )

        form.display()
Exemple #20
0
    def summary(self):
        """
        General information about the network

        """
        self.dialog.infobox(title=self.title,
                            text='Retrieving information ...')

        elements = [
            pvc.widget.form.FormElement(label='Name', item=self.obj.name),
            pvc.widget.form.FormElement(label='Accessible',
                                        item=str(self.obj.summary.accessible)),
            pvc.widget.form.FormElement(label='IP Pool',
                                        item=self.obj.summary.ipPoolName),
        ]

        form = pvc.widget.form.Form(dialog=self.dialog,
                                    form_elements=elements,
                                    title=self.title,
                                    text='Network summary information')

        form.display()
    def info(self):
        """
        Display information about a counter

        """
        self.dialog.infobox(title=self.title,
                            text='Retrieving information ...')

        counter_name = '{0}.{1}.{2}'.format(self.counter.groupInfo.key,
                                            self.counter.nameInfo.key,
                                            self.counter.unitInfo.key)
        intervals = [
            i.name for i in self.pm.historicalInterval
            if self.counter.level == i.level
        ]

        elements = [
            pvc.widget.form.FormElement(label='Key',
                                        item=str(self.counter.key)),
            pvc.widget.form.FormElement(label='Counter', item=counter_name),
            pvc.widget.form.FormElement(label='Label',
                                        item=self.counter.nameInfo.label),
            pvc.widget.form.FormElement(label='Description',
                                        item=self.counter.nameInfo.summary),
            pvc.widget.form.FormElement(label='Group',
                                        item=self.counter.groupInfo.label),
            pvc.widget.form.FormElement(label='Unit',
                                        item=self.counter.unitInfo.label),
            pvc.widget.form.FormElement(label='Intervals',
                                        item=', '.join(intervals)),
        ]

        form = pvc.widget.form.Form(dialog=self.dialog,
                                    form_elements=elements,
                                    title=self.title,
                                    text='Performance counter information')

        form.display()
Exemple #22
0
    def summary(self):
        """
        Performance provider summary information

        """
        self.dialog.infobox(
            title=self.title,
            text='Retrieving information ...'
        )

        provider_summary = self.pm.QueryPerfProviderSummary(
            entity=self.obj
        )

        elements = [
            pvc.widget.form.FormElement(
                label='Real-time statistics support',
                item=str(provider_summary.currentSupported)
            ),
            pvc.widget.form.FormElement(
                label='Historical statistics support',
                item=str(provider_summary.summarySupported)
            ),
            pvc.widget.form.FormElement(
                label='Refresh rate (seconds)',
                item=str(provider_summary.refreshRate)
            )
        ]

        form = pvc.widget.form.Form(
            dialog=self.dialog,
            form_elements=elements,
            title=self.title,
            text='Performance provider summary information'
        )

        form.display()
Exemple #23
0
    def resources(self):
        """
        Resource usage information

        """
        self.dialog.infobox(
            title=self.title,
            text='Retrieving information ...'
        )

        elements = [
            pvc.widget.form.FormElement(
                label='CPU Usage',
                item='{} MHz'.format(self.obj.summary.quickStats.overallCpuUsage)
            ),
            pvc.widget.form.FormElement(
                label='Memory Usage',
                item='{} MB'.format(self.obj.summary.quickStats.overallMemoryUsage)
            ),
            pvc.widget.form.FormElement(
                label='CPU Fairness',
                item='{} MHz'.format(self.obj.summary.quickStats.distributedCpuFairness)
            ),
            pvc.widget.form.FormElement(
                label='Memory Fairness',
                item='{} MB'.format(self.obj.summary.quickStats.distributedMemoryFairness)
            ),
        ]

        form = pvc.widget.form.Form(
            dialog=self.dialog,
            form_elements=elements,
            title=self.title,
            text='Host resource usage information'
        )

        form.display()
Exemple #24
0
    def details(self):
        self.dialog.infobox(text='Retrieving information ...')

        elements = [
            pvc.widget.form.FormElement(label='Username',
                                        item=self.obj.userName),
            pvc.widget.form.FormElement(label='Full Name',
                                        item=self.obj.fullName),
            pvc.widget.form.FormElement(label='Login Time',
                                        item=str(self.obj.loginTime)),
            pvc.widget.form.FormElement(label='Last Active',
                                        item=str(self.obj.lastActiveTime)),
            pvc.widget.form.FormElement(label='Idle',
                                        item=str(self.agent.si.CurrentTime() -
                                                 self.obj.lastActiveTime)),
            pvc.widget.form.FormElement(label='IP Address',
                                        item=self.obj.ipAddress),
            pvc.widget.form.FormElement(label='User Agent',
                                        item=self.obj.userAgent),
            pvc.widget.form.FormElement(label='API Invocations',
                                        item=str(self.obj.callCount)),
        ]

        current_session = self.agent.si.content.sessionManager.currentSession
        if current_session.key == self.obj.key:
            title = 'Session {}@{} (This Session)'
        else:
            title = 'Session {}@{}'

        form = pvc.widget.form.Form(dialog=self.dialog,
                                    form_elements=elements,
                                    title=title.format(self.obj.userName,
                                                       self.obj.ipAddress),
                                    text='Session details')

        form.display()
Exemple #25
0
    def resources_info(self):
        """
        Resources usage information

        """
        self.dialog.infobox(
            title=self.title,
            text='Retrieving information ...'
        )

        provisioned_storage = self.obj.summary.storage.committed + \
            self.obj.summary.storage.uncommitted

        elements = [
            pvc.widget.form.FormElement(
                label='Consumed Host CPU',
                item='{} MHz'.format(self.obj.summary.quickStats.overallCpuUsage)
            ),
            pvc.widget.form.FormElement(
                label='Consumed Host Memory',
                item='{} MB'.format(self.obj.summary.quickStats.hostMemoryUsage)
            ),
            pvc.widget.form.FormElement(
                label='Active Guest Memory',
                item='{} MB'.format(self.obj.summary.quickStats.guestMemoryUsage)
            ),
            pvc.widget.form.FormElement(
                label='Provisioned Storage',
                item=humanize.naturalsize(provisioned_storage, binary=True)
            ),
            pvc.widget.form.FormElement(
                label='Non-shared Storage',
                item=humanize.naturalsize(self.obj.summary.storage.unshared, binary=True)
            ),
            pvc.widget.form.FormElement(
                label='Used Storage',
                item=humanize.naturalsize(self.obj.summary.storage.committed, binary=True)
            ),
        ]

        form = pvc.widget.form.Form(
            dialog=self.dialog,
            form_elements=elements,
            title=self.title,
            text='Virtual Machine resource usage'
        )

        return form.display()
Exemple #26
0
    def settings(self):
        """
        Manual configuration of the VNC settings

        """
        extra_config = self._get_extra_config_options()
        enabled = extra_config.get('RemoteDisplay.vnc.enabled', 'false')
        port = extra_config.get('RemoteDisplay.vnc.port', '')
        password = extra_config.get('RemoteDisplay.vnc.password', '')

        elements = [
            pvc.widget.form.FormElement(
                label='Enabled',
                item=enabled
            ),
            pvc.widget.form.FormElement(
                label='Port',
                item=port
            ),
            pvc.widget.form.FormElement(
                label='Password',
                item=password,
                input_length=8
            )
        ]

        form = pvc.widget.form.Form(
            dialog=self.dialog,
            form_elements=elements,
            title=self.title,
            text='VNC Configuration Options'
        )

        code, fields = form.display()
        if not all(fields.values()):
            self.dialog.msgbox(
                title=self.title,
                text='Invalid configuration settings'
            )
            return

        if code == self.dialog.OK:
            self._configure_vnc_options(
                enabled=fields['Enabled'],
                port=fields['Port'],
                password=fields['Password']
            )
Exemple #27
0
    def details(self):
        self.dialog.infobox(
            title=self.title,
            text='Retrieving information ...'
        )

        elements = [
            pvc.widget.form.FormElement(
                label='Entity',
                item=self.obj.entity.name
            ),
            pvc.widget.form.FormElement(
                label='Status',
                item=self.obj.overallStatus
            ),
            pvc.widget.form.FormElement(
                label='Name',
                item=self.obj.alarm.info.name
            ),
            pvc.widget.form.FormElement(
                label='Triggered',
                item=str(self.obj.time)
            ),
            pvc.widget.form.FormElement(
                label='Acknowledged',
                item=str(self.obj.acknowledged)
            ),
            pvc.widget.form.FormElement(
                label='Acknowledged At',
                item=str(self.obj.acknowledgedTime) if self.obj.acknowledgedTime else ''
            ),
            pvc.widget.form.FormElement(
                label='Acknowledged By',
                item=self.obj.acknowledgedByUser if self.obj.acknowledgedByUser else ''
            )
        ]

        form = pvc.widget.form.Form(
            dialog=self.dialog,
            form_elements=elements,
            title=self.title,
            text='Alarm details'
        )

        return form.display()
Exemple #28
0
    def display(self):
        elements = [
            pvc.widget.form.FormElement(label='Server'),
            pvc.widget.form.FormElement(label='Path', item='/vol0/datastore'),
            pvc.widget.form.FormElement(label='Read-Only', item='False'),
            pvc.widget.form.FormElement(label='Datastore Name'),
        ]

        form = pvc.widget.form.Form(
            dialog=self.dialog,
            form_elements=elements,
            title=self.title,
            text='Provide details of the remote NFS volume')

        code, fields = form.display()

        if code in (self.dialog.CANCEL, self.dialog.ESC):
            return

        if not all(fields.values()):
            self.dialog.msgbox(title=self.title,
                               text='Error, invalid input provided')
            return

        if fields['Read-Only'].lower() in ('yes', 'true'):
            access_mode = pyVmomi.vim.HostMountMode.readOnly
        else:
            access_mode = pyVmomi.vim.HostMountMode.readWrite

        self.dialog.infobox(title=self.title,
                            text='Creating datastore {} ...'.format(
                                fields['Datastore Name']))

        spec = pyVmomi.vim.HostNasVolumeSpec(
            accessMode=access_mode,
            localPath=fields['Datastore Name'],
            remoteHost=fields['Server'],
            remotePath=fields['Path'])

        try:
            self.obj.configManager.datastoreSystem.CreateNasDatastore(
                spec=spec)
        except pyVmomi.vim.MethodFault as e:
            self.dialog.msgbox(title=self.title, text=e.msg)
Exemple #29
0
    def general_info(self):
        """
        Virtual Machine general information

        """
        self.dialog.infobox(
            title=self.title,
            text='Retrieving information ...'
        )

        elements = [
            pvc.widget.form.FormElement(
                label='Guest OS',
                item=self.obj.config.guestFullName if self.obj.config.guestFullName else 'Unknown'
            ),
            pvc.widget.form.FormElement(
                label='VM Version',
                item=self.obj.config.version
            ),
            pvc.widget.form.FormElement(
                label='CPU',
                item='{} vCPU(s)'.format(self.obj.config.hardware.numCPU)
            ),
            pvc.widget.form.FormElement(
                label='Memory',
                item='{} MB'.format(self.obj.config.hardware.memoryMB)
            ),
            pvc.widget.form.FormElement(
                label='Memory Overhead',
                item='{} MB'.format(self.obj.summary.quickStats.consumedOverheadMemory)
            ),
            pvc.widget.form.FormElement(
                label='VMware Tools Status',
                item=self.obj.guest.toolsRunningStatus
            ),
            pvc.widget.form.FormElement(
                label='VMware Tools Version',
                item=self.obj.guest.toolsVersionStatus
            ),
            pvc.widget.form.FormElement(
                label='IP Address',
                item=self.obj.guest.ipAddress if self.obj.guest.ipAddress else 'Unknown'
            ),
            pvc.widget.form.FormElement(
                label='DNS Name',
                item=self.obj.guest.hostName if self.obj.guest.hostName else 'Unknown'
            ),
            pvc.widget.form.FormElement(
                label='State',
                item=self.obj.runtime.powerState
            ),
            pvc.widget.form.FormElement(
                label='Host',
                item=self.obj.runtime.host.name
            ),
            pvc.widget.form.FormElement(
                label='Template',
                item=str(self.obj.config.template)
            ),
            pvc.widget.form.FormElement(
                label='Folder',
                item=self.obj.parent.name
            ),
            pvc.widget.form.FormElement(
                label='VMX Path',
                item=self.obj.config.files.vmPathName
            ),
        ]

        form = pvc.widget.form.Form(
            dialog=self.dialog,
            form_elements=elements,
            title=self.title,
            text='Virtual Machine general information'
        )

        form.display()
Exemple #30
0
    def login(self):
        """
        Login to the VMware vSphere host

        Returns:
            True on successful connect, False otherwise

        """
        form_text = (
            'Enter IP address or DNS name '
            'of the VMware vSphere host you wish '
            'to connect to.\n'
        )

        elements = [
            pvc.widget.form.FormElement(label='Hostname'),
            pvc.widget.form.FormElement(label='Username'),
            pvc.widget.form.FormElement(label='Password', attributes=0x1),
        ]

        form = pvc.widget.form.Form(
            dialog=self.dialog,
            form_elements=elements,
            mixed_form=True,
            title='Login Details',
            text=form_text,
        )

        while True:
            code, fields = form.display()
            if code in (self.dialog.CANCEL, self.dialog.ESC):
                return False

            if not all(fields.values()):
                self.dialog.msgbox(
                    title='Error',
                    text='Invalid login details, please try again.\n'
                )
                continue

            self.dialog.infobox(
                title='Establishing Connection',
                text='Connecting to {} ...'.format(fields['Hostname']),
            )

            self.agent = VConnector(
                host=fields['Hostname'],
                user=fields['Username'],
                pwd=fields['Password'],
            )

            try:
                self.agent.connect()
                text = '{} - {} - Python vSphere Client version {}'
                background_title = text.format(
                    self.agent.host,
                    self.agent.si.content.about.fullName,
                    __version__
                )
                self.dialog.set_background_title(background_title)
                return True
            except Exception as e:
                self.dialog.msgbox(
                    title='Login failed',
                    text='Failed to login to {}\n\n{}\n'.format(self.agent.host, e.msg)
                )
Exemple #31
0
    def login(self):
        """
        Login to the VMware vSphere host

        Returns:
            True on successful connect, False otherwise

        """
        form_text = ('Enter IP address or DNS name '
                     'of the VMware vSphere host you wish '
                     'to connect to.\n')

        elements = [
            pvc.widget.form.FormElement(label='Hostname'),
            pvc.widget.form.FormElement(label='Username'),
            pvc.widget.form.FormElement(label='Password', attributes=0x1),
        ]

        form = pvc.widget.form.Form(
            dialog=self.dialog,
            form_elements=elements,
            mixed_form=True,
            title='Login Details',
            text=form_text,
        )

        while True:
            code, fields = form.display()
            if code in (self.dialog.CANCEL, self.dialog.ESC):
                return False

            if not all(fields.values()):
                self.dialog.msgbox(
                    title='Error',
                    text='Invalid login details, please try again.\n')
                continue

            self.dialog.infobox(
                title='Establishing Connection',
                text='Connecting to {} ...'.format(fields['Hostname']),
            )

            self.agent = VConnector(
                host=fields['Hostname'],
                user=fields['Username'],
                pwd=fields['Password'],
            )

            try:
                self.agent.connect()
                text = '{} - {} - Python vSphere Client version {}'
                background_title = text.format(
                    self.agent.host, self.agent.si.content.about.fullName,
                    __version__)
                self.dialog.set_background_title(background_title)
                return True
            except Exception as e:
                if isinstance(e, pyVmomi.vim.MethodFault):
                    msg = e.msg
                else:
                    msg = e

                self.dialog.msgbox(title='Login failed',
                                   text='Failed to login to {}\n\n{}\n'.format(
                                       self.agent.host, msg))