<?xml version="1.0" encoding="us-ascii"?><InstanceReport xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><Version>2.4.0.8</Version><ReportLongName>2113100 - Disclosure - 5. Commitments and Contingencies</ReportLongName><DisplayLabelColumn>true</DisplayLabelColumn><ShowElementNames>false</ShowElementNames><RoundingOption /><HasEmbeddedReports>false</HasEmbeddedReports><Columns><Column FlagID="0"><Id>1</Id><IsAbstractGroupTitle>false</IsAbstractGroupTitle><LabelSeparator>

</LabelSeparator><CurrencyCode /><FootnoteIndexer /><hasSegments>false</hasSegments><hasScenarios>false</hasScenarios><MCU><KeyName /><CurrencySymbol /><contextRef><ContextID>D2013Q2YTD</ContextID><EntitySchema>http://www.sec.gov/CIK</EntitySchema><EntityValue>0001407739</EntityValue><PeriodDisplayName /><PeriodType>duration</PeriodType><PeriodStartDate>2013-01-01T00:00:00</PeriodStartDate><PeriodEndDate>2013-06-30T00:00:00</PeriodEndDate><Segments /><Scenarios /></contextRef><UPS /><CurrencyCode /><OriginalCurrencyCode /></MCU><CurrencySymbol /><Labels><Label Key="CalendarSupplement" Id="0" Label="6 Months Ended" /><Label Key="Calendar" Id="1" Label="Jun. 30, 2013" /></Labels></Column></Columns><Rows><Row FlagID="0"><Id>1</Id><IsAbstractGroupTitle>true</IsAbstractGroupTitle><LabelSeparator>

</LabelSeparator><Level>1</Level><ElementName>us-gaap_CommitmentsAndContingenciesDisclosureAbstract</ElementName><ElementPrefix>us-gaap_</ElementPrefix><IsBaseElement>true</IsBaseElement><BalanceType>na</BalanceType><PeriodType>duration</PeriodType><IsReportTitle>false</IsReportTitle><IsSegmentTitle>false</IsSegmentTitle><IsCalendarTitle>false</IsCalendarTitle><IsEquityPrevioslyReportedAsRow>false</IsEquityPrevioslyReportedAsRow><IsEquityAdjustmentRow>false</IsEquityAdjustmentRow><IsBeginningBalance>false</IsBeginningBalance><IsEndingBalance>false</IsEndingBalance><IsReverseSign>false</IsReverseSign><FootnoteIndexer /><Cells><Cell FlagID="0" ContextID="" UnitID=""><Id>1</Id><IsNumeric>false</IsNumeric><IsRatio>false</IsRatio><DisplayZeroAsNone>false</DisplayZeroAsNone><NumericAmount>0</NumericAmount><RoundedNumericAmount>0</RoundedNumericAmount><NonNumbericText /><FootnoteIndexer /><CurrencyCode /><CurrencySymbol /><IsIndependantCurrency>false</IsIndependantCurrency><ShowCurrencySymbol>false</ShowCurrencySymbol><DisplayDateInUSFormat>false</DisplayDateInUSFormat></Cell></Cells><ElementDataType>xbrli:stringItemType</ElementDataType><SimpleDataType>string</SimpleDataType><IsTotalLabel>false</IsTotalLabel><UnitID>0</UnitID><Label>Commitments and Contingencies Disclosure [Abstract]</Label></Row><Row FlagID="0"><Id>2</Id><IsAbstractGroupTitle>false</IsAbstractGroupTitle><LabelSeparator>

</LabelSeparator><Level>2</Level><ElementName>us-gaap_CommitmentsAndContingenciesDisclosureTextBlock</ElementName><ElementPrefix>us-gaap_</ElementPrefix><IsBaseElement>true</IsBaseElement><BalanceType>na</BalanceType><PeriodType>duration</PeriodType><IsReportTitle>false</IsReportTitle><IsSegmentTitle>false</IsSegmentTitle><IsCalendarTitle>false</IsCalendarTitle><IsEquityPrevioslyReportedAsRow>false</IsEquityPrevioslyReportedAsRow><IsEquityAdjustmentRow>false</IsEquityAdjustmentRow><IsBeginningBalance>false</IsBeginningBalance><IsEndingBalance>false</IsEndingBalance><IsReverseSign>false</IsReverseSign><PreferredLabelRole>terseLabel</PreferredLabelRole><FootnoteIndexer /><Cells><Cell FlagID="0" ContextID="D2013Q2YTD" UnitID=""><Id>1</Id><IsNumeric>false</IsNumeric><IsRatio>false</IsRatio><DisplayZeroAsNone>false</DisplayZeroAsNone><NumericAmount>0</NumericAmount><RoundedNumericAmount>0</RoundedNumericAmount><NonNumbericText>&lt;div style="font-family:Times New Roman;font-size:10pt;"&gt;&lt;div style="line-height:120%;font-size:10pt;"&gt;&lt;font style="font-family:inherit;font-size:10pt;font-weight:bold;"&gt;Commitments and Contingencies&lt;/font&gt;&lt;/div&gt;&lt;div style="line-height:120%;padding-top:6px;text-indent:32px;font-size:10pt;"&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt;The Company is involved from time to time in various legal proceedings, lawsuits, examinations by various tax authorities and claims that have arisen in the ordinary course of business. Management currently believes that the resolution of such matters will not have a material adverse effect on the Company&amp;#8217;s financial condition or results of operations.&lt;/font&gt;&lt;/div&gt;&lt;div style="line-height:120%;padding-top:6px;text-indent:32px;font-size:10pt;"&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt;A contract related to the development of ACC7 Phase I data center was in place as of &lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;color:#000000;text-decoration:none;"&gt;June&amp;#160;30, 2013&lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt;.  This contract is cost plus in nature whereby the contract sum is the aggregate of the actual work performed and equipment purchased plus a contractor fee.  Control estimates, which are adjusted from time to time to reflect any contract changes, are estimates of the total contract cost at completion.  As of &lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;color:#000000;text-decoration:none;"&gt;June&amp;#160;30, 2013&lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt; the ACC7 Phase I control estimate was &lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;color:#000000;text-decoration:none;"&gt;$157.4 million&lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt; of which &lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;color:#000000;text-decoration:none;"&gt;$10.7 million&lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt; had been incurred.  An additional &lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;color:#000000;text-decoration:none;"&gt;$26.2 million&lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt; has been committed under this contract as of &lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;color:#000000;text-decoration:none;"&gt;June&amp;#160;30, 2013&lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt;.  &lt;/font&gt;&lt;/div&gt;&lt;div style="line-height:120%;padding-top:12px;text-indent:32px;font-size:10pt;"&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt;Concurrent with DFT&amp;#8217;s October 2007 initial public offering, the Company entered into tax protection agreements with some of the contributors of the initial properties including DFT&amp;#8217;s Chairman of the Board and President and CEO. Pursuant to the terms of these agreements, if the Company disposes of any interest in the initial contributed properties that generates more than a certain allowable amount of built-in gain for the contributors, as a group, in any single year through 2017, the Company will indemnify the contributors for a portion of the tax liabilities incurred with respect to the amount of built-in gain and tax liabilities incurred as a result of the reimbursement payment. The amount of initial built-in gain that can be recognized as of January&amp;#160;1, 2013 without triggering the tax protection provisions is approximately &lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;color:#000000;text-decoration:none;"&gt;60%&lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt; of the initial built in gain of &lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;color:#000000;text-decoration:none;"&gt;$667 million&lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt; (unaudited) or &lt;/font&gt;&lt;font style="font-family:Times New Roman;font-size:10pt;color:#000000;font-style:normal;font-weight:normal;text-decoration:none;"&gt;$400 million&lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt; (unaudited). This percentage grows each year by &lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;color:#000000;text-decoration:none;"&gt;10%&lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt;, accumulating to &lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;color:#000000;text-decoration:none;"&gt;100%&lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt; in 2017. If, as of January 1, 2013, the tax protection provisions were triggered, the Company could be liable for protection on the taxes related to approximately up to &lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;color:#000000;text-decoration:none;"&gt;$267 million&lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt; (unaudited) of built-in gain. Additionally, the Company must provide an opportunity for certain of the contributors of the initial properties to guarantee a secured loan. Any sale by the Company that requires payments to any of DFT&amp;#8217;s executive officers or directors pursuant to these agreements requires the approval of at least &lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;color:#000000;text-decoration:none;"&gt;75%&lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt; of the disinterested members of DFT&amp;#8217;s Board of Directors.&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;</NonNumbericText><FootnoteIndexer /><CurrencyCode /><CurrencySymbol /><IsIndependantCurrency>false</IsIndependantCurrency><ShowCurrencySymbol>false</ShowCurrencySymbol><DisplayDateInUSFormat>false</DisplayDateInUSFormat></Cell></Cells><ElementDataType>nonnum:textBlockItemType</ElementDataType><SimpleDataType>na</SimpleDataType><ElementDefenition>The entire disclosure for commitments and contingencies.</ElementDefenition><ElementReferences>Reference 1: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name FASB Interpretation (FIN)

 -Number 14

 -Paragraph 3

 -LegacyDoc This reference is SUPERSEDED by the Accounting Standards Codification effective for interim and annual periods ending after September 15, 2009.  This reference is included to help users transition from the previous accounting hierarchy and will be removed from future versions of this taxonomy.



Reference 2: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Accounting Standards Codification

 -Topic 210

 -SubTopic 10

 -Section S99

 -Paragraph 1

 -Subparagraph (SX 210.5-02.25)

 -URI http://asc.fasb.org/extlink&amp;oid=6877327&amp;loc=d3e13212-122682



Reference 3: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Accounting Standards Codification

 -Topic 825

 -SubTopic 20

 -Section 50

 -Paragraph 1

 -URI http://asc.fasb.org/extlink&amp;oid=6449706&amp;loc=d3e16207-108621



Reference 4: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Accounting Standards Codification

 -Topic 460

 -SubTopic 10

 -Section 50

 -Paragraph 8

 -URI http://asc.fasb.org/extlink&amp;oid=6398077&amp;loc=d3e12565-110249



Reference 5: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Accounting Standards Codification

 -Topic 450

 -SubTopic 20

 -Section 50

 -Paragraph 4

 -URI http://asc.fasb.org/extlink&amp;oid=6952336&amp;loc=d3e14435-108349



Reference 6: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Accounting Standards Codification

 -Topic 440

 -SubTopic 10

 -Section 50

 -Paragraph 2

 -URI http://asc.fasb.org/extlink&amp;oid=6394976&amp;loc=d3e25287-109308



Reference 7: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Statement of Financial Accounting Standard (FAS)

 -Number 5

 -Paragraph 9, 10, 11, 12

 -LegacyDoc This reference is SUPERSEDED by the Accounting Standards Codification effective for interim and annual periods ending after September 15, 2009.  This reference is included to help users transition from the previous accounting hierarchy and will be removed from future versions of this taxonomy.



</ElementReferences><IsTotalLabel>false</IsTotalLabel><UnitID>0</UnitID><Label>Commitments and Contingencies Disclosure [Text Block]</Label></Row></Rows><Footnotes /><IsEquityReport>false</IsEquityReport><ReportName>5. Commitments and Contingencies</ReportName><MonetaryRoundingLevel>UnKnown</MonetaryRoundingLevel><SharesRoundingLevel>UnKnown</SharesRoundingLevel><PerShareRoundingLevel>UnKnown</PerShareRoundingLevel><ExchangeRateRoundingLevel>UnKnown</ExchangeRateRoundingLevel><HasCustomUnits>true</HasCustomUnits><IsEmbedReport>false</IsEmbedReport><IsMultiCurrency>false</IsMultiCurrency><ReportType>Sheet</ReportType><RoleURI>http://www.dft.com/role/A5CommitmentsAndContingencies</RoleURI><NumberOfCols>1</NumberOfCols><NumberOfRows>2</NumberOfRows></InstanceReport>
