VOLTTRON / volttron

VOLTTRON Distributed Control System Platform
https://volttron.readthedocs.io/
Other
456 stars 216 forks source link

revivied Craig s code to resolved the issue that uuid has extra char when using vctl status #3129

Closed kefeimo closed 11 months ago

kefeimo commented 11 months ago

Description

Hot fix: uuid has extra char when using vctl status

Before

kefei@ubuntu-22:~/project/volttron$ vctl install examples/ListenerAgent --tag listener
Agent 6e4546f6-2c28-4830-9fab-973097f12ebc installed
kefei@ubuntu-22:~/project/volttron$ vctl status
UUID AGENT             IDENTITY            TAG      STATUS          HEALTH
6 listeneragent-3.3 listeneragent-3.3_1 listener                 
kefei@ubuntu-22:~/project/volttron$ vctl install examples/ListenerAgent --tag listener2
Agent 85c28535-46a1-49e2-8abd-c89c1450e11e installed
kefei@ubuntu-22:~/project/volttron$ vctl status
UUID AGENT             IDENTITY            TAG       STATUS          HEALTH
6e4546 listeneragent-3.3 listeneragent-3.3_1 listener                  
85c285 listeneragent-3.3 listeneragent-3.3_2 listener2   

After (fixed and verified as shown below)

kefei@ubuntu-22:~/project/volttron$ vctl install examples/ListenerAgent --tag listener
Agent c283e2d4-2ec9-4dde-bffa-db3e7b2f5d7c installed
kefei@ubuntu-22:~/project/volttron$ vctl status
UUID AGENT             IDENTITY            TAG      STATUS          HEALTH
c listeneragent-3.3 listeneragent-3.3_1 listener                 
kefei@ubuntu-22:~/project/volttron$ vctl install examples/ListenerAgent --tag listener2
Agent 8453f0f8-f4c8-463f-b756-28d184709a7e installed
kefei@ubuntu-22:~/project/volttron$ vctl status
UUID AGENT             IDENTITY            TAG       STATUS          HEALTH
8 listeneragent-3.3 listeneragent-3.3_2 listener2                 
c listeneragent-3.3 listeneragent-3.3_1 listener        

Fixes # (issue)

Type of change

Please delete options that are not relevant.

How Has This Been Tested?

Yes, see the description

Checklist:

craig8 commented 11 months ago

This produced bad results Agent = namedtuple('Agent', ('uuid')) my_agents = [Agent(x) for x in ['9b171ba5-f69f-4895-a69e-b51cf4d78150', '2c7c8405-49c8-48eb-86ff-236ebe39da6e', 'd73a71c8-000f-46aa-8e5f-c4436cf847c3', 'da2c1f0d-6ce5-4095-843c-3abc861d5199', 'f5de325c-e723-41e5-9ceb-fae722a40eb6' ]]

def _calc_min_uuid_length(agents): agent_ids = [agent.uuid for agent in agents] common_len = len(os.path.commonprefix(agent_ids)) return common_len + 1

_calc_min_uuid_length(my_agents)

Should be 2 characters but returns 1 but should be 2