From 7bfc694be4a0c157c8ff44f84a2d8b6cd3d36b9b Mon Sep 17 00:00:00 2001 From: Daniel Nichter Date: Wed, 10 Apr 2013 16:57:06 -0600 Subject: [PATCH] Change Agent.user to Agent.username and make it and hostname rw. --- bin/pt-agent | 17 +++++++++-------- lib/Percona/WebAPI/Resource/Agent.pm | 15 ++++++++------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/bin/pt-agent b/bin/pt-agent index 2f7731b9..e752b89e 100755 --- a/bin/pt-agent +++ b/bin/pt-agent @@ -1244,8 +1244,15 @@ has 'uuid' => ( required => 0, ); +has 'username' => ( + is => 'rw', + isa => 'Str', + required => 1, + default => $ENV{USER} || $ENV{LOGNAME}, +); + has 'hostname' => ( - is => 'ro', + is => 'rw', isa => 'Str', required => 1, ); @@ -1256,12 +1263,6 @@ has 'alias' => ( required => 0, ); -has 'user' => ( - is => 'ro', - isa => 'Str', - required => 1, -); - has 'versions' => ( is => 'ro', isa => 'Maybe[HashRef]', @@ -5052,7 +5053,7 @@ sub init_agent { # Other optional attribs, like versions, are left to the caller. chomp(my $hostname = `hostname`); $agent->{hostname} = $hostname; - $agent->{user} = $ENV{USER} || $ENV{LOGNAME}; + $agent->{username} = $ENV{USER} || $ENV{LOGNAME}; # Try forever to create/update the Agent. The tool can't # do anything without an Agent, so we must succeed to proceed. diff --git a/lib/Percona/WebAPI/Resource/Agent.pm b/lib/Percona/WebAPI/Resource/Agent.pm index eab9b2ff..57c7efcb 100644 --- a/lib/Percona/WebAPI/Resource/Agent.pm +++ b/lib/Percona/WebAPI/Resource/Agent.pm @@ -28,8 +28,15 @@ has 'uuid' => ( required => 0, ); +has 'username' => ( + is => 'rw', + isa => 'Str', + required => 1, + default => $ENV{USER} || $ENV{LOGNAME}, +); + has 'hostname' => ( - is => 'ro', + is => 'rw', isa => 'Str', required => 1, ); @@ -40,12 +47,6 @@ has 'alias' => ( required => 0, ); -has 'user' => ( - is => 'ro', - isa => 'Str', - required => 1, -); - has 'versions' => ( is => 'ro', isa => 'Maybe[HashRef]',