Gandi API : Create domain error on test environment - ruby-on-rails

I'm actually working on the test environment of Gandi.
I'm using the gandi gem (https://github.com/veilleperso/gandi)
I can connect with my API key etc... but when I want to create a new domain :
domain_spec = {
'owner' => 'FLN123-GANDI',
'admin' => 'FLN123-GANDI',
'bill' => 'FLN123-GANDI',
'tech' => 'FLN123-GANDI',
'nameservers' => ['a.dns.gandi-ote.net', 'b.dns.gandi-ote.net',
'c.dns.gandi-ote.net'],
'duration' => 1
}
#api.domain.create('foo.fr', domain_spec)
I got this message :
Error on object : OBJECT_CONTACT (CAUSE_INVALID) [Your are not the owner of the domain nor a reseller]

You can only create domains in both OTE and production environment which wasn't registered.
The OTE is not an empty sandbox, it's based on the data from production environment.

Related

Can't connect to clustered Azure Redis Cache with redis-rb gem and public access

We've provisioned an Azure Redis Cache server using the Premium tier. The server is clustered, with 2 shards, and the server is configured to allow public access over the public internet through a firewall--allow-listing a set of known IPs.
Deploys of our Rails application two any of these known IPs fail with the error:
Redis::CannotConnectError: Redis client could not connect to any cluster nodes
Here is our Rails config:
# application.rb
if Rails.env.test?
config.cache_store = :redis_cache_store, {
url: config.nines[:redis_url],
expires_in: 90.minutes,
namespace: ENV['TEST_ENV_NUMBER'],
}
else
config.cache_store = :redis_store, {
namespace:ENV['TEST_ENV_NUMBER'],
cluster: [ Rails.application.config.nines[:redis_url] ],
replica: true, # allow reads from replicas
compress: true,
compress_threshold: 1024,
expires_in: 90.minutes
}
end
The config.nines[:redis_url] is set like this: rediss://:<pw>#<cache-name>.redis.cache.windows.net:6380/0
Then, we initialize the Redis connection in code like this:
if Rails.env.test?
::Redis.new :url => redis_url, :db => ENV['REDIS_DB']
else
::Redis.new(cluster: [ "#{redis_url}" ], db: ENV['REDIS_DB'])
end
We're using the redis-rb gem and redis-rails gem.
If anyone can point out what we're doing wrong, please do share!
Thank you User Peter Pan - Stack Overflow. Posting your suggestion as answer to help other community members.
You can try below code:
# Import the redis library for Ruby
require "redis"
# Create a redis client instance for connecting Azure Redis Cache
# At here, for enabling SSL, set the `:ssl` symbol with the
# symbol value `:true`, see https://github.com/redis/redis-rb#ssltls-support
redis = Redis.new(
:host => '<azure redis cache name>.redis.cache.windows.net',
:port => 6380,
:db => <the db index you selected like 10>,
:password => "<access key>",
:ssl => :true)
# Then, set key `foo` with value `bar` and return `OK`
status = redis.set('foo', 'bar')
puts status # => OK
# Get the value of key `foo`
foo = redis.get('foo')
puts foo # => bar
Reference: How to setup Azure Redis cache with Rails - Stack Overflow

paypal gem multiple accounts ruby on rails

I'm using the paypal-sdk-merchant gem. So far I have set one merchant account with this command:
PayPal::SDK.configure(
:mode => "sandbox",
:app_id => "APP-sdfgjkl",
:username => "lprieto-facilitator_api1.hasu.cl",
:password => "Z7XGVDCHBJN",
:signature => "AFcWxV21C7fd0v3bYYYRCpSSRlXDCFVGBHLBRTnmAzXxHddoa5e",
:sandbox_email_address => "lprieto-facilitator_api1.hasu.cl")
and then create a payment with
api = PayPal::SDK::Merchant::API.new
This have work perfectly so far but now I have to change the paypal account according to the country the person is buying from. If I'm constantly changing the PayPal::SDK.configure will there be any consistence problems??
For example, if a person in Brasil access and the configuration is change. Then a person in Chile access and the configuration is change. After, the brasilian pays. Will it have the brasilian configuration or the chilean one?
What would you recommend for having multiple Paypal accounts in a ruby on rails app?
Thank you in advance.
I recommend taking a look at https://github.com/paypal/PayPal-Ruby-SDK because this gem doesn't support rails 4 and will be deprecated.
As for your problem at hand: Seeing the API, you would indeed need to call PayPal::SDK.configure() for each different type of merchant/country. You can create a YML config file for this something like config/paypal.yml:
chile:
mode: sandbox
app_id: APP-123
username: user1
password: pass1
signature: ABCDEF
sandbox_email_address: test#example.com
brasil:
mode: sandbox
app_id: APP-456
username: user2
password: pass2
signature: GHIJKL
sandbox_email_address: test2#example.com
and use this in your app like:
#api_chile = PayPal::SDK::Merchant::API.new(:chile)
#api_brasil = PayPal::SDK::Merchant::API.new(:brasil)
Hope this helps!

How to get host under a host group, By Ruby script

I am able to get the host group id by
puts zbx.hostgroups.get(:name => "Dev" )
give this o/p
{"groupid"=>"13", "name"=>"Dev", "internal"=>"0", "flags"=>"0"}
But I want to get all the nodes under this host group. Although I tried in other way like
get all host under this host group but I didnt find groupid attribute in host please refer below o/p
puts zbx.hosts.get(:host => "ip-10-10-111-11.ec2.internal")
{"maintenances"=>[], "hostid"=>"10251", "proxy_hostid"=>"10109",
"host"=>"ip-10-10-111-11.ec2.internal", "status"=>"0",
"disable_until"=>"0", "error"=>"", "available"=>"1",
"errors_from"=>"0", "lastaccess"=>"0", "ipmi_authtype"=>"0",
"ipmi_privilege"=>"2", "ipmi_username"=>"", "ipmi_password"=>"",
"ipmi_disable_until"=>"0", "ipmi_available"=>"0",
"snmp_disable_until"=>"0", "snmp_available"=>"0",
"maintenanceid"=>"0", "maintenance_status"=>"0",
"maintenance_type"=>"0", "maintenance_from"=>"0",
"ipmi_errors_from"=>"0", "snmp_errors_from"=>"0", "ipmi_error"=>"",
"snmp_error"=>"", "jmx_disable_until"=>"0", "jmx_available"=>"0",
"jmx_errors_from"=>"0", "jmx_error"=>"",
"name"=>"ip-10-10-111-11.ec2.internal", "flags"=>"0", "templateid"=>"0"}
I didnot find any relation between hosts & hostgroups.
I got it working in the below manner
host_grps = zbx.query(
:method => "host.get",
:params => {
"output" => "extend",
"groupids" => [14]
}
)
puts host_grps
Its gives host groups in list of hashmap.
A simple JSON request for method host.get with the following parameters gives me information for all hosts that belong to the specified groups:
{ "output" : "extend", "groupids": [ "4", "12" ] }
Please consult host.get API documentation for more information.

Create a name to a EC2 instance by using AWS API

I have the following code in my app.
require 'aws-sdk'
require 'rubygems'
AWS.config({
:access_key_id => 'XXXXXXXXXXXXXXXXX',
:secret_access_key => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
ec2 = AWS::EC2.new(:ec2_endpoint => 'ec2.ap-southeast-1.amazonaws.com')
##i = ec2.instances.create(:image_id => 'ami-aabXXXXX', :instance_type => 't1.micro', :security_groups=> ['Drum-Factory'], :key_name => 'some-key' )
sleep 1 while ##i.status == :pending
......
How can i name my instance while creating it, so that it will appear in the Name column of my AWS Management Console.
Name column is actually a tag added to the instance
So you need to set the value of "Name" tag
My guess is something like this
##i.tags["Name"] = "value"
or
tag = ec2.tags.create(##i, "Name","Value")
check http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/EC2/TagCollection.html#create-instance_method
also this SO answer might be of help
For AWS, how do you set tags to a resource with the ruby aws-sdk?

Unable to create cookie if it has a domain

My controller has the following code
cookies[:book] = { :value => "Kids Puzzles", :expires => 2.years.from_now, :domain => "foo.com" }
Unable to create cookie if it has a domain which is different than the server in which the application is running. How should I create/delete a cookie in such cases.
You can't do that.
You can set a cookie for example.com within an app running at app.example.com but not for foo.com.

Resources