Class: Seiso::ImportMaster::Mappers::ServiceInstanceMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/seiso/import_master/mappers/service_instance_mapper.rb

Overview

Author

Willie Wheeler

Copyright

Copyright © 2014-2015 Expedia, Inc.

License

Apache 2.0

Instance Method Summary collapse

Instance Method Details

#seiso_ip_address_role(r) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/seiso/import_master/mappers/service_instance_mapper.rb', line 12

def seiso_ip_address_role(r)
  # Suppressing IP addresses since we don't import those from master files.
  {
    'serviceInstance' => { 'key' => r['serviceInstance'] },
    'name' => r['name'],
    'description' => r['description']
  }
end

#seiso_service_instance(si) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/seiso/import_master/mappers/service_instance_mapper.rb', line 21

def seiso_service_instance(si)
  key = si['key']
  ip_address_roles = si['ipAddressRoles']
  ports = si['ports']
  
  seiso_si = {
    'key' => key,
    'description' => si['description'],
    'service' => { 'key' => si['service'] },
    'environment' => { 'key' => si['environment'] },
    'loadBalanced' => si['loadBalanced'],
    'minCapacityDeploy' => si['minCapacityDeploy'],
    'minCapacityOps' => si['minCapacityOps'],
    
    # FIXME Deprecated. This is a hardcoded field for an internal Expedia app, and we will remove it.
    'eosManaged' => (si['eosManaged'] || false),
    
    # FIXME Deprecated. This is the old name for the minCapacityOps field.
    'requiredCapacity' => si['minCapacityOps']
  }

  data_center = si['dataCenter']
  seiso_si['dataCenter'] = { 'key' => data_center } unless data_center.nil?
  
  load_balancer = si['loadBalancer']
  seiso_si['loadBalancer'] = { 'name' => load_balancer } unless load_balancer.nil?

  seiso_si
end

#seiso_service_instance_dependencies(sdm_dependencies) ⇒ Object



61
62
63
64
65
# File 'lib/seiso/import_master/mappers/service_instance_mapper.rb', line 61

def seiso_service_instance_dependencies(sdm_dependencies)
  sdm_dependencies.map do |d|
    seiso_service_instance_dependency d
  end
end

#seiso_service_instance_dependency(d) ⇒ Object



67
68
69
70
71
72
# File 'lib/seiso/import_master/mappers/service_instance_mapper.rb', line 67

def seiso_service_instance_dependency(d)
  {
    'dependent' => { 'key' => d['serviceInstance'] },
    'dependency' => { 'key' => d['key'] }
  }
end

#seiso_service_instance_port(p) ⇒ Object



51
52
53
54
55
56
57
58
59
# File 'lib/seiso/import_master/mappers/service_instance_mapper.rb', line 51

def seiso_service_instance_port(p)
  # Suppressing endpoints since we don't import those from master files.
  {
    'serviceInstance' => { 'key' => p['serviceInstance'] },
    'number' => p['number'],
    'protocol' => p['protocol'],
    'description' => p['description']
  }
end