示例#1
0
 def query_zvm_uptime(self, zhcp):
     url = self._xcat_url.xdsh("/%s" % zhcp)
     cmd = '/opt/zhcp/bin/smcli System_Info_Query'
     xdsh_commands = 'command=%s' % cmd
     body = [xdsh_commands]
     with xcatutils.expect_invalid_xcat_resp_data():
         ret_str = xcatutils.xcat_request("PUT", url, body)['data'][0][0]
     return ret_str.split('\n')[4].split(': ', 3)[2]
示例#2
0
 def query_xcat_uptime(self):
     url = self._xcat_url.xdsh("/%s" % self._xcat_node_name)
     # get system uptime
     cmd = 'date -d "$(awk -F. \'{print $1}\' /proc/uptime) second ago"'
     cmd += ' +"%Y-%m-%d %H:%M:%S"'
     xdsh_commands = 'command=%s' % cmd
     body = [xdsh_commands]
     with xcatutils.expect_invalid_xcat_resp_data():
         return xcatutils.xcat_request("PUT", url, body)['data'][0][0]
示例#3
0
 def get_nic_ids(self):
     addp = ''
     url = self._xcat_url.tabdump("/switch", addp)
     with xcatutils.expect_invalid_xcat_resp_data():
         nic_settings = xcatutils.xcat_request("GET", url)['data'][0]
     # remove table header
     nic_settings.pop(0)
     # it's possible to return empty array
     return nic_settings
示例#4
0
 def _get_nic_settings(self, port_id, field=None, get_node=False):
     """Get NIC information from xCat switch table."""
     LOG.debug("Get nic information for port: %s", port_id)
     addp = '&col=port&value=%s' % port_id + '&attribute=%s' % (
         field and field or 'node')
     url = self._xcat_url.gettab("/switch", addp)
     with xcatutils.expect_invalid_xcat_resp_data():
         ret_value = xcatutils.xcat_request("GET", url)['data'][0][0]
     if field is None and not get_node:
         ret_value = self.get_userid_from_node(ret_value)
     return ret_value
示例#5
0
    def add_nic_to_user_direct(self, nodename, nic_info):
        """add one NIC's info to user direct."""
        vdev = self._get_nic_settings(nic_info['port_id'], "interface")

        url = self._xcat_url.chvm('/' + nodename)
        command = 'Image_Definition_Update_DM -T %userid%'
        command += ' -k \'NICDEF=VDEV=%s TYPE=QDIO ' % vdev
        command += 'MACID=%s ' % nic_info['mac']
        command += 'LAN=SYSTEM '
        command += 'SWITCHNAME=%s\'' % nic_info['vswitch']
        body = ['--smcli', command]

        with xcatutils.expect_invalid_xcat_resp_data():
            xcatutils.xcat_request("PUT", url, body)
示例#6
0
 def get_userid_from_node(self, node):
     addp = '&col=node&value=%s&attribute=userid' % node
     url = self._xcat_url.gettab("/zvm", addp)
     with xcatutils.expect_invalid_xcat_resp_data():
         return xcatutils.xcat_request("GET", url)['data'][0][0]
示例#7
0
 def _get_xcat_node_name(self):
     xcat_ip = self._get_xcat_node_ip()
     addp = '&col=ip&value=%s&attribute=node' % (xcat_ip)
     url = self._xcat_url.gettab("/hosts", addp)
     with xcatutils.expect_invalid_xcat_resp_data():
         return (xcatutils.xcat_request("GET", url)['data'][0][0])
示例#8
0
 def _get_xcat_node_ip(self):
     addp = '&col=key&value=master&attribute=value'
     url = self._xcat_url.gettab("/site", addp)
     with xcatutils.expect_invalid_xcat_resp_data():
         return xcatutils.xcat_request("GET", url)['data'][0][0]