1710 Rebase - Second Attempt
[so.git] / bpmn / MSOCommonBPMN / src / main / java / org / openecomp / mso / client / aai / AAIValidatorImpl.java
1 package org.openecomp.mso.client.aai;
2
3 import java.io.IOException;
4 import java.util.List;
5
6 import org.openecomp.aai.domain.yang.GenericVnf;
7 import org.openecomp.aai.domain.yang.Pserver;
8 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.stereotype.Service;
10
11
12
13 @Service
14 public class AAIValidatorImpl implements AAIValidator {
15
16
17         @Autowired
18         protected AAIRestClient client;
19         
20         public AAIRestClient getClient() {
21                 return client;
22         }
23
24
25         public void setClient(AAIRestClient client) {
26                 this.client = client;
27         }
28
29         @Override
30         public boolean isPhysicalServerLocked(String vnfId, String transactionLoggingUuid) throws IOException {
31                 List<Pserver> pservers;
32                 boolean isLocked = false;
33                 pservers = client.getPhysicalServerByVnfId(vnfId, transactionLoggingUuid);
34                 for (Pserver pserver : pservers)
35                         if (pserver.isInMaint())
36                                 isLocked = true;
37                 
38                 return isLocked;
39         }
40
41         @Override
42         public boolean isVNFLocked(String vnfId, String transactionLoggingUuid) throws Exception {
43                 boolean isLocked = false;
44                 GenericVnf genericVnf = client.getVnfByName(vnfId, transactionLoggingUuid);
45                 if (genericVnf.isInMaint())
46                         isLocked = true;
47
48                 return isLocked;
49         }
50
51 }