fog 1.32.0 → 1.33.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +59 -0
- data/Gemfile +1 -0
- data/Rakefile +4 -4
- data/fog.gemspec +3 -2
- data/lib/fog/linode/requests/compute/avail_datacenters.rb +8 -7
- data/lib/fog/openstack.rb +1 -0
- data/lib/fog/openstack/compute.rb +7 -1
- data/lib/fog/openstack/core.rb +28 -54
- data/lib/fog/openstack/identity.rb +1 -0
- data/lib/fog/openstack/identity_v3.rb +10 -9
- data/lib/fog/openstack/models/baremetal/chassis.rb +3 -14
- data/lib/fog/openstack/models/baremetal/chassis_collection.rb +5 -5
- data/lib/fog/openstack/models/baremetal/driver.rb +2 -8
- data/lib/fog/openstack/models/baremetal/drivers.rb +3 -5
- data/lib/fog/openstack/models/baremetal/node.rb +3 -14
- data/lib/fog/openstack/models/baremetal/nodes.rb +4 -4
- data/lib/fog/openstack/models/baremetal/port.rb +3 -14
- data/lib/fog/openstack/models/baremetal/ports.rb +4 -4
- data/lib/fog/openstack/models/collection.rb +45 -0
- data/lib/fog/openstack/models/compute/address.rb +2 -2
- data/lib/fog/openstack/models/compute/addresses.rb +3 -5
- data/lib/fog/openstack/models/compute/aggregate.rb +2 -8
- data/lib/fog/openstack/models/compute/aggregates.rb +3 -5
- data/lib/fog/openstack/models/compute/availability_zone.rb +14 -0
- data/lib/fog/openstack/models/compute/availability_zones.rb +22 -0
- data/lib/fog/openstack/models/compute/flavor.rb +2 -8
- data/lib/fog/openstack/models/compute/flavors.rb +6 -6
- data/lib/fog/openstack/models/compute/host.rb +1 -1
- data/lib/fog/openstack/models/compute/hosts.rb +4 -6
- data/lib/fog/openstack/models/compute/image.rb +2 -8
- data/lib/fog/openstack/models/compute/images.rb +4 -6
- data/lib/fog/openstack/models/compute/key_pair.rb +2 -2
- data/lib/fog/openstack/models/compute/key_pairs.rb +3 -4
- data/lib/fog/openstack/models/compute/metadata.rb +3 -2
- data/lib/fog/openstack/models/compute/metadatum.rb +2 -2
- data/lib/fog/openstack/models/compute/network.rb +2 -2
- data/lib/fog/openstack/models/compute/networks.rb +3 -2
- data/lib/fog/openstack/models/compute/security_group.rb +2 -2
- data/lib/fog/openstack/models/compute/security_group_rule.rb +2 -2
- data/lib/fog/openstack/models/compute/security_group_rules.rb +2 -2
- data/lib/fog/openstack/models/compute/security_groups.rb +3 -5
- data/lib/fog/openstack/models/compute/server.rb +20 -1
- data/lib/fog/openstack/models/compute/servers.rb +9 -5
- data/lib/fog/openstack/models/compute/service.rb +2 -8
- data/lib/fog/openstack/models/compute/services.rb +4 -4
- data/lib/fog/openstack/models/compute/snapshot.rb +2 -8
- data/lib/fog/openstack/models/compute/snapshots.rb +5 -5
- data/lib/fog/openstack/models/compute/tenant.rb +2 -2
- data/lib/fog/openstack/models/compute/tenants.rb +3 -4
- data/lib/fog/openstack/models/compute/volume.rb +2 -8
- data/lib/fog/openstack/models/compute/volumes.rb +5 -5
- data/lib/fog/openstack/models/identity_v2/ec2_credential.rb +3 -9
- data/lib/fog/openstack/models/identity_v2/ec2_credentials.rb +3 -5
- data/lib/fog/openstack/models/identity_v2/role.rb +3 -3
- data/lib/fog/openstack/models/identity_v2/roles.rb +3 -5
- data/lib/fog/openstack/models/identity_v2/tenant.rb +5 -9
- data/lib/fog/openstack/models/identity_v2/tenants.rb +3 -5
- data/lib/fog/openstack/models/identity_v2/user.rb +2 -8
- data/lib/fog/openstack/models/identity_v2/users.rb +3 -5
- data/lib/fog/openstack/models/identity_v3/domain.rb +5 -9
- data/lib/fog/openstack/models/identity_v3/domains.rb +3 -5
- data/lib/fog/openstack/models/identity_v3/endpoint.rb +5 -9
- data/lib/fog/openstack/models/identity_v3/endpoints.rb +3 -5
- data/lib/fog/openstack/models/identity_v3/group.rb +5 -9
- data/lib/fog/openstack/models/identity_v3/groups.rb +3 -5
- data/lib/fog/openstack/models/identity_v3/os_credential.rb +3 -3
- data/lib/fog/openstack/models/identity_v3/os_credentials.rb +3 -5
- data/lib/fog/openstack/models/identity_v3/policies.rb +3 -5
- data/lib/fog/openstack/models/identity_v3/policy.rb +5 -9
- data/lib/fog/openstack/models/identity_v3/project.rb +5 -8
- data/lib/fog/openstack/models/identity_v3/projects.rb +21 -10
- data/lib/fog/openstack/models/identity_v3/role.rb +3 -8
- data/lib/fog/openstack/models/identity_v3/role_assignment.rb +3 -3
- data/lib/fog/openstack/models/identity_v3/role_assignments.rb +3 -5
- data/lib/fog/openstack/models/identity_v3/roles.rb +3 -5
- data/lib/fog/openstack/models/identity_v3/service.rb +3 -3
- data/lib/fog/openstack/models/identity_v3/services.rb +3 -5
- data/lib/fog/openstack/models/identity_v3/token.rb +3 -3
- data/lib/fog/openstack/models/identity_v3/tokens.rb +3 -3
- data/lib/fog/openstack/models/identity_v3/user.rb +3 -9
- data/lib/fog/openstack/models/identity_v3/users.rb +3 -5
- data/lib/fog/openstack/models/image/image.rb +2 -13
- data/lib/fog/openstack/models/image/images.rb +5 -5
- data/lib/fog/openstack/models/metering/resource.rb +2 -7
- data/lib/fog/openstack/models/metering/resources.rb +3 -3
- data/lib/fog/openstack/models/model.rb +44 -0
- data/lib/fog/openstack/models/network/floating_ip.rb +2 -7
- data/lib/fog/openstack/models/network/floating_ips.rb +3 -5
- data/lib/fog/openstack/models/network/lb_health_monitor.rb +2 -12
- data/lib/fog/openstack/models/network/lb_health_monitors.rb +3 -5
- data/lib/fog/openstack/models/network/lb_member.rb +2 -12
- data/lib/fog/openstack/models/network/lb_members.rb +3 -5
- data/lib/fog/openstack/models/network/lb_pool.rb +2 -12
- data/lib/fog/openstack/models/network/lb_pools.rb +3 -5
- data/lib/fog/openstack/models/network/lb_vip.rb +2 -12
- data/lib/fog/openstack/models/network/lb_vips.rb +3 -5
- data/lib/fog/openstack/models/network/network.rb +2 -12
- data/lib/fog/openstack/models/network/networks.rb +3 -5
- data/lib/fog/openstack/models/network/port.rb +2 -13
- data/lib/fog/openstack/models/network/ports.rb +3 -5
- data/lib/fog/openstack/models/network/router.rb +2 -13
- data/lib/fog/openstack/models/network/routers.rb +3 -5
- data/lib/fog/openstack/models/network/security_group.rb +2 -2
- data/lib/fog/openstack/models/network/security_group_rule.rb +2 -2
- data/lib/fog/openstack/models/network/security_group_rules.rb +3 -5
- data/lib/fog/openstack/models/network/security_groups.rb +3 -5
- data/lib/fog/openstack/models/network/subnet.rb +3 -14
- data/lib/fog/openstack/models/network/subnets.rb +3 -5
- data/lib/fog/openstack/models/orchestration/event.rb +2 -2
- data/lib/fog/openstack/models/orchestration/events.rb +5 -7
- data/lib/fog/openstack/models/orchestration/resource.rb +2 -2
- data/lib/fog/openstack/models/orchestration/resource_schemas.rb +2 -2
- data/lib/fog/openstack/models/orchestration/resources.rb +3 -5
- data/lib/fog/openstack/models/orchestration/stack.rb +3 -7
- data/lib/fog/openstack/models/orchestration/stacks.rb +5 -5
- data/lib/fog/openstack/models/orchestration/template.rb +2 -2
- data/lib/fog/openstack/models/orchestration/templates.rb +1 -1
- data/lib/fog/openstack/models/planning/plan.rb +2 -13
- data/lib/fog/openstack/models/planning/plans.rb +3 -5
- data/lib/fog/openstack/models/planning/role.rb +2 -8
- data/lib/fog/openstack/models/planning/roles.rb +3 -6
- data/lib/fog/openstack/models/storage/directories.rb +4 -6
- data/lib/fog/openstack/models/storage/directory.rb +2 -2
- data/lib/fog/openstack/models/storage/file.rb +15 -2
- data/lib/fog/openstack/models/storage/files.rb +7 -8
- data/lib/fog/openstack/models/volume/availability_zone.rb +13 -0
- data/lib/fog/openstack/models/volume/availability_zones.rb +17 -0
- data/lib/fog/openstack/models/volume/transfer.rb +36 -0
- data/lib/fog/openstack/models/volume/transfers.rb +38 -0
- data/lib/fog/openstack/models/volume/volume.rb +9 -8
- data/lib/fog/openstack/models/volume/volume_type.rb +2 -8
- data/lib/fog/openstack/models/volume/volume_types.rb +3 -6
- data/lib/fog/openstack/models/volume/volumes.rb +5 -6
- data/lib/fog/openstack/requests/compute/list_servers.rb +8 -5
- data/lib/fog/openstack/requests/compute/list_servers_detail.rb +9 -6
- data/lib/fog/openstack/requests/compute/list_zones.rb +6 -5
- data/lib/fog/openstack/requests/compute/list_zones_detailed.rb +55 -0
- data/lib/fog/openstack/requests/compute/shelve_offload_server.rb +24 -0
- data/lib/fog/openstack/requests/compute/shelve_server.rb +24 -0
- data/lib/fog/openstack/requests/compute/unshelve_server.rb +24 -0
- data/lib/fog/openstack/requests/identity_v3/get_project.rb +2 -2
- data/lib/fog/openstack/requests/network/create_subnet.rb +1 -1
- data/lib/fog/openstack/requests/network/update_subnet.rb +8 -7
- data/lib/fog/openstack/requests/volume/accept_transfer.rb +24 -0
- data/lib/fog/openstack/requests/volume/create_transfer.rb +27 -0
- data/lib/fog/openstack/requests/volume/delete_transfer.rb +17 -0
- data/lib/fog/openstack/requests/volume/extend_volume.rb +25 -0
- data/lib/fog/openstack/requests/volume/get_transfer_details.rb +17 -0
- data/lib/fog/openstack/requests/volume/list_transfers.rb +18 -0
- data/lib/fog/openstack/requests/volume/list_transfers_detailed.rb +18 -0
- data/lib/fog/openstack/requests/volume/list_zones.rb +32 -0
- data/lib/fog/openstack/storage.rb +3 -1
- data/lib/fog/openstack/volume.rb +16 -0
- data/lib/fog/rackspace/examples/compute_v2/create_network.rb +1 -1
- data/lib/fog/vcloud_director/generators/compute/edge_gateway_service_configuration.rb +31 -30
- data/lib/fog/vcloud_director/models/compute/task.rb +2 -2
- data/lib/fog/version.rb +1 -1
- data/lib/fog/vsphere/compute.rb +1 -0
- data/lib/fog/vsphere/requests/compute/get_resource_pool.rb +1 -1
- data/lib/fog/vsphere/requests/compute/get_virtual_machine.rb +4 -3
- data/lib/fog/vsphere/requests/compute/list_clusters.rb +1 -1
- data/lib/fog/vsphere/requests/compute/list_vm_interfaces.rb +2 -2
- data/lib/fog/vsphere/requests/compute/vm_clone.rb +101 -30
- data/lib/fog/vsphere/requests/compute/vm_execute.rb +47 -0
- data/lib/tasks/changelog_task.rb +1 -0
- data/spec/fog/openstack/identity_v3/{idv3.yml → common_setup.yml} +0 -0
- data/spec/fog/openstack/identity_v3/idv3_project_hier_crud_list.yml +1394 -0
- data/spec/fog/openstack/identity_v3_spec.rb +255 -196
- data/spec/fog/openstack/network/common_setup.yml +131 -0
- data/spec/fog/openstack/network/subnets_crud.yml +140 -0
- data/spec/fog/openstack/network_spec.rb +43 -0
- data/spec/fog/openstack/shared_context.rb +98 -0
- data/spec/fog/openstack/volume/{volume_common_setup.yml → common_setup.yml} +0 -0
- data/spec/fog/openstack/volume/volume_extend.yml +762 -0
- data/spec/fog/openstack/volume/volume_transfer_and_accept.yml +1078 -0
- data/spec/fog/openstack/volume/volume_transfer_and_delete.yml +695 -0
- data/spec/fog/openstack/volume_spec.rb +232 -67
- data/tests/openstack/models/storage/file_tests.rb +26 -0
- data/tests/openstack/requests/compute/availability_zone_tests.rb +18 -0
- data/tests/openstack/requests/compute/server_tests.rb +12 -0
- data/tests/openstack/requests/network/subnet_tests.rb +2 -2
- data/tests/openstack/requests/volume/availability_zone_tests.rb +13 -0
- data/tests/vcloud_director/requests/compute/edge_gateway_tests.rb +2 -2
- metadata +61 -26
- data/lib/fog/dynect.rb +0 -1
- data/lib/fog/dynect/core.rb +0 -26
- data/lib/fog/dynect/dns.rb +0 -157
- data/lib/fog/dynect/models/dns/record.rb +0 -67
- data/lib/fog/dynect/models/dns/records.rb +0 -48
- data/lib/fog/dynect/models/dns/zone.rb +0 -56
- data/lib/fog/dynect/models/dns/zones.rb +0 -25
- data/lib/fog/dynect/requests/dns/delete_record.rb +0 -55
- data/lib/fog/dynect/requests/dns/delete_zone.rb +0 -41
- data/lib/fog/dynect/requests/dns/get_all_records.rb +0 -56
- data/lib/fog/dynect/requests/dns/get_node_list.rb +0 -55
- data/lib/fog/dynect/requests/dns/get_record.rb +0 -83
- data/lib/fog/dynect/requests/dns/get_zone.rb +0 -57
- data/lib/fog/dynect/requests/dns/post_record.rb +0 -71
- data/lib/fog/dynect/requests/dns/post_session.rb +0 -43
- data/lib/fog/dynect/requests/dns/post_zone.rb +0 -70
- data/lib/fog/dynect/requests/dns/put_record.rb +0 -76
- data/lib/fog/dynect/requests/dns/put_zone.rb +0 -76
- data/tests/dynect/requests/dns/dns_tests.rb +0 -258
@@ -1,71 +0,0 @@
|
|
1
|
-
module Fog
|
2
|
-
module DNS
|
3
|
-
class Dynect
|
4
|
-
class Real
|
5
|
-
# Create a record
|
6
|
-
#
|
7
|
-
# ==== Parameters
|
8
|
-
# * type<~String> - type of record in ['AAAA', 'ANY', 'A', 'CNAME', 'DHCID', 'DNAME', 'DNSKEY', 'DS', 'KEY', 'LOC', 'MX', 'NSA', 'NS', 'PTR', 'PX', 'RP', 'SOA', 'SPF', 'SRV', 'SSHFP', 'TXT']
|
9
|
-
# * zone<~String> - zone of record
|
10
|
-
# * rdata<~Hash> - rdata for record
|
11
|
-
# * options<~Hash>: (options vary by type, listing below includes common parameters)
|
12
|
-
# * ttl<~Integer> - ttl for the record, defaults to zone ttl
|
13
|
-
|
14
|
-
def post_record(type, zone, fqdn, rdata, options = {})
|
15
|
-
options.merge!('rdata' => rdata)
|
16
|
-
request(
|
17
|
-
:body => Fog::JSON.encode(options),
|
18
|
-
:expects => 200,
|
19
|
-
:method => :post,
|
20
|
-
:path => ["#{type.to_s.upcase}Record", zone, fqdn].join('/')
|
21
|
-
)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
class Mock
|
26
|
-
def post_record(type, zone, fqdn, rdata, options = {})
|
27
|
-
raise Fog::DNS::Dynect::NotFound unless zone = self.data[:zones][zone]
|
28
|
-
|
29
|
-
records = zone[:records]
|
30
|
-
record_id = zone[:next_record_id]
|
31
|
-
zone[:next_record_id] += 1
|
32
|
-
|
33
|
-
record = {
|
34
|
-
:type => type,
|
35
|
-
:zone => zone,
|
36
|
-
:fqdn => fqdn,
|
37
|
-
:rdata => rdata,
|
38
|
-
:ttl => options[:ttl] || zone[:ttl],
|
39
|
-
:record_id => record_id
|
40
|
-
}
|
41
|
-
|
42
|
-
records[type] << record
|
43
|
-
|
44
|
-
response = Excon::Response.new
|
45
|
-
response.status = 200
|
46
|
-
|
47
|
-
response.body = {
|
48
|
-
"status" => "success",
|
49
|
-
"data" => {
|
50
|
-
"zone" => record[:zone][:zone],
|
51
|
-
"ttl" => record[:ttl],
|
52
|
-
"fqdn" => record[:fqdn],
|
53
|
-
"record_type" => record[:type],
|
54
|
-
"rdata" => record[:rdata],
|
55
|
-
"record_id" => record[:record_id]
|
56
|
-
},
|
57
|
-
"job_id" => Fog::Dynect::Mock.job_id,
|
58
|
-
"msgs" => [{
|
59
|
-
"INFO"=>"add: Record added",
|
60
|
-
"SOURCE"=>"BLL",
|
61
|
-
"ERR_CD"=>nil,
|
62
|
-
"LVL"=>"INFO"
|
63
|
-
}]
|
64
|
-
}
|
65
|
-
|
66
|
-
response
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module Fog
|
2
|
-
module DNS
|
3
|
-
class Dynect
|
4
|
-
class Real
|
5
|
-
def post_session
|
6
|
-
request(
|
7
|
-
:expects => 200,
|
8
|
-
:idempotent => true,
|
9
|
-
:method => :post,
|
10
|
-
:path => "Session",
|
11
|
-
:body => Fog::JSON.encode({
|
12
|
-
:customer_name => @dynect_customer,
|
13
|
-
:user_name => @dynect_username,
|
14
|
-
:password => @dynect_password
|
15
|
-
})
|
16
|
-
)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class Mock
|
21
|
-
def post_session
|
22
|
-
response = Excon::Response.new
|
23
|
-
response.status = 200
|
24
|
-
response.body = {
|
25
|
-
"status" => "success",
|
26
|
-
"data" => {
|
27
|
-
"token" => auth_token,
|
28
|
-
"version" => Fog::Dynect::Mock.version
|
29
|
-
},
|
30
|
-
"job_id" => Fog::Dynect::Mock.job_id,
|
31
|
-
"msgs"=>[{
|
32
|
-
"INFO"=>"login: Login successful",
|
33
|
-
"SOURCE"=>"BLL",
|
34
|
-
"ERR_CD"=>nil,
|
35
|
-
"LVL"=>"INFO"
|
36
|
-
}]
|
37
|
-
}
|
38
|
-
response
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,70 +0,0 @@
|
|
1
|
-
module Fog
|
2
|
-
module DNS
|
3
|
-
class Dynect
|
4
|
-
class Real
|
5
|
-
# Create a zone
|
6
|
-
#
|
7
|
-
# ==== Parameters
|
8
|
-
# * rname<~String> - administrative contact
|
9
|
-
# * ttl<~Integer> - time to live (in seconds) for records in this zone
|
10
|
-
# * zone<~String> - name of zone to host
|
11
|
-
# * options<~Hash>:
|
12
|
-
# * serial_style<~String> - style of serial number, in ['day', 'epoch', 'increment', 'minute']. Defaults to increment
|
13
|
-
|
14
|
-
def post_zone(rname, ttl, zone, options = {})
|
15
|
-
body = Fog::JSON.encode({
|
16
|
-
:rname => rname,
|
17
|
-
:token => auth_token,
|
18
|
-
:ttl => ttl
|
19
|
-
}.merge!(options))
|
20
|
-
|
21
|
-
request(
|
22
|
-
:body => body,
|
23
|
-
:expects => 200,
|
24
|
-
:method => :post,
|
25
|
-
:path => 'Zone/' << zone
|
26
|
-
)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class Mock
|
31
|
-
def post_zone(rname, ttl, zone, options = {})
|
32
|
-
new_zone = self.data[:zones][zone] = {
|
33
|
-
:next_record_id => 0,
|
34
|
-
:records => Hash.new do |records_hash, type|
|
35
|
-
records_hash[type] = []
|
36
|
-
end,
|
37
|
-
:records_to_delete => [],
|
38
|
-
:rname => rname,
|
39
|
-
:serial_style => options[:serial_style] || "increment",
|
40
|
-
:serial => 0,
|
41
|
-
:ttl => ttl,
|
42
|
-
:zone => zone,
|
43
|
-
:zone_type => "Primary"
|
44
|
-
}
|
45
|
-
|
46
|
-
response = Excon::Response.new
|
47
|
-
response.status = 200
|
48
|
-
response.body = {
|
49
|
-
"status" => "success",
|
50
|
-
"data" => {
|
51
|
-
"zone_type" => new_zone[:zone_type],
|
52
|
-
"serial_style" => new_zone[:serial_style],
|
53
|
-
"serial" => new_zone[:serial],
|
54
|
-
"zone" => zone
|
55
|
-
},
|
56
|
-
"job_id" => Fog::Dynect::Mock.job_id,
|
57
|
-
"msgs" => [{
|
58
|
-
"INFO" => "create: New zone #{zone} created. Publish it to put it on our server.",
|
59
|
-
"SOURCE" => "BLL",
|
60
|
-
"ERR_CD" => nil,
|
61
|
-
"LVL" => "INFO"
|
62
|
-
}]
|
63
|
-
}
|
64
|
-
|
65
|
-
response
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
@@ -1,76 +0,0 @@
|
|
1
|
-
module Fog
|
2
|
-
module DNS
|
3
|
-
class Dynect
|
4
|
-
class Real
|
5
|
-
# Update or replace a record
|
6
|
-
#
|
7
|
-
# ==== Parameters
|
8
|
-
# * type<~String> - type of record in ['AAAA', 'ANY', 'A', 'CNAME', 'DHCID', 'DNAME', 'DNSKEY', 'DS', 'KEY', 'LOC', 'MX', 'NSA', 'NS', 'PTR', 'PX', 'RP', 'SOA', 'SPF', 'SRV', 'SSHFP', 'TXT']
|
9
|
-
# * zone<~String> - zone of record
|
10
|
-
# * rdata<~Hash> - rdata for record
|
11
|
-
# * options<~Hash>: (options vary by type, listing below includes common parameters)
|
12
|
-
# * ttl<~Integer> - ttl for the record, defaults to zone ttl
|
13
|
-
|
14
|
-
def put_record(type, zone, fqdn, rdata, options = {})
|
15
|
-
options.merge!('rdata' => rdata)
|
16
|
-
type.to_s.upcase!
|
17
|
-
options = {"#{type}Records" => [options]} unless options['record_id']
|
18
|
-
path = ["#{type}Record", zone, fqdn].join('/')
|
19
|
-
path += "/#{options.delete('record_id')}" if options['record_id']
|
20
|
-
request(
|
21
|
-
:body => Fog::JSON.encode(options),
|
22
|
-
:expects => 200,
|
23
|
-
:idempotent => true,
|
24
|
-
:method => :put,
|
25
|
-
:path => path
|
26
|
-
)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class Mock
|
31
|
-
def put_record(type, zone, fqdn, rdata, options = {})
|
32
|
-
raise Fog::DNS::Dynect::NotFound unless zone = self.data[:zones][zone]
|
33
|
-
|
34
|
-
records = zone[:records]
|
35
|
-
record_id = zone[:next_record_id]
|
36
|
-
zone[:next_record_id] += 1
|
37
|
-
|
38
|
-
record = {
|
39
|
-
:type => type,
|
40
|
-
:zone => zone,
|
41
|
-
:fqdn => fqdn,
|
42
|
-
:rdata => rdata,
|
43
|
-
:ttl => options[:ttl] || zone[:ttl],
|
44
|
-
:record_id => record_id
|
45
|
-
}
|
46
|
-
|
47
|
-
records[type] << record
|
48
|
-
|
49
|
-
response = Excon::Response.new
|
50
|
-
response.status = 200
|
51
|
-
|
52
|
-
response.body = {
|
53
|
-
"status" => "success",
|
54
|
-
"data" => {
|
55
|
-
"zone" => record[:zone][:zone],
|
56
|
-
"ttl" => record[:ttl],
|
57
|
-
"fqdn" => record[:fqdn],
|
58
|
-
"record_type" => record[:type],
|
59
|
-
"rdata" => record[:rdata],
|
60
|
-
"record_id" => record[:record_id]
|
61
|
-
},
|
62
|
-
"job_id" => Fog::Dynect::Mock.job_id,
|
63
|
-
"msgs" => [{
|
64
|
-
"INFO"=>"add: Record added",
|
65
|
-
"SOURCE"=>"BLL",
|
66
|
-
"ERR_CD"=>nil,
|
67
|
-
"LVL"=>"INFO"
|
68
|
-
}]
|
69
|
-
}
|
70
|
-
|
71
|
-
response
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
@@ -1,76 +0,0 @@
|
|
1
|
-
module Fog
|
2
|
-
module DNS
|
3
|
-
class Dynect
|
4
|
-
class Real
|
5
|
-
# Update a zone
|
6
|
-
#
|
7
|
-
# ==== Parameters
|
8
|
-
# * zone<~String> - name or id of zone
|
9
|
-
# * options<~Hash>:
|
10
|
-
# * freeze<~Boolean> - causes zone to become frozen
|
11
|
-
# * publish<~Boolean> - causes all pending changes to be pushed to nameservers
|
12
|
-
# * thaw<~Boolean> - causes zone to cease being frozen
|
13
|
-
|
14
|
-
def put_zone(zone, options = {})
|
15
|
-
request(
|
16
|
-
:body => Fog::JSON.encode(options),
|
17
|
-
:expects => 200,
|
18
|
-
:idempotent => true,
|
19
|
-
:method => :put,
|
20
|
-
:path => 'Zone/' << zone
|
21
|
-
)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
class Mock
|
26
|
-
def put_zone(zone, options = {})
|
27
|
-
raise Fog::DNS::Dynect::NotFound unless zone = self.data[:zones][zone]
|
28
|
-
|
29
|
-
raise ArgumentError unless options.size == 1
|
30
|
-
|
31
|
-
response = Excon::Response.new
|
32
|
-
response.status = 200
|
33
|
-
|
34
|
-
data = {}
|
35
|
-
|
36
|
-
if options['freeze']
|
37
|
-
zone['frozen'] = true
|
38
|
-
info = "freeze: Your zone is now frozen"
|
39
|
-
elsif options['publish']
|
40
|
-
zone[:changes] = {}
|
41
|
-
zone[:records_to_delete].each do |record|
|
42
|
-
zone[:records][record[:type]].delete_if { |r| r[:fqdn] == record[:fqdn] && r[:record_id] == record[:record_id] }
|
43
|
-
end
|
44
|
-
zone[:records_to_delete] = []
|
45
|
-
data = {
|
46
|
-
"zone_type" => zone[:zone_type],
|
47
|
-
"serial_style" => zone[:serial_style],
|
48
|
-
"serial" => zone[:serial] += 1,
|
49
|
-
"zone" => zone[:zone]
|
50
|
-
}
|
51
|
-
info = "publish: #{zone[:zone]} published"
|
52
|
-
elsif options['thaw']
|
53
|
-
zone[:frozen] = false
|
54
|
-
info = "thaw: Your zone is now thawed, you may edit normally"
|
55
|
-
else
|
56
|
-
raise ArgumentError
|
57
|
-
end
|
58
|
-
|
59
|
-
response.body = {
|
60
|
-
"status" => "success",
|
61
|
-
"data" => data,
|
62
|
-
"job_id" => Fog::Dynect::Mock.job_id,
|
63
|
-
"msgs" => [{
|
64
|
-
"INFO" => info,
|
65
|
-
"SOURCE"=>"BLL",
|
66
|
-
"ERR_CD"=>nil,
|
67
|
-
"LVL"=>"INFO"
|
68
|
-
}]
|
69
|
-
}
|
70
|
-
|
71
|
-
response
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
@@ -1,258 +0,0 @@
|
|
1
|
-
Shindo.tests('Dynect::dns | DNS requests', ['dynect', 'dns']) do
|
2
|
-
|
3
|
-
shared_format = {
|
4
|
-
'job_id' => Integer,
|
5
|
-
'msgs' => [{
|
6
|
-
'ERR_CD' => Fog::Nullable::String,
|
7
|
-
'INFO' => String,
|
8
|
-
'LVL' => String,
|
9
|
-
'SOURCE' => String
|
10
|
-
}],
|
11
|
-
'status' => String
|
12
|
-
}
|
13
|
-
|
14
|
-
tests "success" do
|
15
|
-
|
16
|
-
@dns = Fog::DNS[:dynect]
|
17
|
-
@domain = generate_unique_domain
|
18
|
-
@fqdn = "www.#{@domain}"
|
19
|
-
|
20
|
-
post_session_format = shared_format.merge({
|
21
|
-
'data' => {
|
22
|
-
'token' => String,
|
23
|
-
'version' => String
|
24
|
-
}
|
25
|
-
})
|
26
|
-
|
27
|
-
tests("post_session").formats(post_session_format) do
|
28
|
-
@dns.post_session.body
|
29
|
-
end
|
30
|
-
|
31
|
-
post_zone_format = shared_format.merge({
|
32
|
-
'data' => {
|
33
|
-
'serial' => Integer,
|
34
|
-
'zone' => String,
|
35
|
-
'zone_type' => String,
|
36
|
-
'serial_style' => String
|
37
|
-
}
|
38
|
-
})
|
39
|
-
|
40
|
-
tests("post_zone('netops@#{@domain}', 3600, '#{@domain}')").formats(post_zone_format) do
|
41
|
-
@dns.post_zone("netops@#{@domain}", 3600, @domain).body
|
42
|
-
end
|
43
|
-
|
44
|
-
get_zones_format = shared_format.merge({
|
45
|
-
'data' => [String]
|
46
|
-
})
|
47
|
-
|
48
|
-
tests("get_zone").formats(get_zones_format) do
|
49
|
-
@dns.get_zone.body
|
50
|
-
end
|
51
|
-
|
52
|
-
get_zone_format = shared_format.merge({
|
53
|
-
'data' => {
|
54
|
-
"serial" => Integer,
|
55
|
-
"serial_style" => String,
|
56
|
-
"zone" => String,
|
57
|
-
"zone_type" => String
|
58
|
-
}
|
59
|
-
})
|
60
|
-
|
61
|
-
tests("get_zone('zone' => '#{@domain}')").formats(get_zone_format) do
|
62
|
-
@dns.get_zone('zone' => @domain).body
|
63
|
-
end
|
64
|
-
|
65
|
-
post_record_format = shared_format.merge({
|
66
|
-
'data' => {
|
67
|
-
'fqdn' => String,
|
68
|
-
'rdata' => {
|
69
|
-
'address' => String
|
70
|
-
},
|
71
|
-
'record_id' => Integer,
|
72
|
-
'record_type' => String,
|
73
|
-
'ttl' => Integer,
|
74
|
-
'zone' => String
|
75
|
-
}
|
76
|
-
})
|
77
|
-
|
78
|
-
tests("post_record('A', '#{@domain}', '#{@fqdn}', 'address' => '1.2.3.4')").formats(post_record_format) do
|
79
|
-
@dns.post_record('A', @domain, @fqdn, {'address' => '1.2.3.4'}).body
|
80
|
-
end
|
81
|
-
|
82
|
-
put_record_format = shared_format.merge({
|
83
|
-
'data' => {
|
84
|
-
'fqdn' => String,
|
85
|
-
'ARecords' => [
|
86
|
-
{
|
87
|
-
'rdata' => {
|
88
|
-
'address' => String
|
89
|
-
}
|
90
|
-
}
|
91
|
-
],
|
92
|
-
'record_id' => Integer,
|
93
|
-
'record_type' => String,
|
94
|
-
'ttl' => Integer,
|
95
|
-
'zone' => String
|
96
|
-
}
|
97
|
-
})
|
98
|
-
|
99
|
-
tests("put_record('A', '#{@domain}', '#{@fqdn}', 'address' => '1.2.3.4')").formats(post_record_format) do
|
100
|
-
@dns.put_record('A', @domain, @fqdn, {'address' => '1.2.3.4'}).body
|
101
|
-
end
|
102
|
-
|
103
|
-
publish_zone_format = shared_format.merge({
|
104
|
-
'data' => {
|
105
|
-
'serial' => Integer,
|
106
|
-
'serial_style' => String,
|
107
|
-
'zone' => String,
|
108
|
-
'zone_type' => String
|
109
|
-
}
|
110
|
-
})
|
111
|
-
|
112
|
-
tests("put_zone('#{@domain}', 'publish' => true)").formats(publish_zone_format) do
|
113
|
-
@dns.put_zone(@domain, 'publish' => true).body
|
114
|
-
end
|
115
|
-
|
116
|
-
freeze_zone_format = shared_format.merge({
|
117
|
-
'data' => {}
|
118
|
-
})
|
119
|
-
|
120
|
-
tests("put_zone('#{@domain}', 'freeze' => true)").formats(freeze_zone_format) do
|
121
|
-
@dns.put_zone(@domain, 'freeze' => true).body
|
122
|
-
end
|
123
|
-
|
124
|
-
thaw_zone_format = shared_format.merge({
|
125
|
-
'data' => {}
|
126
|
-
})
|
127
|
-
|
128
|
-
tests("put_zone('#{@domain}', 'thaw' => true)").formats(thaw_zone_format) do
|
129
|
-
@dns.put_zone(@domain, 'thaw' => true).body
|
130
|
-
end
|
131
|
-
|
132
|
-
get_node_list_format = shared_format.merge({
|
133
|
-
'data' => [String]
|
134
|
-
})
|
135
|
-
|
136
|
-
tests("get_node_list('#{@domain}')").formats(get_node_list_format) do
|
137
|
-
@dns.get_node_list(@domain).body
|
138
|
-
end
|
139
|
-
|
140
|
-
get_all_records_format = shared_format.merge({
|
141
|
-
'data' => [String]
|
142
|
-
})
|
143
|
-
|
144
|
-
tests("get_all_records('#{@domain}')").formats(get_all_records_format) do
|
145
|
-
@dns.get_all_records(@domain).body
|
146
|
-
end
|
147
|
-
|
148
|
-
get_records_format = shared_format.merge({
|
149
|
-
'data' => [String]
|
150
|
-
})
|
151
|
-
|
152
|
-
tests("get_record('A', '#{@domain}', '#{@fqdn}')").formats(get_records_format) do
|
153
|
-
data = @dns.get_record('A', @domain, @fqdn).body
|
154
|
-
@record_id = data['data'].first.split('/').last
|
155
|
-
data
|
156
|
-
end
|
157
|
-
|
158
|
-
sleep 5 unless Fog.mocking?
|
159
|
-
|
160
|
-
@dns.post_record('CNAME', @domain, "cname.#{@fqdn}", {'cname' => "#{@fqdn}."})
|
161
|
-
|
162
|
-
tests("get_record('ANY', '#{@domain}', 'cname.#{@fqdn}')").formats(get_records_format) do
|
163
|
-
@dns.get_record('ANY', @domain, "cname.#{@fqdn}").body
|
164
|
-
end
|
165
|
-
|
166
|
-
get_record_format = shared_format.merge({
|
167
|
-
'data' => {
|
168
|
-
'zone' => String,
|
169
|
-
'ttl' => Integer,
|
170
|
-
'fqdn' => String,
|
171
|
-
'record_type' => String,
|
172
|
-
'rdata' => {
|
173
|
-
'address' => String
|
174
|
-
},
|
175
|
-
'record_id' => Integer
|
176
|
-
}
|
177
|
-
})
|
178
|
-
|
179
|
-
tests("get_record('A', '#{@domain}', '#{@fqdn}', 'record_id' => '#{@record_id}')").formats(get_record_format) do
|
180
|
-
@dns.get_record('A', @domain, @fqdn, 'record_id' => @record_id).body
|
181
|
-
end
|
182
|
-
|
183
|
-
delete_record_format = shared_format.merge({
|
184
|
-
'data' => {}
|
185
|
-
})
|
186
|
-
|
187
|
-
tests("delete_record('A', '#{@domain}', '#{@fqdn}', '#{@record_id}')").formats(delete_record_format) do
|
188
|
-
@dns.delete_record('A', @domain, "#{@fqdn}", @record_id).body
|
189
|
-
end
|
190
|
-
|
191
|
-
delete_zone_format = shared_format.merge({
|
192
|
-
'data' => {}
|
193
|
-
})
|
194
|
-
|
195
|
-
sleep 5 unless Fog.mocking?
|
196
|
-
|
197
|
-
tests("delete_zone('#{@domain}')").formats(delete_zone_format) do
|
198
|
-
@dns.delete_zone(@domain).body
|
199
|
-
end
|
200
|
-
|
201
|
-
tests("job handling") do
|
202
|
-
pending unless Fog.mocking?
|
203
|
-
|
204
|
-
old_mock_value = Excon.defaults[:mock]
|
205
|
-
Excon.stubs.clear
|
206
|
-
|
207
|
-
tests("returns final response from a complete job").returns({"status" => "success"}) do
|
208
|
-
begin
|
209
|
-
Excon.defaults[:mock] = true
|
210
|
-
|
211
|
-
Excon.stub({:method => :post, :path => "/REST/Session"}, {:body=>"{\"status\": \"success\", \"data\": {\"token\": \"foobar\", \"version\": \"2.3.1\"}, \"job_id\": 150583906, \"msgs\": [{\"INFO\": \"login: Login successful\", \"SOURCE\": \"BLL\", \"ERR_CD\": null, \"LVL\": \"INFO\"}]}", :headers=>{"Content-Type"=>"application/json"}, :status=>200})
|
212
|
-
|
213
|
-
Excon.stub({:method => :get, :path => "/REST/Zone/example.com"}, {:status => 307, :body => '/REST/Job/150576635', :headers => {'Content-Type' => 'text/html', 'Location' => '/REST/Job/150576635'}})
|
214
|
-
Excon.stub({:method => :get, :path => "/REST/Job/150576635"}, {:status => 307, :body => '{"status":"success"}', :headers => {'Content-Type' => 'application/json'}})
|
215
|
-
|
216
|
-
Fog::DNS::Dynect::Real.new.request(:method => :get, :path => "Zone/example.com").body
|
217
|
-
ensure
|
218
|
-
Excon.stubs.clear
|
219
|
-
Excon.defaults[:mock] = old_mock_value
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
tests("passes expects through when polling a job").returns({"status" => "success"}) do
|
224
|
-
begin
|
225
|
-
Excon.defaults[:mock] = true
|
226
|
-
|
227
|
-
Excon.stub({:method => :post, :path => "/REST/Session"}, {:body=>"{\"status\": \"success\", \"data\": {\"token\": \"foobar\", \"version\": \"2.3.1\"}, \"job_id\": 150583906, \"msgs\": [{\"INFO\": \"login: Login successful\", \"SOURCE\": \"BLL\", \"ERR_CD\": null, \"LVL\": \"INFO\"}]}", :headers=>{"Content-Type"=>"application/json"}, :status=>200})
|
228
|
-
|
229
|
-
Excon.stub({:method => :get, :path => "/REST/Zone/example.com"}, {:status => 307, :body => '/REST/Job/150576635', :headers => {'Content-Type' => 'text/html', 'Location' => '/REST/Job/150576635'}})
|
230
|
-
Excon.stub({:method => :get, :path => "/REST/Job/150576635"}, {:status => 404, :body => '{"status":"success"}', :headers => {'Content-Type' => 'application/json'}})
|
231
|
-
|
232
|
-
Fog::DNS::Dynect::Real.new.request(:method => :get, :expects => 404, :path => "Zone/example.com").body
|
233
|
-
ensure
|
234
|
-
Excon.stubs.clear
|
235
|
-
Excon.defaults[:mock] = old_mock_value
|
236
|
-
end
|
237
|
-
end
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
tests('failure') do
|
242
|
-
tests("#auth_token with expired credentials").raises(Excon::Errors::BadRequest) do
|
243
|
-
pending if Fog.mocking?
|
244
|
-
@dns = Fog::DNS[:dynect]
|
245
|
-
@dns.instance_variable_get(:@connection).stub(:request) { raise Excon::Errors::BadRequest.new('Expected(200) <=> Actual(400 Bad Request) request => {:headers=>{"Content-Type"=>"application/json", "API-Version"=>"2.3.1", "Auth-Token"=>"auth-token", "Host"=>"api2.dynect.net:443", "Content-Length"=>0}, :host=>"api2.dynect.net", :mock=>nil, :path=>"/REST/CNAMERecord/domain.com/www.domain.com", :port=>"443", :query=>nil, :scheme=>"https", :expects=>200, :method=>:get} response => #<Excon::Response:0x00000008478b98 @body="{"status": "failure", "data": {}, "job_id": 21326025, "msgs": [{"INFO": "login: Bad or expired credentials", "SOURCE": "BLL", "ERR_CD": "INVALID_DATA", "LVL": "ERROR"}, {"INFO": "login: There was a problem with your credentials", "SOURCE": "BLL", "ERR_CD": null, "LVL": "INFO"}]}", @headers={"Server"=>"nginx/0.7.67", "Date"=>"Thu, 08 Sep 2011 20:04:21 GMT", "Content-Type"=>"application/json", "Transfer-Encoding"=>"chunked", "Connection"=>"keep-alive"}, @status=400>') }
|
246
|
-
@dns.instance_variable_get(:@connection).should_receive(:request).exactly(2).times
|
247
|
-
@dns.auth_token
|
248
|
-
end
|
249
|
-
|
250
|
-
tests("#auth_token with inactivity logout").raises(Excon::Errors::BadRequest) do
|
251
|
-
pending if Fog.mocking?
|
252
|
-
@dns = Fog::DNS[:dynect]
|
253
|
-
@dns.instance_variable_get(:@connection).stub(:request) { raise Excon::Errors::BadRequest.new('Expected(200) <=> Actual(400 Bad Request) request => {:headers=>{"Content-Type"=>"application/json", "API-Version"=>"2.3.1", "Auth-Token"=>"auth-token", "Host"=>"api2.dynect.net:443", "Content-Length"=>0}, :host=>"api2.dynect.net", :mock=>nil, :path=>"/REST/CNAMERecord/domain.com/www.domain.com", :port=>"443", :query=>nil, :scheme=>"https", :expects=>200, :method=>:get} response => #<Excon::Response:0x00000008478b98 @body="{"status": "failure", "data": {}, "job_id": 21326025, "msgs": [{"INFO": "login: inactivity logout", "SOURCE": "BLL", "ERR_CD": "INVALID_DATA", "LVL": "ERROR"}, {"INFO": "login: There was a problem with your credentials", "SOURCE": "BLL", "ERR_CD": null, "LVL": "INFO"}]}", @headers={"Server"=>"nginx/0.7.67", "Date"=>"Thu, 08 Sep 2011 20:04:21 GMT", "Content-Type"=>"application/json", "Transfer-Encoding"=>"chunked", "Connection"=>"keep-alive"}, @status=400>') }
|
254
|
-
@dns.instance_variable_get(:@connection).should_receive(:request).exactly(2).times
|
255
|
-
@dns.auth_token
|
256
|
-
end
|
257
|
-
end
|
258
|
-
end
|