Rename all not associated with LXC stuff.
[platform/core/security/vasum.git] / server / zone-admin.cpp
index b584279..473a11c 100644 (file)
 
 namespace vasum {
 
-namespace {
-
-// TODO: this should be in zone's configuration file
-const int SHUTDOWN_WAIT = 10;
-
-} // namespace
-
 const std::uint64_t DEFAULT_CPU_SHARES = 1024;
 const std::uint64_t DEFAULT_VCPU_PERIOD_MS = 100000;
 
 ZoneAdmin::ZoneAdmin(const std::string& zoneId,
                      const std::string& zonesPath,
-                     const std::string& lxcTemplatePrefix,
+                     const std::string& zoneTemplatePrefix,
                      const ZoneConfig& config,
                      const ZoneDynamicConfig& dynamicConfig)
     : mConfig(config),
@@ -67,9 +60,9 @@ ZoneAdmin::ZoneAdmin(const std::string& zoneId,
 
     if (!mZone.isDefined()) {
 
-        const std::string lxcTemplate = utils::getAbsolutePath(config.lxcTemplate,
-                                                               lxcTemplatePrefix);
-        LOGI(mId << ": Creating zone from template: " << lxcTemplate);
+        const std::string zoneTemplate = utils::getAbsolutePath(config.zoneTemplate,
+                                                               zoneTemplatePrefix);
+        LOGI(mId << ": Creating zone from template: " << zoneTemplate);
         utils::CStringArrayBuilder args;
         if (!dynamicConfig.ipv4Gateway.empty()) {
             args.add("--ipv4-gateway");
@@ -84,7 +77,7 @@ ZoneAdmin::ZoneAdmin(const std::string& zoneId,
             args.add("--vt");
             args.add(vt.c_str());
         }
-        if (!mZone.create(lxcTemplate, args.c_array())) {
+        if (!mZone.create(zoneTemplate, args.c_array())) {
             throw ZoneOperationException("Could not create zone");
         }
     }
@@ -163,7 +156,7 @@ void ZoneAdmin::stop()
         return;
     }
 
-    if (!mZone.shutdown(SHUTDOWN_WAIT)) {
+    if (!mZone.shutdown(mConfig.shutdownTimeout)) {
         // force stop
         if (!mZone.stop()) {
             throw ZoneOperationException("Could not stop zone");
@@ -322,4 +315,9 @@ std::vector<std::string> ZoneAdmin::getNetdevList()
     return netdev::listNetdev(mZone.getInitPid());
 }
 
+void ZoneAdmin::deleteNetdevIpAddress(const std::string& netdev, const std::string& ip)
+{
+    netdev::deleteIpAddress(mZone.getInitPid(), netdev, ip);
+}
+
 } // namespace vasum