From: NjeriChelimo <martha.c.ch...@gmail.com> --- clients/cimi/app.rb | 1 + clients/cimi/lib/entities.rb | 1 + clients/cimi/lib/entities/address_template.rb | 30 +++++++++++++++++++++++ clients/cimi/views/address_templates/index.haml | 23 +++++++++++++++++ clients/cimi/views/address_templates/show.haml | 30 +++++++++++++++++++++++ 5 files changed, 85 insertions(+) create mode 100644 clients/cimi/lib/entities/address_template.rb create mode 100644 clients/cimi/views/address_templates/index.haml create mode 100644 clients/cimi/views/address_templates/show.haml
diff --git a/clients/cimi/app.rb b/clients/cimi/app.rb index 9247254..988430a 100644 --- a/clients/cimi/app.rb +++ b/clients/cimi/app.rb @@ -20,6 +20,7 @@ module CIMI::Frontend class Application < Sinatra::Base use CIMI::Frontend::Address + use CIMI::Frontend::AddressTemplate use CIMI::Frontend::CloudEntryPoint use CIMI::Frontend::MachineConfiguration use CIMI::Frontend::MachineImage diff --git a/clients/cimi/lib/entities.rb b/clients/cimi/lib/entities.rb index 841c4e6..bb431ea 100644 --- a/clients/cimi/lib/entities.rb +++ b/clients/cimi/lib/entities.rb @@ -21,6 +21,7 @@ end require 'entities/base_entity' require 'entities/cloud_entry_point' require 'entities/address' +require 'entities/address_template' require 'entities/machine_configuration' require 'entities/machine_admin' require 'entities/machine_image' diff --git a/clients/cimi/lib/entities/address_template.rb b/clients/cimi/lib/entities/address_template.rb new file mode 100644 index 0000000..667e647 --- /dev/null +++ b/clients/cimi/lib/entities/address_template.rb @@ -0,0 +1,30 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +class CIMI::Frontend::AddressTemplate < CIMI::Frontend::Entity + + get '/cimi/address_templates/:id' do + address_templates_xml = get_entity('address_templates', params[:id], credentials) + @address_template = CIMI::Model::AddressTemplate.from_xml(address_templates_xml) + haml :'address_templates/show' + end + + get '/cimi/address_templates' do + address_template_xml = get_entity_collection('address_templates', credentials) + @address_templates = CIMI::Model::AddressTemplateCollection.from_xml(address_template_xml) + haml :'address_templates/index' + end + +end diff --git a/clients/cimi/views/address_templates/index.haml b/clients/cimi/views/address_templates/index.haml new file mode 100644 index 0000000..93d1e48 --- /dev/null +++ b/clients/cimi/views/address_templates/index.haml @@ -0,0 +1,23 @@ +- @title=collection_name @address_templates + +- content_for :breadcrumb do + %ul.breadcrumb + %li + %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint + %span.divider="/" + %li.active + AddressTemplateCollection + +- content_for :actions do + %p + %a{ :href => "#{@address_templates.id}?format=xml", :class => 'label warning' } XML + %a{ :href => "#{@address_templates.id}?format=json", :class => 'label warning' } JSON + +%ul + - @address_templates.address_templates.each do |template| + %li + %a{ :href => "/cimi/address_templates/#{href_to_id(template.id)}"}=href_to_id(template.id) + +-details do + -row 'ID', @address_templates.id + -row 'Count', @address_templates.count diff --git a/clients/cimi/views/address_templates/show.haml b/clients/cimi/views/address_templates/show.haml new file mode 100644 index 0000000..aac2ff5 --- /dev/null +++ b/clients/cimi/views/address_templates/show.haml @@ -0,0 +1,30 @@ +- @title="#{@address_template.name}" + +- content_for :breadcrumb do + %ul.breadcrumb + %li + %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint + %span.divider="/" + %li + %a{ :href => "/cimi/network_port_templates"} AddressTemplateCollection + %span.divider="/" + %li.active + = @address_template.name + +- content_for :actions do + %p + %a{ :href => "#{@address_template.id}?format=xml", :class => 'label warning' } XML + %a{ :href => "#{@address_template.id}?format=json", :class => 'label warning' } JSON + +-details do + -row 'ID', @address_template.id + -row 'Name',@address_template.name + -row 'Description',@address_template.description + -row 'Created',@address_template.created + -row 'IP',@address_template.ip + -row 'Host name',@address_template.hostname + -row 'Allocation',@address_template.allocation + -row 'Default gateway',@address_template.default_gateway + -row 'DNS',@address_template.dns + -row 'Protocol',@address_template.protocol + -row 'mask',@address_template.mask -- 1.7.9.5