use of com.cloud.baremetal.networkservice.BaremetalVlanStruct in project cloudstack by apache.
the class BaremetalVlanManagerImpl method prepareVlan.
@Override
public void prepareVlan(Network nw, DeployDestination destHost) {
List<BaremetalRctVO> vos = rctDao.listAll();
if (vos.isEmpty()) {
throw new CloudRuntimeException("no rack configuration found, please call addBaremetalRct to add one");
}
BaremetalRctVO vo = vos.get(0);
BaremetalRct rct = gson.fromJson(vo.getRct(), BaremetalRct.class);
RackPair rp = findRack(rct, destHost.getHost().getPrivateMacAddress());
if (rp == null) {
throw new CloudRuntimeException(String.format("cannot find any rack contains host[mac:%s], please double check your rack configuration file, update it and call addBaremetalRct again", destHost.getHost().getPrivateMacAddress()));
}
int vlan = Integer.parseInt(Networks.BroadcastDomainType.getValue(nw.getBroadcastUri()));
BaremetalSwitchBackend backend = getSwitchBackend(rp.rack.getL2Switch().getType());
BaremetalVlanStruct struct = new BaremetalVlanStruct();
struct.setHostMac(rp.host.getMac());
struct.setPort(rp.host.getPort());
struct.setSwitchIp(rp.rack.getL2Switch().getIp());
struct.setSwitchPassword(rp.rack.getL2Switch().getPassword());
struct.setSwitchType(rp.rack.getL2Switch().getType());
struct.setSwitchUsername(rp.rack.getL2Switch().getUsername());
struct.setVlan(vlan);
backend.prepareVlan(struct);
}
use of com.cloud.baremetal.networkservice.BaremetalVlanStruct in project cloudstack by apache.
the class BaremetalVlanManagerImpl method releaseVlan.
@Override
public void releaseVlan(Network nw, VirtualMachineProfile vm) {
List<BaremetalRctVO> vos = rctDao.listAll();
if (vos.isEmpty()) {
throw new CloudRuntimeException("no rack configuration found, please call addBaremetalRct to add one");
}
BaremetalRctVO vo = vos.get(0);
BaremetalRct rct = gson.fromJson(vo.getRct(), BaremetalRct.class);
HostVO host = hostDao.findById(vm.getVirtualMachine().getHostId());
RackPair rp = findRack(rct, host.getPrivateMacAddress());
assert rp != null : String.format("where is my rack???");
int vlan = Integer.parseInt(Networks.BroadcastDomainType.getValue(nw.getBroadcastUri()));
BaremetalVlanStruct struct = new BaremetalVlanStruct();
struct.setHostMac(rp.host.getMac());
struct.setPort(rp.host.getPort());
struct.setSwitchIp(rp.rack.getL2Switch().getIp());
struct.setSwitchPassword(rp.rack.getL2Switch().getPassword());
struct.setSwitchType(rp.rack.getL2Switch().getType());
struct.setSwitchUsername(rp.rack.getL2Switch().getUsername());
struct.setVlan(vlan);
BaremetalSwitchBackend backend = getSwitchBackend(rp.rack.getL2Switch().getType());
backend.removePortFromVlan(struct);
}
Aggregations