cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jburwell <...@git.apache.org>
Subject [GitHub] cloudstack pull request #1545: CLOUDSTACK-8715: Add channel to Instances for...
Date Wed, 10 Aug 2016 14:11:03 GMT
Github user jburwell commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1545#discussion_r74251286
  
    --- Diff: plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
---
    @@ -1209,25 +1209,95 @@ public String toString() {
             }
         }
     
    -    public static class VirtioSerialDef {
    -        private final String _name;
    -        private String _path;
    +    public static class ChannelDef {
    +        enum ChannelType {
    +            UNIX("unix"), SERIAL("serial");
    +            String type;
     
    -        public VirtioSerialDef(String name, String path) {
    -            _name = name;
    -            _path = path;
    +            ChannelType(String type) {
    +                this.type = type;
    +            }
    +
    +            @Override
    +            public String toString() {
    +                return this.type;
    +            }
    +        }
    +
    +        enum ChannelState {
    +            DISCONNECTED("disconnected"), CONNECTED("connected");
    +            String type;
    +
    +            ChannelState(String type) {
    +                this.type = type;
    +            }
    +
    +            @Override
    +            public String toString() {
    +                return type;
    +            }
    +        }
    +
    +        private String name;
    +        private String path;
    +        private ChannelType type;
    +        private ChannelState state;
    +
    +        public ChannelDef(String name, ChannelType type) {
    +            this.name = name;
    +            this.type = type;
    +        }
    +
    +        public ChannelDef(String name, ChannelType type, String path) {
    +            this.name = name;
    +            this.path = path;
    +            this.type = type;
    +        }
    +
    +        public ChannelDef(String name, ChannelType type, ChannelState state) {
    +            this.name = name;
    +            this.state = state;
    +            this.type = type;
    +        }
    +
    +        public ChannelDef(String name, ChannelType type, ChannelState state, String path)
{
    +            this.name = name;
    +            this.path = path;
    +            this.state = state;
    +            this.type = type;
    +        }
    +
    +        public ChannelType getChannelType() {
    +            return type;
    +        }
    +
    +        public ChannelState getChannelState() {
    +            return state;
    +        }
    +
    +        public String getName() {
    +            return name;
    +        }
    +
    +        public String getPath() {
    +            return path;
             }
     
             @Override
             public String toString() {
                 StringBuilder virtioSerialBuilder = new StringBuilder();
    -            if (_path == null) {
    -                _path = "/var/lib/libvirt/qemu";
    +            virtioSerialBuilder.append("<channel type='" + type.toString() + "'>\n");
    +            if (path == null) {
    +                virtioSerialBuilder.append("<source mode='bind'/>\n");
    +            } else {
    +                virtioSerialBuilder.append("<source mode='bind' path='" + path + "'/>\n");
    --- End diff --
    
    ``<source mode=`bind`" is duplicated between both if conditions.  Furthermore, the
else appears to be a superset of the default case.  Therefore, please consider refactoring
as follows:
    ```
    virtioSerialBuilder.append("<source mode='bind'");
    if (path != null) {
       virtioSerialBuilder.append("path='");
       virtioSerialBuilder.append(path);
       virtioSerialBuilder.append("'");
    }
    virtioSerialBuilder.append("/>");
    virtioSerialBuilder.append(System.lineSeparator());
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message