def create_infrastructure_network(config, context, dc): """ Creates the default infrastructure network entities """ log.info("### Configuring networking ###") admin = context.getAdministrationService() enterprise = admin.findEnterprise(EnterprisePredicates.name("Abiquo")) networking = InfrastructureNetwork(context) pubnet = networking.create_public_network(dc, config.get("public network", "name"), config.get("public network", "address"), config.getint("public network", "mask"), config.get("public network", "gateway"), config.getint("public network", "tag"), config.get("public network", "dns")) networking.create_external_network(dc, enterprise, config.get("external network", "name"), config.get("external network", "address"), config.getint("external network", "mask"), config.get("external network", "gateway"), config.getint("external network", "tag"), config.get("external network", "dns")) networking.create_unmanaged_network(dc, enterprise, config.get("unmanaged network", "name"), config.get("unmanaged network", "address"), config.getint("unmanaged network", "mask"), config.get("unmanaged network", "gateway"), config.getint("unmanaged network", "tag"), config.get("unmanaged network", "dns")) return pubnet
def create_infrastructure_network(config, context, dc): """ Creates the default infrastructure network entities """ log.info("### Configuring networking ###") admin = context.getAdministrationService() enterprise = admin.findEnterprise(EnterprisePredicates.name("Abiquo")) networking = InfrastructureNetwork(context) pubnet = networking.create_public_network( dc, config.get("public network", "name"), config.get("public network", "address"), config.getint("public network", "mask"), config.get("public network", "gateway"), config.getint("public network", "tag"), config.get("public network", "dns")) networking.create_external_network( dc, enterprise, config.get("external network", "name"), config.get("external network", "address"), config.getint("external network", "mask"), config.get("external network", "gateway"), config.getint("external network", "tag"), config.get("external network", "dns")) networking.create_unmanaged_network( dc, enterprise, config.get("unmanaged network", "name"), config.get("unmanaged network", "address"), config.getint("unmanaged network", "mask"), config.get("unmanaged network", "gateway"), config.getint("unmanaged network", "tag"), config.get("unmanaged network", "dns")) return pubnet
def create_cloud_compute(config, context, dc): """ Creates the default cloud compute entities """ log.info("### Configuring the cloud ###") cloud = CloudCompute(context) # Create it into the 'abiquo' enterprise, to make it easier to use admin = context.getAdministrationService() enterprise = admin.findEnterprise(EnterprisePredicates.name("Abiquo")) vdc = cloud.create_virtual_datacenter(dc, enterprise, HypervisorType.valueOf(config.get("machine", "type")), config.get("virtual datacenter", "name"), config.get("private network", "name"), config.get("private network", "address"), config.getint("private network", "mask"), config.get("private network", "gateway")) vapp = cloud.create_virtual_appliance(vdc, config.get("virtual appliance", "name")) cloud.refresh_template_repository(enterprise, dc) template = find_smallest_template(context, vdc) if template: cloud.create_virtual_machine(vapp, template) return vdc
def create_cloud_compute(config, context, dc): """ Creates the default cloud compute entities """ log.info("### Configuring the cloud ###") cloud = CloudCompute(context) # Create it into the 'abiquo' enterprise, to make it easier to use admin = context.getAdministrationService() enterprise = admin.findEnterprise(EnterprisePredicates.name("Abiquo")) vdc = cloud.create_virtual_datacenter( dc, enterprise, HypervisorType.valueOf(config.get("machine", "type")), config.get("virtual datacenter", "name"), config.get("private network", "name"), config.get("private network", "address"), config.getint("private network", "mask"), config.get("private network", "gateway")) vapp = cloud.create_virtual_appliance( vdc, config.get("virtual appliance", "name")) cloud.refresh_template_repository(enterprise, dc) template = find_smallest_template(context, vdc) if template: cloud.create_virtual_machine(vapp, template) return vdc
def cleanup_default_tenants(config, context): """ Cleans up a previously created default tenants """ log.info("### Cleaning up tenants ###") admin = context.getAdministrationService() enterprises = admin.listEnterprises( Predicates.not(EnterprisePredicates.name("Abiquo"))) for enterprise in enterprises: # This will remove the enterprise and all users # (if none of them is a Cloud Admin) log.info("Removing enterprise %s and all users..." \ % enterprise.getName()) enterprise.delete() rolefilter = Predicates.not(Predicates.or( RolePredicates.name("CLOUD_ADMIN"), RolePredicates.name("ENTERPRISE_ADMIN"), RolePredicates.name("USER"))) roles = admin.listRoles(rolefilter) # This will remove all non default roles for role in roles: log.info("Removing role %s..." % role.getName()) role.delete()