Esempio n. 1
0
        /// <summary>
        /// Restrns the storepath based on the load on each volume
        /// </summary>
        /// <returns>Storepath</returns>
        public static DataStore[] GetVolumes()
        {
            HostNode host = HostNode.GetLocalHost();

            if (host != null)
            {
                MultiValuedList mv         = host.Properties.GetProperties(PropertyTags.DataPath);
                ArrayList       VolumeList = new ArrayList();
                int             count      = 1;
                if (mv != null)
                {
                    foreach (Property prop in mv)
                    {
                        VolumeList.Add(prop.Value);
                    }
                }
                string[] stringArray = new string[VolumeList.Count];
                VolumeList.CopyTo(stringArray);
                DataStore[] DataStoreArray = new DataStore[VolumeList.Count + 1];
                DataStoreArray[0] = new DataStore("Default-Store");
                foreach (string a in stringArray)
                {
                    string[] comps = a.Split('|');
                    DataStoreArray[count] = new DataStore(comps[0], comps[1], comps[2]);
                    count++;
                }
                return(DataStoreArray);
            }
            else
            {
                DataStore[] DataStoreArray = new DataStore[1];
                DataStoreArray[0] = new DataStore("Default-Store");
                return(DataStoreArray);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Modify data store for an iFolder Server.
        /// </summary>
        /// <param name="name">The name of the data store.</param>
        /// <returns>Bool true on success.</returns>
        public bool ModifyStore(string datapath, bool enabled)
        {
            log.Debug(" Modify store called - :  {0}", datapath);
            HostNode        host = HostNode.GetLocalHost();
            MultiValuedList mv   = host.Properties.GetProperties(PropertyTags.DataPath);

            foreach (Property prop in mv)
            {
                string[] comps = ((string)prop.Value).Split('|');
                if ((datapath.Equals(comps[0])))
                {
                    Store  store  = Store.GetStore();
                    Domain domain = store.GetDomain(store.DefaultDomain);

                    prop.Delete();
                    domain.Commit(host);
                    string storageFormat = String.Format("{0}|{1}", comps[0], comps[1]);
                    storageFormat = String.Format("{0}|{1}", storageFormat, enabled.ToString());
                    Property p = new Property(PropertyTags.DataPath, storageFormat);
                    p.LocalProperty = true;
                    host.Properties.AddProperty(p);
                    domain.Commit(host);
                }
            }

            return(true);
        }
Esempio n. 3
0
        /// <summary>
        /// Delete data store for an iFolder Server.
        /// </summary>
        /// <param name="name">The name of the data store.</param>
        /// <returns>Bool true on success.</returns>
        public bool DeleteStore(string datapathname)
        {
            log.Debug(" Delete Store called with : {0}", datapathname);
            HostNode        host = HostNode.GetLocalHost();
            MultiValuedList mv   = host.Properties.GetProperties(PropertyTags.DataPath);

            foreach (Property prop in mv)
            {
                string[] comps = ((string)prop.Value).Split('|');
                if ((datapathname.Equals(comps[0])))
                {
                    Store  store  = Store.GetStore();
                    Domain domain = store.GetDomain(store.DefaultDomain);

                    if (!Directory.Exists(Path.Combine(comps[1], "SimiasFiles")))
                    {
                        prop.Delete();
                        domain.Commit(host);

                        //delete the source link of the symbolic link created
                        string storepath = Store.StorePath;
                        string tmppath   = Path.Combine(storepath, "SimiasFiles");
                        tmppath = Path.Combine(tmppath, datapathname);
                        Mono.Unix.Native.Syscall.unlink(tmppath);
                    }
                }
            }
            return(true);
        }
Esempio n. 4
0
        /// <summary>
        /// Add a data store for an iFolder Server.
        /// </summary>
        /// <returns>Bool true on success.</returns>
        public int AddStore(string ServerID)
        {
            Store  store     = Store.GetStore();
            Domain domain    = store.GetDomain(store.DefaultDomain);
            string storepath = Store.StorePath;
            string tmppath   = Path.Combine(storepath, "SimiasFiles");

            tmppath = Path.Combine(tmppath, this.DataPath);
            int result = 0;

            if (Directory.Exists(tmppath) == true)
            {
                return(1);
            }
            else if (Directory.Exists(this.FullPath) != true)
            {
                return(2);
            }

            Mono.Unix.Native.Syscall.symlink(this.FullPath, tmppath);

            string storageFormat = String.Format("{0}|{1}", this.DataPath, this.FullPath);

            storageFormat = String.Format("{0}|{1}", storageFormat, this.Enabled.ToString());
            HostNode host = HostNode.GetLocalHost();
            Property p    = new Property(PropertyTags.DataPath, storageFormat);

            p.LocalProperty = true;
            host.Properties.AddProperty(p);
            domain.Commit(host);
            return(result);
        }
Esempio n. 5
0
        /// <summary>
        /// Gets the hosts available in a domain
        /// </summary>
        /// <param name="domainId">Domain ID</param>
        /// <returns>Array of HostNode</returns>
        public static HostNode[] GetHosts(string domainId)
        {
            Domain    domain  = Store.GetStore().GetDomain(domainId);
            ICSList   snHosts = domain.GetNodesByType(HostNodeType);
            ArrayList hosts   = new ArrayList();

            foreach (ShallowNode sn in snHosts)
            {
                HostNode hn = new HostNode(domain.GetNodeByID(sn.ID));
                hosts.Add(hn);
            }
            return((HostNode[])hosts.ToArray(typeof(HostNode)));
        }