def create_network_interface(subnetId, options = {})
response = Excon::Response.new
if subnetId
id = Fog::AWS::Mock.network_interface_id
groups = {}
if options['GroupSet']
options['GroupSet'].each do |group_id|
name = self.data[:security_groups].select { |k,v| v['groupId'] == group_id } .first.first
if name.nil?
raise Fog::Compute::AWS::Error.new("Unknown security group '#{group_id}' specified")
end
groups[group_id] = name
end
end
if options['PrivateIpAddress'].nil?
options['PrivateIpAddress'] = "10.0.0.2"
end
data = {
'networkInterfaceId' => id,
'subnetId' => subnetId,
'vpcId' => 'mock-vpc-id',
'availabilityZone' => 'mock-zone',
'description' => options['Description'],
'ownerId' => '',
'requesterManaged' => 'false',
'status' => 'available',
'macAddress' => '00:11:22:33:44:55',
'privateIpAddress' => options['PrivateIpAddress'],
'sourceDestCheck' => true,
'groupSet' => groups,
'attachment' => {},
'association' => {},
'tagSet' => {}
}
self.data[:network_interfaces][id] = data
response.body = {
'requestId' => Fog::AWS::Mock.request_id,
'networkInterface' => data
}
response
else
response.status = 400
response.body = {
'Code' => 'InvalidParameterValue',
'Message' => "Invalid value '' for subnetId"
}
end
end