diff --git a/lib/NGCP/Template/Object.pm b/lib/NGCP/Template/Object.pm
index 4c794064..69b255a4 100644
--- a/lib/NGCP/Template/Object.pm
+++ b/lib/NGCP/Template/Object.pm
@@ -43,6 +43,24 @@ sub has_role
     return 0;
 }
 
+sub get_version
+{
+    my $self = shift;
+
+    my $filename = '/etc/ngcp_upgrade_version';
+    unless (-e $filename) {
+        $filename = '/etc/ngcp_version';
+    }
+
+    open my $hh, '<', $filename or die "Error opening $filename";
+    my $version = <$hh>;
+    close $hh;
+    chomp $version;
+    die "Fatal error retrieving ngcp_version [$version]" unless length $version;
+
+    return $version;
+}
+
 sub get_hostname
 {
     my $self = shift;
@@ -210,6 +228,10 @@ The $config argument contains the deserialized ngcp-config YAML configuration.
 
 Checks whether the $hostname node has the $role.
 
+=item $version = $t->get_version()
+
+Returns the NGCP version.
+
 =item $hostname = $t->get_hostname()
 
 Returns the hostname of the node calling this function.
diff --git a/lib/get_ngcp_version b/lib/get_ngcp_version
index 7221d81b..f029d9ac 100644
--- a/lib/get_ngcp_version
+++ b/lib/get_ngcp_version
@@ -4,18 +4,7 @@
 # Returns the NGCP version of the node calling this function.
 #
 # @return out           The NGCP version (e.g. 'mr4.5.3' or 'trunk').
--%]
-[% PERL -%]
-  my $filename = '/etc/ngcp_upgrade_version';
-  unless (-e $filename) {
-    $filename = '/etc/ngcp_version';
-  }
-  open my $hh, '<', $filename or die "Error opening $filename";
-  my $ngcp_version = <$hh>;
-  close $hh;
-  chomp $ngcp_version;
-  die "Fatal error retrieving ngcp_version [$ngcp_version]" unless length $ngcp_version;
 
-  $stash->set(out => $ngcp_version);
-  return;
-[% END -%]
+out = ngcp.get_version();
+
+-%]