From: NjeriChelimo <martha.c.ch...@gmail.com> --- clients/cimi/app.rb | 1 + clients/cimi/lib/entities.rb | 1 + clients/cimi/lib/entities/address.rb | 30 ++++++++++++++++++++++++++++++ clients/cimi/views/addresses/index.haml | 23 +++++++++++++++++++++++ clients/cimi/views/addresses/show.haml | 29 +++++++++++++++++++++++++++++ 5 files changed, 84 insertions(+) create mode 100644 clients/cimi/lib/entities/address.rb create mode 100644 clients/cimi/views/addresses/index.haml create mode 100644 clients/cimi/views/addresses/show.haml
diff --git a/clients/cimi/app.rb b/clients/cimi/app.rb index 00d6346..9247254 100644 --- a/clients/cimi/app.rb +++ b/clients/cimi/app.rb @@ -19,6 +19,7 @@ module CIMI::Frontend class Application < Sinatra::Base + use CIMI::Frontend::Address 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 76b53cd..841c4e6 100644 --- a/clients/cimi/lib/entities.rb +++ b/clients/cimi/lib/entities.rb @@ -20,6 +20,7 @@ end require 'entities/base_entity' require 'entities/cloud_entry_point' +require 'entities/address' require 'entities/machine_configuration' require 'entities/machine_admin' require 'entities/machine_image' diff --git a/clients/cimi/lib/entities/address.rb b/clients/cimi/lib/entities/address.rb new file mode 100644 index 0000000..31f5de9 --- /dev/null +++ b/clients/cimi/lib/entities/address.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::Address < CIMI::Frontend::Entity + + get '/cimi/addresses/:id' do + address_xml = get_entity('addresses', params[:id], credentials) + @address = CIMI::Model::Address.from_xml(address_xml) + haml :'addresses/show' + end + + get '/cimi/addresses' do + addresses_xml = get_entity_collection('addresses', credentials) + @addresses = CIMI::Model::AddressCollection.from_xml(addresses_xml) + haml :'addresses/index' + end + +end diff --git a/clients/cimi/views/addresses/index.haml b/clients/cimi/views/addresses/index.haml new file mode 100644 index 0000000..128ebef --- /dev/null +++ b/clients/cimi/views/addresses/index.haml @@ -0,0 +1,23 @@ +- @title=collection_name @addresses + +- content_for :breadcrumb do + %ul.breadcrumb + %li + %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint + %span.divider="/" + %li.active + AddressCollection + +- content_for :actions do + %p + %a{ :href => "#{@addresses.id}?format=xml", :class => 'label warning' } XML + %a{ :href => "#{@addresses.id}?format=json", :class => 'label warning' } JSON + +%ul + - @addresses.addresses.each do |address| + %li + %a{ :href => "/cimi/addresses/#{href_to_id(address.id)}"}=href_to_id(address.id) + +-details 'AddressCollection details' do + -row 'ID', @addresses.id + -row 'Count', @addresses.count diff --git a/clients/cimi/views/addresses/show.haml b/clients/cimi/views/addresses/show.haml new file mode 100644 index 0000000..b45ce6e --- /dev/null +++ b/clients/cimi/views/addresses/show.haml @@ -0,0 +1,29 @@ +- @title="#{@address.name}" + +- content_for :breadcrumb do + %ul.breadcrumb + %li + %a{ :href => "/cimi/cloudEntryPoint"} CloudEntryPoint + %span.divider="/" + %li + %a{ :href => "/cimi/addresses"} AddressCollection + %span.divider="/" + %li.active + = @address.name + +- content_for :actions do + %p + %a{ :href => "#{@address.id}?format=xml", :class => 'label warning' } XML + %a{ :href => "#{@address.id}?format=json", :class => 'label warning' } JSON + +-details do + -row 'ID', @address.id + -row 'Description',@address.description + -row 'Created',@address.created + -row 'IP',@address.ip + -row 'Host name',@address.hostname + -row 'Allocation',@address.allocation + -row 'Default gateway',@address.default_gateway + -row 'DNS',@address.dns + -row 'Protocol',@address.protocol + -row 'Mask',@address.mask -- 1.7.9.5