forked from vmware-archive/admiral
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove photon-model dependency from admiral
- Remove the dependency to photon-model - moved all the necessary classes in the admiral repository - keep the package names in order not to affect the upgrade Change-Id: I6d9b25d2897229a65a2fcd5cf482ab84e431f358 Reviewed-on: https://bellevue-ci.eng.vmware.com:8080/36816 Upgrade-Verified: jenkins <[email protected]> Closures-Verified: jenkins <[email protected]> CS-Verified: jenkins <[email protected]> Bellevue-Verified: jenkins <[email protected]> Reviewed-by: Lazarin Lazarov <[email protected]>
- Loading branch information
1 parent
310a4dc
commit d3d10de
Showing
119 changed files
with
24,509 additions
and
50 deletions.
There are no files selected for viewing
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
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,81 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright (c) 2016 VMware, Inc. All Rights Reserved. | ||
~ | ||
~ This product is licensed to you under the Apache License, Version 2.0 (the "License"). | ||
~ You may not use this product except in compliance with the License. | ||
~ | ||
~ This product may include a number of subcomponents with separate copyright notices | ||
~ and license terms. Your use of these subcomponents is subject to the terms and | ||
~ conditions of the subcomponent's license, as noted in the LICENSE file. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>com.vmware.admiral</groupId> | ||
<artifactId>admiral</artifactId> | ||
<version>1.4.1-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>admiral-photon</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<build> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>${xenon.group}</groupId> | ||
<artifactId>xenon-common</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.bouncycastle</groupId> | ||
<artifactId>bcprov-jdk15on</artifactId> | ||
<version>${bouncycastle.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.bouncycastle</groupId> | ||
<artifactId>bcpkix-jdk15on</artifactId> | ||
<version>${bouncycastle.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-net</groupId> | ||
<artifactId>commons-net</artifactId> | ||
<version>3.5</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-lang3</artifactId> | ||
<version>3.4</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-validator</groupId> | ||
<artifactId>commons-validator</artifactId> | ||
<version>1.5.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.jcraft</groupId> | ||
<artifactId>jsch</artifactId> | ||
<version>0.1.54</version> | ||
</dependency> | ||
|
||
<!-- TEST --> | ||
<dependency> | ||
<groupId>${xenon.group}</groupId> | ||
<artifactId>xenon-common</artifactId> | ||
<version>${xenon.version}</version> | ||
<classifier>tests</classifier> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
90 changes: 90 additions & 0 deletions
90
photon/src/main/java/com/vmware/photon/controller/model/ComputeProperties.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,90 @@ | ||
/* | ||
* Copyright (c) 2018 VMware, Inc. All Rights Reserved. | ||
* | ||
* This product is licensed to you under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this product except in compliance with the License. | ||
* | ||
* This product may include a number of subcomponents with separate copyright notices | ||
* and license terms. Your use of these subcomponents is subject to the terms and | ||
* conditions of the subcomponent's license, as noted in the LICENSE file. | ||
*/ | ||
|
||
package com.vmware.photon.controller.model; | ||
|
||
/** | ||
* Common infrastructure provider properties for compute resources manipulated by adapters. | ||
*/ | ||
public class ComputeProperties { | ||
|
||
/** | ||
* The display name of the compute resource. | ||
*/ | ||
public static final String CUSTOM_DISPLAY_NAME = "displayName"; | ||
|
||
/** | ||
* The resource group name to use to group the resources. E.g. on vSpehere this can be the | ||
* folder name, on Azure this is the resourceGroupName, on AWS this value can be used to tag the | ||
* resources. | ||
*/ | ||
public static final String RESOURCE_GROUP_NAME = "resourceGroupName"; | ||
|
||
/** | ||
* Custom property to hold the link to the endpoint. | ||
*/ | ||
public static final String ENDPOINT_LINK_PROP_NAME = "__endpointLink"; | ||
|
||
/** | ||
* The normalized OS type of the compute resource. | ||
* See {@link OSType} for a list of possible values. | ||
*/ | ||
public static final String CUSTOM_OS_TYPE = "osType"; | ||
|
||
/** | ||
* A link to a compute resource where to deploy this compute. | ||
*/ | ||
public static final String PLACEMENT_LINK = "__placementLink"; | ||
|
||
/** | ||
* A key for the custom properties property which value stores the specific type of the | ||
* resource state. | ||
* <p> | ||
* Useful when one resource state class can represent more than one target system type | ||
* (e.g. Both Azure Resource Groups and Storage containers are represented by | ||
* {@link com.vmware.photon.controller.model.resources.ResourceGroupService.ResourceGroupState} | ||
*/ | ||
public static final String RESOURCE_TYPE_KEY = "__type"; | ||
|
||
/** | ||
* A key for the custom properties property which value stores the parent compute host link. | ||
*/ | ||
public static final String COMPUTE_HOST_LINK_PROP_NAME = "computeHostLink"; | ||
|
||
/** | ||
* A key for the custom properties property which value stores compute that has created the | ||
* object. | ||
*/ | ||
public static final String CREATE_CONTEXT_PROP_NAME = "__createContext"; | ||
|
||
public static final String FIELD_VIRTUAL_GATEWAY = "__virtualGateway"; | ||
|
||
/** | ||
* A key for the custom properties which indicates if the resource is for infrastructure use | ||
* only (the value is set to "true" in this case). | ||
*/ | ||
public static final String INFRASTRUCTURE_USE_PROP_NAME = "__infrastructureUse"; | ||
|
||
/** | ||
* A key for a linked endpoint link, used to link two accounts. | ||
*/ | ||
public static final String LINKED_ENDPOINT_PROP_NAME = "linkedEndpointLink"; | ||
|
||
/** | ||
* A key for the custom properties in compute which stores flag as whether a snapshot exists | ||
* for the given compute. | ||
*/ | ||
public static final String CUSTOM_PROP_COMPUTE_HAS_SNAPSHOTS = "__hasSnapshot"; | ||
|
||
public enum OSType { | ||
WINDOWS, LINUX; | ||
} | ||
} |
107 changes: 107 additions & 0 deletions
107
photon/src/main/java/com/vmware/photon/controller/model/Constraint.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,107 @@ | ||
/* | ||
* Copyright (c) 2018 VMware, Inc. All Rights Reserved. | ||
* | ||
* This product is licensed to you under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this product except in compliance with the License. | ||
* | ||
* This product may include a number of subcomponents with separate copyright notices | ||
* and license terms. Your use of these subcomponents is subject to the terms and | ||
* conditions of the subcomponent's license, as noted in the LICENSE file. | ||
*/ | ||
|
||
package com.vmware.photon.controller.model; | ||
|
||
import java.util.List; | ||
|
||
import com.vmware.xenon.services.common.QueryTask.Query.Occurance; | ||
import com.vmware.xenon.services.common.QueryTask.QueryTerm; | ||
import com.vmware.xenon.services.common.QueryTask.QueryTerm.MatchType; | ||
|
||
/** | ||
* Definition of a constraint that one resource may have on other resources, typically expressed in | ||
* the resource's desired state. | ||
*/ | ||
public class Constraint { | ||
/** | ||
* A definition of a single condition that is part of the constraint. | ||
*/ | ||
public static class Condition { | ||
/** | ||
* Supported types of constraint conditions. | ||
*/ | ||
public static enum Type { | ||
/** | ||
* The condition is against a tag on the resource. | ||
*/ | ||
TAG, | ||
|
||
/** | ||
* The condition is against a field on the resource. | ||
*/ | ||
FIELD | ||
} | ||
|
||
/** | ||
* Condition enforcement. | ||
*/ | ||
public static enum Enforcement { | ||
/** | ||
* Hard enforcement - the condition must be met. | ||
*/ | ||
HARD, | ||
|
||
/** | ||
* Soft enforcement - meeting the condition would be preferable but no failure will | ||
* occur if it is not met. | ||
*/ | ||
SOFT | ||
} | ||
|
||
/** | ||
* The type of the condition. | ||
*/ | ||
public Type type; | ||
|
||
/** | ||
* Whether this is a hard or soft condition. | ||
*/ | ||
public Enforcement enforcement = Enforcement.HARD; | ||
|
||
/** | ||
* The {@code occurrence} field allows turning the condition to an anti-condition - for | ||
* example, resources that do not have the given tag. | ||
*/ | ||
public Occurance occurrence = Occurance.MUST_OCCUR; | ||
|
||
/** | ||
* The actual condition expression. | ||
* | ||
* <p> | ||
* <ul> | ||
* <li>For tag conditions, the {@code propertyName} field should contain the string | ||
* representation of the tag to match (key:value) and no {@code matchValue} is expected. | ||
* </ul> | ||
*/ | ||
public QueryTerm expression; | ||
|
||
public static Condition forTag(String key, String value, Enforcement enforcement, | ||
Occurance occurrence) { | ||
Condition condition = new Condition(); | ||
condition.type = Type.TAG; | ||
condition.enforcement = enforcement; | ||
condition.occurrence = occurrence; | ||
|
||
QueryTerm term = new QueryTerm(); | ||
term.propertyName = key + ((value != null && !value.isEmpty()) ? (":" + value) : ""); | ||
term.matchType = MatchType.TERM; | ||
condition.expression = term; | ||
|
||
return condition; | ||
} | ||
} | ||
|
||
/** | ||
* The list of conditions that define this constraint. | ||
*/ | ||
public List<Condition> conditions; | ||
} |
59 changes: 59 additions & 0 deletions
59
photon/src/main/java/com/vmware/photon/controller/model/PhotonModelMetricServices.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,59 @@ | ||
/* | ||
* Copyright (c) 2018 VMware, Inc. All Rights Reserved. | ||
* | ||
* This product is licensed to you under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this product except in compliance with the License. | ||
* | ||
* This product may include a number of subcomponents with separate copyright notices | ||
* and license terms. Your use of these subcomponents is subject to the terms and | ||
* conditions of the subcomponent's license, as noted in the LICENSE file. | ||
*/ | ||
|
||
package com.vmware.photon.controller.model; | ||
|
||
import com.vmware.photon.controller.model.monitoring.ResourceMetricsService; | ||
import com.vmware.xenon.common.Operation; | ||
import com.vmware.xenon.common.Service; | ||
import com.vmware.xenon.common.ServiceHost; | ||
import com.vmware.xenon.common.ServiceStats; | ||
import com.vmware.xenon.common.UriUtils; | ||
|
||
/** | ||
* Helper class that starts all the photon model provisioning services | ||
*/ | ||
public class PhotonModelMetricServices { | ||
|
||
public static final String[] LINKS = { | ||
ResourceMetricsService.FACTORY_LINK}; | ||
|
||
public static void startServices(ServiceHost host) throws Throwable { | ||
host.startFactory(ResourceMetricsService.class, ResourceMetricsService::createFactory); | ||
setFactoryToAvailable(host, ResourceMetricsService.FACTORY_LINK); | ||
} | ||
|
||
/** @see #setFactoryToAvailable(ServiceHost, String, Operation.CompletionHandler) */ | ||
public static void setFactoryToAvailable(ServiceHost host, String factoryPath) { | ||
setFactoryToAvailable(host, factoryPath, null); | ||
} | ||
|
||
/** | ||
* Helper method to explicitly set a factory to be "available". This is usually unnecessary, | ||
* but currently factories that create {@code ON_DEMAND_LOAD} services are not being set to | ||
* available... and currently require this work-around. | ||
* | ||
* @param host the host | ||
* @param factoryPath the path of the factory to explicitly set to be available | ||
* @param handler an optional completion handler | ||
*/ | ||
public static void setFactoryToAvailable(ServiceHost host, String factoryPath, Operation.CompletionHandler handler) { | ||
ServiceStats.ServiceStat body = new ServiceStats.ServiceStat(); | ||
body.name = Service.STAT_NAME_AVAILABLE; | ||
body.latestValue = Service.STAT_VALUE_TRUE; | ||
|
||
Operation put = Operation.createPut(UriUtils.buildAvailableUri(host, factoryPath)) | ||
.setBody(body) | ||
.setCompletion(handler) | ||
.setReferer(host.getUri()); | ||
host.sendRequest(put); | ||
} | ||
} |
Oops, something went wrong.