[PATCH aggregator] initial dbomatic implementation
by Mo Morsi
This patch contains the rough first pass of dbomatic's implementation.
There are various things TBD such as event error handling and making sure
all the correct events are collected with all their metadata but what
is present should be a rough estimate as to the parsing strategy.
To get condor to yield the neccessary info for dbomatic to parse, add the
following to /var/lib/condor/condor_config.local
EVENT_LOG=$(LOG)/EventLog
EVENT_LOG_USE_XML=True
EVENT_LOG_JOB_AD_INFORMATION_ATTRS=Owner,GlobalJobId,Cmd,JobStartDate,JobCurrentStartDate,JobFinishedHookDone
Also be sure to set CONDOR_HOST appropriately (I merely set it to 'localhost' in my case).
A condor restart is required (eg sudo service condor restart) after these changes.
---
src/app/models/instance_event.rb | 30 +++++++
.../20100810221250_create_instance_events.rb | 34 ++++++++
src/dbomatic/dbomatic.rb | 90 ++++++++++++++++++++
3 files changed, 154 insertions(+), 0 deletions(-)
create mode 100644 src/app/models/instance_event.rb
create mode 100644 src/db/migrate/20100810221250_create_instance_events.rb
create mode 100644 src/dbomatic/dbomatic.rb
diff --git a/src/app/models/instance_event.rb b/src/app/models/instance_event.rb
new file mode 100644
index 0000000..cc1eaa0
--- /dev/null
+++ b/src/app/models/instance_event.rb
@@ -0,0 +1,30 @@
+# Copyright (C) 2010 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA. A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+# Filters added to this controller apply to all controllers in the application.
+# Likewise, all the methods added will be available for all controllers.
+
+class InstanceEvent < ActiveRecord::Base
+ belongs_to :instance
+
+ validates_presence_of :instance_id
+ validates_presence_of :event_type
+
+ #validates_inclusion_of :event_type,
+ # :in => TYPES
+
+end
diff --git a/src/db/migrate/20100810221250_create_instance_events.rb b/src/db/migrate/20100810221250_create_instance_events.rb
new file mode 100644
index 0000000..22e5191
--- /dev/null
+++ b/src/db/migrate/20100810221250_create_instance_events.rb
@@ -0,0 +1,34 @@
+# Copyright (C) 2010 Red Hat, Inc.
+# Written by Mohammed Morsi <mmorsi(a)redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA. A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+class CreateInstanceEvents < ActiveRecord::Migration
+ def self.up
+ create_table :instance_events do |t|
+ t.integer :instance_id, :null => false
+ t.string :event_type, :null => false
+ t.datetime :event_time
+ t.string :status
+ t.string :message
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :instance_events
+ end
+end
diff --git a/src/dbomatic/dbomatic.rb b/src/dbomatic/dbomatic.rb
new file mode 100644
index 0000000..8b80c81
--- /dev/null
+++ b/src/dbomatic/dbomatic.rb
@@ -0,0 +1,90 @@
+# Copyright (C) 2010 Red Hat, Inc.
+# Written by Mohammed Morsi <mmorsi(a)redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA. A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+$: << File.join(File.dirname(__FILE__), "../dutils")
+require 'dutils'
+require 'nokogiri'
+
+# Handle the event log's xml
+class CondorEventLog < Nokogiri::XML::SAX::Document
+ attr_accessor :tag, :event_type, :event_cmd, :event_time
+
+ # Store the name of the event log attribute we're looking at
+ def start_element(element, attributes)
+ @tag = attributes[1] if element == "a"
+ end
+
+ # Store the value of the event log attribute we're looking at
+ def characters(string)
+ unless string.strip == ""
+ if @tag == "MyType"
+ @event_type = string
+ elsif @tag == "Cmd"
+ @event_cmd = string
+ elsif @tag == "EventTime"
+ @event_time = string
+ end
+ end
+ end
+
+ # Create a new entry for events which we have all the neccessary data for
+ def end_element(element)
+ if element == "c" && !(a)event_cmd.nil?
+ inst = Instance.find(:first, :conditions => ['condor_job_id = ?', @event_cmd])
+ #puts "Instance event #{inst.name} #{@event_type} #{@event_time}"
+ InstanceEvent.create! :instance => inst,
+ :event_type => @event_type,
+ :event_time => @event_time
+ @tag = @event_type = @event_cmd = @event_time = nil
+ end
+ end
+end
+parser = Nokogiri::XML::SAX::PushParser.new(CondorEventLog.new)
+
+# XXX bit of a hack, condor event log doesn't seem to have a top level element
+# enclosing everything else in the doc (as standards conforming xml must).
+# Create one for parsing purposes.
+parser << "<events>"
+
+# last time the event log was modified
+event_log_timestamp = nil
+
+# last position we've read in the log
+event_log_position = 0
+
+# set true to terminate dbomatic
+terminate = false
+until terminate
+ log_file = File.open("/var/log/condor/EventLog")
+
+ # Condor seems to open / close the event log for every
+ # entry. Simply poll for new data in the log
+ unless log_file.mtime == event_log_timestamp
+ event_log_timestamp = log_file.mtime
+ log_file.pos = event_log_position
+ while c = log_file.getc
+ parser << c.chr
+ end
+ event_log_position = log_file.pos
+ end
+
+ sleep 1
+end
+
+parser << "</events>"
+parser.finish
--
1.7.2
13 years, 9 months
[PATCH aggregator] Commented all gettext codes
by jzigmund@redhat.com
From: Jozef Zigmund <jzigmund(a)redhat.com>
---
deltacloud-aggregator.spec.in | 2 +-
src/Rakefile | 32 ++++++++++++------------
src/app/controllers/application_controller.rb | 2 +-
src/app/models/user_session.rb | 6 ++--
src/config/environment.rb | 4 +-
5 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/deltacloud-aggregator.spec.in b/deltacloud-aggregator.spec.in
index 6baf65e..f8f9508 100644
--- a/deltacloud-aggregator.spec.in
+++ b/deltacloud-aggregator.spec.in
@@ -21,7 +21,7 @@ Requires: ruby >= 1.8.1
Requires: ruby(abi) = 1.8
Requires: rubygem(rails) >= 2.1.1
Requires: rubygem(daemons)
-Requires: rubygem(gettext_rails)
+#Requires: rubygem(gettext_rails)
Requires: rubygem(haml)
Requires: rubygem(nokogiri) >= 1.4.0
Requires: rubygem(will_paginate)
diff --git a/src/Rakefile b/src/Rakefile
index eebf798..b2e972c 100644
--- a/src/Rakefile
+++ b/src/Rakefile
@@ -11,19 +11,19 @@ require 'rake/rdoctask'
require 'tasks/rails'
# Do not require 'gettext/utils' here, it breaks rdoc,
# require it in tasks that actually need it instead
-
-desc "Create mo-files for L10n"
-task :makemo do
- require 'gettext/utils'
- GetText.create_mofiles(true, "po", "locale")
-end
-
-desc "Update pot/po files to match new version."
-task :updatepo do
- require 'gettext/utils'
- MY_APP_TEXT_DOMAIN = "ovirt"
- MY_APP_VERSION = "ovirt 0.0.1"
- GetText.update_pofiles(MY_APP_TEXT_DOMAIN,
- Dir.glob("{app,lib}/**/*.{rb,rhtml}"),
- MY_APP_VERSION)
-end
+#
+#desc "Create mo-files for L10n"
+#task :makemo do
+# require 'gettext/utils'
+# GetText.create_mofiles(true, "po", "locale")
+#end
+#
+#desc "Update pot/po files to match new version."
+#task :updatepo do
+# require 'gettext/utils'
+# MY_APP_TEXT_DOMAIN = "ovirt"
+# MY_APP_VERSION = "ovirt 0.0.1"
+# GetText.update_pofiles(MY_APP_TEXT_DOMAIN,
+# Dir.glob("{app,lib}/**/*.{rb,rhtml}"),
+# MY_APP_VERSION)
+#end
diff --git a/src/app/controllers/application_controller.rb b/src/app/controllers/application_controller.rb
index 0bc3ca7..0aeafe4 100644
--- a/src/app/controllers/application_controller.rb
+++ b/src/app/controllers/application_controller.rb
@@ -27,7 +27,7 @@ class ApplicationController < ActionController::Base
filter_parameter_logging :password, :password_confirmation
helper_method :current_user_session, :current_user
- init_gettext "ovirt"
+ # init_gettext "ovirt"
layout :choose_layout
before_filter :get_nav_items
diff --git a/src/app/models/user_session.rb b/src/app/models/user_session.rb
index b01cd33..02f75c9 100644
--- a/src/app/models/user_session.rb
+++ b/src/app/models/user_session.rb
@@ -23,7 +23,7 @@ class UserSession < Authlogic::Session::Base
# gettext_activerecord defines a gettext method for the activerecord
# Validations module. Authlogic uses these Validations also but does
# not define the gettext method. We define it here instead.
- def gettext(str)
- GetText._(str)
- end
+ #def gettext(str)
+ # GetText._(str)
+ #end
end
diff --git a/src/config/environment.rb b/src/config/environment.rb
index 7863031..7f2c140 100644
--- a/src/config/environment.rb
+++ b/src/config/environment.rb
@@ -41,8 +41,8 @@ Rails::Initializer.run do |config|
# config.gem "bj"
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
# config.gem "aws-s3", :lib => "aws/s3"
- config.gem "gettext", :lib => "gettext_rails"
- config.gem "gettext", :lib => "gettext_activerecord"
+ # config.gem "gettext", :lib => "gettext_rails"
+ # config.gem "gettext", :lib => "gettext_activerecord"
config.gem "authlogic"
config.gem "deltacloud-client", :lib => "deltacloud"
config.gem "haml"
--
1.7.2.1
13 years, 9 months
Support for Pulp repo (rev. 2)
by Jan Provazník
This patch should be applied on top of these pending patches:
Fixed Bug 619838 - display errors when user registration fails
Fixed fetching of instance state
Converts HardwareProfileProperty 'kind' attr to string.
13 years, 9 months
rubygem-cucumber testing
by Jason Guiditta
Michal has been nice enough to package up cucumber for us, but we need a
couple more reviews to get it pushed to stable sooner. If anyone has a
couple minutes, it is as simple as:
yum install rubygem-cucumber --enablerepo updates-testing
You should get version 0.8.5. Then, simply run:
rake cucumber
from the aggregator src/ dir. If it runs tests w/o blowing up, please
submit comment here:
https://admin.fedoraproject.org/updates/rubygem-cucumber-0.8.5-4.fc13
Thanks,
-j
13 years, 9 months
[PATCH aggregator] Support for Pulp repo
by Jan Provazník
From: Jan Provaznik <jprovazn(a)redhat.com>
First shot in supporting Pulp as a package repository. This version enables
groups/packages listing (parsing yum repos directly is still supported).
If you want to run Pulp locally, I suggest to use RPMs, version 0.0.50 (GIT
version doesn't work well now - repository sync fails, but this could be fixed
in a short time).
By default, Pulp repos are exposed as standard yum repos in /var/www/pub dir so
these repos can be used by image builder too.
---
src/app/util/image_descriptor_xml.rb | 9 +-
src/app/util/repository_manager.rb | 157 ++++----------------
.../util/repository_manager/abstract_repository.rb | 9 +
.../util/repository_manager/comps_repository.rb | 116 +++++++++++++++
src/app/util/repository_manager/pulp_repository.rb | 62 ++++++++
src/app/views/templates/software.haml | 2 +-
.../image_descriptor_package_repositories.yml | 21 ++-
7 files changed, 232 insertions(+), 144 deletions(-)
create mode 100644 src/app/util/repository_manager/abstract_repository.rb
create mode 100644 src/app/util/repository_manager/comps_repository.rb
create mode 100644 src/app/util/repository_manager/pulp_repository.rb
diff --git a/src/app/util/image_descriptor_xml.rb b/src/app/util/image_descriptor_xml.rb
index d9b8348..2100109 100644
--- a/src/app/util/image_descriptor_xml.rb
+++ b/src/app/util/image_descriptor_xml.rb
@@ -216,9 +216,9 @@ class ImageDescriptorXML
rnode = get_or_create_node('repo', repo_node)
rnode.content = repconf['baseurl']
- repository_manager.repositories.each do |rname, repo|
+ repository_manager.repositories.each do |repo|
rnode = get_or_create_node('repo', repo_node)
- rnode.content = repo['baseurl']
+ rnode.content = repo.baseurl
end
end
@@ -246,9 +246,6 @@ class ImageDescriptorXML
end
def repository_manager
- unless @repository_manager
- @repository_manager = RepositoryManager.new
- end
- return @repository_manager
+ @repository_manager ||= RepositoryManager.new
end
end
diff --git a/src/app/util/repository_manager.rb b/src/app/util/repository_manager.rb
index 05cc5da..9d4baa3 100644
--- a/src/app/util/repository_manager.rb
+++ b/src/app/util/repository_manager.rb
@@ -17,145 +17,24 @@
# MA 02110-1301, USA. A copy of the GNU General Public License is
# also available at http://www.gnu.org/copyleft/gpl.html.
-require 'open-uri'
require 'yaml'
+require 'util/repository_manager/comps_repository'
+require 'util/repository_manager/pulp_repository'
class RepositoryManager
- class CompsRepository
- def initialize(baseurl, id)
- @id = id
- @baseurl = baseurl
- end
-
- def get_packages
- packages = []
- get_packages_nodes.each do |node|
- name = node.at_xpath('./xmlns:name/child::text()')
- group = node.at_xpath('./xmlns:format/rpm:group/child::text()')
- description = node.at_xpath('./xmlns:description/child::text()')
- next unless name and group
- packages << {
- :repository_id => @id,
- :name => name.text,
- :group => group.text,
- :description => description ? description.text : '',
- }
- end
- return packages
- end
-
- def get_groups
- groups = {}
- get_groups_nodes.each do |g|
- pkgs = get_group_packages(g)
- next if pkgs.empty?
- name = g.at_xpath('name').text
- groups[name] = {
- :name => name,
- :description => (t = g.at_xpath('description')) ? t.text : '',
- :packages => pkgs,
- }
- end
- return groups
- end
-
- def download_xml(type)
- begin
- url = get_url(type)
- rescue
- return ''
- end
-
- xml_data = open(url)
- if url =~ /\.gz$/
- return Zlib::GzipReader.new(xml_data).read
- else
- return xml_data.read
- end
- end
-
- private
-
- def get_xml(type)
- # FIXME: I'm not sure config is right dir for automatic storing of
- # xml files, but this should be temporary solution until Image Repo is
- # done
- xml_dir = "#{RAILS_ROOT}/config/image_descriptor_xmls"
- xml_file = "#{xml_dir}/#{(a)id}.#{type}.xml"
- begin
- return File.open(xml_file) { |f| f.read }
- rescue
- xml = download_xml(type)
- Dir.mkdir(xml_dir) unless File.directory?(xml_dir)
- File.open(xml_file, 'w') { |f| f.write xml }
- return xml
- end
- end
-
- def get_group_packages(group_node)
- pkgs = {}
- group_node.xpath('packagelist/packagereq').each do |p|
- pkgs[p.text] = p.attr('type')
- end
- return pkgs
- end
-
- def get_packages_nodes
- unless @packages_nodes
- data = get_xml('primary')
- xml = Nokogiri::XML(data)
- @packages_nodes = xml.xpath('/xmlns:metadata/xmlns:package')
- end
- return @packages_nodes
- end
-
- def get_groups_nodes
- unless @groups_nodes
- data = get_xml('group')
- xml = Nokogiri::XML(data)
- @groups_nodes = xml.xpath('/comps/group')
- end
- return @groups_nodes
- end
-
- def get_url(type)
- if type == 'repomd'
- return File.join(@baseurl, 'repodata', 'repomd.xml')
- else
- location = repomd.xpath("/xmlns:repomd/xmlns:data[@type=\"#{type}\"]/xmlns:location").first
- raise "location for #{type} data not found" unless location
- return File.join(@baseurl, location['href'])
- end
- end
-
- def repomd
- unless @repomd
- @repomd = Nokogiri::XML(get_xml('repomd'))
- end
- return @repomd
- end
- end
+ attr_reader :repositories
def initialize
@config = YAML.load_file("#{RAILS_ROOT}/config/image_descriptor_package_repositories.yml")
- end
-
- def get_repository(repository_id)
- repo = @config[repository_id]
- raise "Repository '#{repository_id}' doesn't exist" unless repo
- return CompsRepository.new(repo['baseurl'], repository_id)
- end
-
- def repositories
- return @config
+ @repositories = get_repositories
end
def all_groups(repository = nil)
unless @all_groups
@all_groups = {}
- repositories.keys.each do |r|
- next if repository and repository != 'all' and repository != r
- get_repository(r).get_groups.each do |group, data|
+ repositories.each do |r|
+ next if repository and repository != 'all' and repository != r.id
+ r.groups.each do |group, data|
if @all_groups[group]
@all_groups[group][:packages].merge!(data[:packages])
else
@@ -170,11 +49,27 @@ class RepositoryManager
def all_packages(repository = nil)
unless @all_packages
@all_packages = []
- repositories.keys.each do |r|
- next if repository and repository != 'all' and repository != r
- @all_packages += get_repository(r).get_packages
+ repositories.each do |r|
+ next if repository and repository != 'all' and repository != r.id
+ @all_packages += r.packages
end
end
return @all_packages
end
+
+ private
+
+ def get_repositories
+ repositories = []
+ if @config
+ @config.each do |rep|
+ if rep['type'] == 'xml'
+ repositories << CompsRepository.new(rep)
+ elsif rep['type'] == 'pulp'
+ repositories += PulpRepository.repositories(rep)
+ end
+ end
+ end
+ return repositories
+ end
end
diff --git a/src/app/util/repository_manager/abstract_repository.rb b/src/app/util/repository_manager/abstract_repository.rb
new file mode 100644
index 0000000..ab35d04
--- /dev/null
+++ b/src/app/util/repository_manager/abstract_repository.rb
@@ -0,0 +1,9 @@
+class AbstractRepository
+ attr_reader :id, :name, :baseurl
+
+ def initialize(conf)
+ @id = conf['id']
+ @name = conf['name']
+ @baseurl = conf['baseurl']
+ end
+end
diff --git a/src/app/util/repository_manager/comps_repository.rb b/src/app/util/repository_manager/comps_repository.rb
new file mode 100644
index 0000000..d7e192a
--- /dev/null
+++ b/src/app/util/repository_manager/comps_repository.rb
@@ -0,0 +1,116 @@
+require 'util/repository_manager/abstract_repository'
+require 'open-uri'
+
+class CompsRepository < AbstractRepository
+ def initialize(conf)
+ super
+ @baseurl = conf['baseurl']
+ end
+
+ def packages
+ packages = []
+ get_packages_nodes.each do |node|
+ name = node.at_xpath('./xmlns:name/child::text()')
+ group = node.at_xpath('./xmlns:format/rpm:group/child::text()')
+ description = node.at_xpath('./xmlns:description/child::text()')
+ next unless name and group
+ packages << {
+ :repository_id => @id,
+ :name => name.text,
+ :description => description ? description.text : '',
+ }
+ end
+ return packages
+ end
+
+ def groups
+ groups = {}
+ get_groups_nodes.each do |g|
+ pkgs = get_group_packages(g)
+ next if pkgs.empty?
+ name = g.at_xpath('name').text
+ groups[name] = {
+ :name => name,
+ :description => (t = g.at_xpath('description')) ? t.text : '',
+ :packages => pkgs,
+ }
+ end
+ return groups
+ end
+
+ def download_xml(type)
+ begin
+ url = get_url(type)
+ rescue
+ return ''
+ end
+
+ xml_data = open(url)
+ if url =~ /\.gz$/
+ return Zlib::GzipReader.new(xml_data).read
+ else
+ return xml_data.read
+ end
+ end
+
+ private
+
+ def get_xml(type)
+ # FIXME: I'm not sure config is right dir for automatic storing of
+ # xml files, but this should be temporary solution until Image Repo is
+ # done
+ xml_dir = "#{RAILS_ROOT}/config/image_descriptor_xmls"
+ xml_file = "#{xml_dir}/#{(a)id}.#{type}.xml"
+ begin
+ return File.open(xml_file) { |f| f.read }
+ rescue
+ xml = download_xml(type)
+ Dir.mkdir(xml_dir) unless File.directory?(xml_dir)
+ File.open(xml_file, 'w') { |f| f.write xml }
+ return xml
+ end
+ end
+
+ def get_group_packages(group_node)
+ pkgs = {}
+ group_node.xpath('packagelist/packagereq').each do |p|
+ pkgs[p.text] = p.attr('type')
+ end
+ return pkgs
+ end
+
+ def get_packages_nodes
+ unless @packages_nodes
+ data = get_xml('primary')
+ xml = Nokogiri::XML(data)
+ @packages_nodes = xml.xpath('/xmlns:metadata/xmlns:package')
+ end
+ return @packages_nodes
+ end
+
+ def get_groups_nodes
+ unless @groups_nodes
+ data = get_xml('group')
+ xml = Nokogiri::XML(data)
+ @groups_nodes = xml.xpath('/comps/group')
+ end
+ return @groups_nodes
+ end
+
+ def get_url(type)
+ if type == 'repomd'
+ return File.join(@baseurl, 'repodata', 'repomd.xml')
+ else
+ location = repomd.xpath("/xmlns:repomd/xmlns:data[@type=\"#{type}\"]/xmlns:location").first
+ raise "location for #{type} data not found" unless location
+ return File.join(@baseurl, location['href'])
+ end
+ end
+
+ def repomd
+ unless @repomd
+ @repomd = Nokogiri::XML(get_xml('repomd'))
+ end
+ return @repomd
+ end
+end
diff --git a/src/app/util/repository_manager/pulp_repository.rb b/src/app/util/repository_manager/pulp_repository.rb
new file mode 100644
index 0000000..ee9840f
--- /dev/null
+++ b/src/app/util/repository_manager/pulp_repository.rb
@@ -0,0 +1,62 @@
+require 'restclient'
+require 'json'
+require 'util/repository_manager/abstract_repository'
+
+class PulpRepository < AbstractRepository
+ class WrappedRestClient
+ def self.method_missing(method, *args)
+ begin
+ JSON.parse(RestClient.send(method, *args))
+ rescue Errno::ECONNREFUSED
+ raise "pulp repository: connection failed (#{args.first})"
+ rescue RestClient::ResourceNotFound
+ raise "pulp repository: resource not found (#{args.first})"
+ rescue JSON::ParserError
+ raise "pulp repository: failed to parse response (#{args.first})"
+ end
+ end
+ end
+
+ def self.repositories(conf)
+ WrappedRestClient.get("#{conf['baseurl']}/repositories/").map do |r|
+ next if conf['except'] and conf['except'].include?(r['id'])
+ PulpRepository.new(r.merge('baseurl' => conf['baseurl']))
+ end.compact
+ end
+
+ def initialize(conf)
+ super
+ @packages_url = @baseurl + conf['packages']
+ @groups_url = @baseurl + conf['packagegroups']
+ end
+
+ def packages
+ packages = []
+ WrappedRestClient.get((a)packages_url).each_value do |info|
+ packages << {
+ :repository_id => @id,
+ :name => info['name'],
+ :description => info['description'],
+ }
+ end
+ return packages
+ end
+
+ def groups
+ groups = {}
+ WrappedRestClient.get(@groups_url, {}).each do |id, info|
+ pkgs = {}
+ info['default_package_names'].each {|p| pkgs[p] = 'default'}
+ info['optional_package_names'].each {|p| pkgs[p] = 'optional'}
+ info['mandatory_package_names'].each {|p| pkgs[p] = 'mandatory'}
+ next if pkgs.empty?
+ name = info['name']
+ groups[name] = {
+ :name => name,
+ :description => info['description'].to_s,
+ :packages => pkgs,
+ }
+ end
+ return groups
+ end
+end
diff --git a/src/app/views/templates/software.haml b/src/app/views/templates/software.haml
index 998ce9b..9d11b5e 100644
--- a/src/app/views/templates/software.haml
+++ b/src/app/views/templates/software.haml
@@ -82,7 +82,7 @@
%li{ :class => "#{selection_style} ui-state-default ui-corner-top", :style => 'clear: none' }
= "<a href=\"#{url_for(:action => "software", :id => @image_descriptor, :tab => item[:tab])}\"><span>#{item[:text]}</span></a>"
%li{ :class => "select_repository"}
- = select_tag("repository", ["<option value='all' selected='selected'>All</option>"] + @repository_manager.repositories.map{|repid, rep| "<option value=\"#{repid}\">#{rep['name']}</option>"}, {:onchange => "get_repository(event)"})
+ = select_tag("repository", ["<option value='all' selected='selected'>All</option>"] + @repository_manager.repositories.map{|rep| "<option value=\"#{rep.id}\">#{rep.name}</option>"}, {:onchange => "get_repository(event)"})
- unless request.xhr?
= render :partial => @selected_tab
.pkglist{:style => "margin-left: 30px", :class => "left-pkglist"}
diff --git a/src/config/image_descriptor_package_repositories.yml b/src/config/image_descriptor_package_repositories.yml
index 40335ea..42f2d8e 100644
--- a/src/config/image_descriptor_package_repositories.yml
+++ b/src/config/image_descriptor_package_repositories.yml
@@ -1,6 +1,15 @@
-fedora:
- name: Fedora
- baseurl: http://download.fedoraproject.org/pub/fedora/linux/releases/11/Everything...
-jboss:
- name: JBoss
- baseurl: http://repo.oddthesis.org/cirras/packages/fedora/11/RPMS/noarch/
+#-
+# id: fedora
+# name: Fedora
+# baseurl: http://download.fedoraproject.org/pub/fedora/linux/releases/11/Everything...
+# type: xml
+#
+#-
+# id: jboss
+# name: JBoss
+# baseurl: http://repo.oddthesis.org/cirras/packages/fedora/11/RPMS/noarch/
+# type: xml
+#
+-
+ baseurl: https://admin:admin@localhost:8811/
+ type: pulp
--
1.7.0.1
13 years, 9 months
[PATCH aggregator] Removed cloud type field from new provider form
by Jan Provazník
From: Jan Provaznik <jprovazn(a)redhat.com>
Cloud type is fetched from backend driver before save.
---
src/app/controllers/provider_controller.rb | 7 ++++---
src/app/models/provider.rb | 4 ++++
src/app/views/provider/_form.html.erb | 3 +--
3 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/app/controllers/provider_controller.rb b/src/app/controllers/provider_controller.rb
index 59c9393..7422c95 100644
--- a/src/app/controllers/provider_controller.rb
+++ b/src/app/controllers/provider_controller.rb
@@ -35,9 +35,10 @@ class ProviderController < ApplicationController
def new
require_privilege(Privilege::PROVIDER_MODIFY)
@provider = Provider.new(params[:provider])
- if request.post? && @provider.save && @provider.populate_hardware_profiles
- flash[:notice] = "Provider added."
- redirect_to :action => "show", :id => @provider
+ if request.post? && @provider.set_cloud_type &&
+ @provider.save && @provider.populate_hardware_profiles
+ flash[:notice] = "Provider added."
+ redirect_to :action => "show", :id => @provider
end
condormatic_classads_sync
end
diff --git a/src/app/models/provider.rb b/src/app/models/provider.rb
index e439520..ae8e98f 100644
--- a/src/app/models/provider.rb
+++ b/src/app/models/provider.rb
@@ -38,6 +38,10 @@ class Provider < ActiveRecord::Base
:include => [:role],
:order => "permissions.id ASC"
+ def set_cloud_type
+ self.cloud_type = connect.driver_name
+ end
+
def connect
begin
return DeltaCloud.new(nil, nil, url)
diff --git a/src/app/views/provider/_form.html.erb b/src/app/views/provider/_form.html.erb
index 9b4735f..6058894 100644
--- a/src/app/views/provider/_form.html.erb
+++ b/src/app/views/provider/_form.html.erb
@@ -5,9 +5,8 @@
<% form_tag :controller => :provider, :action => 'new' do %>
<ul>
<li><label>Name<span>Provide a descriptive name for this provider connection.</span></label><%= text_field :provider, :name, :class => "txtfield" %></li>
- <li><label>Type<span>Choose the type of provider connection.</span></label><%= select :provider, :cloud_type, [["Mock","Mock"],["EC2", "EC2"],["RHEV-M", "RHEV-M"]], :class => "txtfield" %></li>
<li><label>URL<span>Enter the URL of the cloud provider.</span></label><%= text_field:provider, :url, :class => "txtfield" %></li>
</ul>
<%= submit_tag "Save", :class => "submit" %>
<% end %>
-</div>
\ No newline at end of file
+</div>
--
1.7.0.1
13 years, 9 months
[PATCH 1/1] Add Gemfile for possible use with Bundler.
by Ladislav Martincik
---
server/Gemfile | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
create mode 100644 server/Gemfile
diff --git a/server/Gemfile b/server/Gemfile
new file mode 100644
index 0000000..102d895
--- /dev/null
+++ b/server/Gemfile
@@ -0,0 +1,21 @@
+source "http://rubygems.org"
+
+gem "rake"
+gem "eventmachine"
+gem "haml"
+gem "sinatra"
+gem "rack"
+gem "thin"
+gem "rerun"
+gem "json"
+gem "open_gem"
+
+group :test do
+ gem 'ruby-debug'
+ gem "compass"
+ gem "nokogiri"
+ gem "rack-test"
+ gem "cucumber"
+ gem "rcov"
+ gem "rspec"
+end
--
1.6.6.1
13 years, 9 months