lib/osa/servers.rb
#
# maps all details of openstack's security_groups with servers' security_groups to
#   merge required details since servers' details have only security groups' names
#
# @param security_groups [SecurityGroups] object or [Array <SecurityGroup>]
#   if SecurityGroups is given #neutralize_security_groups will get the SecurityGroups#sec_grp_objs ([Array <SecurityGroup>])
#   if SecurityGroups#sec_grp_objs ([Array <SecurityGroup>]), #neutralize_security_groups returns it.
#
# @example
#   openstack = OpenStack::Connection.create(connection)
#   security_groups = SecurityGroups.parse(openstack.security_groups).security_groups
#   servers = Servers.parse(openstack.servers_detail)
#   servers.map_security_groups(security_groups)
#
# @return [Array <[Servers]>]
#
maps all details of openstack's security_groups with servers' security_groups to
merge required details since servers' details have only security groups' names
maps all details of openstack ' s security_groups with servers ' security_groups to merge required details since servers ' details have only security groups ' names
def map_security_groups(security_groups)
      security_groups = neutralize_security_groups(security_groups)
      @servers_details =
          @servers.each do |server|
            server[:security_groups] =
                security_groups.select do |security_group|
                  server.security_groups.include? security_group.name
                end
          end
    end
def map_security_groups ( security_groups ) security_groups = neutralize_security_groups ( security_groups ) @servers_details = @servers . each do | server | server [ :security_groups ] = security_groups . select do | security_group | server . security_groups . include? security_group . name end end end
maps all details of openstack's security_groups with servers' security_groups to
merge required details since servers' details have only security groups' names
maps all details of openstack ' s security_groups with servers ' security_groups to merge required details since servers ' details have only security groups ' names
# We must match by name since the server's details includes security groups' names only
None
Array <[Servers
security_groups
object or [Array ] if SecurityGroups is given #neutralize_security_groups will get the SecurityGroups#sec_grp_objs ([Array ]) if SecurityGroups#sec_grp_objs ([Array ]), #neutralize_security_groups returns it.
object or [ Array ] if SecurityGroups is given #neutralize_security_groups will get the SecurityGroups#sec_grp_objs ( [ Array ] ) if SecurityGroups#sec_grp_objs ( [ Array ] ) #neutralize_security_groups returns it .
example
openstack = OpenStack::Connection.create(connection) security_groups = SecurityGroups.parse(openstack.security_groups).security_groups servers = Servers.parse(openstack.servers_detail) servers.map_security_groups(security_groups)
openstack = OpenStack :: Connection . create ( connection ) security_groups = SecurityGroups . parse ( openstack . security_groups ) . security_groups servers = Servers . parse ( openstack . servers_detail ) servers . map_security_groups ( security_groups )