Mike Kolesnik has posted comments on this change.
Change subject: engine: Added 'OpenStack Network' provider proxy
......................................................................
Patch Set 21: (9 inline comments)
....................................................
File
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/network/openstack/OpenstackNetworkProviderProxy.java
Line 19: private Provider providerDetails;
Line 20:
Line 21: private QuantumClient quantumClient;
Line 22:
Line 23: public OpenstackNetworkProviderProxy(Provider providerDetails) {
Done
Line 24: this.providerDetails = providerDetails;
Line 25: this.quantumClient = new
QuantumClient(providerDetails.getUrl());
Line 26: }
Line 27:
Line 23: public OpenstackNetworkProviderProxy(Provider providerDetails) {
Line 24: this.providerDetails = providerDetails;
Line 25: this.quantumClient = new
QuantumClient(providerDetails.getUrl());
Line 26: }
Line 27:
It is the OO way to encapsulate the data.
Line 28: private Provider getProviderDetails() {
Line 29: return providerDetails;
Line 30: }
Line 31:
Line 38: try {
Line 39: Networks networks = getQuantumClient().execute(new
ListNetworks());
Line 40: return map(networks.getList());
Line 41: } catch (RuntimeException e) {
Line 42: throw new VdcBLLException(VdcBllErrors.ENGINE, new
RuntimeException(e));
Done
Line 43: }
Line 44: }
Line 45:
Line 46: /**
Line 44: }
Line 45:
Line 46: /**
Line 47: * Quantum implementation must call {@link
QuantumProviderClient#getAll()} since the root API returns an exception
Line 48: * when accessing it.
Currently Openstack Network returns an error when accessing the root resource
of the API, so as described in the JavaDoc we need to do something different.
We could access any of the three collections - networks, ports or subnets..
Any of these could have multiple entities, and it seems that network will
usually have the least amount.
We can't try to find a specific network since in that case we will get an
error, and we don't have a way to know what caused it from the client (SDK).
If we will have such a way, we can refactor the code to use that instead of
this approach.
Although, I would rather that Openstack Network root resource worked properly,
than it raising an exception.
Line 49: */
Line 50: @Override
Line 51: public void testConnection() {
Line 52: getAll();
Line 51: public void testConnection() {
Line 52: getAll();
Line 53: }
Line 54:
Line 55: private List<Network>
map(List<org.openstack.quantum.model.Network> list) {
Done
Line 56: ArrayList<Network> networks = new
ArrayList<Network>(list.size());
Line 57:
Line 58: for (org.openstack.quantum.model.Network quantumNetwork :
list) {
Line 59: Network network = new Network();
Line 52: getAll();
Line 53: }
Line 54:
Line 55: private List<Network>
map(List<org.openstack.quantum.model.Network> list) {
Line 56: ArrayList<Network> networks = new
ArrayList<Network>(list.size());
Done
Line 57:
Line 58: for (org.openstack.quantum.model.Network quantumNetwork :
list) {
Line 59: Network network = new Network();
Line 60: network.setVmNetwork(true);
Line 58: for (org.openstack.quantum.model.Network quantumNetwork :
list) {
Line 59: Network network = new Network();
Line 60: network.setVmNetwork(true);
Line 61: network.setProvidedBy(new
ProviderNetwork(getProviderDetails().getId(),
quantumNetwork.getId().toString()));
Line 62:
network.setId(Guid.createGuidFromString(quantumNetwork.getId().toString()));
Actually this line was forgotten here and has no meaning..
Line 63: network.setName(quantumNetwork.getName());
Line 64: networks.add(network);
Line 65: }
Line 66:
Line 59: Network network = new Network();
Line 60: network.setVmNetwork(true);
Line 61: network.setProvidedBy(new
ProviderNetwork(getProviderDetails().getId(),
quantumNetwork.getId().toString()));
Line 62:
network.setId(Guid.createGuidFromString(quantumNetwork.getId().toString()));
Line 63: network.setName(quantumNetwork.getName());
How is this relevant?
Line 64: networks.add(network);
Line 65: }
Line 66:
Line 67: return networks;
....................................................
File
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/ProviderProxyFactory.java
Line 21: * The provider to create the proxy for.
Line 22: * @return The proxy for communicating with the provider
Line 23: */
Line 24: @SuppressWarnings("unchecked")
Line 25: public <P extends ProviderProxy> P create(Provider provider) {
Done
Line 26: return (P) new OpenstackNetworkProviderProxy(provider);
Line 27: }
Line 28:
Line 29: /**
--
To view, visit http://gerrit.ovirt.org/10787
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I3f9ab9d0e4e8d6bc801c4825605aa435552152c0
Gerrit-PatchSet: 21
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Mike Kolesnik <[email protected]>
Gerrit-Reviewer: Alona Kaplan <[email protected]>
Gerrit-Reviewer: Lior Vernia <[email protected]>
Gerrit-Reviewer: Livnat Peer <[email protected]>
Gerrit-Reviewer: Mike Kolesnik <[email protected]>
Gerrit-Reviewer: Moti Asayag <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches