-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Henar Munoz
committed
Aug 28, 2014
1 parent
1add85a
commit 3cdd895
Showing
5 changed files
with
142 additions
and
5 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
core/src/main/java/com/telefonica/euro_iaas/sdc/dao/PuppetClientConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U <br> | ||
* This file is part of FI-WARE project. | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. | ||
* </p> | ||
* <p> | ||
* You may obtain a copy of the License at:<br> | ||
* <br> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* </p> | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* </p> | ||
* <p> | ||
* See the License for the specific language governing permissions and limitations under the License. | ||
* </p> | ||
* <p> | ||
* For those usages not covered by the Apache version 2.0 License please contact with opensource@tid.es | ||
* </p> | ||
*/ | ||
|
||
package com.telefonica.euro_iaas.sdc.dao; | ||
|
||
|
||
|
||
import com.sun.jersey.api.client.Client; | ||
import com.sun.jersey.api.client.config.ClientConfig; | ||
|
||
public interface PuppetClientConfig extends ClientConfig { | ||
|
||
Client getClient (); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
model/src/main/java/com/telefonica/euro_iaas/sdc/model/dto/PuppetNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/** | ||
* Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U <br> | ||
* This file is part of FI-WARE project. | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. | ||
* </p> | ||
* <p> | ||
* You may obtain a copy of the License at:<br> | ||
* <br> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* </p> | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* </p> | ||
* <p> | ||
* See the License for the specific language governing permissions and limitations under the License. | ||
* </p> | ||
* <p> | ||
* For those usages not covered by the Apache version 2.0 License please contact with opensource@tid.es | ||
* </p> | ||
*/ | ||
|
||
package com.telefonica.euro_iaas.sdc.model.dto; | ||
|
||
import java.text.MessageFormat; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import net.sf.json.JSONArray; | ||
import net.sf.json.JSONObject; | ||
|
||
/** | ||
* Models a chef node. | ||
* | ||
* @author Sergio Arroyo | ||
*/ | ||
public class PuppetNode { | ||
|
||
private final static String RECIPE_ITEM_TEMPLATE = "recipe[{0}]"; | ||
|
||
private String name; | ||
private String deactivated; | ||
private String catalog_timestamp; | ||
private String facts_timestamp; | ||
private String report_timestamp; | ||
|
||
public String getName (){ | ||
return name; | ||
} | ||
|
||
public String getCatalogTimestamp (){ | ||
return catalog_timestamp; | ||
} | ||
|
||
|
||
@SuppressWarnings("unchecked") | ||
public void fromJson(JSONObject jsonNode) { | ||
name = jsonNode.getString("name"); | ||
deactivated = jsonNode.getString("deactivated"); | ||
catalog_timestamp = jsonNode.getString("catalog_timestamp"); | ||
catalog_timestamp = jsonNode.getString("catalog_timestamp"); | ||
report_timestamp = jsonNode.getString("report_timestamp"); | ||
|
||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public String getNodeName(String stringNodes, String hostname) { | ||
|
||
JSONArray array = JSONArray.fromObject(stringNodes); | ||
for(Object js : array){ | ||
JSONObject json = (JSONObject)js; | ||
PuppetNode node = new PuppetNode(); | ||
node.fromJson(json); | ||
if (node.getName().startsWith(hostname+".")) { | ||
return node.getName(); | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public PuppetNode getNode(String stringNodes, String hostname) { | ||
|
||
JSONArray array = JSONArray.fromObject(stringNodes); | ||
for(Object js : array){ | ||
JSONObject json = (JSONObject)js; | ||
PuppetNode node = new PuppetNode(); | ||
node.fromJson(json); | ||
if (node.getName().startsWith(hostname+".")) { | ||
return node; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
} |