Thursday 25 December 2014

select and describe table in MySQL by using wxpython

#!/usr/bin/python

import wx
import MySQLdb

###############################################
class func:

   #------------------------------------
   def __init__(self,opt):
       """Constractor"""
       self.opt = opt

###############################################
class dbOpt():
   #------------------------------------
   def __init__(self,host,user,passwd,dbname,tbname):
       self.host = host
       self.user = user
       self.passwd = passwd
       self.dbname = dbname
       self.tbname = tbname

   #------------------------------------
   def dbSelect(self):
       db = MySQLdb.connect(host=self.host, user=self.user, passwd=self.passwd, db=self.dbname)
       selectSql = "SELECT * FROM " + self.tbname
       cursor = db.cursor()
       cursor.execute(selectSql)
       db.commit()
       data = cursor.fetchall()
       cursor.close()
       db.close()
       data = "{}".format(data)
       return data

   #------------------------------------
   def dbDescribe(self):
       db = MySQLdb.connect(host="localhost", user="root", passwd="1988628",db=self.dbname)
       selectSql = "describe " + self.tbname
       cursor = db.cursor()
       cursor.execute(selectSql)
       db.commit()
       data = cursor.fetchall()
       cursor.close()
       db.close()
       data = "{}".format(data)
       return data

###############################################
class myFrame(wx.Frame):
   #-------------------------------------
   def __init__(self):
       wx.Frame.__init__(self, None, wx.ID_ANY, "Colin's SQL")

       # Add a panel, so it looks the correct on all platfroms
       panel = wx.Panel(self, wx.ID_ANY)

       opts = [func("show tables"),
              func("describe")]
       sampleList = []
       self.cb = wx.ComboBox(panel, size=wx.DefaultSize,choices=sampleList)
       self.widgetMaker(self.cb, opts)
       self.dbhost = wx.TextCtrl(panel)
       self.dbuser = wx.TextCtrl(panel)
       self.dbpasswd = wx.TextCtrl(panel)
       self.dbfield = wx.TextCtrl(panel)
       self.tbfield = wx.TextCtrl(panel)
       self.contents = wx.TextCtrl(panel,style=wx.TE_MULTILINE|wx.HSCROLL)

       tsizer = wx.BoxSizer()
       tsizer.Add(self.dbhost, 1, wx.EXPAND)
       tsizer.Add(self.dbuser, 1, wx.EXPAND)
       tsizer.Add(self.dbpasswd, 1, wx.EXPAND)

       hsizer = wx.BoxSizer()
       hsizer.Add(self.dbfield, 1, wx.EXPAND)
       hsizer.Add(self.tbfield, 1, wx.EXPAND)
       hsizer.Add(self.cb, 0, wx.RIGHT, 5)

       vsizer = wx.BoxSizer(wx.VERTICAL)
       vsizer.Add(tsizer, 0, wx.EXPAND, 5)
       vsizer.Add(hsizer, 0, wx.EXPAND, 5)
       vsizer.Add(self.contents, 1, wx.EXPAND|wx.LEFT|wx.RIGHT|wx.BOTTOM)

       panel.SetSizer(vsizer)

   #-------------------------------------
   def widgetMaker(self, widget, objects):
       """"""
       for obj in objects:
           widget.Append(obj.opt, obj)
       widget.Bind(wx.EVT_COMBOBOX, self.onSelect)

   #-------------------------------------
   def onSelect(self, event):
       obj = self.cb.GetClientData(self.cb.GetSelection())
       if obj.opt == "show tables":
           stb=dbOpt(self.dbhost.GetValue(),self.dbuser.GetValue(),self.dbpasswd.GetValue(),self.dbfield.GetValue(),self.tbfield.GetValue())
           self.contents.SetValue(stb.dbSelect())
       elif obj.opt == "describe":
           stb=dbOpt(self.dbhost.GetValue(),self.dbuser.GetValue(),self.dbpasswd.GetValue(),self.dbfield.GetValue(),self.tbfield.GetValue())
           self.contents.SetValue(stb.dbDescribe())

# Run the Program
if __name__ == "__main__":
   app = wx.App(False)
   frame = myFrame()
   frame.Show()
app.MainLoop()


Sunday 30 November 2014

UCS C240 Installs VMware ESXI5.1

UCS C240 Installs VMware ESXI5.1

1.Preparation

  1. VMware  ESXI5.1的IOS iamge
path:\\server5\software\Vmware\ESX\VSphere5.1
  1. Connect NIC to network in order to acquire ip。(if not using dhcp, F8 to assign static)

2.login CIMC

After reboot server. Will display sys info:


Fill find cimc address. Press F8 to enter CIMC config for detailed configs
可以选择DHCP 和手动静态指定。
Choose dhcp or manually assign address

Login page
Admin/password by initial login
  1. CIMC operations

CIMC:
  1. Raid settings

  1. After a reboot, ctrl + H login to raid config page  then choose configuration Wizard


2、New Configuration -> Next















3、Custom configuration












  1. Add disk to logic disk group

5、press Cotrol to select all disk.  Add To Array-- Next
6、add Span  and press Add to SPAN-> Next


7、Next


8、showing raid level ,choose size of disk。
9、点击Accept










10、select Yes

10、select Fast Initialize-> Go
12、reboot server and save config

  1. Login KVM console

Choose yes to continue


  1. virtual cd-rom settings

      in KVM Console, click Virtual Media->Add image to select image,
and click mapped
image becomes an vitual disk

  1. install VMware ESXI5.1

click Macros –> Ctrl-Alt-Del
after boot, press F6 to Boot Menu
choose cisco virtual CD/DVD 1.22






Select ESXi-5.1.0
Install starts

About 20 minutes late will see Mware ESXi

N6K Upgrade

N6001 Upgrade Step

Boot up

Uncompressing system image: bootflash:/n6000-uk9.6.0.2.N1.2.bin Thu Jan 19 13:47:50 UTC 2012

Load plugins that defined in image conf: /isan/plugin_img/img.conf
Loading plugin 0: core_plugin...
load_plugin: Can't get exclude list from /isan/plugin/0/boot/etc/plugin_exclude.conf (rc 0x40ea0017)
Loading plugin 1: eth_plugin...
ethernet switching mode
INIT: Entering runlevel: 3
touch: cannot touch `/var/lock/s
/isan/bin/muxif_config: fex vlan id: -f,4042
Set name-type for VLAN subsystem. Should be visible in /proc/net/vlan/config
Added VLAN with VID == 4042 to IF -:muxif:-
2012 Jan 19 13:48:12  %$ VDC-1 %$ %USER-2-SYSTEM_MSG: CLIS: loading cmd files begin  - clis
2012 Jan 19 13:48:21  %$ VDC-1 %$ %USER-2-SYSTEM_MSG: CLIS: loading cmd files end  - clis
2012 Jan 19 13:48:21  %$ VDC-1 %$ %USER-2-SYSTEM_MSG: CLIS: init begin  - clis

Be patient. Wait for a long while

System is coming up ... Please wait ...
System is coming up ... Please wait ...
System is coming up ... Please wait ...
Starting Power On Auto Provisioning...2012 Jan 19 13:52:50  %$ VDC-1 %$ %VDC_MGR-2-VDC_ONLINE: vdc 1 has come online
Done

Abort Power On Auto Provisioning and continue with normal setup ?(yes/no)[n]: 2012 Jan 19 13:52:50 switch %$ VDC-1 %$ %POAP-2-POAP_INITED: S/N[FOC1739R137]-MAC[00:2A:6A:7C:D2:C1] - POAP process initialized
y



        ---- System Admin Account Setup ----


Do you want to enforce secure password standard (yes/no): no

 Enter the password for "admin": Passw0rd
 Confirm the password for "admin": Passw0rd

        ---- Basic System Configuration Dialog ----

This setup utility will guide you through the basic configuration of
the system. Setup configures only enough connectivity for management
of the system.

Please register Cisco Nexus 6000 Family devices promptly with your
supplier. Failure to register may affect response times for initial
service calls. Nexus devices must be registered to receive entitled
support services.

Press Enter at anytime to skip a dialog. Use ctrl-c at anytime
to skip the remaining dialogs.

Would you like to enter the basic configuration dialog (yes/no): n


Login system

User Access Verification
login: admin
Password:
Cisco Nexus Operating System (NX-OS) Software
TAC support: http://www.cisco.com/tac
Copyright (c) 2002-2013, Cisco Systems, Inc. All rights reserved.
The copyrights to certain works contained in this software are
owned by other third parties and used and distributed under
license. Certain components of this software are licensed under
the GNU General Public License (GPL) version 2.0 or the GNU
Lesser General Public License (LGPL) Version 2.1. A copy of each
such license is available at
http://www.opensource.org/licenses/gpl-2.0.php and

config management port

switch# conf t
Enter configuration commands, one per line.  End with CNTL/Z.
switch(config)# int mgmt 0
switch(config-if)# ip address 1.1.1.3 255.255.255.0
switch(config-if)# no shutdown
switch(config-if)# end
switch# ping 1.1.1.1 vrf management
PING 1.1.1.1 (1.1.1.1): 56 data bytes
36 bytes from 1.1.1.3: Destination Host Unreachable
Request 0 timed out
64 bytes from 1.1.1.1: icmp_seq=1 ttl=63 time=0.874 ms
64 bytes from 1.1.1.1: icmp_seq=2 ttl=63 time=0.516 ms
64 bytes from 1.1.1.1: icmp_seq=3 ttl=63 time=0.614 ms
64 bytes from 1.1.1.1: icmp_seq=4 ttl=63 time=0.481 ms

--- 1.1.1.1 ping statistics ---
5 packets transmitted, 4 packets received, 20.00% packet loss
round-trip min/avg/max = 0.481/0.621/0.874 ms


copy image

switch# copy ftp://frank:cisco123@1.1.1.1/n6000-uk9.6.0.2.N1.2a.bin bootflash:
Enter vrf (If no input, current vrf 'default' is considered): management
Password:
***** Transfer of file Completed Successfully *****    
Copy complete, now saving to disk (please wait)...
switch#
switch#
switch# copy ftp://frank:cisco123@1.1.1.1/n6000-uk9-kickstart.6.0.2.N1.2a.bin bootflash:
Enter vrf (If no input, current vrf 'default' is considered): management
Password:
***** Transfer of file Completed Successfully *****    
Copy complete, now saving to disk (please wait)...

NOTE: install command doesn’t take effect, and shows errors. Have to wait a while…
switch# install all kickstart bootflash:n6000-uk9-kickstart.6.0.2.N1.2a.bin system bootflash:n6000-uk9.6.0.2.N1.2a.bin
Pre-upgrade check failed. Return code 0x4093002A (all modules are not in a terminal state).


After couple minutes. Start installing
switch# install all kickstart bootflash:n6000-uk9-kickstart.6.0.2.N1.2a.bin system bootflash:n6000-uk9.6.0.2.N1.2a.bin

Verifying image bootflash:/n6000-uk9-kickstart.6.0.2.N1.2a.bin for boot variable "kickstart".
[####################] 100% -- SUCCESS

Verifying image bootflash:/n6000-uk9.6.0.2.N1.2a.bin for boot variable "system".
[####################] 100% -- SUCCESS

Verifying image type.
[####################] 100% -- SUCCESS

Extracting "system" version from image bootflash:/n6000-uk9.6.0.2.N1.2a.bin.
[####################] 100% -- SUCCESS

Extracting "kickstart" version from image bootflash:/n6000-uk9-kickstart.6.0.2.N1.2a.bin.
[####################] 100% -- SUCCESS

Extracting "bios" version from image bootflash:/n6000-uk9.6.0.2.N1.2a.bin.
[####################] 100% -- SUCCESS

Performing module support checks.
[####################] 100% -- SUCCESS

Notifying services about system upgrade.


[####################] 100% -- SUCCESS



Compatibility check is done:
Module  bootable          Impact  Install-type  Reason
------  --------  --------------  ------------  ------
    1       yes      disruptive         reset  Non-disruptive install not supported if L3 was enabled
    2       yes      disruptive         reset  Non-disruptive install not supported if L3 was enabled



Images will be upgraded according to following table:
Module             Image         Running-Version             New-Version  Upg-Required
------  ----------------  ----------------------  ----------------------  ------------
    1            system             6.0(2)N1(2)            6.0(2)N1(2a)           yes
    1         kickstart             6.0(2)N1(2)            6.0(2)N1(2a)           yes
    1              bios      v1.5.0(12/29/2012)      v1.4.0(10/29/2012)            no
    1         power-seq                    v3.0                    v3.0            no
    1  fabric-power-seq                    v3.0                    v3.0            no
    2         power-seq                    v1.0                    v1.0            no
    1   microcontroller                v1.2.0.5                v1.0.0.1            no


Switch will be reloaded for disruptive upgrade.
Do you want to continue with the installation (y/n)?  [n]y

Choose y to restart


After boot up, confirm OS

switch# show version
Cisco Nexus Operating System (NX-OS) Software
TAC support: http://www.cisco.com/tac
Documents: http://www.cisco.com/en/US/products/ps9372/tsd_products_support_serie
s_home.html
Copyright (c) 2002-2013, Cisco Systems, Inc. All rights reserved.
The copyrights to certain works contained herein are owned by
other third parties and are used and distributed under license.
Some parts of this software are covered under the GNU Public
License. A copy of the license is available at
http://www.gnu.org/licenses/gpl.html.

Software
 BIOS:      version 1.5.0
 loader:    version N/A
 kickstart: version 6.0(2)N1(2)
 system:    version 6.0(2)N1(2)
 Power Sequencer Firmware:
            Module 1: version v3.0
 Fabric Power Sequencer Firmware: Module 1: version v3.0
 Microcontroller Firmware:        version v1.2.0.5
 QSFP Microcontroller Firmware:   
            Module not detected
 ESFP uC:   Module 1: v1.1.0.0
 BIOS compile time:       12/29/2012
 kickstart image file is: bootflash:///n6000-uk9-kickstart.6.0.2.N1.2.bin
 kickstart compile time:  3/14/2013 1:00:00 [03/14/2013 11:31:34]
 system image file is:    bootflash:///n6000-uk9.6.0.2.N1.2.bin
 system compile time:     3/14/2013 1:00:00 [03/14/2013 12:57:39]


Hardware
 cisco Nexus 6001 Chassis ("Norcal 64 Supervisor")
 Intel(R) Xeon(R) CPU  @ 2.00 with 8248476 kB of memory.
 Processor Board ID FOC17421FKT

 Device name: switch
 bootflash:    8028160 kB

Kernel uptime is 0 day(s), 0 hour(s), 6 minute(s), 54 second(s)

Last reset at 375933 usecs after  Thu Jan 19 14:00:16 2012

 Reason: Reset Requested by CLI command reload
 System version: 6.0(2)N1(2)
 Service:

plugin
 Core Plugin, Ethernet Plugin