def create_mount_target(file_system_id, subnet_id, options={})
response = Excon::Response.new
default_security_group = mock_compute.data[:security_groups]['default']
security_groups = options["SecurityGroups"] || [default_security_group['groupId']]
unless file_system = self.data[:file_systems][file_system_id]
raise Fog::AWS::EFS::NotFound.new("invalid file system ID: #{file_system_id}")
end
unless file_system["LifeCycleState"] == 'available'
raise Fog::AWS::EFS::IncorrectFileSystemLifeCycleState.new("")
end
unless subnet = mock_compute.subnets.get(subnet_id)
raise Fog::AWS::EFS::InvalidSubnet.new("invalid subnet ID: #{subnet_id}")
end
security_groups.each do |sg|
raise Fog::AWS::EFS::NotFound.new("invalid security group ID: #{sg}") unless mock_compute.data[:security_groups].values.detect { |sgd| sgd["groupId"] == sg }
end
id = "fsmt-#{Fog::Mock.random_letters(8)}"
mount_target = {
'MountTargetId' => id,
'FileSystemId' => file_system_id,
'IpAddress' => Fog::AWS::Mock.ip_address,
'OwnerId' => Fog::AWS::Mock.owner_id,
'LifeCycleState' => 'creating',
'NetworkInterfaceId' => "eni-#{Fog::Mock.random_hex(8)}",
'SubnetId' => subnet.identity,
}
self.data[:mount_targets][id] = mount_target
self.data[:security_groups][id] = security_groups
response.body = mount_target
response
end