fluke/devops-service/db/mongo/models/provider_accounts/openstack_provider_account.rb

51 lines
1.2 KiB
Ruby
Raw Normal View History

2015-10-22 12:39:22 +03:00
require "db/mongo/models/provider_accounts/provider_account"
module Devops
module Model
class OpenstackProviderAccount < ProviderAccount
attr_accessor :username, :auth_url, :tenant, :api_key
2015-11-02 11:42:20 +03:00
def self.account_fields
{
username: "Openstack user name",
auth_url: "Identity API endpoint",
tenant: "Tenant to access",
api_key: "Openstack user password"
}.merge(ProviderAccount::ACCOUNT_FIELDS)
end
2015-10-22 12:39:22 +03:00
def initialize a={}
super(a)
self.provider = Provider::Openstack::PROVIDER
2015-10-22 12:39:22 +03:00
self.username = a["username"]
self.auth_url = a["auth_url"]
self.tenant = a["tenant"]
self.api_key = a["api_key"]
end
def to_list_hash
s = super
s["username"] = self.username
s["auth_url"] = self.auth_url
s["tenant"] = self.tenant
end
def to_mongo_hash
s = super
s["username"] = self.username
s["auth_url"] = self.auth_url
s["tenant"] = self.tenant
s["api_key"] = self.api_key
end
def self.build_from_bson a
a["account_name"] = a["_id"]
OpenstackProviderAccount.new a
end
end
end
end