Jonathan Hart

Remove old XOS-integration application

Change-Id: Ie4207f34714f75618fd3db52dd5c9474d91cb151
......@@ -44,7 +44,6 @@
<module>bgprouter</module>
<module>test</module>
<module>segmentrouting</module>
<module>xos-integration</module>
<module>kafka-integration</module>
<module>pcep-api</module>
<module>iptopology-api</module>
......
COMPILE_DEPS = [
'//lib:CORE_DEPS',
'//lib:jersey-client',
'//lib:javax.ws.rs-api',
'//lib:org.apache.karaf.shell.console',
'//cli:onos-cli',
'//utils/rest:onlab-rest',
]
osgi_jar_with_tests (
deps = COMPILE_DEPS,
import_packages = '*,org.onosproject.cli.net',
resources_root = 'src/main/resources',
resources = glob(['src/main/resources/**']),
)
onos_app (
title = 'ONOS XOS Integration App',
category = 'Utility',
url = 'http://onosproject.org',
description = 'ONOS XOS integration application.',
)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ Copyright 2015-present Open Networking Laboratory
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ 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.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}">
<feature name="${project.artifactId}" version="${project.version}"
description="${project.description}">
<bundle>mvn:org.glassfish.jersey.core/jersey-client/2.22.2</bundle>
<bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
</feature>
</features>
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2015-present Open Networking Laboratory
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ 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.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-apps</artifactId>
<version>1.7.0-SNAPSHOT</version>
</parent>
<artifactId>onos-app-xos-integration</artifactId>
<packaging>bundle</packaging>
<description>ONOS XOS integration application</description>
<properties>
<onos.app.name>org.onosproject.xosintegration</onos.app.name>
<onos.app.title>ONOS XOS Integration App</onos.app.title>
<onos.app.category>Utility</onos.app.category>
<onos.app.url>http://onosproject.org</onos.app.url>
<onos.app.readme>ONOS XOS integration application.</onos.app.readme>
</properties>
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.22.2</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-cli</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.karaf.shell</groupId>
<artifactId>org.apache.karaf.shell.console</artifactId>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-misc</artifactId>
</dependency>
</dependencies>
</project>
/*
* Copyright 2015-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.xosintegration;
import com.google.common.base.MoreObjects;
import org.onosproject.net.ConnectPoint;
public final class VoltTenant {
private final String humanReadableName;
private final long id;
private final long providerService;
private final String serviceSpecificId;
private final String vlanId;
private final ConnectPoint port;
/**
* Constructs a vOLT tenant object.
*
* @param humanReadableName name string
* @param id identifier for the tenant
* @param providerService provider service ID
* @param serviceSpecificId id for the user
* @param vlanId vlan id for the user
*/
private VoltTenant(String humanReadableName, long id, long providerService,
String serviceSpecificId, String vlanId, ConnectPoint port) {
this.humanReadableName = humanReadableName;
this.id = id;
this.providerService = providerService;
this.serviceSpecificId = serviceSpecificId;
this.vlanId = vlanId;
this.port = port;
}
/**
* Fetches a builder to make a tenant.
*
* @return tenant builder
*/
public static Builder builder() {
return new Builder();
}
/**
* Fetches the name of the tenant.
*
* @return human readable name
*/
public String humanReadableName() {
return humanReadableName;
}
/**
* Fetches the ID of the tenant object.
*
* @return ID of tenant object.
*/
public long id() {
return id;
}
/**
* Fetches the identifier for the provider service.
*
* @return provider service ID
*/
public long providerService() {
return providerService;
}
/**
* Fetches the server specific ID (user id).
*
* @return server specific ID
*/
public String serviceSpecificId() {
return serviceSpecificId;
}
/**
* Fetches the vlan id for this tenant.
*
* @return VLAN ID
*/
public String vlanId() {
return vlanId;
}
public ConnectPoint port() {
return port;
}
/**
* Builder class to allow callers to assemble tenants.
*/
public static final class Builder {
private String humanReadableName = "unknown";
private long id = 0;
private long providerService = -1;
private String serviceSpecificId = "unknown";
private String vlanId = "unknown";
private ConnectPoint port;
/**
* Sets the name string for the tenant.
*
* @param humanReadableName name
* @return self
*/
public Builder withHumanReadableName(String humanReadableName) {
this.humanReadableName = humanReadableName;
return this;
}
/**
* Sets the identifier for the tenant.
*
* @param id identifier for the tenant
* @return self
*/
public Builder withId(long id) {
this.id = id;
return this;
}
/**
* Sets the server specific id (user id) for the tenant.
*
* @param serviceSpecificId server specific (user) id
* @return self
*/
public Builder withServiceSpecificId(String serviceSpecificId) {
this.serviceSpecificId = serviceSpecificId;
return this;
}
/**
* Sets the VLAN ID for the tenant.
*
* @param vlanId VLAN ID
* @return self
*/
public Builder withVlanId(String vlanId) {
this.vlanId = vlanId;
return this;
}
/**
* Sets the provider service ID.
*
* @param providerService provider service ID
* @return self
*/
public Builder withProviderService(long providerService) {
this.providerService = providerService;
return this;
}
public Builder withPort(ConnectPoint port) {
this.port = port;
return this;
}
/**
* Constructs a VoltTenant from the assembled data.
*
* @return constructed tenant object
*/
public VoltTenant build() {
return new VoltTenant(humanReadableName, id, providerService,
serviceSpecificId, vlanId, port);
}
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("humanReadableName", humanReadableName())
.add("id", id())
.add("providerService", providerService())
.add("serviceSpecificId", serviceSpecificId())
.add("vlanId", vlanId())
.add("port", port())
.toString();
}
}
/*
* Copyright 2015-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.xosintegration;
import java.util.Set;
public interface VoltTenantService {
/**
* Queries all the tenants.
*
* @return Set of all of the tenants
*/
Set<VoltTenant> getAllTenants();
/**
* Removes a tenant given its ID.
*
* @param id if od tenant to remove.
*/
void removeTenant(long id);
/**
* Creates a new tenant and adds it to the XOS instance.
*
* @param newTenant tenant to add
* @return the added tenant
*/
VoltTenant addTenant(VoltTenant newTenant);
/**
* Gets a single tenant for the given ID.
*
* @param id ID of the tenant to fetch
* @return tenant that was fetched
*/
VoltTenant getTenant(long id);
}
/*
* Copyright 2015-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.xosintegration.cli;
import java.util.List;
import org.onosproject.cli.AbstractChoicesCompleter;
import org.onosproject.xosintegration.VoltTenant;
import org.onosproject.xosintegration.VoltTenantService;
import static java.util.stream.Collectors.toList;
import static org.onosproject.cli.AbstractShellCommand.get;
/**
* Application command completer.
*/
public class TenantIdCompleter extends AbstractChoicesCompleter {
@Override
public List<String> choices() {
VoltTenantService service = get(VoltTenantService.class);
return service.getAllTenants().stream()
.map(VoltTenant::id)
.map(Object::toString)
.collect(toList());
}
}
/*
* Copyright 2015-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.xosintegration.cli;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.onosproject.cli.AbstractShellCommand;
import org.onosproject.xosintegration.VoltTenantService;
/**
* CLI command to remove an existing tenant from the system.
*/
@Command(scope = "onos", name = "remove-tenant",
description = "Removes a tenant")
public class VoltRemoveTenantCommand extends AbstractShellCommand {
@Argument(index = 0, name = "tenant",
description = "Tenant ID",
required = true, multiValued = false)
String tenantIdString = null;
@Override
protected void execute() {
VoltTenantService service = get(VoltTenantService.class);
service.removeTenant(Long.parseLong(tenantIdString));
}
}
/*
* Copyright 2015-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.xosintegration.cli;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.onosproject.cli.AbstractShellCommand;
import org.onosproject.net.ConnectPoint;
import org.onosproject.xosintegration.VoltTenant;
import org.onosproject.xosintegration.VoltTenantService;
/**
* CLI command to create a new tenant.
*/
@Command(scope = "onos", name = "add-tenant",
description = "Lists the inventory of VOLT tenants and their contents")
public class VoltTenantsCreateCommand extends AbstractShellCommand {
@Argument(index = 0, name = "service specific ID",
description = "service specific ID",
required = true, multiValued = false)
String serviceSpecificId;
@Argument(index = 1, name = "vlan ID",
description = "vlan ID",
required = true, multiValued = false)
String vlanId;
@Argument(index = 2, name = "port",
description = "Port",
required = true, multiValued = false)
String port;
@Override
protected void execute() {
VoltTenantService service = get(VoltTenantService.class);
VoltTenant newTenant = VoltTenant.builder()
.withServiceSpecificId(serviceSpecificId)
.withVlanId(vlanId)
.withPort(ConnectPoint.deviceConnectPoint(port))
.build();
service.addTenant(newTenant);
}
}
/*
* Copyright 2015-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.xosintegration.cli;
import java.util.Set;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.onosproject.cli.AbstractShellCommand;
import org.onosproject.xosintegration.VoltTenant;
import org.onosproject.xosintegration.VoltTenantService;
/**
* CLI command for listing VOLT tenant objects.
*/
/**
* CLI command to list the existing tenants.
*/
@Command(scope = "onos", name = "tenants",
description = "Lists the inventory of VOLT tenants and their contents")
public class VoltTenantsListCommand extends AbstractShellCommand {
@Argument(index = 0, name = "tenantId",
description = "Tenant ID",
required = false, multiValued = false)
private String tenantId = null;
@Override
protected void execute() {
VoltTenantService service = get(VoltTenantService.class);
if (tenantId != null) {
VoltTenant tenant = service.getTenant(Long.parseLong(tenantId));
if (tenant != null) {
print(tenant.toString());
} else {
error("Tenant not found {}", tenantId);
}
} else {
Set<VoltTenant> tenants = service.getAllTenants();
for (VoltTenant tenant : tenants) {
print(tenant.toString());
}
}
}
}
/*
* Copyright 2015-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* XOS integration application CLI commands.
*/
package org.onosproject.xosintegration.cli;
\ No newline at end of file
/*
* Copyright 2015-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* XOS integration application which relies on XOS REST APIs to manage VMs.
*/
package org.onosproject.xosintegration;
<!--
~ Copyright 2015-present Open Networking Laboratory
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ 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.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
<command>
<action class="org.onosproject.xosintegration.cli.VoltTenantsListCommand"/>
<completers>
<ref component-id="tenantIdCompleter"/>
<null/>
</completers>
</command>
<command>
<action class="org.onosproject.xosintegration.cli.VoltTenantsCreateCommand"/>
<completers>
<ref component-id="placeholderCompleter"/>
<ref component-id="placeholderCompleter"/>
<ref component-id="connectPointCompleter"/>
<null/>
</completers>
</command>
<command>
<action class="org.onosproject.xosintegration.cli.VoltRemoveTenantCommand"/>
<completers>
<ref component-id="tenantIdCompleter"/>
<null/>
</completers>
</command>
</command-bundle>
<bean id="tenantIdCompleter" class="org.onosproject.xosintegration.cli.TenantIdCompleter"/>
<bean id="placeholderCompleter" class="org.onosproject.cli.PlaceholderCompleter"/>
<bean id="connectPointCompleter" class="org.onosproject.cli.net.ConnectPointCompleter"/>
</blueprint>