opened
Choppra
username_0
I am working with the latest gem.  I am attempting to pull the scan template used for a site.  I am calling scan_template_name (I remember it being just scan_template) at one point.  Its returning no value.  Has anyone noticed this recently?

```
sites = @nsc.sites
sites.each do |s|
template = site.scan_template_name
puts template
end
#returns no value
```
Having issues pulling template used.
issue
created
peterjmcg
username_1
s.scan_template_name   ?

Peter
comment
created
Choppra
username_0
```
sites.each do |s|
        #ignore sites
        ignore_sites = [31,32,33,40,25,23,38]
        next if ignore_sites.include?(s.id)
        #end ignore sites
        site = Site.load(@nsc, s.id)
        puts "site: ##{site.id}\tname: #{site.name}"
        template = site.scan_template_name
        latest = @nsc.last_scan(site.id)
        if latest
          start_time = latest.start_time
          status = latest.status
          active = latest.nodes.live
          engine_name = engine_list[site.engine_id]
          if sched = site.schedules.first
            schedule = "#{sched.type}:#{sched.interval}"
          end
          if latest.end_time
            duration_sec = latest.end_time - start_time
            hours = (duration_sec / 3600).to_i
            minutes = (duration_sec / 60 - hours * 60).to_i
            seconds = (duration_sec - (minutes * 60 + hours * 3600))
            duration = sprintf('%dh %02dm %02ds', hours, minutes, seconds)
          else
            duration = ''
          end
        else
          # No scans found.
          start_time = status = active = duration = engine_name = ''
        end
        file.puts "#{site.name},#{start_time},#{status},#{active},#{duration},#{template},#{engine_name},NEXT SCAN,#{schedule}"
      end
    end
```

Returns no value for template.
comment
created
Choppra
username_0
Looks like its scan_template_id - shouldn't this be a number rather than a returned name?
comment
created
Choppra
username_0
Now that I think about it, if multiple templates are used in 1 site, it would be difficult to return what i'm looking for anyway.  I want the last template used for this report.
comment
created
gschneider-r7
username_2
The template ID is not stored numerically in Nexpose. It is basically a flattened representation of the template name at time of creation - this ID does not change over time, though the template name can change.

I think that template name not being populated here is just something missing from the API, but in general the template ID should be more useful to work with.
comment
closed
Choppra
username_0
issue
created
Choppra
username_0
Thanks, it is.  I'm using that for now.  As long as I can report on the last template used i'm fine with it.
comment