Abstract-Cloud computing is a novel computing paradigm that offers data, software, and hardware services in a manner similar to traditional utilities such as water, electricity, and telephony. Usually, in Cloud and Grid computing, contracts between traders are established using Service Level Agreements (SLAs), which include objectives of service usage. However, due to the rapidly growing number of service offerings and the lack of a standard for their specification, manual service selection is a costly task, preventing the successful implementation of ubiquitous computing on demand. In order to counteract these issues, automatic methods for matching SLAs are necessary. In this paper, we introduce a method for finding semantically equal SLA elements from differing SLAs by utilizing several machine learning algorithms. Moreover, we utilize this method to enable automatic selection of optimal service offerings for Cloud and Grid users. Finally, we introduce a framework for automatic SLA management, present a simulation-based evaluation, and demonstrate several significant benefits of our approach for Cloud and Grid users.