Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement on DB operations in import #142

Merged
merged 10 commits into from
Nov 1, 2018
Merged

enhancement on DB operations in import #142

merged 10 commits into from
Nov 1, 2018

Conversation

immarvin
Copy link
Contributor

@immarvin immarvin commented Oct 25, 2018

Description:

  1. switch table is mapped to network_info. connections of node object , export node object:
[root@c910f03c05k21 inventory]# xcat-inventory export -t node -o testnodes
node:
  testnodes:
    device_info:
      arch: armel
      characteristics: switch
      switchtype: onie
    device_type: switch
    engines:
      hardware_mgt_engine:
        engine_type: switch
      netboot_engine:
        engine_info:
          osimage: cumulus3.5.2-armel
        engine_type: onie
    network_info:
      connections:
      - switch: mid05tor11
        switchport: '22'
      - switch: mid05tor13
        switchport: '22'
      - switch: mid05tor14
        switchport: '22'
      primarynic:
        ip: 10.3.5.141
        mac:
        - 8c:ea:2b:12:ca:40
    obj_info:
      description: Cumulus Linux 3.4.1 (Linux Kernel 4.1.33-1+cl3u9)
      groups: switch,edge_switch
    obj_type: node
    role: compute
    role_info:
      tftpserver: briggs01
schema_version: '2.0'

#Version 2.14.5 (git commit 5bab3f8bac3374cd9cb2e26b4a71c7cb32bb1126, built Mon Oct 22 06:16:06 EDT 2018)
[root@c910f03c05k21 inventory]#

  1. import node object:
[root@c910f03c05k21 inventory]# xcat-inventory import -f /tmp/testnodes
loading inventory date in "/tmp/testnodes"
start to import "node" type objects
 preprocessing "node" type objects
 writting "node" type objects
start to import "networkconn" type objects
 preprocessing "networkconn" type objects
 writting "networkconn" type objects
Inventory import successfully!
[root@c910f03c05k21 inventory]# xcat-inventory export -t node -o testnodes
node:
  testnodes:
    device_info:
      arch: armel
      characteristics: switch
      switchtype: onie
    device_type: switch
    engines:
      hardware_mgt_engine:
        engine_type: switch
      netboot_engine:
        engine_info:
          osimage: cumulus3.5.2-armel
        engine_type: onie
    network_info:
      connections:
      - switch: mid05tor11
        switchport: '22'
      - switch: mid05tor13
        switchport: '22'
      - switch: mid05tor14
        switchport: '24'
      primarynic:
        ip: 10.3.5.141
        mac:
        - 8c:ea:2b:12:ca:40
    obj_info:
      description: Cumulus Linux 3.4.1 (Linux Kernel 4.1.33-1+cl3u9)
      groups: switch,edge_switch
    obj_type: node
    role: compute
    role_info:
      tftpserver: briggs01
schema_version: '2.0'
  1. export of passwd:
[root@c910f03c05k21 inventory]# xcat-inventory export -t passwd
passwd:
  ipmi:
    password: '''USERID'''
    username: '''admin'''
  openbmc:
  - password: xcat
    username: mmmmmmmm
  - password: USERID
    username: ssss
  switch:
    password: admin
    username: root
  system:
  - password: cluster
    username: root
  - password: cluster
    username: wsuser
schema_version: '2.0'
  1. import of passwd:
[root@c910f03c05k21 inventory]# cat /tmp/passwd
passwd:
  ipmi:
    password: '''USERID'''
    username: '''admin'''
  openbmc:
  - password: 'USERID'
    username: 'ssss'
  switch:
    password: admin
    username: root
  system:
  - password: cluster
    username: root
  - password: cluster
    username: wsuser
schema_version: '2.0'

#Version 2.14.5 (git commit 5bab3f8bac3374cd9cb2e26b4a71c7cb32bb1126, built Mon Oct 22 06:16:06 EDT 2018)
[root@c910f03c05k21 inventory]# xcat-inventory import -f /tmp/passwd -c
loading inventory date in "/tmp/passwd"
start to import "passwd" type objects
 preprocessing "passwd" type objects
 writting "passwd" type objects
Inventory import successfully!
[root@c910f03c05k21 inventory]# tabdump passwd
#key,username,password,cryptmethod,authdomain,comments,disable
"ipmi","'admin'","'USERID'",,,,
"openbmc","ssss","USERID",,,,
"switch","root","admin",,,,
"system","root","cluster",,,,
"system","wsuser","cluster",,,,
[root@c910f03c05k21 inventory]#

@immarvin immarvin changed the title Ondb multiple key table support Oct 26, 2018
@immarvin immarvin changed the title multiple key table support multiple key table support[DO NOT MERGE] Oct 26, 2018
@immarvin immarvin changed the title multiple key table support[DO NOT MERGE] multiple key table support Oct 31, 2018
@@ -0,0 +1,280 @@
!!python/dict
Copy link
Contributor

@bybai bybai Nov 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xcat-inventory/xcclient/inventory/schema/2.0/1 is not valid schema file name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -244,23 +331,27 @@ def cleartab(self,tabs):
flattabs.append(tab)
else:
matrixtabs.append(tab)
for tab in matrixtabs:
for tab in tabs:
if hasattr(dbobject,tab):
tabcls=getattr(dbobject,tab)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line 323~333: to generate flattabs and matrixtabs. But these 2 lists are not used by function cleartab

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


if tabkey != item and newdict[item] is None:
if item not in objkeys and newdict[item] is None:
newdict[item]=''

#delete table rows when (1)the key is None or blank (2)the key is not specified in newdict and all non-key values are blank
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you update the comments according to new codes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

#print(tabdict)
#print("\n")
if tabdict is None:
return None
for key in tabdict.keys():
utils.verbose(" writting object: "+str(key),file=sys.stdout)
#clear any existing table entries before adding new entries
df=dbfactory(self._dbsession)
df.cleartab(tabdict[key].keys(),[key])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When it is not update, manager.py calls cleartab to clear up db, there is no data in DB now. In line 171 call cleartab, it clear up DB again in for loop. And if there are too many nodes, for each node, it clear up switch table once, the performance can be enhanced here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will refine this in following sprints

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened a ticket to trace this enhance #147, thanks

@bybai
Copy link
Contributor

bybai commented Nov 1, 2018

I agree to merge this pull request for functions fixing , the DB execution performance enhancement ticket (#147) can be planned in another sprint. Thanks

@bybai bybai merged commit 8bfa208 into xcat2:master Nov 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants